[Plugin: ShareThis: Share Buttons and Sharing Analytics] HTTPS fix for ShareThis Plugin
-
Courtesty of the Grindflow Management team, here is a small patch to eliminate HTTPS content warnings:
--- share-this/sharethis.php.orig 2012-08-09 12:31:36.000000000 -0600 +++ share-this/sharethis.php 2012-08-09 12:29:27.000000000 -0600 @@ -31,9 +31,14 @@ $_stversion=5.0; +function st_get_widget() { + $option = (empty($_SERVER['HTTPS'])) ? 'st_widget' : 'st_widget_ssl'; + return get_option($option); +} + function install_ShareThis(){ $publisher_id = get_option('st_pubid'); //pub key value - $widget = get_option('st_widget'); //entire script tag + $widget = st_get_widget(); //entire script tag $newUser=false; if (get_option('st_version') == '') { @@ -56,7 +61,12 @@ } if($widget==false || !preg_match('/stLight.options/',$widget)){ - $pkey2=get_option('st_pubid'); + $pkey2=get_option('st_pubid'); + $widget ="<script charset=\"utf-8\" type=\"text/javascript\">var switchTo5x=true;</script>"; + $widget.="<script charset=\"utf-8\" type=\"text/javascript\" src=\"https://ws.sharethis.com/button/buttons.js\"></script>"; + $widget.="<script type=\"text/javascript\">stLight.options({publisher:'$pkey2'});var st_type='wordpress".trim(get_bloginfo('version'))."';</script>"; + update_option('st_widget_ssl',$widget); + $widget ="<script charset=\"utf-8\" type=\"text/javascript\">var switchTo5x=true;</script>"; $widget.="<script charset=\"utf-8\" type=\"text/javascript\" src=\"https://w.sharethis.com/button/buttons.js\"></script>"; $widget.="<script type=\"text/javascript\">stLight.options({publisher:'$pkey2'});var st_type='wordpress".trim(get_bloginfo('version'))."';</script>"; @@ -91,7 +101,7 @@ } function getKeyFromTag(){ - $widget = get_option('st_widget'); + $widget = st_get_widget(); $pattern = "/publisher\=([^\&\"]*)/"; preg_match($pattern, $widget, $matches); $pkey = $matches[1]; @@ -134,7 +144,7 @@ } function st_widget_head() { - $widget = get_option('st_widget'); + $widget = st_get_widget(); if ($widget == '') { } else{ @@ -349,6 +359,10 @@ $pkeyUpdated=false; } if(!preg_match('/stLight.options/',$widget) || $pkeyUpdated==true){ + $widget="<script charset=\"utf-8\" type=\"text/javascript\" src=\"https://ws.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_ssl',$widget); + $widgetTemp="<script charset=\"utf-8\" type=\"text/javascript\" src=\"https://w.sharethis.com/button/buttons.js\"></script>"; $widgetTemp.="<script type=\"text/javascript\">stLight.options({publisher:'$publisher_id'});var st_type='wordpress".trim(get_bloginfo('version'))."';</script>"; if (preg_match('/loader.js/',$widget)) { @@ -494,7 +508,7 @@ $toShow=""; } else{ - $toShow=get_option('st_widget'); + $toShow=st_get_widget(); } $hidden_input_feild = ''; @@ -738,7 +752,7 @@ global $post; //$st_json='{"type":"vcount","services":"sharethis,facebook,twitter,email"}'; $out=""; - $widget=get_option('st_widget'); + $widget=st_get_widget(); $tags=get_option('st_tags'); if(!empty($widget)){ if(preg_match('/buttons.js/',$widget)){
- The topic ‘[Plugin: ShareThis: Share Buttons and Sharing Analytics] HTTPS fix for ShareThis Plugin’ is closed to new replies.