Title: [Plugin: ShareThis: Share Buttons and Sharing Analytics] HTTPS fix for ShareThis Plugin
Last modified: August 20, 2016

---

# [Plugin: ShareThis: Share Buttons and Sharing Analytics] HTTPS fix for ShareThis Plugin

 *  [grindflow](https://wordpress.org/support/users/grindflow/)
 * (@grindflow)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-sharethis-share-buttons-and-sharing-analytics-https-fix-for-sharethis-plugin/)
 * Courtesty of the [Grindflow Management](http://grindflow.com) 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=\"http://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=\"http://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)){
       ```
   
 * [http://wordpress.org/extend/plugins/share-this/](http://wordpress.org/extend/plugins/share-this/)

The topic ‘[Plugin: ShareThis: Share Buttons and Sharing Analytics] HTTPS fix for
ShareThis Plugin’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/share-this_b9babb.svg)
 * [ShareThis: Free Sharing Buttons and Tools](https://wordpress.org/plugins/share-this/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/share-this/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/share-this/)
 * [Active Topics](https://wordpress.org/support/plugin/share-this/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/share-this/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/share-this/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [grindflow](https://wordpress.org/support/users/grindflow/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-sharethis-share-buttons-and-sharing-analytics-https-fix-for-sharethis-plugin/)
 * Status: not resolved