Configuration options are here. Questions on configuration, etc.? Make sure to read the README. Version: 2.1 Author: ShareThis and Crowd Favorite (crowdfavorite.com) Author URI: http://sharethis.com */ load_plugin_textdomain('sharethis'); if (!function_exists('ak_uuid')) { function ak_uuid() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x' , mt_rand( 0, 0xffff ) , mt_rand( 0, 0xffff ) , mt_rand( 0, 0xffff ) , mt_rand( 0, 0x0fff ) | 0x4000 , mt_rand( 0, 0x3fff ) | 0x8000 , mt_rand( 0, 0xffff ) , mt_rand( 0, 0xffff ) , mt_rand( 0, 0xffff ) ); } } function st_install() { $publisher_id = get_option('st_pubid'); $widget = get_option('st_widget'); if ($publisher_id != "") { if ($widget != "") { $widget = preg_replace("/\&/", "&", $widget); $pattern = "/([\&\?])publisher\=([^\&\"]*)/"; preg_match($pattern, $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\"\>\s*\<\/\s*script\s*\>/", "&publisher=".$publisher_id."\">", $widget); $widget = preg_replace("/widget\/\&publisher\=/", "widget/?publisher=", $widget); } elseif ($matches[2] == "") { $widget = preg_replace("/([\&\?])publisher\=/", "$1publisher=".$publisher_id, $widget); } else { if ($publisher_id != $matches[2]) { $publisher_id = $matches[2]; } } } else { $widget = st_default_widget(); $widget = preg_replace("/\"\>\s*\<\/\s*script\s*\>/", "&publisher=".$publisher_id."\">", $widget); } } else { if ($widget != "") { $widget = preg_replace("/\&/", "&", $widget); $pattern = "/([\&\?])publisher\=([^\&\"]*)/"; preg_match($pattern, $widget, $matches); if ($matches[0] == "") { $publisher_id = ak_uuid(); $widget = preg_replace("/\"\>\s*\<\/\s*script\s*\>/", "&publisher=".$publisher_id."\">", $widget); $widget = preg_replace("/widget\/\&publisher\=/", "widget/?publisher=", $widget); } elseif ($matches[2] == "") { $publisher_id = ak_uuid(); $widget = preg_replace("/([\&\?])publisher\=/", "$1publisher=".$publisher_id, $widget); } else { $publisher_id = $matches[2]; } } else { $publisher_id = ak_uuid(); $widget = st_default_widget(); $widget = preg_replace("/\"\>\s*\<\/\s*script\s*\>/", "&publisher=".$publisher_id."\">", $widget); } } preg_match("/\]*charset\=\"utf\-8\"[^\>]*/", $widget, $matches); if ($matches[0] == "") { preg_match("/\]*charset\=\"[^\"]*\"[^\>]*/", $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\]*type\=\"text\/javascript\"[^\>]*/", $widget, $matches); if ($matches[0] == "") { preg_match("/\]*type\=\"[^\"]*\"[^\>]*/", $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\ID).'" });'; return $sharethis; } function st_link() { global $post; $sharethis = '

ShareThis

'; return $sharethis; } function sharethis_button() { echo st_widget(); } function st_add_link($content) { if (is_feed()) { return $content.st_link(); } else if ( (is_page() && get_option('st_add_to_page') != 'no') || (!is_page() && get_option('st_add_to_content') != 'no') ) { return $content.'

'.st_widget().'

'; } else { return $content; } } function st_remove_st_add_link($content) { remove_action('the_content', 'st_add_link'); return $content; } function st_add_st_add_link($content) { add_action('the_content', 'st_add_link'); $content .= st_widget(); return $content; } if (get_option('st_add_to_content') != 'no' || get_option('st_add_to_page') != 'no') { add_action('the_content_rss', 'st_add_link'); add_filter('get_the_excerpt', 'st_remove_st_add_link', 9); add_filter('the_content', 'st_add_link'); if (substr(get_bloginfo('version'), 0, 3) == "1.5" || substr(get_bloginfo('version'), 0, 3) == "2.0") { add_filter('the_excerpt', 'st_add_st_add_link', 11); } else { add_filter('get_the_excerpt', 'st_add_st_add_link', 11); } } function st_widget_fix_domain($widget) { return preg_replace( "/\]*)src\=\"http\:\/\/sharethis/" , "", $widget); $widget = preg_replace("/widget\/\&wp\=/", "widget/?wp=", $widget); } else { $widget = preg_replace("/([\&\?])wp\=([^\&\"]*)/", "$1wp=".get_bloginfo('version'), $widget); } return $widget; } function st_default_widget() { return ''; } if (!function_exists('ak_can_update_options')) { function ak_can_update_options() { if (function_exists('current_user_can')) { if (current_user_can('manage_options')) { return true; } } else { global $user_level; get_currentuserinfo(); if ($user_level >= 8) { return true; } } return false; } } function st_request_handler() { if (!empty($_REQUEST['st_action'])) { switch ($_REQUEST['st_action']) { case 'st_update_settings': if (ak_can_update_options()) { if (!empty($_POST['st_widget'])) { // have widget $widget = stripslashes($_POST['st_widget']); $widget = preg_replace("/\&/", "&", $widget); $pattern = "/([\&\?])publisher\=([^\&\"]*)/"; preg_match($pattern, $widget, $matches); if ($matches[0] == "") { // widget does not have publisher parameter at all $publisher_id = get_option('st_pubid'); if ($publisher_id != "") { $widget = preg_replace("/\"\>\s*\<\/\s*script\s*\>/", "&publisher=".$publisher_id."\">", $widget); $widget = preg_replace("/widget\/\&publisher\=/", "widget/?publisher=", $widget); } else { $publisher_id = ak_uuid(); $widget = preg_replace("/\"\>\s*\<\/\s*script\s*\>/", "&publisher=".$publisher_id."\">", $widget); $widget = preg_replace("/widget\/\&publisher\=/", "widget/?publisher=", $widget); } } elseif ($matches[2] == "") { // widget does not have pubid in publisher parameter $publisher_id = get_option('st_pubid'); if ($publisher_id != "") { $widget = preg_replace("/([\&\?])publisher\=/", "$1publisher=".$publisher_id, $widget); } else { $publisher_id = ak_uuid(); $widget = preg_replace("/([\&\?])publisher\=/", "$1publisher=".$publisher_id, $widget); } } else { // widget has pubid in publisher parameter $publisher_id = get_option('st_pubid'); if ($publisher_id != "") { if ($publisher_id != $matches[2]) { $publisher_id = $matches[2]; } } else { $publisher_id = $matches[2]; } } } else { // does not have widget $publisher_id = get_option('st_pubid'); if ($publisher_id == "") { $publisher_id = ak_uuid(); } $widget = st_default_widget(); $widget = preg_replace("/\"\>\s*\<\/\s*script\s*\>/", "&publisher=".$publisher_id."\">", $widget); $widget = preg_replace("/widget\/\&publisher\=/", "widget/?publisher=", $widget); } preg_match("/\]*charset\=\"utf\-8\"[^\>]*/", $widget, $matches); if ($matches[0] == "") { preg_match("/\]*charset\=\"[^\"]*\"[^\>]*/", $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\]*type\=\"text\/javascript\"[^\>]*/", $widget, $matches); if ($matches[0] == "") { preg_match("/\]*type\=\"[^\"]*\"[^\>]*/", $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\

'.__('ShareThis Options', 'sharethis').'

Paste your widget code in here:

'); $options = array( 'st_add_to_content' => __('Automatically add ShareThis to your posts?*', 'sharethis') , 'st_add_to_page' => __('Automatically add ShareThis to your pages?*', 'sharethis') ); foreach ($options as $option => $description) { $$option = get_option($option); if (empty($$option) || $$option == 'yes') { $yes = ' selected="selected"'; $no = ''; } else { $yes = ''; $no = ' selected="selected"'; } print('

'); } print('

'.__('* Note, if you turn this off, you will want to add the ShareThis template tag to your theme.', 'sharethis').'

'); } function st_menu_items() { if (ak_can_update_options()) { add_options_page( __('ShareThis Options', 'sharethis') , __('ShareThis', 'sharethis') , 8 , basename(__FILE__) , 'st_options_form' ); } } add_action('admin_menu', 'st_menu_items'); ?>