Example #1
0
function sl_settings_display_errors($setting)
{
    $option = get_option($setting);
    if (!sl_is_footer_js_verified()) {
        $option['not-verified'] = 'There appears to be an error in calling the Skimlinks Plugin from your theme\'s footer.php file, please ensure your footer.php file includes the standard WordPress function "wp_footer()" above the closing body tag.';
    }
    if (sl_is_subdomain_enabled() && !sl_get_subdomain()) {
        $option['no-subdomain'] = 'Please enter your custom subdomain or unselect "Enable Custom Subdomain"';
    }
    if (is_array($option)) {
        foreach ($option as $slug => $message) {
            echo "<div id='sl_messages' class='error fade {$slug}'><p>{$message}</p></div>";
            unset($option[$slug]);
        }
        update_option($setting, $option);
    }
}
Example #2
0
/**
 * Modifies a link with the skimlinks version (used from preg_replace_callback
 * 
 * @param array $links
 * @return string new link
 */
function sl_modify_external_link($links)
{
    $redirect_domain = "http://go.redirectingat.com/";
    $do_not_touch_domains = array("redirectingat.com", "go.redirectingat.com");
    // if the admin set up a custom subdomain add it to the list
    if (sl_is_subdomain_enabled() && sl_get_subdomain()) {
        $redirect_domain = sl_get_subdomain();
        $url_parts = parse_url($redirect_domain);
        if (isset($url_parts['host'])) {
            $do_not_touch_domains[] = $url_parts['host'];
        }
    }
    $is_encoded = $links[1] == '&quot;';
    $link = $links[2];
    // get the url's domain so we can do exact mathcing
    $url_parts = parse_url($link);
    if (isset($url_parts['host'])) {
        $link_domain = $url_parts['host'];
    } else {
        $link_domain = "";
    }
    // dont modify internal links, or not http ones, or already skimlinked ones
    if (strpos($link, 'http') !== 0 || strpos($link, get_bloginfo('url')) !== false || in_array($link_domain, $do_not_touch_domains)) {
        return $links[0];
    }
    $link = htmlentities($redirect_domain . '?id=' . sl_get_publisher_id() . '&xs=1&url=' . urlencode($link) . '&sref=rss');
    // in some cases the content contains already encoded data. lets double encode it
    if ($is_encoded) {
        $link = htmlentities($link);
    }
    return ' href=' . $links[1] . $link . $links[1];
}