Plugin Directory

Changeset 3733014


Ignore:
Timestamp:
10/07/2026 04:46:55 PM (3 weeks ago)
Author:
ShareThis
Message:

Update to version 2.3.13 from GitHub

Location:
sharethis-share-buttons
Files:
4 added
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • sharethis-share-buttons/tags/2.3.13/js/admin.js

    r2981272 r3733014  
    523523                                nonce: self.data.nonce
    524524                        } ).always( function(response) {
    525                                 self.loadPreview( 'submit', 'inline' );
    526                                 self.loadPreview( 'submit', 'sticky' );
    527                                 self.loadPreview( 'submit', 'gdpr' );
    528 
    529                                 window.location.reload();
     525                                var save = function( buttonCode ) {
     526                                        var done = $.Deferred();
     527
     528                                        $.when( self.loadPreview( 'submit', buttonCode ) ).always( done.resolve );
     529
     530                                        return done.promise();
     531                                };
     532
     533                                save( 'inline' ).then( function() {
     534                                        return save( 'sticky' );
     535                                } ).then( function() {
     536                                        return save( 'gdpr' );
     537                                } ).then( function() {
     538                                        window.location.reload();
     539                                } );
    530540                        } );
    531541
    … …  
    659669        getConfig: function() {
    660670          var result = null,
    661                 callExtra = 'secret=' + this.data.secret;
     671                callExtra = 'secret=' + this.data.secret,
     672                local;
     673
     674          if ( this.data.demo ) {
     675                local = this.data.buttonConfig || {};
     676
     677                return {
     678                  'inline-share-buttons': local.inline,
     679                  'sticky-share-buttons': local.sticky,
     680                  'gdpr-compliance-tool-v2': local.gdpr,
     681                };
     682          }
    662683
    663684          if ( 'undefined' === this.data.secret || undefined === this.data.secret ) {
    … …  
    754775                upConfig,
    755776                theData,
     777                saved,
    756778                enabled = false,
    757779                buttonCode = button.toLowerCase();
    … …  
    9811003                  }.bind( this ) );
    9821004                } else {
    983                   wp.ajax.post( 'set_button_config', {
     1005                  saved = wp.ajax.post( 'set_button_config', {
    9841006                        button: buttonCode,
    9851007                        config: config,
    … …  
    10281050                        theData = JSON.stringify( theData );
    10291051
    1030                         // Send new button status value.
    1031                         $.ajax( {
    1032                           url: 'https://platform-api.sharethis.com/v1.0/property/product',
    1033                           method: 'POST',
    1034                           async: false,
    1035                           contentType: 'application/json; charset=utf-8',
    1036                           data: theData,
    1037                           success: function () {
    1038                                 if ( 'turnon' === type || 'turnoff' === type ) {
     1052                        // Demo sites share one property, so changes are only saved to this site.
     1053                        if ( this.data.demo ) {
     1054                          if ( 'turnon' === type || 'turnoff' === type ) {
     1055                                saved.always( function() {
    10391056                                  location.reload();
     1057                                } );
     1058                          }
     1059                        } else {
     1060                          // Send new button status value.
     1061                          $.ajax( {
     1062                                url: 'https://platform-api.sharethis.com/v1.0/property/product',
     1063                                method: 'POST',
     1064                                async: false,
     1065                                contentType: 'application/json; charset=utf-8',
     1066                                data: theData,
     1067                                success: function () {
     1068                                  if ( 'turnon' === type || 'turnoff' === type ) {
     1069                                        location.reload();
     1070                                  }
    10401071                                }
    1041                           }
    1042                         } );
     1072                          } );
     1073                        }
    10431074                  }
    10441075                }
    … …  
    10851116                }
    10861117          } );
     1118
     1119          return saved;
    10871120        },
    10881121
  • sharethis-share-buttons/tags/2.3.13/php/class-plugin.php

    r3656993 r3733014  
    4646                $first_prod = false !== $first_prod && null !== $first_prod ? $first_prod : '';
    4747
    48                 if ( is_array( $propertyid ) && array() !== $propertyid ) {
     48                if ( self::isDemoMode() ) {
     49                        $this->register_demo_assets();
     50                } elseif ( is_array( $propertyid ) && array() !== $propertyid ) {
    4951                        wp_register_script(
    5052                                ASSET_PREFIX . '-mu',
    … …  
    6668
    6769        /**
     70         * Register the demo mode front end script.
     71         *
     72         * Demo sites share one property, so the buttons are drawn from this site's
     73         * saved config instead of the config stored on the property.
     74         */
     75        private function register_demo_assets() {
     76                $config = get_option( 'sharethis_button_config', array() );
     77                $config = is_array( $config ) ? $config : array();
     78
     79                wp_register_script(
     80                        ASSET_PREFIX . '-mu-src',
     81                        self::getPlatformApiUrl() . '/js/sharethis.js?product=inline-share-buttons',
     82                        array(),
     83                        SHARETHIS_SHARE_BUTTONS_VERSION,
     84                        false
     85                );
     86                wp_register_script(
     87                        ASSET_PREFIX . '-mu',
     88                        DIR_URL . 'js/demo-mode.js',
     89                        array( ASSET_PREFIX . '-mu-src' ),
     90                        filemtime( DIR_PATH . 'js/demo-mode.js' ),
     91                        false
     92                );
     93                wp_add_inline_script(
     94                        ASSET_PREFIX . '-mu',
     95                        sprintf(
     96                                'DemoMode.boot( %s );',
     97                                wp_json_encode(
     98                                        array(
     99                                                'inline' => 'true' === get_option( 'sharethis_inline' ) && isset( $config['inline'] ) ? $config['inline'] : null,
     100                                                'sticky' => 'true' === get_option( 'sharethis_sticky' ) && isset( $config['sticky'] ) ? $config['sticky'] : null,
     101                                                'gdpr'   => 'true' === get_option( 'sharethis_gdpr' ) && isset( $config['gdpr'] ) ? $config['gdpr'] : null,
     102                                        )
     103                                )
     104                        )
     105                );
     106        }
     107
     108        /**
    68109         * Register admin scripts/styles.
    69110         *
    … …  
    73114                wp_register_script(
    74115                        ASSET_PREFIX . '-mua',
    75                         '//platform-api.sharethis.com/js/sharethis.js?product=inline-share-buttons',
     116                        self::getPlatformApiUrl() . '/js/sharethis.js?product=inline-share-buttons',
    76117                        array(),
    77118                        SHARETHIS_SHARE_BUTTONS_VERSION,
    … …  
    125166
    126167        /**
     168         * Helper to get the host serving sharethis.js.
     169         *
     170         * Defaults to production. Define SHARETHIS_PLATFORM_API_URL in wp-config.php,
     171         * or filter it, to point the buttons at a local platform-api during development.
     172         *
     173         * @return string
     174         */
     175        public static function getPlatformApiUrl() {
     176                $url = defined( 'SHARETHIS_PLATFORM_API_URL' )
     177                        ? SHARETHIS_PLATFORM_API_URL
     178                        : 'https://platform-api.sharethis.com';
     179
     180                return untrailingslashit( apply_filters( 'sharethis_platform_api_url', $url ) );
     181        }
     182
     183        /**
     184         * Helper to check if the plugin is running as a shared demo, such as the
     185         * WordPress.org Live Preview.
     186         *
     187         * Demo sites all point at one property, so config changes stay in the site
     188         * and are never written to the property.
     189         *
     190         * @return bool
     191         */
     192        public static function isDemoMode() {
     193                $demo = defined( 'SHARETHIS_DEMO_MODE' ) && SHARETHIS_DEMO_MODE;
     194
     195                return (bool) apply_filters( 'sharethis_demo_mode', $demo );
     196        }
     197
     198        /**
    127199         * Helper to get the AI assistant networks.
    128200         *
    129          * These open a chat prefilled with a prompt about the page in a new tab,
    130          * rather than a share dialog in a popup window.
     201         * These open a chat about the page in a new tab rather than a share dialog
     202         * in a popup window. Most take the prompt in the URL; Copilot and Gemini
     203         * accept none, so sharethis.js copies it to the clipboard for those two.
    131204         *
    132205         * @return array
  • sharethis-share-buttons/tags/2.3.13/php/class-share-buttons.php

    r3656993 r3733014  
    464464                                                'fresh'         => get_option( 'sharethis_fract' ),
    465465                                                'first'         => get_option( 'sharethis_first_product', false ),
     466                                                'demo'          => Plugin::isDemoMode(),
    466467                                        )
    467468                                )
  • sharethis-share-buttons/tags/2.3.13/readme.txt

    r3657326 r3733014  
    77Requires at least: 5.5
    88Tested up to: 7.1
    9 Stable tag: 2.3.12
    10 Version: 2.3.12
     9Stable tag: 2.3.13
     10Version: 2.3.13
    1111License: GPLv2 or later
    1212
    … …  
    188188== Changelog ==
    189189
     190= 2.3.13 =
     191* Add a Live Preview on WordPress.org so you can try the plugin in WordPress Playground before installing.
     192
    190193= 2.3.12 =
    191194* Tested wp 7.1
  • sharethis-share-buttons/tags/2.3.13/sharethis-share-buttons.php

    r3657326 r3733014  
    88 * Plugin URI: https://sharethis.com/
    99 * Description: Grow your website traffic with share buttons for 40+ social channels including Facebook, LinkedIn, Twitter, WhatsApp, and more.
    10  * Version: 2.3.12
     10 * Version: 2.3.13
    1111 * Author: ShareThis
    1212 * Author URI: https://sharethis.com/
    … …  
    3333 * Plugin version constant.
    3434 */
    35 const SHARETHIS_SHARE_BUTTONS_VERSION = '2.3.12';
     35const SHARETHIS_SHARE_BUTTONS_VERSION = '2.3.13';
    3636
    3737if ( version_compare( phpversion(), '5.3', '>=' ) ) {
  • sharethis-share-buttons/trunk/js/admin.js

    r2981272 r3733014  
    523523                                nonce: self.data.nonce
    524524                        } ).always( function(response) {
    525                                 self.loadPreview( 'submit', 'inline' );
    526                                 self.loadPreview( 'submit', 'sticky' );
    527                                 self.loadPreview( 'submit', 'gdpr' );
    528 
    529                                 window.location.reload();
     525                                var save = function( buttonCode ) {
     526                                        var done = $.Deferred();
     527
     528                                        $.when( self.loadPreview( 'submit', buttonCode ) ).always( done.resolve );
     529
     530                                        return done.promise();
     531                                };
     532
     533                                save( 'inline' ).then( function() {
     534                                        return save( 'sticky' );
     535                                } ).then( function() {
     536                                        return save( 'gdpr' );
     537                                } ).then( function() {
     538                                        window.location.reload();
     539                                } );
    530540                        } );
    531541
    … …  
    659669        getConfig: function() {
    660670          var result = null,
    661                 callExtra = 'secret=' + this.data.secret;
     671                callExtra = 'secret=' + this.data.secret,
     672                local;
     673
     674          if ( this.data.demo ) {
     675                local = this.data.buttonConfig || {};
     676
     677                return {
     678                  'inline-share-buttons': local.inline,
     679                  'sticky-share-buttons': local.sticky,
     680                  'gdpr-compliance-tool-v2': local.gdpr,
     681                };
     682          }
    662683
    663684          if ( 'undefined' === this.data.secret || undefined === this.data.secret ) {
    … …  
    754775                upConfig,
    755776                theData,
     777                saved,
    756778                enabled = false,
    757779                buttonCode = button.toLowerCase();
    … …  
    9811003                  }.bind( this ) );
    9821004                } else {
    983                   wp.ajax.post( 'set_button_config', {
     1005                  saved = wp.ajax.post( 'set_button_config', {
    9841006                        button: buttonCode,
    9851007                        config: config,
    … …  
    10281050                        theData = JSON.stringify( theData );
    10291051
    1030                         // Send new button status value.
    1031                         $.ajax( {
    1032                           url: 'https://platform-api.sharethis.com/v1.0/property/product',
    1033                           method: 'POST',
    1034                           async: false,
    1035                           contentType: 'application/json; charset=utf-8',
    1036                           data: theData,
    1037                           success: function () {
    1038                                 if ( 'turnon' === type || 'turnoff' === type ) {
     1052                        // Demo sites share one property, so changes are only saved to this site.
     1053                        if ( this.data.demo ) {
     1054                          if ( 'turnon' === type || 'turnoff' === type ) {
     1055                                saved.always( function() {
    10391056                                  location.reload();
     1057                                } );
     1058                          }
     1059                        } else {
     1060                          // Send new button status value.
     1061                          $.ajax( {
     1062                                url: 'https://platform-api.sharethis.com/v1.0/property/product',
     1063                                method: 'POST',
     1064                                async: false,
     1065                                contentType: 'application/json; charset=utf-8',
     1066                                data: theData,
     1067                                success: function () {
     1068                                  if ( 'turnon' === type || 'turnoff' === type ) {
     1069                                        location.reload();
     1070                                  }
    10401071                                }
    1041                           }
    1042                         } );
     1072                          } );
     1073                        }
    10431074                  }
    10441075                }
    … …  
    10851116                }
    10861117          } );
     1118
     1119          return saved;
    10871120        },
    10881121
  • sharethis-share-buttons/trunk/php/class-plugin.php

    r3656993 r3733014  
    4646                $first_prod = false !== $first_prod && null !== $first_prod ? $first_prod : '';
    4747
    48                 if ( is_array( $propertyid ) && array() !== $propertyid ) {
     48                if ( self::isDemoMode() ) {
     49                        $this->register_demo_assets();
     50                } elseif ( is_array( $propertyid ) && array() !== $propertyid ) {
    4951                        wp_register_script(
    5052                                ASSET_PREFIX . '-mu',
    … …  
    6668
    6769        /**
     70         * Register the demo mode front end script.
     71         *
     72         * Demo sites share one property, so the buttons are drawn from this site's
     73         * saved config instead of the config stored on the property.
     74         */
     75        private function register_demo_assets() {
     76                $config = get_option( 'sharethis_button_config', array() );
     77                $config = is_array( $config ) ? $config : array();
     78
     79                wp_register_script(
     80                        ASSET_PREFIX . '-mu-src',
     81                        self::getPlatformApiUrl() . '/js/sharethis.js?product=inline-share-buttons',
     82                        array(),
     83                        SHARETHIS_SHARE_BUTTONS_VERSION,
     84                        false
     85                );
     86                wp_register_script(
     87                        ASSET_PREFIX . '-mu',
     88                        DIR_URL . 'js/demo-mode.js',
     89                        array( ASSET_PREFIX . '-mu-src' ),
     90                        filemtime( DIR_PATH . 'js/demo-mode.js' ),
     91                        false
     92                );
     93                wp_add_inline_script(
     94                        ASSET_PREFIX . '-mu',
     95                        sprintf(
     96                                'DemoMode.boot( %s );',
     97                                wp_json_encode(
     98                                        array(
     99                                                'inline' => 'true' === get_option( 'sharethis_inline' ) && isset( $config['inline'] ) ? $config['inline'] : null,
     100                                                'sticky' => 'true' === get_option( 'sharethis_sticky' ) && isset( $config['sticky'] ) ? $config['sticky'] : null,
     101                                                'gdpr'   => 'true' === get_option( 'sharethis_gdpr' ) && isset( $config['gdpr'] ) ? $config['gdpr'] : null,
     102                                        )
     103                                )
     104                        )
     105                );
     106        }
     107
     108        /**
    68109         * Register admin scripts/styles.
    69110         *
    … …  
    73114                wp_register_script(
    74115                        ASSET_PREFIX . '-mua',
    75                         '//platform-api.sharethis.com/js/sharethis.js?product=inline-share-buttons',
     116                        self::getPlatformApiUrl() . '/js/sharethis.js?product=inline-share-buttons',
    76117                        array(),
    77118                        SHARETHIS_SHARE_BUTTONS_VERSION,
    … …  
    125166
    126167        /**
     168         * Helper to get the host serving sharethis.js.
     169         *
     170         * Defaults to production. Define SHARETHIS_PLATFORM_API_URL in wp-config.php,
     171         * or filter it, to point the buttons at a local platform-api during development.
     172         *
     173         * @return string
     174         */
     175        public static function getPlatformApiUrl() {
     176                $url = defined( 'SHARETHIS_PLATFORM_API_URL' )
     177                        ? SHARETHIS_PLATFORM_API_URL
     178                        : 'https://platform-api.sharethis.com';
     179
     180                return untrailingslashit( apply_filters( 'sharethis_platform_api_url', $url ) );
     181        }
     182
     183        /**
     184         * Helper to check if the plugin is running as a shared demo, such as the
     185         * WordPress.org Live Preview.
     186         *
     187         * Demo sites all point at one property, so config changes stay in the site
     188         * and are never written to the property.
     189         *
     190         * @return bool
     191         */
     192        public static function isDemoMode() {
     193                $demo = defined( 'SHARETHIS_DEMO_MODE' ) && SHARETHIS_DEMO_MODE;
     194
     195                return (bool) apply_filters( 'sharethis_demo_mode', $demo );
     196        }
     197
     198        /**
    127199         * Helper to get the AI assistant networks.
    128200         *
    129          * These open a chat prefilled with a prompt about the page in a new tab,
    130          * rather than a share dialog in a popup window.
     201         * These open a chat about the page in a new tab rather than a share dialog
     202         * in a popup window. Most take the prompt in the URL; Copilot and Gemini
     203         * accept none, so sharethis.js copies it to the clipboard for those two.
    131204         *
    132205         * @return array
  • sharethis-share-buttons/trunk/php/class-share-buttons.php

    r3656993 r3733014  
    464464                                                'fresh'         => get_option( 'sharethis_fract' ),
    465465                                                'first'         => get_option( 'sharethis_first_product', false ),
     466                                                'demo'          => Plugin::isDemoMode(),
    466467                                        )
    467468                                )
  • sharethis-share-buttons/trunk/readme.txt

    r3657326 r3733014  
    77Requires at least: 5.5
    88Tested up to: 7.1
    9 Stable tag: 2.3.12
    10 Version: 2.3.12
     9Stable tag: 2.3.13
     10Version: 2.3.13
    1111License: GPLv2 or later
    1212
    … …  
    188188== Changelog ==
    189189
     190= 2.3.13 =
     191* Add a Live Preview on WordPress.org so you can try the plugin in WordPress Playground before installing.
     192
    190193= 2.3.12 =
    191194* Tested wp 7.1
  • sharethis-share-buttons/trunk/sharethis-share-buttons.php

    r3657326 r3733014  
    88 * Plugin URI: https://sharethis.com/
    99 * Description: Grow your website traffic with share buttons for 40+ social channels including Facebook, LinkedIn, Twitter, WhatsApp, and more.
    10  * Version: 2.3.12
     10 * Version: 2.3.13
    1111 * Author: ShareThis
    1212 * Author URI: https://sharethis.com/
    … …  
    3333 * Plugin version constant.
    3434 */
    35 const SHARETHIS_SHARE_BUTTONS_VERSION = '2.3.12';
     35const SHARETHIS_SHARE_BUTTONS_VERSION = '2.3.13';
    3636
    3737if ( version_compare( phpversion(), '5.3', '>=' ) ) {
Note: See TracChangeset for help on using the changeset viewer.