Пример #1
0
<?php

//hook to insert js code in footer
add_action('wp_footer', 'sl_footer_js');
//hook into switch theme to check if the new theme works with the skimlinks js footer
add_action('switch_theme', 'sl_verify_footer_js');
//hook into the RSS feed to replace external links with skimlinks ones (only if option is selected)
add_action('template_redirect', 'sl_rss_filtering_hooks');
function sl_rss_filtering_hooks()
{
    if (sl_is_rss_filtering_enabled()) {
        global $wp_version;
        //versions older than 2.9 do not call the 'the_content_rss' filter, so it must be check manually
        if (version_compare($wp_version, '2.9', '<')) {
            if (is_feed()) {
                add_filter('the_content', 'sl_modify_enternal_links');
            }
        } else {
            add_filter('the_content_rss', 'sl_modify_enternal_links');
            add_filter('the_content_feed', 'sl_modify_enternal_links');
        }
    }
}
// hook to insert disclosure badge (if checked)
if (sl_is_disclosure_badge_enabled() && sl_is_plugin_configured()) {
    add_filter('the_content', 'sl_add_displausre_badge_to_content');
}
Пример #2
0
/**
 * Echoes sl_get_footer_js and also is responsible for the footer js validation
 * 
 * @return void
 */
function sl_footer_js()
{
    // set an option to say footer js is being shown (so the theme is working)
    if (isset($_GET['sl_verify_footer_js']) && untrailingslashit($_GET['sl_verify_footer_js']) == '1') {
        update_option('sl_footer_js_works_for', get_current_theme());
    }
    // if the plugin is not configered, don't show anything
    if (!sl_is_plugin_configured()) {
        return;
    }
    echo sl_get_footer_js();
}