Changeset 2901546
- Timestamp:
- 04/20/2023 12:50:26 AM (3 years ago)
- Location:
- text-replacer
- Files:
-
- 2 edited
-
tags/1.0.0/text_replacer.php (modified) (3 diffs)
-
trunk/text_replacer.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
text-replacer/tags/1.0.0/text_replacer.php
r2898901 r2901546 57 57 <input type="hidden" name="justsubmitted" value="true" /> 58 58 <?php wp_nonce_field('saveReplaceText', 'ourNonce') ?> 59 <h6>Enter a list of words or exact phrases with replacement texts to replace from your site dynamically.</h6> 59 <h6>Enter a list of words or exact phrases with replacement texts to replace in content of any post dynamically. 60 </h6> 60 61 <br /> 61 62 <?php 62 if ( !isset($data)) { ?>63 if (count($data) == 0) { ?> 63 64 <div class="input-group mb-3 "> 64 65 <label class="input-group-text" for="inputGroupSelect01">#1</label> … … 73 74 <input type="text" class="form-control" placeholder="replacement text" aria-label=<?php echo esc_attr('replace_text_with__f2') ?> name=<?php echo esc_attr('replace_text_with__f2') ?> value=""> 74 75 </div> 75 <?php } 76 foreach ($data as $key => $value) { 77 foreach ($value as $k => $v) { 78 $fieldA = 'text_to_replace__f' . $counter; 79 $fieldB = 'replace_text_with__f' . $counter; 80 ?> 81 <div class="input-group mb-3 "> 82 <label class="input-group-text" for="inputGroupSelect01"># 83 <?php echo esc_attr($counter); ?> 84 </label> 85 <input type="text" class="form-control" placeholder="text to replace" aria-label=<?php echo esc_attr($fieldA) ?> name=<?php echo esc_attr($fieldA) ?> value="<?php echo esc_attr($k); ?>"> 86 <span class="input-group-text">→</span> 87 <input type="text" class="form-control" placeholder="replacement text" aria-label=<?php echo esc_attr($fieldB) ?> name=<?php echo esc_attr($fieldB) ?> value="<?php echo esc_attr($v); ?>"> 88 </div> 89 <?php $counter++; 76 <?php } else { 77 foreach ($data as $key => $value) { 78 foreach ($value as $k => $v) { 79 $fieldA = 'text_to_replace__f' . $counter; 80 $fieldB = 'replace_text_with__f' . $counter; 81 ?> 82 <div class="input-group mb-3 "> 83 <label class="input-group-text" for="inputGroupSelect01"># 84 <?php echo esc_attr($counter); ?> 85 </label> 86 <input type="text" class="form-control" placeholder="text to replace" aria-label=<?php echo esc_attr($fieldA) ?> name=<?php echo esc_attr($fieldA) ?> value="<?php echo esc_attr($k); ?>"> 87 <span class="input-group-text">→</span> 88 <input type="text" class="form-control" placeholder="replacement text" aria-label=<?php echo esc_attr($fieldB) ?> name=<?php echo esc_attr($fieldB) ?> value="<?php echo esc_attr($v); ?>"> 89 </div> 90 <?php $counter++; 91 } 90 92 } 91 93 } 92 94 93 if (count($data) < 2) { ?>94 <div class="input-group mb-3 ">95 <label class="input-group-text" for="inputGroupSelect01">#2</label>96 <input type="text" class="form-control" placeholder="text to replace" aria-label=<?php echo esc_attr('text_to_replace__f2') ?> name=<?php echo esc_attr('text_to_replace__f2') ?> value="">97 <span class="input-group-text">→</span>98 <input type="text" class="form-control" placeholder="replacement text" aria-label=<?php echo esc_attr('replace_text_with__f2') ?> name=<?php echo esc_attr('replace_text_with__f2') ?> value="">99 </div>100 <?php }101 95 ?> 102 96 </br> … … 156 150 foreach ($value as $k => $v) { 157 151 $replaceWith = esc_html($v); 158 $new_content = str_ replace($k, $replaceWith, $new_content);152 $new_content = str_ireplace($k, $replaceWith, $new_content); 159 153 } 160 154 } -
text-replacer/trunk/text_replacer.php
r2898901 r2901546 57 57 <input type="hidden" name="justsubmitted" value="true" /> 58 58 <?php wp_nonce_field('saveReplaceText', 'ourNonce') ?> 59 <h6>Enter a list of words or exact phrases with replacement texts to replace from your site dynamically.</h6> 59 <h6>Enter a list of words or exact phrases with replacement texts to replace in content of any post dynamically. 60 </h6> 60 61 <br /> 61 62 <?php 62 if ( !isset($data)) { ?>63 if (count($data) == 0) { ?> 63 64 <div class="input-group mb-3 "> 64 65 <label class="input-group-text" for="inputGroupSelect01">#1</label> … … 73 74 <input type="text" class="form-control" placeholder="replacement text" aria-label=<?php echo esc_attr('replace_text_with__f2') ?> name=<?php echo esc_attr('replace_text_with__f2') ?> value=""> 74 75 </div> 75 <?php } 76 foreach ($data as $key => $value) { 77 foreach ($value as $k => $v) { 78 $fieldA = 'text_to_replace__f' . $counter; 79 $fieldB = 'replace_text_with__f' . $counter; 80 ?> 81 <div class="input-group mb-3 "> 82 <label class="input-group-text" for="inputGroupSelect01"># 83 <?php echo esc_attr($counter); ?> 84 </label> 85 <input type="text" class="form-control" placeholder="text to replace" aria-label=<?php echo esc_attr($fieldA) ?> name=<?php echo esc_attr($fieldA) ?> value="<?php echo esc_attr($k); ?>"> 86 <span class="input-group-text">→</span> 87 <input type="text" class="form-control" placeholder="replacement text" aria-label=<?php echo esc_attr($fieldB) ?> name=<?php echo esc_attr($fieldB) ?> value="<?php echo esc_attr($v); ?>"> 88 </div> 89 <?php $counter++; 76 <?php } else { 77 foreach ($data as $key => $value) { 78 foreach ($value as $k => $v) { 79 $fieldA = 'text_to_replace__f' . $counter; 80 $fieldB = 'replace_text_with__f' . $counter; 81 ?> 82 <div class="input-group mb-3 "> 83 <label class="input-group-text" for="inputGroupSelect01"># 84 <?php echo esc_attr($counter); ?> 85 </label> 86 <input type="text" class="form-control" placeholder="text to replace" aria-label=<?php echo esc_attr($fieldA) ?> name=<?php echo esc_attr($fieldA) ?> value="<?php echo esc_attr($k); ?>"> 87 <span class="input-group-text">→</span> 88 <input type="text" class="form-control" placeholder="replacement text" aria-label=<?php echo esc_attr($fieldB) ?> name=<?php echo esc_attr($fieldB) ?> value="<?php echo esc_attr($v); ?>"> 89 </div> 90 <?php $counter++; 91 } 90 92 } 91 93 } 92 94 93 if (count($data) < 2) { ?>94 <div class="input-group mb-3 ">95 <label class="input-group-text" for="inputGroupSelect01">#2</label>96 <input type="text" class="form-control" placeholder="text to replace" aria-label=<?php echo esc_attr('text_to_replace__f2') ?> name=<?php echo esc_attr('text_to_replace__f2') ?> value="">97 <span class="input-group-text">→</span>98 <input type="text" class="form-control" placeholder="replacement text" aria-label=<?php echo esc_attr('replace_text_with__f2') ?> name=<?php echo esc_attr('replace_text_with__f2') ?> value="">99 </div>100 <?php }101 95 ?> 102 96 </br> … … 156 150 foreach ($value as $k => $v) { 157 151 $replaceWith = esc_html($v); 158 $new_content = str_ replace($k, $replaceWith, $new_content);152 $new_content = str_ireplace($k, $replaceWith, $new_content); 159 153 } 160 154 }
Note: See TracChangeset
for help on using the changeset viewer.