-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathword-replacer.php
534 lines (475 loc) · 21.6 KB
/
word-replacer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
<?php
/*
Plugin Name: Word Replacer
Plugin URI: http://takien.com/587/word-replacer-wordpress-plugin.php
Description: Replace word in post, page, title or comment. Now with RegEx supports.
Author: Takien
Version: 0.2.4 dev
Author URI: http://takien.com/
*/
/* Copyright 2011 takien.com
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
For a copy of the GNU General Public License, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
if(!defined('ABSPATH')) die();
if (!class_exists('WordReplacer')) {
class WordReplacer {
var $name = 'Word Replacer';
var $version = '0.2.3';
var $table_name = '';
var $base_name = 'wordreplacer';
function WordReplacer(){
$this->__construct();
}
function __construct(){
register_activation_hook(__FILE__,array(&$this,'word_replacer_install'));
add_action('init', array(&$this, 'word_replacer_init'));
$plugin = plugin_basename(__FILE__);
add_filter("plugin_action_links_$plugin", array(&$this,'word_replacer_settings_link' ));
add_filter('comment_text', array(&$this,'word_replacer_comment'), 200, 2);
add_filter('the_content', array(&$this,'word_replacer_postpage'),200);
add_filter('the_title', array(&$this,'word_replacer_title'), 200);
add_filter('wp_title', array(&$this,'word_replacer_pagetitle'),200);
add_action('admin_head', array(&$this,'word_replacer_script'));
add_action('admin_menu', array(&$this,'word_replacer_add_page'));
add_action('contextual_help', array(&$this,'word_replacer_help'));
}
//bbp_get_reply_content
function word_replacer_init() {
global $wpdb;
$this->table_name = $wpdb->prefix .'word_replacer';
}
var $fields = Array(
'original' => 'Original',
'replacement' => 'Replacement',
'in_posts' => 'Posts',
'in_comments' => 'Comments',
'in_pages' => 'Pages',
'in_titles' => 'Titles',
'in_sensitive' => 'Insensitive',
'in_wordonly' => 'Whole Word',
'in_regex' => 'Regex'
);
static function word_replacer_install () {
global $wpdb;
$wordreplacer = new WordReplacer;
$sql = "CREATE TABLE " . $wordreplacer->table_name . " (
id mediumint(9) NOT NULL AUTO_INCREMENT,
original TEXT NOT NULL,
replacement TEXT NOT NULL,
in_posts VARCHAR(5) NOT NULL,
in_comments VARCHAR(5) NOT NULL,
in_pages VARCHAR(5) NOT NULL,
in_titles VARCHAR(5) NOT NULL,
in_sensitive VARCHAR(5) NOT NULL,
in_wordonly VARCHAR(5) NOT NULL,
in_regex VARCHAR(5) NOT NULL,
UNIQUE KEY id (id)
);";
require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
if($wpdb->get_var('show tables like "'.$wordreplacer->table_name.'"') !== $wordreplacer->table_name) {
dbDelta($sql);
add_option("word_replacer_ver", $wordreplacer->version);
}
elseif (get_option("word_replacer_ver") !== $wordreplacer->version) {
dbDelta($sql);
update_option("word_replacer_ver", $wordreplacer->version);
}
} /* end word_replacer_install*/
function word_replacer_script(){
$page = isset($_GET['page']) ? $_GET['page'] : false;
if($page == $this->base_name) { ?>
<script type="text/javascript">
//<![CDATA[
jQuery(document).ready(function($){
$('#add_more_field').click(function(){
var count = $("input[name='count']").length;
$('#word-replacer-list').append("<tr><td><input type='checkbox' name='delete["+count+"]' value='1' /></td><?php
foreach($this->fields as $field=>$name) {
if( 'original' == $field ) {
echo "<td><input type='hidden' name='id[\"+count+\"]' value='' /><input type='hidden' name='count' value='' /><input style='width:100%' name='".$field."[\"+count+\"]' value='' type='text' /></td><td> » </td>";
}
else if ( 'replacement' == $field ) {
echo "<td><textarea style='resize:vertical;width:100%' name='".$field."[\"+count+\"]'></textarea><label><input type='checkbox' value='1' name='strip_backslash[\"+count+\"]'/> Strip backslash?</label></td>";
}
else {
echo "<td class='replacer_expandable'><input value='yes' name='".$field."[\"+count+\"]' type='checkbox' /></td>";
}
}
?><td></td>\n</tr>\n");
cektkp_growtextarea($('#word-replacer-list textarea'));
return false;
});
$('#show_hide_help').click(function(){
$('#contextual-help-link').trigger('click');
return false;
});
$('.replacer_expandall a').click(function(){
$('.replacer_expandable').toggle();
return false;
});
function cektkp_growtextarea(textarea){
textarea.each(function(index){
textarea = $(this);
textarea.css({'overflow':'hidden','word-wrap':'break-word'});
var pos = textarea.position();
var growerid = 'textarea_grower_'+index;
textarea.after('<div style="position:absolute;z-index:-1000;visibility:hidden;top:'+pos.top+';height:'+textarea.outerHeight()+'" id="'+growerid+'"></div>');
var growerdiv = $('#'+growerid);
growerdiv.css({'min-height':'20px','font-size':textarea.css('font-size'),'width':textarea.width(),'word-wrap':'break-word'});
growerdiv.html($('<div/>').text(textarea.val()).html().replace(/\n/g, "<br />."));
if(textarea.val() == ''){
growerdiv.text('.');
}
textarea.height(growerdiv.height()+10);
textarea.keyup(function(){
growerdiv.html($('<div/>').text($(this).val()).html().replace(/\n/g, "<br />."));
if($(this).val() == ''){
growerdiv.text('.');
}
$(this).height(growerdiv.height()+10);
});
});
}
cektkp_growtextarea($('#word-replacer-list textarea'));
});
//]]>
</script>
<?php
}
} /* end word_replacer_script*/
function word_replacer_post(){
global $wpdb;
$message = false;
if(isset($_POST['submit-word-replacer'])) {
if(!wp_verify_nonce($_POST['word_replacer_nonce'],'word_replacer_nonce_action') ){
wp_die('Not allowed');
}
$id = isset($_POST['id']) ? $_POST['id'] : Array();
$original = isset($_POST['original']) ? $_POST['original'] : Array();
$replacement = isset($_POST['replacement']) ? stripslashes_deep($_POST['replacement']) : Array();
$in_posts = isset($_POST['in_posts']) ? $_POST['in_posts'] : Array();
$in_comments = isset($_POST['in_comments']) ? $_POST['in_comments'] : Array();
$in_pages = isset($_POST['in_pages']) ? $_POST['in_pages'] : Array();
$in_titles = isset($_POST['in_titles']) ? $_POST['in_titles'] : Array();
$in_sensitive = isset($_POST['in_sensitive']) ? $_POST['in_sensitive'] : Array();
$in_wordonly = isset($_POST['in_wordonly']) ? $_POST['in_wordonly'] : Array();
$in_regex = isset($_POST['in_regex']) ? $_POST['in_regex'] : Array();
$delete = isset($_POST['delete']) ? $_POST['delete'] : Array();
$strip_backslash = isset($_POST['strip_backslash']) ? $_POST['strip_backslash'] : Array();
if(is_array($original) && !empty($original)) {
$numfield = array_diff($original,Array(''));
$numfield = count($numfield);
for ($i = 0; $i <= $numfield; $i++) {
$in_posts[$i] = (empty($in_posts[$i]) ? 'no' : $in_posts[$i]);
$in_comments[$i] = (empty($in_comments[$i]) ? 'no' : $in_comments[$i]);
$in_pages[$i] = (empty($in_pages[$i]) ? 'no' : $in_pages[$i]);
$in_titles[$i] = (empty($in_titles[$i]) ? 'no' : $in_titles[$i]);
$in_sensitive[$i] = (empty($in_sensitive[$i]) ? 'no' : $in_sensitive[$i]);
$in_wordonly[$i] = (empty($in_wordonly[$i]) ? 'no' : $in_wordonly[$i]);
$in_regex[$i] = (empty($in_regex[$i]) ? 'no' : $in_regex[$i]);
if(!empty($strip_backslash[$i])) {
$replacement[$i] = str_replace('\\','',$replacement[$i]);
}
if(!empty($original[$i]) && empty($id[$i])) {
$wpdb->query($wpdb->prepare("
INSERT INTO ".$this->table_name."
(original, replacement, in_posts, in_comments, in_pages, in_titles, in_sensitive, in_wordonly, in_regex)
VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)",
array(
$wpdb->escape(base64_encode(trim($original[$i]))),
$wpdb->escape(trim($replacement[$i])),
$wpdb->escape($in_posts[$i]),
$wpdb->escape($in_comments[$i]),
$wpdb->escape($in_pages[$i]),
$wpdb->escape($in_titles[$i]),
$wpdb->escape($in_sensitive[$i]),
$wpdb->escape($in_wordonly[$i]),
$wpdb->escape($in_regex[$i]))));
$message = '<div id="message" class="updated fade"><p><strong>Word Inserted.</strong></p></div>';
}
elseif((empty($original[$i]) && !empty($id[$i])) OR (!empty($delete[$i]) && !empty($id[$i]))) {
$wpdb->query("
DELETE FROM ".$this->table_name." WHERE id = '".$id[$i]."'");
$message = '<div id="message" class="updated fade"><p><strong>Word Deleted.</strong></p></div>';
}
elseif(!empty($original[$i]) && !empty($id[$i])) {
$wpdb->update($this->table_name,
array('original' => $wpdb->escape(base64_encode(trim($original[$i]))),
'replacement' => $wpdb->escape(trim($replacement[$i])),
'in_posts' => $wpdb->escape($in_posts[$i]),
'in_comments' => $wpdb->escape($in_comments[$i]),
'in_pages' => $wpdb->escape($in_pages[$i]),
'in_titles' => $wpdb->escape($in_titles[$i]),
'in_sensitive' => $wpdb->escape($in_sensitive[$i]),
'in_wordonly' => $wpdb->escape($in_wordonly[$i]),
'in_regex' => $wpdb->escape($in_regex[$i])
),
array('id' => $id[$i]), array('%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'), array('%d'));
$message = '<div id="message" class="updated fade"><p><strong>Word Updated.</strong></p></div>';
}
}
}
else{
$message = '<div id="message" class="updated fade"><p><strong>Please add a field first.</strong></p></div>';
}
delete_transient('word_replacer_db'); /*update transient each time update data*/
}
echo $message;
} /*end word_replacer_post*/
private function esc_textarea($string) {
//return htmlspecialchars(stripcslashes($string));
$string = stripcslashes($string);
return htmlspecialchars($string,ENT_QUOTES);
}
private function word_replacer_db() {
global $wpdb;
/* now use Transients API to reduce db load :D */
if ( false === ( $word_replacer_db = get_transient( 'word_replacer_db' ) ) ) {
/* It wasn't there, so regenerate the data and save the transient*/
$word_replacer_db = $wpdb->get_results("SELECT * FROM ".$this->table_name." ORDER BY id", ARRAY_A);
set_transient( 'word_replacer_db', $word_replacer_db );
}
return $word_replacer_db;
} /*end word replacer_db*/
private function replace_replace($original='',$replacement='',$in_sensitive='',$in_wordonly='',$in_regex='',$string='') {
$b = $i = '';
if($in_wordonly == 'yes') $b ='\b';
if($in_sensitive == 'yes') $i ='i';
$original = ($in_regex == 'yes') ? $original : preg_quote($original);
return preg_replace("/$b$original$b/$i",$replacement,$string);
} /*end replace_replace*/
function base64($string) {
return base64_decode($string,true) ? base64_decode($string) : $string;
}
function word_replacer_postpage($content) {
/* $i = 1;
foreach($this->word_replacer_db() as $wrdb) {
$i++;
$original[$i] = $this->base64($wrdb['original']);
$replacement[$i] = htmlspecialchars_decode($this->esc_textarea($wrdb['replacement']));
$in_posts[$i] = $wrdb['in_posts'];
$in_pages[$i] = $wrdb['in_pages'];
$in_sensitive[$i] = $wrdb['in_sensitive'];
$in_wordonly[$i] = $wrdb['in_wordonly'];
$in_regex[$i] = $wrdb['in_regex'];
if(is_page() && ($in_pages[$i] == 'yes')) {
$content = $this->replace_replace($original[$i],$replacement[$i],$in_sensitive[$i],$in_wordonly[$i],$in_regex[$i],$content);
}
elseif(!is_page() && ($in_posts[$i] == 'yes')) {
$content = $this->replace_replace($original[$i],$replacement[$i],$in_sensitive[$i],$in_wordonly[$i],$in_regex[$i],$content);
}
} */
$original = $replacement = Array();
$b = $i = '';
$n = 1;
foreach($this->word_replacer_db() as $wrdb) { $n++;
if($wrdb['in_wordonly'] == 'yes') $b ='\b';
if($wrdb['in_sensitive'] == 'yes') $i ='i';
$original[$n] = "/$b".$this->base64($wrdb['original'])."$b/$i";
$replacement[$n] = htmlspecialchars_decode($this->esc_textarea($wrdb['replacement']));
}
$content = preg_replace($original,$replacement,$content);
/*
DEBUG
*echo'<pre>';
print_r($original);
echo'</pre>';
echo'<pre>';
print_r($replacement);
echo'</pre>'; */
return $content;
} /*end word_replacer_postpage**/
function word_replacer_comment($content,$comment) {
$i = 1;
foreach($this->word_replacer_db() as $wrdb) {
$i++;
$original[$i] = $this->base64($wrdb['original']);
$replacement[$i] = stripslashes($wrdb['replacement']);
$in_comments[$i] = $wrdb['in_comments'];
$in_sensitive[$i] = $wrdb['in_sensitive'];
$in_wordonly[$i] = $wrdb['in_wordonly'];
$in_regex[$i] = $wrdb['in_regex'];
if($in_comments[$i] == 'yes') {
if($comment->comment_approved == '1')
$content = $this->replace_replace($original[$i],$replacement[$i],$in_sensitive[$i],$in_wordonly[$i],$in_regex[$i],$content);
}
}
return $content;
} /* end word_replacer_comment*/
function word_replacer_title($content) {
$i = 1;
foreach($this->word_replacer_db() as $wrdb) {
$i++;
$original[$i] = $this->base64($wrdb['original']);
$replacement[$i] = stripslashes($wrdb['replacement']);
$in_titles[$i] = $wrdb['in_titles'];
$in_sensitive[$i] = $wrdb['in_sensitive'];
$in_wordonly[$i] = $wrdb['in_wordonly'];
$in_regex[$i] = $wrdb['in_regex'];
if($in_titles[$i] == 'yes') {
$content = $this->replace_replace($original[$i],$replacement[$i],$in_sensitive[$i],$in_wordonly[$i],$in_regex[$i],$content);
}
}
return $content;
} /* end word_replacer_title*/
function word_replacer_pagetitle($content){
$i = 1;
foreach($this->word_replacer_db() as $wrdb) { $i++;
$original[$i] = $this->base64($wrdb['original']);
$replacement[$i] = stripslashes($wrdb['replacement']);
$in_titles[$i] = $wrdb['in_titles'];
$in_sensitive[$i] = $wrdb['in_sensitive'];
$in_wordonly[$i] = $wrdb['in_wordonly'];
$in_regex[$i] = $wrdb['in_regex'];
if($in_titles[$i] == 'yes') {
$content = $this->replace_replace($original[$i],$replacement[$i],$in_sensitive[$i],$in_wordonly[$i],$in_regex[$i],$content);
}
}
return $content;
} /* end word_replacer_pagetitle */
function word_replacer_settings_link($links) {
$settings_link = '<a href="options-general.php?page='.$this->base_name.'">Settings</a>';
array_unshift($links, $settings_link);
return $links;
} /* end word_replacer_settings_link*/
function word_replacer_help($help) {
$page = isset($_GET['page']) ? $_GET['page'] : false;
if($page == $this->base_name) {
$help = '
<h2>'.$this->name.' '.$this->version.'</h2>
<h5>Instruction:</h5>
<ol>
<li>To <strong>Add New Word</strong> click Add More Fields add your word, replacement and filter, then hit Add/Update Words.</li>
<li>To <strong>Update</strong> a word, just replace/retype in it\'s place an hit Add/Update Words.</li>
<li>To <strong>Delete</strong> a word, leave blank/clear word in "original" field and hit Add/Update Words. Or check on the Delete column</li></ol>
<h5>Regex:</h5>
<ol>
<li>Do not use delimiter "/" in the begining and the end of each REGEX pattern. It will be added when it\'s processed.</li>
<li>The REGEX options <em>i</em> also will be added automatically if you check Case Insensitive on</li>
</ol>
<h5>Example:</h5>
<ol>
<li>BASIC: To replace word "<strong>foo</strong>" in a post with "bar", put "foo" in the original field, and "bar" in the replacement field, tick on the <em>Post</em> column and Save.</li>
<li>BASIC REGEX: To replace words "ipsum, dolor, amet" become bold "<strong>ipsum, dolor, amet</strong>", put "(lorem|dolor|amet)" in the original field, and "<strong>$1</strong>" in the replacement field, tick on the <em>Post</em>, <em>Insensitive</em>, and <em>Regex</em> column and Save/Update. This will replace sentence "Lorem ipsum dolor sit amet" become "<strong>Lorem</strong> ipsum <strong>dolor</strong> sit <strong>amet</strong>" in your posts.</li>
</ol>
<h5>Note:</h5>
<ol>
<li>Be wise to put word in the original field, if you made a mistake may cause unexpected output. If so, just delete it and your post will back to normal.</li>
<li>Replacement fields accept HTML tag, make sure you do not replace <em>title</em> with HTML tag.</li>
</ol>
<p>Further question, suggestion, comment, or help please <a href="http://takien.com/587/word-replacer-wordpress-plugin.php" target="_blank">go here.</a></p>
<p>Support is limited to plugins usage and feature only, for advanced info about RegEx and preg_replace please
refers to the following resources:</p>
<ol>
<li>Regex info <a href="http://www.regular-expressions.info/" target="_blank">http://www.regular-expressions.info/</a></li>
<li>preg_replace function <a href="http://www.php.net/manual/en/function.preg-replace.php" target="_blank">http://www.php.net/manual/en/function.preg-replace.php</a></li>
</ol>
';
}
return $help;
} /* end word_replacer_help */
function word_replacer_add_page() {
add_options_page($this->name, $this->name, 'activate_plugins', $this->base_name, array(&$this,'word_replacer_page'));
} /* end word_replacer_add_page*/
function word_replacer_page() {
echo '<div class="wrap">
<h2>'.$this->name.'</h2>';
$this->word_replacer_post();
$basefield = '<tr>
<td><input type="checkbox" name="delete[]" value="1" /></td>';
foreach($this->fields as $field=>$name) {
if( 'original' == $field ) {
$basefield .= '<td><input type="hidden" name="id[]" value="" /><input type="hidden" name="id[]" value="" />
<input style="width:100%" name="'.$field.'[]" type="text" /></td><td> » </td>';
}
else if ( 'replacement' == $field ) {
$basefield .= '<td><textarea style="resize:none;width:100%" name="'.$field.'[]"></textarea><label><input type="checkbox" value="1" name="strip_backslash[]"/> Strip backslash?</label></td>';
}
else {
$basefield .= '<td class="replacer_expandable"><input value="yes" name="'.$field.'[]" type="checkbox" /></td>';
}
}
$basefield .= '<td></td></tr>';
$action_url = admin_url('options-general.php?page=' . $this->base_name);
?>
<p>Put the word to be replaced on the left, and what to change it to on the right. <a id="show_hide_help" href="#">Help?</a></p>
<form method="post" action="<?php echo $action_url;?>">
<?php wp_nonce_field('word_replacer_nonce_action','word_replacer_nonce'); ?>
<table class="widefat fixed" width="650" align="center" width="100%" id="word-replacer-list">
<thead>
<tr>
<th width="40">Delete</th>
<th>Original</th><th width="5"> </th><th>Replacement</th>
<th class="replacer_expandable" width="40">Posts</th>
<th class="replacer_expandable" width="70">Comments</th>
<th class="replacer_expandable" width="40">Pages</th>
<th class="replacer_expandable" width="40">Titles</th>
<th class="replacer_expandable" width="80">Insensitive</th>
<th class="replacer_expandable" width="80">Whole Word</th>
<th class="replacer_expandable" width="40">Regex</th>
<th class="replacer_expandall" width="20"><a style="color:black" href="#" title="Expand/Collapse">«»</a></th>
</tr>
</thead>
<?php
$i = -1;
$word_replacer_db = $this->word_replacer_db();
if(is_array($word_replacer_db) AND !empty($word_replacer_db)) {
foreach($word_replacer_db as $wrdb) { $i++ ?>
<?php $alternate = (empty($alternate) ? 'class="alternate"' : '');?>
<tr <?php echo $alternate;?>>
<td><input type="checkbox" name="delete[<?php echo $i;?>]" value="1" /></td>
<td>
<input type="hidden" name="id[<?php echo $i;?>]" value="<?php echo $wrdb['id']; ?>" />
<input type="hidden" name="count" value="" />
<?php
foreach($this->fields as $field=>$name) {
if( 'original' == $field ) {
?>
<input style="width:100%" type="text" name="original[<?php echo $i;?>]" id="original_<?php echo $i;?>" value="<?php echo htmlspecialchars($this->base64($wrdb['original'])); ?>" /></td><td> » </td>
<?php
}
else if ( 'replacement' == $field ) {
?>
<td>
<textarea style="resize:vertical;width:100%" name="replacement[<?php echo $i;?>]"><?php echo $this->esc_textarea($wrdb['replacement']); ?></textarea><label><input type="checkbox" value="1" name="strip_backslash[<?php echo $i;?>]"/> Strip backslash?</label>
</td>
<?php
}
else {
?>
<td class="replacer_expandable">
<input value="yes" name="<?php echo $field;?>[<?php echo $i;?>]" <?php echo (($wrdb[$field] == 'yes') ? 'checked="checked"' : ''); ?> type="checkbox" /></td>
<?php
}
}
?>
<td></td>
</tr>
<?php }
}
else {
echo $basefield;
}
?>
</table>
<input type="button" id="add_more_field" value="+ Add More Fields" style="cursor:pointer" />
<input type="hidden" name="action" value="update" />
<input name="submit-word-replacer" class="button-primary" type="submit" value="<?php _e('Add/Update Words') ?>" />
</form>
</div>
<?php
}
} /* end class */
}
if (class_exists('WordReplacer')) {
$wordreplacer = new WordReplacer();
}