function st_widget_head() { adding_st_filters(); $widget = get_option('st_widget'); if ($widget == '') { } else { //$widget = st_widget_add_wp_version($widget); $widget = st_widget_fix_domain($widget); $widget = preg_replace("/\\&/", "&", $widget); } print stripslashes($widget); }
function st_request_handler() { if (!empty($_REQUEST['st_action'])) { switch ($_REQUEST['st_action']) { case 'st_update_settings': // Security check nonce if (!wp_verify_nonce($_REQUEST['st_nonce'], 'wp-sharethis')) { // This nonce is not valid. die('Security check'); } if (ak_can_update_options()) { if ($_POST['Edit'] == "") { $publisher_id = $_POST['st_pkey']; if ($_POST['st_callesi'] == "0") { $cns_settings = $_POST['copynshareSettings']; } else { $cns_settings = ""; } //print_r ($_POST); //var_dump($cns_settings); /* updates username in database*/ if ($_POST['st_user_name'] != "" && $_POST['st_user_name'] != "undefined") { update_option('st_username', $_POST['st_user_name']); } //update st_version to figure out which widget to use. if (!empty($_POST['st_version'])) { update_option('st_version', $_POST['st_version']); if ($_POST['st_version'] == '5x') { $st_switchTo5x = "true"; } elseif ($_POST['st_version'] == '4x') { $st_switchTo5x = "false"; } } $widgetTemp = "<script charset=\"utf-8\" type=\"text/javascript\">var switchTo5x=" . $st_switchTo5x . ";</script>"; $widgetTemp .= "<script charset=\"utf-8\" type=\"text/javascript\" src=\"http://w.sharethis.com/button/buttons.js\"></script>"; $widgetTemp .= "<script charset=\"utf-8\" type=\"text/javascript\">stLight.options({publisher:\"{$publisher_id}\" {$cns_settings}});var st_type='wordpress" . trim(get_bloginfo('version')) . "';</script>"; if ($_POST['selectedBar'] == "hoverbarStyle" || $_POST['selectedBar'] == "pulldownStyle" || $_POST['sharenowSelected'] == "true") { $widgetTemp .= "<script charset=\"utf-8\" type=\"text/javascript\" src=\"http://s.sharethis.com/loader.js\"></script>"; } if ($_POST['selectedBar'] == "hoverbarStyle") { $st_hoverbar_services = $_POST['hoverbar']['services']; $st_hoverbar_services = '"' . str_replace(',', '","', $st_hoverbar_services) . '"'; $widgetTemp .= "<script charset=\"utf-8\" type=\"text/javascript\">var options={ \"publisher\":\"" . $publisher_id . "\", \"position\": \"" . $_POST['hoverbar']['position'] . "\", \"chicklets_params\": {\"twitter\":{\"st_via\":\"" . $_POST['twitter']['via'] . "\" }, \"instagram\" :{\"st_username\":\"" . $_POST['instagram']['username'] . "\" } }, \"chicklets\": { \"items\": [" . $st_hoverbar_services . "] } }; var st_hover_widget = new sharethis.widgets.hoverbuttons(options);</script>"; } else { if ($_POST['selectedBar'] == "pulldownStyle") { $st_pulldown_services = $_POST['pulldownbar']['services']; $st_pulldown_services = '"' . str_replace(',', '","', $st_pulldown_services) . '"'; $widgetTemp .= "<script charset=\"utf-8\" type=\"text/javascript\">var options={ \"publisher\": \"" . $publisher_id . "\", \"scrollpx\": " . $_POST['pulldownbar']['scrollpx'] . ", \"ad\": { \"visible\": false}, \"chicklets\": { \"items\": [" . $st_pulldown_services . "]}};var st_pulldown_widget = new sharethis.widgets.pulldownbar(options); </script>"; update_option('st_pulldownlogo', $_POST['pulldownbar']['logo']); } } if ($_POST['sharenowSelected'] == "true") { $widgetTemp .= "<script charset=\"utf-8\" type=\"text/javascript\">var options={ \"service\": \"facebook\", \"timer\": { \"countdown\": 30, \"interval\": 10, \"enable\": false}, \"frictionlessShare\": false, \"style\": \"" . $_POST['sharenow']['theme'] . "\", publisher:\"" . $publisher_id . "\"};var st_service_widget = new sharethis.widgets.serviceWidget(options);</script>"; } // note: do not convert & to & or append WP version here $widget = st_widget_fix_domain($widgetTemp); update_option('st_pubid', $publisher_id); update_option('st_widget', $widget); if (!empty($_POST['st_tags'])) { $tagsin = $_POST['st_tags']; $tagsin = preg_replace("/\\n|\\t/", "", $tagsin); $tagsin = preg_replace("/\\\\'/", "'", $tagsin); $tagsin = trim($tagsin); update_option('st_tags', $tagsin); } else { update_option('st_tags', ' '); // in case of buttons not selected } if (!empty($_POST['st_services'])) { update_option('st_services', trim($_POST['st_services'], ",")); } if (!empty($_POST['st_current_type'])) { update_option('st_current_type', trim($_POST['st_current_type'], ",")); } $options = array('st_add_to_content', 'st_add_to_page'); foreach ($options as $option) { if (isset($_POST[$option]) && in_array($_POST[$option], array('yes', 'no'))) { update_option($option, $_POST[$option]); } } //header('Location: '.get_bloginfo('wpurl').'/wp-admin/options-general.php?page=sharethis.php&updated=true'); //$blog_title = get_bloginfo('wpurl'); //$blog_title .= "/wp-admin/options-general.php?page=sharethis.php"; //header('refresh:0;url='.$blog_title); //die(); die("SUCCESS"); } } break; } die("FAILURE"); } }
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\=([^\&\"]*)/"; $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 . "\"></script>", $widget); $widget = preg_replace("/widget\\/\\&publisher\\=/", "widget/?publisher=", $widget); } } elseif ($matches[1] == "") { // 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 { $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[1]) { $publisher_id = $matches[1]; } } else { $publisher_id = $matches[1]; } } } else { // does not have widget $publisher_id = get_option('st_pubid'); } preg_match("/\\<script\\s[^\\>]*charset\\=\"utf\\-8\"[^\\>]*/", $widget, $matches); if ($matches[0] == "") { preg_match("/\\<script\\s[^\\>]*charset\\=\"[^\"]*\"[^\\>]*/", $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\\<script\\s/", "<script charset=\"utf-8\" ", $widget); } else { $widget = preg_replace("/\\scharset\\=\"[^\"]*\"/", " charset=\"utf-8\"", $widget); } } preg_match("/\\<script\\s[^\\>]*type\\=\"text\\/javascript\"[^\\>]*/", $widget, $matches); if ($matches[0] == "") { preg_match("/\\<script\\s[^\\>]*type\\=\"[^\"]*\"[^\\>]*/", $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\\<script\\s/", "<script type=\"text/javascript\" ", $widget); } else { $widget = preg_replace("/\\stype\\=\"[^\"]*\"/", " type=\"text/javascript\"", $widget); } } // note: do not convert & to & or append WP version here $widget = st_widget_fix_domain($widget); update_option('st_pubid', $publisher_id); update_option('st_widget', $widget); $options = array('st_add_to_content', 'st_add_to_page'); foreach ($options as $option) { if (isset($_POST[$option]) && in_array($_POST[$option], array('yes', 'no'))) { update_option($option, $_POST[$option]); } } header('Location: ' . get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=sharethis.php&updated=true'); die; } break; } } }
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); if (!preg_match('/buttons.js/', $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 . "\"></script>", $widget); $widget = preg_replace("/widget\\/\\&publisher\\=/", "widget/?publisher=", $widget); } } elseif ($matches[1] == "") { // 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 { $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[1]) { $publisher_id = $matches[1]; } } else { $publisher_id = $matches[1]; } } } else { $publisher_id = get_option('st_pubid'); $pkeyUpdated = false; if (!empty($_POST['st_pkey']) && $publisher_id !== $_POST['st_pkey']) { update_option('st_pubid', $_POST['st_pkey']); $publisher_id = $_POST['st_pkey']; $pkeyUpdated = true; } if (!preg_match('/stLight.options/', $widget) || $pkeyUpdated == true) { $widget = "<script charset=\"utf-8\" type=\"text/javascript\" src=\"http://w.sharethis.com/button/buttons.js\"></script>"; $widget .= "<script type=\"text/javascript\">stLight.options({publisher:'{$publisher_id}'});var st_type='wordpress" . trim(get_bloginfo('version')) . "';</script>"; update_option('st_widget', $widget); } } } else { // does not have widget $publisher_id = get_option('st_pubid'); } preg_match("/\\<script\\s[^\\>]*charset\\=\"utf\\-8\"[^\\>]*/", $widget, $matches); if ($matches[0] == "") { preg_match("/\\<script\\s[^\\>]*charset\\=\"[^\"]*\"[^\\>]*/", $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\\<script\\s/", "<script charset=\"utf-8\" ", $widget); } else { $widget = preg_replace("/\\scharset\\=\"[^\"]*\"/", " charset=\"utf-8\"", $widget); } } preg_match("/\\<script\\s[^\\>]*type\\=\"text\\/javascript\"[^\\>]*/", $widget, $matches); if ($matches[0] == "") { preg_match("/\\<script\\s[^\\>]*type\\=\"[^\"]*\"[^\\>]*/", $widget, $matches); if ($matches[0] == "") { $widget = preg_replace("/\\<script\\s/", "<script type=\"text/javascript\" ", $widget); } else { $widget = preg_replace("/\\stype\\=\"[^\"]*\"/", " type=\"text/javascript\"", $widget); } } //update st_version to figure out which widget to use. if (!empty($_POST['st_version'])) { update_option('st_version', $_POST['st_version']); if ($_POST['st_version'] == '5x') { if (strpos($widget, "switchTo5x=true")) { } else { if (strpos($widget, "switchTo5x=false")) { $widget = preg_replace("/switchTo5x=false/", "switchTo5x=true", $widget); } else { $widget = "<script charset=\"utf-8\" type=\"text/javascript\">var switchTo5x=true;</script>" . $widget; } } } elseif ($_POST['st_version'] == '4x') { $widget = preg_replace("/switchTo5x=true/", "switchTo5x=false", $widget); } } // note: do not convert & to & or append WP version here $widget = st_widget_fix_domain($widget); update_option('st_pubid', $publisher_id); update_option('st_widget', $widget); if (!empty($_POST['st_pkey'])) { update_option('st_pubid', $_POST['st_pkey']); } if (!empty($_POST['st_tags'])) { $tagsin = $_POST['st_tags']; $tagsin = preg_replace("/\\n|\\t/", "</span>", $tagsin); $tagsin = preg_replace("/\\\\'/", "'", $tagsin); //$tagsin=htmlspecialchars_decode($tagsin); $tagsin = trim($tagsin); update_option('st_tags', $tagsin); } if (!empty($_POST['st_services'])) { update_option('st_services', trim($_POST['st_services'], ",")); } if (!empty($_POST['st_current_type'])) { update_option('st_current_type', trim($_POST['st_current_type'], ",")); } $options = array('st_add_to_content', 'st_add_to_page'); foreach ($options as $option) { if (isset($_POST[$option]) && in_array($_POST[$option], array('yes', 'no'))) { update_option($option, $_POST[$option]); } } header('Location: ' . get_bloginfo('wpurl') . '/wp-admin/options-general.php?page=sharethis.php&updated=true'); die; } break; } } }