Plugin Directory

Changeset 1531405


Ignore:
Timestamp:
11/10/2016 05:59:31 AM (9 years ago)
Author:
surdotly
Message:

option of replace all

Location:
surly/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • surly/trunk/readme.txt

    r1513288 r1531405  
    2929
    3030== Changelog ==
     31
     32= 2.4.1 =
     33
     34* Option of replace all
    3135
    3236= 2.4.0 =
  • surly/trunk/surly-behaviour.php

    r1513288 r1531405  
    3636                    <p class="description">
    3737                        If it's not selected, the links will be replaced in Comments only.
     38                    </p>
     39                </fieldset>
     40            </td>
     41        </tr>
     42        <tr valign="top">
     43            <th scope="row">Replace all outbound URLs</th>
     44            <td>
     45                <fieldset>
     46                    <legend class="screen-reader-text">
     47                        <span>Replace all outbound URLs</span>
     48                    </legend>
     49                    <label for="replace_all">
     50                        <input id="replace_all" type="checkbox" value="1" name="surly_replace_all"<?php if (get_option('surly_replace_all') == 1) {echo ' checked';}?>>
     51                    </label>
     52                    <p class="description">
     53                        Sur.ly will process all outbound links on your website <b>(beta)</b>.
    3854                    </p>
    3955                </fieldset>
  • surly/trunk/surly.php

    r1513288 r1531405  
    2020 * Plugin URI: http://sur.ly
    2121 * Description: Sur.ly enables you to control and analyze any outbound links published by your site visitors in user-generated content as well as to protect and retain users that follow such links.
    22  * Version: 2.4.0
     22 * Version: 2.4.1
    2323 * Author: Sur.ly
    2424 */
     
    116116    delete_option('surly_users');
    117117    delete_option('surly_replace_in_posts');
     118    delete_option('surly_replace_all');
    118119    delete_option('surly_shorten_urls');
    119120    delete_option('surly_panel_settings');
     
    222223}
    223224
    224 function surly_replace($content, $userId)
     225function surly_replace($content, $userId = null)
    225226{
    226227    $surly = _surly_get_sdk();
    227228
    228     return $surly->isWhitelistedUser($userId) ? $content : $surly->process($content);
     229    return ($userId && $surly->isWhitelistedUser($userId)) ? $content : $surly->process($content);
    229230}
    230231
     
    254255
    255256    return $surly;
     257}
     258
     259function surly_replace_all()
     260{
     261    if ( !is_admin() ) {
     262        ob_start('surly_replace');
     263    }
    256264}
    257265
     
    384392    $shorten_urls = isset($_POST['surly_shorten_urls']) ? 1 : 0;
    385393    $replace_in_posts = isset($_POST['surly_replace_in_posts']) ? 1 : 0;
     394    $replace_all = isset($_POST['surly_replace_all']) ? 1 : 0;
    386395    $trusted_users = isset($_POST['trusted_users']) ? $_POST['trusted_users'] : array();
    387396    $url_processing = isset($_POST['surly_url_processing']) ? 1 : 0;
     
    426435    update_option('surly_shorten_urls', $shorten_urls);
    427436    update_option('surly_replace_in_posts', $replace_in_posts);
     437    update_option('surly_replace_all', $replace_all);
    428438    update_option('surly_url_processing', $url_processing);
    429439    update_option('surly_subdomain', $subdomain);
     
    452462
    453463if (get_option('surly_url_processing') == 1) {
    454     if (get_option('surly_replace_in_posts') == 1) {
    455         add_filter('the_content', 'surly_replace_in_content', 9999);
    456         add_filter('the_excerpt', 'surly_replace_in_content', 9999);
    457     }
    458 
    459     add_filter('comment_text', 'surly_replace_in_comment', 9999);
    460     add_filter('comment_excerpt', 'surly_replace_in_comment', 9999);
    461     add_filter('get_comment_author_link', 'surly_replace_in_comment', 9999);
     464    if (get_option('surly_replace_all') == 1) {
     465        add_action('wp_loaded', 'surly_replace_all', 9999);
     466    } else {
     467        if (get_option('surly_replace_in_posts') == 1) {
     468            add_filter('the_content', 'surly_replace_in_content', 9999);
     469            add_filter('the_excerpt', 'surly_replace_in_content', 9999);
     470        }
     471
     472        add_filter('comment_text', 'surly_replace_in_comment', 9999);
     473        add_filter('comment_excerpt', 'surly_replace_in_comment', 9999);
     474        add_filter('get_comment_author_link', 'surly_replace_in_comment', 9999);
     475    }
    462476}
    463477
Note: See TracChangeset for help on using the changeset viewer.