Plugin Directory

Changeset 2901546


Ignore:
Timestamp:
04/20/2023 12:50:26 AM (3 years ago)
Author:
teamuqb
Message:

bug fix

Location:
text-replacer
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • text-replacer/tags/1.0.0/text_replacer.php

    r2898901 r2901546  
    5757                <input type="hidden" name="justsubmitted" value="true" />
    5858                <?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>
    6061                <br />
    6162                <?php
    62                 if (!isset($data)) { ?>
     63                if (count($data) == 0) { ?>
    6364                    <div class="input-group mb-3 ">
    6465                        <label class="input-group-text" for="inputGroupSelect01">#1</label>
     
    7374                        <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="">
    7475                    </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">&#8594;</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">&#8594;</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                        }
    9092                    }
    9193                }
    9294
    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">&#8594;</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 }
    10195                ?>
    10296                </br>
     
    156150            foreach ($value as $k => $v) {
    157151                $replaceWith = esc_html($v);
    158                 $new_content = str_replace($k, $replaceWith, $new_content);
     152                $new_content = str_ireplace($k, $replaceWith, $new_content);
    159153            }
    160154        }
  • text-replacer/trunk/text_replacer.php

    r2898901 r2901546  
    5757                <input type="hidden" name="justsubmitted" value="true" />
    5858                <?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>
    6061                <br />
    6162                <?php
    62                 if (!isset($data)) { ?>
     63                if (count($data) == 0) { ?>
    6364                    <div class="input-group mb-3 ">
    6465                        <label class="input-group-text" for="inputGroupSelect01">#1</label>
     
    7374                        <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="">
    7475                    </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">&#8594;</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">&#8594;</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                        }
    9092                    }
    9193                }
    9294
    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">&#8594;</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 }
    10195                ?>
    10296                </br>
     
    156150            foreach ($value as $k => $v) {
    157151                $replaceWith = esc_html($v);
    158                 $new_content = str_replace($k, $replaceWith, $new_content);
     152                $new_content = str_ireplace($k, $replaceWith, $new_content);
    159153            }
    160154        }
Note: See TracChangeset for help on using the changeset viewer.