Plugin Directory

Changeset 1995970


Ignore:
Timestamp:
12/16/2018 07:42:45 PM (7 years ago)
Author:
leocolomb
Message:

v1.2.0

Location:
wp-auto-links
Files:
1 added
10 edited
8 copied

Legend:

Unmodified
Added
Removed
  • wp-auto-links/tags/1.2.0/src/class-wp-auto-links-helper.php

    r1994755 r1995970  
    258258
    259259    /**
     260     * @param mixed $value
     261     * @param int $null
     262     * @return int
     263     */
     264    public static function option_integer($value, int $null = 0): int
     265    {
     266        return (is_numeric($value) && $value > 0) ? (int) $value : $null;
     267    }
     268
     269    /**
    260270     * Instantiate the filter.
    261271     *
  • wp-auto-links/tags/1.2.0/templates/admin.php

    r1994755 r1995970  
    55 */
    66
    7 $instance = WP_Auto_Links_Helper::get_instance();
    8 $options = $instance->get_options();
     7$helper = WP_Auto_Links_Helper::get_instance();
     8$options = $helper->get_options();
    99
    1010$boolean_options = [
     
    4343
    4444if (isset($_POST['submitted'])) {
    45     check_admin_referer($instance::DOMAIN);
    46 
    47     foreach ($integer_options + $boolean_options as $option_name) {
     45    check_admin_referer($helper::DOMAIN);
     46
     47    foreach ($boolean_options as $option_name) {
     48        $options[$option_name] = (isset($_POST[$option_name]) && !empty($_POST[$option_name])) ? (bool) $_POST[$option_name] : false;
     49    }
     50
     51    foreach ($integer_options as $option_name) {
    4852        $val = (isset($_POST[$option_name]) && !empty($_POST[$option_name])) ? $_POST[$option_name] : 0;
    4953        $options[$option_name] = is_numeric($val) ? (int) $val : 1;
     
    5559    $options['term_ignore'] = array_filter(array_map('trim', explode(',', sanitize_text_field($_POST['term_ignore']))), 'is_numeric');
    5660
    57     $instance->set_options($options);
    58 
    59     echo '<div class="updated"><p>' . __('Plugin settings saved.', $instance::DOMAIN) . '</p></div>';
     61    $helper->set_options($options);
     62
     63    echo '<div class="updated"><p>' . __('Plugin settings saved.', $helper::DOMAIN) . '</p></div>';
    6064}
    6165
     
    7276$options['keywords'] = stripslashes($options['keywords']);
    7377
    74 function not_null($value, int $null = 0): bool
    75 {
    76     return (is_numeric($value) && $value > 0) ? (int) $value : $null;
    77 }
    78 
    79 $options['max_links'] = not_null($options['max_links']);
    80 $options['max_single_keyword'] = not_null($options['max_single_keyword'], -1);
    81 $options['max_single_url'] = not_null($options['max_single_url']);
    82 $options['min_term_usage'] = not_null($options['min_term_usage'], 1);
     78$options['max_links'] = $helper::option_integer($options['max_links']);
     79$options['max_single_keyword'] = $helper::option_integer($options['max_single_keyword'], -1);
     80$options['max_single_url'] = $helper::option_integer($options['max_single_url']);
     81$options['min_term_usage'] = $helper::option_integer($options['min_term_usage'], 1);
    8382
    8483?>
     
    9089        <input type="hidden" name="option_page" value="discussion">
    9190        <input type="hidden" name="action" value="update">
    92         <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?= wp_create_nonce($instance::DOMAIN); ?>"/>
     91        <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?= wp_create_nonce($helper::DOMAIN); ?>"/>
    9392        <input type="hidden" name="submitted" value="1"/>
    9493
    9594        <h2 class="title"><?php _e('Keywords'); ?></h2>
    96         <p><?php _e('Which custom keywords to automatically link.', $instance::DOMAIN); ?></p>
     95        <p><?php _e('Which custom keywords to automatically link.', $helper::DOMAIN); ?></p>
    9796        <table class="form-table">
    9897            <tbody>
     
    106105                    <textarea name="keywords" id="keywords" rows="10" cols="90"><?= $options['keywords']; ?></textarea>
    107106                    <p class="description">
    108                         <?php _e('Use comma to separate keywords and add target url at the end. Use a new line for new url and set of keywords. You can have these keywords link to any url, not only your site.', $instance::DOMAIN); ?>
     107                        <?php _e('Use comma to separate keywords and add target url at the end. Use a new line for new url and set of keywords. You can have these keywords link to any url, not only your site.', $helper::DOMAIN); ?>
    109108                    </p>
    110109                    <code>example,auto links,https://example.com</code><br/>
     
    113112            </tr>
    114113            <tr>
    115                 <th><?php _e('Duplicates', $instance::DOMAIN); ?></th>
     114                <th><?php _e('Duplicates', $helper::DOMAIN); ?></th>
    116115                <td>
    117116                    <label>
    118117                        <input type="checkbox" name="prevent_duplicate_link" <?= $options['prevent_duplicate_link']; ?> />
    119                         <strong><?php _e('Prevent a link to be used more than once in a content', $instance::DOMAIN); ?></strong>
    120                     </label>
    121                 </td>
    122             </tr>
    123             </tbody>
    124         </table>
    125 
    126         <h2 class="title"><?php _e('Placements', $instance::DOMAIN); ?></h2>
    127         <p><?php _e('Where to automatically add links.', $instance::DOMAIN); ?></p>
     118                        <strong><?php _e('Prevent a link to be used more than once in a content', $helper::DOMAIN); ?></strong>
     119                    </label>
     120                </td>
     121            </tr>
     122            </tbody>
     123        </table>
     124
     125        <h2 class="title"><?php _e('Placements', $helper::DOMAIN); ?></h2>
     126        <p><?php _e('Where to automatically add links.', $helper::DOMAIN); ?></p>
    128127        <table class="form-table">
    129128            <tbody>
     
    138137                    <label>
    139138                        <input type="checkbox" name="on_post_self" <?= $options['on_post_self']; ?>/>
    140                         <strong><?php _e('Enable self linking for posts', $instance::DOMAIN); ?></strong>
     139                        <strong><?php _e('Enable self linking for posts', $helper::DOMAIN); ?></strong>
    141140                    </label>
    142141                </td>
     
    152151                    <label>
    153152                        <input type="checkbox" name="on_page_self" <?= $options['on_page_self']; ?>/>
    154                         <strong><?php _e('Enable self linking for pages', $instance::DOMAIN); ?></strong>
     153                        <strong><?php _e('Enable self linking for pages', $helper::DOMAIN); ?></strong>
    155154                    </label>
    156155                </td>
     
    163162                        <strong><?php _e('Enable to link in comments'); ?></strong>
    164163                    </label>
    165                     <?= $instance->may_slow_down(); ?>
    166                 </td>
    167             </tr>
    168             <tr>
    169                 <th><?php _e('Feeds', $instance::DOMAIN); ?></th>
     164                    <?= $helper->may_slow_down(); ?>
     165                </td>
     166            </tr>
     167            <tr>
     168                <th><?php _e('Feeds', $helper::DOMAIN); ?></th>
    170169                <td>
    171170                    <label>
    172171                        <input type="checkbox" name="on_feed" <?= $options['on_feed']; ?> />
    173                         <strong><?php _e('Enable to link in feeds', $instance::DOMAIN); ?></strong>
    174                     </label>
    175                     <p class="description">
    176 
    177                     </p>
    178                 </td>
    179             </tr>
    180             <tr>
    181                 <th><?php _e('Archives', $instance::DOMAIN); ?></th>
     172                        <strong><?php _e('Enable to link in feeds', $helper::DOMAIN); ?></strong>
     173                    </label>
     174                    <p class="description">
     175
     176                    </p>
     177                </td>
     178            </tr>
     179            <tr>
     180                <th><?php _e('Archives', $helper::DOMAIN); ?></th>
    182181                <td>
    183182                    <label>
    184183                        <input type="checkbox" name="on_archive" <?= $options['on_archive']; ?>/>
    185                         <strong><?php _e('Enable to link on archive and index pages (including home page)', $instance::DOMAIN); ?></strong>
    186                     </label>
    187                     <?= $instance->may_slow_down(); ?>
    188                 </td>
    189             </tr>
    190             <tr>
    191                 <th><?php _e('Heading', $instance::DOMAIN); ?></th>
     184                        <strong><?php _e('Enable to link on archive and index pages (including home page)', $helper::DOMAIN); ?></strong>
     185                    </label>
     186                    <?= $helper->may_slow_down(); ?>
     187                </td>
     188            </tr>
     189            <tr>
     190                <th><?php _e('Heading', $helper::DOMAIN); ?></th>
    192191                <td>
    193192                    <label>
    194193                        <input type="checkbox" name="on_heading" <?= $options['on_heading']; ?>/>
    195                         <strong><?php _e('Enable to link in heading tags (h1, h2, h3, h4, h5 and h6)', $instance::DOMAIN); ?></strong>
    196                     </label>
    197                 </td>
    198             </tr>
    199             </tbody>
    200         </table>
    201 
    202         <h2 class="title"><?php _e('Targeting', $instance::DOMAIN); ?></h2>
    203         <p><?php _e('What to automatically link.', $instance::DOMAIN); ?></p>
     194                        <strong><?php _e('Enable to link in heading tags (h1, h2, h3, h4, h5 and h6)', $helper::DOMAIN); ?></strong>
     195                    </label>
     196                </td>
     197            </tr>
     198            </tbody>
     199        </table>
     200
     201        <h2 class="title"><?php _e('Targeting', $helper::DOMAIN); ?></h2>
     202        <p><?php _e('What to automatically link.', $helper::DOMAIN); ?></p>
    204203        <table class="form-table">
    205204            <tbody>
     
    209208                    <label>
    210209                        <input type="checkbox" name="keywords_enable" <?= $options['keywords_enable']; ?> />
    211                         <strong><?php _e('Enable to link links with custom keywords', $instance::DOMAIN); ?></strong>
    212                     </label>
    213                     <?= $instance->may_slow_down(); ?>
     210                        <strong><?php _e('Enable to link links with custom keywords', $helper::DOMAIN); ?></strong>
     211                    </label>
     212                    <?= $helper->may_slow_down(); ?>
    214213                </td>
    215214            </tr>
     
    219218                    <label>
    220219                        <input type="checkbox" name="posts_enable" <?= $options['posts_enable']; ?> />
    221                         <strong><?php _e('Enable to link internal links to posts', $instance::DOMAIN); ?></strong>
    222                     </label>
    223                     <?= $instance->may_slow_down(); ?>
     220                        <strong><?php _e('Enable to link internal links to posts', $helper::DOMAIN); ?></strong>
     221                    </label>
     222                    <?= $helper->may_slow_down(); ?>
    224223                </td>
    225224            </tr>
     
    229228                    <label>
    230229                        <input type="checkbox" name="pages_enable" <?= $options['pages_enable']; ?> />
    231                         <strong><?php _e('Enable to link internal links to pages', $instance::DOMAIN); ?></strong>
    232                     </label>
    233                     <?= $instance->may_slow_down(); ?>
     230                        <strong><?php _e('Enable to link internal links to pages', $helper::DOMAIN); ?></strong>
     231                    </label>
     232                    <?= $helper->may_slow_down(); ?>
    234233                </td>
    235234            </tr>
     
    239238                    <label>
    240239                        <input type="checkbox" name="categories_enable" <?= $options['categories_enable']; ?> />
    241                         <strong><?php _e('Enable to link internal links to categories', $instance::DOMAIN); ?></strong>
    242                     </label>
    243                     <?= $instance->may_slow_down(); ?>
     240                        <strong><?php _e('Enable to link internal links to categories', $helper::DOMAIN); ?></strong>
     241                    </label>
     242                    <?= $helper->may_slow_down(); ?>
    244243                </td>
    245244            </tr>
     
    249248                    <label>
    250249                        <input type="checkbox" name="tags_enable" <?= $options['tags_enable']; ?> />
    251                         <strong><?php _e('Enable to link internal links to tags', $instance::DOMAIN); ?></strong>
    252                     </label>
    253                     <?= $instance->may_slow_down(); ?>
     250                        <strong><?php _e('Enable to link internal links to tags', $helper::DOMAIN); ?></strong>
     251                    </label>
     252                    <?= $helper->may_slow_down(); ?>
    254253                </td>
    255254            </tr>
     
    257256                <th>
    258257                    <label for="min_term_usage">
    259                         <?php _e('Minimum categories / tags', $instance::DOMAIN); ?>
     258                        <?php _e('Minimum categories / tags', $helper::DOMAIN); ?>
    260259                    </label>
    261260                </th>
     
    263262                    <input type="number" name="min_term_usage" id="min_term_usage" size="2" value="<?= $options['min_term_usage']; ?>"/>
    264263                    <p class="description">
    265                         <?php _e('Only link categories and tags that have been used the above number of times or more.', $instance::DOMAIN); ?>
    266                     </p>
    267                 </td>
    268             </tr>
    269             </tbody>
    270         </table>
    271 
    272         <h2 class="title"><?php _e('Excluding', $instance::DOMAIN); ?></h2>
    273         <table class="form-table">
    274             <tbody>
    275             <tr>
    276                 <th><?php _e('Exclude Keywords', $instance::DOMAIN); ?></th>
     264                        <?php _e('Only link categories and tags that have been used the above number of times or more.', $helper::DOMAIN); ?>
     265                    </p>
     266                </td>
     267            </tr>
     268            </tbody>
     269        </table>
     270
     271        <h2 class="title"><?php _e('Excluding', $helper::DOMAIN); ?></h2>
     272        <table class="form-table">
     273            <tbody>
     274            <tr>
     275                <th><?php _e('Exclude Keywords', $helper::DOMAIN); ?></th>
    277276                <td>
    278277                    <input type="text" name="keyword_ignore" size="90"
    279                            value="<?= $options['keyword_ignore']; ?>" placeholder="<?php _e('Add a word', $instance::DOMAIN); ?>"/>
    280                     <p class="description">
    281                         <?php _e('You may wish to ignore certain words or phrases from automatic linking. Separate them by comma.', $instance::DOMAIN); ?>
    282                     </p>
    283                 </td>
    284             </tr>
    285             <tr>
    286                 <th><?php _e('Exclude Posts / Pages', $instance::DOMAIN); ?></th>
     278                           value="<?= $options['keyword_ignore']; ?>" placeholder="<?php _e('Add a word', $helper::DOMAIN); ?>"/>
     279                    <p class="description">
     280                        <?php _e('You may wish to ignore certain words or phrases from automatic linking. Separate them by comma.', $helper::DOMAIN); ?>
     281                    </p>
     282                </td>
     283            </tr>
     284            <tr>
     285                <th><?php _e('Exclude Posts / Pages', $helper::DOMAIN); ?></th>
    287286                <td>
    288287                    <input type="text" name="post_ignore" size="90"
    289288                           value="<?= $options['post_ignore']; ?>" placeholder="<?php _e('Add an ID'); ?>"/>
    290289                    <p class="description">
    291                         <?php _e('You may wish to forbid automatic linking on certain posts or pages. Separate their ID by a comma.', $instance::DOMAIN); ?>
    292                     </p>
    293                 </td>
    294             </tr>
    295             <tr>
    296                 <th><?php _e('Exclude Categories / Tags', $instance::DOMAIN); ?></th>
     290                        <?php _e('You may wish to forbid automatic linking on certain posts or pages. Separate their ID by a comma.', $helper::DOMAIN); ?>
     291                    </p>
     292                </td>
     293            </tr>
     294            <tr>
     295                <th><?php _e('Exclude Categories / Tags', $helper::DOMAIN); ?></th>
    297296                <td>
    298297                    <input type="text" name="term_ignore" size="90"
    299                            value="<?= $options['term_ignore']; ?>" placeholder="<?php _e('Add an ID', $instance::DOMAIN); ?>"/>
    300                     <p class="description">
    301                         <?php _e('You may wish to forbid automatic linking on certain categories or tags. Separate their ID by a comma.', $instance::DOMAIN); ?>
     298                           value="<?= $options['term_ignore']; ?>" placeholder="<?php _e('Add an ID', $helper::DOMAIN); ?>"/>
     299                    <p class="description">
     300                        <?php _e('You may wish to forbid automatic linking on certain categories or tags. Separate their ID by a comma.', $helper::DOMAIN); ?>
    302301                    </p>
    303302                </td>
     
    307306
    308307        <h2 class="title"><?php _e('Options'); ?></h2>
    309         <p><?php _e('How automatically link', $instance::DOMAIN); ?></p>
     308        <p><?php _e('How automatically link', $helper::DOMAIN); ?></p>
    310309        <table class="form-table">
    311310            <tbody>
     
    313312                <th>
    314313                    <label for="max_links">
    315                         <?php _e('Max Links', $instance::DOMAIN); ?>
     314                        <?php _e('Max Links', $helper::DOMAIN); ?>
    316315                    </label>
    317316                </th>
     
    319318                    <input type="number" name="max_links" id="max_links" size="2" value="<?= $options['max_links']; ?>"/>
    320319                    <p class="description">
    321                         <?php _e('You can limit the maximum number of different links that will be generated per post. Set to 0 for no limit.', $instance::DOMAIN); ?>
     320                        <?php _e('You can limit the maximum number of different links that will be generated per post. Set to 0 for no limit.', $helper::DOMAIN); ?>
    322321                    </p>
    323322                </td>
     
    326325                <th>
    327326                    <label for="max_single_keyword">
    328                         <?php _e('Max Keyword Links', $instance::DOMAIN); ?>
     327                        <?php _e('Max Keyword Links', $helper::DOMAIN); ?>
    329328                    </label>
    330329                </th>
     
    332331                    <input type="number" name="max_single_keyword" id="max_single_keyword" size="2" value="<?= $options['max_single_keyword']; ?>"/>
    333332                    <p class="description">
    334                         <?php _e('You can limit the maximum number of links created with the same keyword. Set to 0 for no limit.', $instance::DOMAIN); ?>
     333                        <?php _e('You can limit the maximum number of links created with the same keyword. Set to 0 for no limit.', $helper::DOMAIN); ?>
    335334                    </p>
    336335                </td>
     
    339338                <th>
    340339                    <label for="max_single_url">
    341                         <?php _e('Max Same URLs', $instance::DOMAIN); ?>
     340                        <?php _e('Max Same URLs', $helper::DOMAIN); ?>
    342341                    </label>
    343342                </th>
     
    345344                    <input type="number" name="max_single_url" id="max_single_url" size="2" value="<?= $options['max_single_url']; ?>"/>
    346345                    <p class="description">
    347                         <?php _e('Limit number of same URLs the plugin will link to. Works only when Max Keyword Links above is set to 1. Set to 0 for no limit.', $instance::DOMAIN); ?>
    348                     </p>
    349                 </td>
    350             </tr>
    351             <tr>
    352                 <th><?php _e('Case sensitive', $instance::DOMAIN); ?></th>
     346                        <?php _e('Limit number of same URLs the plugin will link to. Works only when Max Keyword Links above is set to 1. Set to 0 for no limit.', $helper::DOMAIN); ?>
     347                    </p>
     348                </td>
     349            </tr>
     350            <tr>
     351                <th><?php _e('Case sensitive', $helper::DOMAIN); ?></th>
    353352                <td>
    354353                    <label>
    355354                        <input type="checkbox" name="case_sensitive" <?= $options['case_sensitive']; ?> />
    356                         <strong><?php _e('Enable case sensitivity', $instance::DOMAIN); ?></strong>
    357                     </label>
    358                 </td>
    359             </tr>
    360             <tr>
    361                 <th><?php _e('No follow', $instance::DOMAIN); ?></th>
     355                        <strong><?php _e('Enable case sensitivity', $helper::DOMAIN); ?></strong>
     356                    </label>
     357                </td>
     358            </tr>
     359            <tr>
     360                <th><?php _e('No follow', $helper::DOMAIN); ?></th>
    362361                <td>
    363362                    <label>
    364363                        <input type="checkbox" name="link_nofollow" <?= $options['link_nofollow']; ?>/>
    365                         <strong><?php _e('Add a nofollow attribute to the external links.', $instance::DOMAIN); ?></strong>
    366                     </label>
    367                 </td>
    368             </tr>
    369             <tr>
    370                 <th><?php _e('Open in new window', $instance::DOMAIN); ?></th>
     364                        <strong><?php _e('Add a nofollow attribute to the external links.', $helper::DOMAIN); ?></strong>
     365                    </label>
     366                </td>
     367            </tr>
     368            <tr>
     369                <th><?php _e('Open in new window', $helper::DOMAIN); ?></th>
    371370                <td>
    372371                    <label>
    373372                        <input type="checkbox" name="link_blank" <?= $options['link_blank']; ?>/>
    374                         <strong><?php _e('Open the external links in a new window.', $instance::DOMAIN); ?></strong>
     373                        <strong><?php _e('Open the external links in a new window.', $helper::DOMAIN); ?></strong>
    375374                    </label>
    376375                </td>
  • wp-auto-links/tags/1.2.0/vendor/autoload.php

    r1994765 r1995970  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInited7cf8d6445ccabd2c78f8bf66b1be21::getLoader();
     7return ComposerAutoloaderInit924981ff406542d5045ead6999706070::getLoader();
  • wp-auto-links/tags/1.2.0/vendor/composer/autoload_real.php

    r1994765 r1995970  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInited7cf8d6445ccabd2c78f8bf66b1be21
     5class ComposerAutoloaderInit924981ff406542d5045ead6999706070
    66{
    77    private static $loader;
     
    2020        }
    2121
    22         spl_autoload_register(array('ComposerAutoloaderInited7cf8d6445ccabd2c78f8bf66b1be21', 'loadClassLoader'), true, true);
     22        spl_autoload_register(array('ComposerAutoloaderInit924981ff406542d5045ead6999706070', 'loadClassLoader'), true, true);
    2323        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInited7cf8d6445ccabd2c78f8bf66b1be21', 'loadClassLoader'));
     24        spl_autoload_unregister(array('ComposerAutoloaderInit924981ff406542d5045ead6999706070', 'loadClassLoader'));
    2525
    2626        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    2828            require_once __DIR__ . '/autoload_static.php';
    2929
    30             call_user_func(\Composer\Autoload\ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21::getInitializer($loader));
     30            call_user_func(\Composer\Autoload\ComposerStaticInit924981ff406542d5045ead6999706070::getInitializer($loader));
    3131        } else {
    3232            $map = require __DIR__ . '/autoload_namespaces.php';
  • wp-auto-links/tags/1.2.0/vendor/composer/autoload_static.php

    r1994765 r1995970  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21
     7class ComposerStaticInit924981ff406542d5045ead6999706070
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    122122    {
    123123        return \Closure::bind(function () use ($loader) {
    124             $loader->prefixLengthsPsr4 = ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21::$prefixLengthsPsr4;
    125             $loader->prefixDirsPsr4 = ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21::$prefixDirsPsr4;
    126             $loader->classMap = ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21::$classMap;
     124            $loader->prefixLengthsPsr4 = ComposerStaticInit924981ff406542d5045ead6999706070::$prefixLengthsPsr4;
     125            $loader->prefixDirsPsr4 = ComposerStaticInit924981ff406542d5045ead6999706070::$prefixDirsPsr4;
     126            $loader->classMap = ComposerStaticInit924981ff406542d5045ead6999706070::$classMap;
    127127
    128128        }, null, ClassLoader::class);
  • wp-auto-links/trunk/src/class-wp-auto-links-helper.php

    r1994755 r1995970  
    258258
    259259    /**
     260     * @param mixed $value
     261     * @param int $null
     262     * @return int
     263     */
     264    public static function option_integer($value, int $null = 0): int
     265    {
     266        return (is_numeric($value) && $value > 0) ? (int) $value : $null;
     267    }
     268
     269    /**
    260270     * Instantiate the filter.
    261271     *
  • wp-auto-links/trunk/templates/admin.php

    r1994755 r1995970  
    55 */
    66
    7 $instance = WP_Auto_Links_Helper::get_instance();
    8 $options = $instance->get_options();
     7$helper = WP_Auto_Links_Helper::get_instance();
     8$options = $helper->get_options();
    99
    1010$boolean_options = [
     
    4343
    4444if (isset($_POST['submitted'])) {
    45     check_admin_referer($instance::DOMAIN);
    46 
    47     foreach ($integer_options + $boolean_options as $option_name) {
     45    check_admin_referer($helper::DOMAIN);
     46
     47    foreach ($boolean_options as $option_name) {
     48        $options[$option_name] = (isset($_POST[$option_name]) && !empty($_POST[$option_name])) ? (bool) $_POST[$option_name] : false;
     49    }
     50
     51    foreach ($integer_options as $option_name) {
    4852        $val = (isset($_POST[$option_name]) && !empty($_POST[$option_name])) ? $_POST[$option_name] : 0;
    4953        $options[$option_name] = is_numeric($val) ? (int) $val : 1;
     
    5559    $options['term_ignore'] = array_filter(array_map('trim', explode(',', sanitize_text_field($_POST['term_ignore']))), 'is_numeric');
    5660
    57     $instance->set_options($options);
    58 
    59     echo '<div class="updated"><p>' . __('Plugin settings saved.', $instance::DOMAIN) . '</p></div>';
     61    $helper->set_options($options);
     62
     63    echo '<div class="updated"><p>' . __('Plugin settings saved.', $helper::DOMAIN) . '</p></div>';
    6064}
    6165
     
    7276$options['keywords'] = stripslashes($options['keywords']);
    7377
    74 function not_null($value, int $null = 0): bool
    75 {
    76     return (is_numeric($value) && $value > 0) ? (int) $value : $null;
    77 }
    78 
    79 $options['max_links'] = not_null($options['max_links']);
    80 $options['max_single_keyword'] = not_null($options['max_single_keyword'], -1);
    81 $options['max_single_url'] = not_null($options['max_single_url']);
    82 $options['min_term_usage'] = not_null($options['min_term_usage'], 1);
     78$options['max_links'] = $helper::option_integer($options['max_links']);
     79$options['max_single_keyword'] = $helper::option_integer($options['max_single_keyword'], -1);
     80$options['max_single_url'] = $helper::option_integer($options['max_single_url']);
     81$options['min_term_usage'] = $helper::option_integer($options['min_term_usage'], 1);
    8382
    8483?>
     
    9089        <input type="hidden" name="option_page" value="discussion">
    9190        <input type="hidden" name="action" value="update">
    92         <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?= wp_create_nonce($instance::DOMAIN); ?>"/>
     91        <input type="hidden" id="_wpnonce" name="_wpnonce" value="<?= wp_create_nonce($helper::DOMAIN); ?>"/>
    9392        <input type="hidden" name="submitted" value="1"/>
    9493
    9594        <h2 class="title"><?php _e('Keywords'); ?></h2>
    96         <p><?php _e('Which custom keywords to automatically link.', $instance::DOMAIN); ?></p>
     95        <p><?php _e('Which custom keywords to automatically link.', $helper::DOMAIN); ?></p>
    9796        <table class="form-table">
    9897            <tbody>
     
    106105                    <textarea name="keywords" id="keywords" rows="10" cols="90"><?= $options['keywords']; ?></textarea>
    107106                    <p class="description">
    108                         <?php _e('Use comma to separate keywords and add target url at the end. Use a new line for new url and set of keywords. You can have these keywords link to any url, not only your site.', $instance::DOMAIN); ?>
     107                        <?php _e('Use comma to separate keywords and add target url at the end. Use a new line for new url and set of keywords. You can have these keywords link to any url, not only your site.', $helper::DOMAIN); ?>
    109108                    </p>
    110109                    <code>example,auto links,https://example.com</code><br/>
     
    113112            </tr>
    114113            <tr>
    115                 <th><?php _e('Duplicates', $instance::DOMAIN); ?></th>
     114                <th><?php _e('Duplicates', $helper::DOMAIN); ?></th>
    116115                <td>
    117116                    <label>
    118117                        <input type="checkbox" name="prevent_duplicate_link" <?= $options['prevent_duplicate_link']; ?> />
    119                         <strong><?php _e('Prevent a link to be used more than once in a content', $instance::DOMAIN); ?></strong>
    120                     </label>
    121                 </td>
    122             </tr>
    123             </tbody>
    124         </table>
    125 
    126         <h2 class="title"><?php _e('Placements', $instance::DOMAIN); ?></h2>
    127         <p><?php _e('Where to automatically add links.', $instance::DOMAIN); ?></p>
     118                        <strong><?php _e('Prevent a link to be used more than once in a content', $helper::DOMAIN); ?></strong>
     119                    </label>
     120                </td>
     121            </tr>
     122            </tbody>
     123        </table>
     124
     125        <h2 class="title"><?php _e('Placements', $helper::DOMAIN); ?></h2>
     126        <p><?php _e('Where to automatically add links.', $helper::DOMAIN); ?></p>
    128127        <table class="form-table">
    129128            <tbody>
     
    138137                    <label>
    139138                        <input type="checkbox" name="on_post_self" <?= $options['on_post_self']; ?>/>
    140                         <strong><?php _e('Enable self linking for posts', $instance::DOMAIN); ?></strong>
     139                        <strong><?php _e('Enable self linking for posts', $helper::DOMAIN); ?></strong>
    141140                    </label>
    142141                </td>
     
    152151                    <label>
    153152                        <input type="checkbox" name="on_page_self" <?= $options['on_page_self']; ?>/>
    154                         <strong><?php _e('Enable self linking for pages', $instance::DOMAIN); ?></strong>
     153                        <strong><?php _e('Enable self linking for pages', $helper::DOMAIN); ?></strong>
    155154                    </label>
    156155                </td>
     
    163162                        <strong><?php _e('Enable to link in comments'); ?></strong>
    164163                    </label>
    165                     <?= $instance->may_slow_down(); ?>
    166                 </td>
    167             </tr>
    168             <tr>
    169                 <th><?php _e('Feeds', $instance::DOMAIN); ?></th>
     164                    <?= $helper->may_slow_down(); ?>
     165                </td>
     166            </tr>
     167            <tr>
     168                <th><?php _e('Feeds', $helper::DOMAIN); ?></th>
    170169                <td>
    171170                    <label>
    172171                        <input type="checkbox" name="on_feed" <?= $options['on_feed']; ?> />
    173                         <strong><?php _e('Enable to link in feeds', $instance::DOMAIN); ?></strong>
    174                     </label>
    175                     <p class="description">
    176 
    177                     </p>
    178                 </td>
    179             </tr>
    180             <tr>
    181                 <th><?php _e('Archives', $instance::DOMAIN); ?></th>
     172                        <strong><?php _e('Enable to link in feeds', $helper::DOMAIN); ?></strong>
     173                    </label>
     174                    <p class="description">
     175
     176                    </p>
     177                </td>
     178            </tr>
     179            <tr>
     180                <th><?php _e('Archives', $helper::DOMAIN); ?></th>
    182181                <td>
    183182                    <label>
    184183                        <input type="checkbox" name="on_archive" <?= $options['on_archive']; ?>/>
    185                         <strong><?php _e('Enable to link on archive and index pages (including home page)', $instance::DOMAIN); ?></strong>
    186                     </label>
    187                     <?= $instance->may_slow_down(); ?>
    188                 </td>
    189             </tr>
    190             <tr>
    191                 <th><?php _e('Heading', $instance::DOMAIN); ?></th>
     184                        <strong><?php _e('Enable to link on archive and index pages (including home page)', $helper::DOMAIN); ?></strong>
     185                    </label>
     186                    <?= $helper->may_slow_down(); ?>
     187                </td>
     188            </tr>
     189            <tr>
     190                <th><?php _e('Heading', $helper::DOMAIN); ?></th>
    192191                <td>
    193192                    <label>
    194193                        <input type="checkbox" name="on_heading" <?= $options['on_heading']; ?>/>
    195                         <strong><?php _e('Enable to link in heading tags (h1, h2, h3, h4, h5 and h6)', $instance::DOMAIN); ?></strong>
    196                     </label>
    197                 </td>
    198             </tr>
    199             </tbody>
    200         </table>
    201 
    202         <h2 class="title"><?php _e('Targeting', $instance::DOMAIN); ?></h2>
    203         <p><?php _e('What to automatically link.', $instance::DOMAIN); ?></p>
     194                        <strong><?php _e('Enable to link in heading tags (h1, h2, h3, h4, h5 and h6)', $helper::DOMAIN); ?></strong>
     195                    </label>
     196                </td>
     197            </tr>
     198            </tbody>
     199        </table>
     200
     201        <h2 class="title"><?php _e('Targeting', $helper::DOMAIN); ?></h2>
     202        <p><?php _e('What to automatically link.', $helper::DOMAIN); ?></p>
    204203        <table class="form-table">
    205204            <tbody>
     
    209208                    <label>
    210209                        <input type="checkbox" name="keywords_enable" <?= $options['keywords_enable']; ?> />
    211                         <strong><?php _e('Enable to link links with custom keywords', $instance::DOMAIN); ?></strong>
    212                     </label>
    213                     <?= $instance->may_slow_down(); ?>
     210                        <strong><?php _e('Enable to link links with custom keywords', $helper::DOMAIN); ?></strong>
     211                    </label>
     212                    <?= $helper->may_slow_down(); ?>
    214213                </td>
    215214            </tr>
     
    219218                    <label>
    220219                        <input type="checkbox" name="posts_enable" <?= $options['posts_enable']; ?> />
    221                         <strong><?php _e('Enable to link internal links to posts', $instance::DOMAIN); ?></strong>
    222                     </label>
    223                     <?= $instance->may_slow_down(); ?>
     220                        <strong><?php _e('Enable to link internal links to posts', $helper::DOMAIN); ?></strong>
     221                    </label>
     222                    <?= $helper->may_slow_down(); ?>
    224223                </td>
    225224            </tr>
     
    229228                    <label>
    230229                        <input type="checkbox" name="pages_enable" <?= $options['pages_enable']; ?> />
    231                         <strong><?php _e('Enable to link internal links to pages', $instance::DOMAIN); ?></strong>
    232                     </label>
    233                     <?= $instance->may_slow_down(); ?>
     230                        <strong><?php _e('Enable to link internal links to pages', $helper::DOMAIN); ?></strong>
     231                    </label>
     232                    <?= $helper->may_slow_down(); ?>
    234233                </td>
    235234            </tr>
     
    239238                    <label>
    240239                        <input type="checkbox" name="categories_enable" <?= $options['categories_enable']; ?> />
    241                         <strong><?php _e('Enable to link internal links to categories', $instance::DOMAIN); ?></strong>
    242                     </label>
    243                     <?= $instance->may_slow_down(); ?>
     240                        <strong><?php _e('Enable to link internal links to categories', $helper::DOMAIN); ?></strong>
     241                    </label>
     242                    <?= $helper->may_slow_down(); ?>
    244243                </td>
    245244            </tr>
     
    249248                    <label>
    250249                        <input type="checkbox" name="tags_enable" <?= $options['tags_enable']; ?> />
    251                         <strong><?php _e('Enable to link internal links to tags', $instance::DOMAIN); ?></strong>
    252                     </label>
    253                     <?= $instance->may_slow_down(); ?>
     250                        <strong><?php _e('Enable to link internal links to tags', $helper::DOMAIN); ?></strong>
     251                    </label>
     252                    <?= $helper->may_slow_down(); ?>
    254253                </td>
    255254            </tr>
     
    257256                <th>
    258257                    <label for="min_term_usage">
    259                         <?php _e('Minimum categories / tags', $instance::DOMAIN); ?>
     258                        <?php _e('Minimum categories / tags', $helper::DOMAIN); ?>
    260259                    </label>
    261260                </th>
     
    263262                    <input type="number" name="min_term_usage" id="min_term_usage" size="2" value="<?= $options['min_term_usage']; ?>"/>
    264263                    <p class="description">
    265                         <?php _e('Only link categories and tags that have been used the above number of times or more.', $instance::DOMAIN); ?>
    266                     </p>
    267                 </td>
    268             </tr>
    269             </tbody>
    270         </table>
    271 
    272         <h2 class="title"><?php _e('Excluding', $instance::DOMAIN); ?></h2>
    273         <table class="form-table">
    274             <tbody>
    275             <tr>
    276                 <th><?php _e('Exclude Keywords', $instance::DOMAIN); ?></th>
     264                        <?php _e('Only link categories and tags that have been used the above number of times or more.', $helper::DOMAIN); ?>
     265                    </p>
     266                </td>
     267            </tr>
     268            </tbody>
     269        </table>
     270
     271        <h2 class="title"><?php _e('Excluding', $helper::DOMAIN); ?></h2>
     272        <table class="form-table">
     273            <tbody>
     274            <tr>
     275                <th><?php _e('Exclude Keywords', $helper::DOMAIN); ?></th>
    277276                <td>
    278277                    <input type="text" name="keyword_ignore" size="90"
    279                            value="<?= $options['keyword_ignore']; ?>" placeholder="<?php _e('Add a word', $instance::DOMAIN); ?>"/>
    280                     <p class="description">
    281                         <?php _e('You may wish to ignore certain words or phrases from automatic linking. Separate them by comma.', $instance::DOMAIN); ?>
    282                     </p>
    283                 </td>
    284             </tr>
    285             <tr>
    286                 <th><?php _e('Exclude Posts / Pages', $instance::DOMAIN); ?></th>
     278                           value="<?= $options['keyword_ignore']; ?>" placeholder="<?php _e('Add a word', $helper::DOMAIN); ?>"/>
     279                    <p class="description">
     280                        <?php _e('You may wish to ignore certain words or phrases from automatic linking. Separate them by comma.', $helper::DOMAIN); ?>
     281                    </p>
     282                </td>
     283            </tr>
     284            <tr>
     285                <th><?php _e('Exclude Posts / Pages', $helper::DOMAIN); ?></th>
    287286                <td>
    288287                    <input type="text" name="post_ignore" size="90"
    289288                           value="<?= $options['post_ignore']; ?>" placeholder="<?php _e('Add an ID'); ?>"/>
    290289                    <p class="description">
    291                         <?php _e('You may wish to forbid automatic linking on certain posts or pages. Separate their ID by a comma.', $instance::DOMAIN); ?>
    292                     </p>
    293                 </td>
    294             </tr>
    295             <tr>
    296                 <th><?php _e('Exclude Categories / Tags', $instance::DOMAIN); ?></th>
     290                        <?php _e('You may wish to forbid automatic linking on certain posts or pages. Separate their ID by a comma.', $helper::DOMAIN); ?>
     291                    </p>
     292                </td>
     293            </tr>
     294            <tr>
     295                <th><?php _e('Exclude Categories / Tags', $helper::DOMAIN); ?></th>
    297296                <td>
    298297                    <input type="text" name="term_ignore" size="90"
    299                            value="<?= $options['term_ignore']; ?>" placeholder="<?php _e('Add an ID', $instance::DOMAIN); ?>"/>
    300                     <p class="description">
    301                         <?php _e('You may wish to forbid automatic linking on certain categories or tags. Separate their ID by a comma.', $instance::DOMAIN); ?>
     298                           value="<?= $options['term_ignore']; ?>" placeholder="<?php _e('Add an ID', $helper::DOMAIN); ?>"/>
     299                    <p class="description">
     300                        <?php _e('You may wish to forbid automatic linking on certain categories or tags. Separate their ID by a comma.', $helper::DOMAIN); ?>
    302301                    </p>
    303302                </td>
     
    307306
    308307        <h2 class="title"><?php _e('Options'); ?></h2>
    309         <p><?php _e('How automatically link', $instance::DOMAIN); ?></p>
     308        <p><?php _e('How automatically link', $helper::DOMAIN); ?></p>
    310309        <table class="form-table">
    311310            <tbody>
     
    313312                <th>
    314313                    <label for="max_links">
    315                         <?php _e('Max Links', $instance::DOMAIN); ?>
     314                        <?php _e('Max Links', $helper::DOMAIN); ?>
    316315                    </label>
    317316                </th>
     
    319318                    <input type="number" name="max_links" id="max_links" size="2" value="<?= $options['max_links']; ?>"/>
    320319                    <p class="description">
    321                         <?php _e('You can limit the maximum number of different links that will be generated per post. Set to 0 for no limit.', $instance::DOMAIN); ?>
     320                        <?php _e('You can limit the maximum number of different links that will be generated per post. Set to 0 for no limit.', $helper::DOMAIN); ?>
    322321                    </p>
    323322                </td>
     
    326325                <th>
    327326                    <label for="max_single_keyword">
    328                         <?php _e('Max Keyword Links', $instance::DOMAIN); ?>
     327                        <?php _e('Max Keyword Links', $helper::DOMAIN); ?>
    329328                    </label>
    330329                </th>
     
    332331                    <input type="number" name="max_single_keyword" id="max_single_keyword" size="2" value="<?= $options['max_single_keyword']; ?>"/>
    333332                    <p class="description">
    334                         <?php _e('You can limit the maximum number of links created with the same keyword. Set to 0 for no limit.', $instance::DOMAIN); ?>
     333                        <?php _e('You can limit the maximum number of links created with the same keyword. Set to 0 for no limit.', $helper::DOMAIN); ?>
    335334                    </p>
    336335                </td>
     
    339338                <th>
    340339                    <label for="max_single_url">
    341                         <?php _e('Max Same URLs', $instance::DOMAIN); ?>
     340                        <?php _e('Max Same URLs', $helper::DOMAIN); ?>
    342341                    </label>
    343342                </th>
     
    345344                    <input type="number" name="max_single_url" id="max_single_url" size="2" value="<?= $options['max_single_url']; ?>"/>
    346345                    <p class="description">
    347                         <?php _e('Limit number of same URLs the plugin will link to. Works only when Max Keyword Links above is set to 1. Set to 0 for no limit.', $instance::DOMAIN); ?>
    348                     </p>
    349                 </td>
    350             </tr>
    351             <tr>
    352                 <th><?php _e('Case sensitive', $instance::DOMAIN); ?></th>
     346                        <?php _e('Limit number of same URLs the plugin will link to. Works only when Max Keyword Links above is set to 1. Set to 0 for no limit.', $helper::DOMAIN); ?>
     347                    </p>
     348                </td>
     349            </tr>
     350            <tr>
     351                <th><?php _e('Case sensitive', $helper::DOMAIN); ?></th>
    353352                <td>
    354353                    <label>
    355354                        <input type="checkbox" name="case_sensitive" <?= $options['case_sensitive']; ?> />
    356                         <strong><?php _e('Enable case sensitivity', $instance::DOMAIN); ?></strong>
    357                     </label>
    358                 </td>
    359             </tr>
    360             <tr>
    361                 <th><?php _e('No follow', $instance::DOMAIN); ?></th>
     355                        <strong><?php _e('Enable case sensitivity', $helper::DOMAIN); ?></strong>
     356                    </label>
     357                </td>
     358            </tr>
     359            <tr>
     360                <th><?php _e('No follow', $helper::DOMAIN); ?></th>
    362361                <td>
    363362                    <label>
    364363                        <input type="checkbox" name="link_nofollow" <?= $options['link_nofollow']; ?>/>
    365                         <strong><?php _e('Add a nofollow attribute to the external links.', $instance::DOMAIN); ?></strong>
    366                     </label>
    367                 </td>
    368             </tr>
    369             <tr>
    370                 <th><?php _e('Open in new window', $instance::DOMAIN); ?></th>
     364                        <strong><?php _e('Add a nofollow attribute to the external links.', $helper::DOMAIN); ?></strong>
     365                    </label>
     366                </td>
     367            </tr>
     368            <tr>
     369                <th><?php _e('Open in new window', $helper::DOMAIN); ?></th>
    371370                <td>
    372371                    <label>
    373372                        <input type="checkbox" name="link_blank" <?= $options['link_blank']; ?>/>
    374                         <strong><?php _e('Open the external links in a new window.', $instance::DOMAIN); ?></strong>
     373                        <strong><?php _e('Open the external links in a new window.', $helper::DOMAIN); ?></strong>
    375374                    </label>
    376375                </td>
  • wp-auto-links/trunk/vendor/autoload.php

    r1994765 r1995970  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInited7cf8d6445ccabd2c78f8bf66b1be21::getLoader();
     7return ComposerAutoloaderInit924981ff406542d5045ead6999706070::getLoader();
  • wp-auto-links/trunk/vendor/composer/autoload_real.php

    r1994765 r1995970  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInited7cf8d6445ccabd2c78f8bf66b1be21
     5class ComposerAutoloaderInit924981ff406542d5045ead6999706070
    66{
    77    private static $loader;
     
    2020        }
    2121
    22         spl_autoload_register(array('ComposerAutoloaderInited7cf8d6445ccabd2c78f8bf66b1be21', 'loadClassLoader'), true, true);
     22        spl_autoload_register(array('ComposerAutoloaderInit924981ff406542d5045ead6999706070', 'loadClassLoader'), true, true);
    2323        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInited7cf8d6445ccabd2c78f8bf66b1be21', 'loadClassLoader'));
     24        spl_autoload_unregister(array('ComposerAutoloaderInit924981ff406542d5045ead6999706070', 'loadClassLoader'));
    2525
    2626        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    2828            require_once __DIR__ . '/autoload_static.php';
    2929
    30             call_user_func(\Composer\Autoload\ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21::getInitializer($loader));
     30            call_user_func(\Composer\Autoload\ComposerStaticInit924981ff406542d5045ead6999706070::getInitializer($loader));
    3131        } else {
    3232            $map = require __DIR__ . '/autoload_namespaces.php';
  • wp-auto-links/trunk/vendor/composer/autoload_static.php

    r1994765 r1995970  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21
     7class ComposerStaticInit924981ff406542d5045ead6999706070
    88{
    99    public static $prefixLengthsPsr4 = array (
     
    122122    {
    123123        return \Closure::bind(function () use ($loader) {
    124             $loader->prefixLengthsPsr4 = ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21::$prefixLengthsPsr4;
    125             $loader->prefixDirsPsr4 = ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21::$prefixDirsPsr4;
    126             $loader->classMap = ComposerStaticInited7cf8d6445ccabd2c78f8bf66b1be21::$classMap;
     124            $loader->prefixLengthsPsr4 = ComposerStaticInit924981ff406542d5045ead6999706070::$prefixLengthsPsr4;
     125            $loader->prefixDirsPsr4 = ComposerStaticInit924981ff406542d5045ead6999706070::$prefixDirsPsr4;
     126            $loader->classMap = ComposerStaticInit924981ff406542d5045ead6999706070::$classMap;
    127127
    128128        }, null, ClassLoader::class);
Note: See TracChangeset for help on using the changeset viewer.