Plugin Directory

Changeset 3736727


Ignore:
Timestamp:
10/09/2026 01:20:50 PM (2 weeks ago)
Author:
ShareThis
Message:

Update to version 1.3.8 from GitHub

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

Legend:

Unmodified
Added
Removed
  • sharethis-reaction-buttons/tags/1.3.8/js/admin.js

    r2826768 r3736727  
    188188                getConfig: function() {
    189189                        var result = null,
    190                                 callExtra = 'secret=' + this.data.secret;
     190                                callExtra = 'secret=' + this.data.secret,
     191                                local;
     192
     193                        // Demo sites share one property, so this site's saved config stands in for it.
     194                        if ( this.data.demo ) {
     195                                local = this.data.buttonConfig || {};
     196
     197                                return {
     198                                        'inline-reaction-buttons': local['inline-reaction'],
     199                                };
     200                        }
    191201
    192202                        if ( 'undefined' === this.data.secret ) {
    … …  
    379389
    380390                        // Submit configurations.
    381                         $( '.sharethis-wrap form' ).submit( function() {
    382                                 self.loadPreview( 'submit', 'inline-reaction' );
     391                        $( '.sharethis-wrap form' ).submit( function( e ) {
     392                                var form = this,
     393                                        saved = self.loadPreview( 'submit', 'inline-reaction' );
     394
     395                                // Without the blocking property call, leaving the page could cancel the save.
     396                                if ( self.data.demo ) {
     397                                        e.preventDefault();
     398
     399                                        $.when( saved ).always( function() {
     400                                                form.submit();
     401                                        } );
     402                                }
    383403                        } );
    384404
    … …  
    422442                                upConfig,
    423443                                theData,
     444                                saved,
    424445                                enabled = false,
    425446                                button = 'inline-reaction';
    … …  
    532553                                        }.bind( this ) );
    533554                                } else {
    534                                         wp.ajax.post( 'set_reaction_button_config', {
     555                                        saved = wp.ajax.post( 'set_reaction_button_config', {
    535556                                                button: button,
    536557                                                config: config,
    … …  
    556577                                                } );
    557578
    558                                                 // Send new button status value.
    559                                                 $.ajax( {
    560                                                         url: 'https://platform-api.sharethis.com/v1.0/property/product',
    561                                                         method: 'POST',
    562                                                         async: false,
    563                                                         contentType: 'application/json; charset=utf-8',
    564                                                         data: theData,
    565                                                         success: function() {
    566                                                                 if ( 'turnon' === type || 'turnoff' === type ) {
     579                                                // Demo sites share one property, so changes are only saved to this site.
     580                                                if ( this.data.demo ) {
     581                                                        if ( 'turnon' === type || 'turnoff' === type ) {
     582                                                                saved.always( function() {
    567583                                                                        location.reload();
     584                                                                } );
     585                                                        }
     586                                                } else {
     587                                                        // Send new button status value.
     588                                                        $.ajax( {
     589                                                                url: 'https://platform-api.sharethis.com/v1.0/property/product',
     590                                                                method: 'POST',
     591                                                                async: false,
     592                                                                contentType: 'application/json; charset=utf-8',
     593                                                                data: theData,
     594                                                                success: function() {
     595                                                                        if ( 'turnon' === type || 'turnoff' === type ) {
     596                                                                                location.reload();
     597                                                                        }
    568598                                                                }
    569                                                         }
    570                                                 } );
     599                                                        } );
     600                                                }
    571601                                        }
    572602                                }
    … …  
    587617                                }
    588618                        } );
     619
     620                        return saved;
    589621                }
    590622        };
  • sharethis-reaction-buttons/tags/1.3.8/php/class-plugin.php

    r2826768 r3736727  
    7070                $sb_active = in_array( 'sharethis-share-buttons/sharethis-share-buttons.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true );
    7171
    72                 if ( false === $sb_active && true === is_array( $propertyid ) && array() !== $propertyid ) {
     72                if ( self::is_demo_mode() ) {
     73                        $this->register_demo_assets();
     74                } elseif ( false === $sb_active && true === is_array( $propertyid ) && array() !== $propertyid ) {
    7375                        wp_register_script(
    7476                                "{$this->assets_prefix}-mu",
    … …  
    7981                        );
    8082                }
     83        }
     84
     85        /**
     86         * Register the demo mode front end script.
     87         *
     88         * Demo sites share one property, so the buttons are drawn from this site's
     89         * saved config instead of the config stored on the property.
     90         */
     91        private function register_demo_assets() {
     92                $config = get_option( 'sharethis_button_config' );
     93                $config = is_array( $config ) && isset( $config['inline-reaction'] ) ? $config['inline-reaction'] : null;
     94
     95                wp_register_script(
     96                        "{$this->assets_prefix}-mu-src",
     97                        '//platform-api.sharethis.com/js/sharethis.js?product=inline-reaction-buttons',
     98                        null,
     99                        SHARETHIS_REACTION_BUTTONS_VERSION,
     100                        false
     101                );
     102                wp_register_script(
     103                        "{$this->assets_prefix}-mu",
     104                        "{$this->dir_url}js/demo-mode.js",
     105                        array( "{$this->assets_prefix}-mu-src" ),
     106                        filemtime( "{$this->dir_path}js/demo-mode.js" ),
     107                        false
     108                );
     109                wp_add_inline_script(
     110                        "{$this->assets_prefix}-mu",
     111                        sprintf(
     112                                'ReactionDemoMode.boot( %s );',
     113                                wp_json_encode(
     114                                        array(
     115                                                'reaction' => 'true' === get_option( 'sharethis_inline-reaction' ) ? $config : null,
     116                                        )
     117                                )
     118                        )
     119                );
     120        }
     121
     122        /**
     123         * Helper to check if the plugin is running as a shared demo, such as the
     124         * WordPress.org Live Preview.
     125         *
     126         * Demo sites all point at one property, so config changes stay in the site
     127         * and are never written to the property.
     128         *
     129         * @return bool
     130         */
     131        public static function is_demo_mode() {
     132                $demo = defined( 'SHARETHIS_DEMO_MODE' ) && SHARETHIS_DEMO_MODE;
     133
     134                return (bool) apply_filters( 'sharethis_demo_mode', $demo );
    81135        }
    82136
  • sharethis-reaction-buttons/tags/1.3.8/php/class-reaction-buttons.php

    r3513978 r3736727  
    290290                                                        'shareButtons'    => $share_buttons_exist,
    291291                                                        'nonce'           => wp_create_nonce( $this->plugin->meta_prefix ),
     292                                                        'demo'            => Plugin::is_demo_mode(),
    292293                                                )
    293294                                        )
  • sharethis-reaction-buttons/tags/1.3.8/readme.txt

    r3657288 r3736727  
    77Requires at least: 5.9
    88Tested up to: 7.1
    9 Stable tag: 1.3.7
    10 Version: 1.3.7
     9Stable tag: 1.3.8
     10Version: 1.3.8
    1111License: GPLv2 or later
    1212
    … …  
    6868
    6969== Changelog ==
     70
     71= 1.3.8 =
     72* Add a Live Preview on WordPress.org so you can try the plugin in WordPress Playground before installing.
    7073
    7174= 1.3.7 =
  • sharethis-reaction-buttons/tags/1.3.8/sharethis-reaction-buttons.php

    r3657288 r3736727  
    44 * Plugin URI: https://www.sharethis.com/platform/reaction-buttons-wordpress/
    55 * Description: Integrates the ShareThis Reaction Buttons directly into your website.
    6  * Version: 1.3.7
     6 * Version: 1.3.8
    77 * Author: ShareThis
    88 * Author URI: https://sharethis.com/
    … …  
    3232if ( ! defined( 'ABSPATH' ) ) exit;
    3333
    34 const SHARETHIS_REACTION_BUTTONS_VERSION = '1.3.7';
     34const SHARETHIS_REACTION_BUTTONS_VERSION = '1.3.8';
    3535
    3636if ( version_compare( phpversion(), '5.3', '>=' ) ) {
  • sharethis-reaction-buttons/trunk/js/admin.js

    r2826768 r3736727  
    188188                getConfig: function() {
    189189                        var result = null,
    190                                 callExtra = 'secret=' + this.data.secret;
     190                                callExtra = 'secret=' + this.data.secret,
     191                                local;
     192
     193                        // Demo sites share one property, so this site's saved config stands in for it.
     194                        if ( this.data.demo ) {
     195                                local = this.data.buttonConfig || {};
     196
     197                                return {
     198                                        'inline-reaction-buttons': local['inline-reaction'],
     199                                };
     200                        }
    191201
    192202                        if ( 'undefined' === this.data.secret ) {
    … …  
    379389
    380390                        // Submit configurations.
    381                         $( '.sharethis-wrap form' ).submit( function() {
    382                                 self.loadPreview( 'submit', 'inline-reaction' );
     391                        $( '.sharethis-wrap form' ).submit( function( e ) {
     392                                var form = this,
     393                                        saved = self.loadPreview( 'submit', 'inline-reaction' );
     394
     395                                // Without the blocking property call, leaving the page could cancel the save.
     396                                if ( self.data.demo ) {
     397                                        e.preventDefault();
     398
     399                                        $.when( saved ).always( function() {
     400                                                form.submit();
     401                                        } );
     402                                }
    383403                        } );
    384404
    … …  
    422442                                upConfig,
    423443                                theData,
     444                                saved,
    424445                                enabled = false,
    425446                                button = 'inline-reaction';
    … …  
    532553                                        }.bind( this ) );
    533554                                } else {
    534                                         wp.ajax.post( 'set_reaction_button_config', {
     555                                        saved = wp.ajax.post( 'set_reaction_button_config', {
    535556                                                button: button,
    536557                                                config: config,
    … …  
    556577                                                } );
    557578
    558                                                 // Send new button status value.
    559                                                 $.ajax( {
    560                                                         url: 'https://platform-api.sharethis.com/v1.0/property/product',
    561                                                         method: 'POST',
    562                                                         async: false,
    563                                                         contentType: 'application/json; charset=utf-8',
    564                                                         data: theData,
    565                                                         success: function() {
    566                                                                 if ( 'turnon' === type || 'turnoff' === type ) {
     579                                                // Demo sites share one property, so changes are only saved to this site.
     580                                                if ( this.data.demo ) {
     581                                                        if ( 'turnon' === type || 'turnoff' === type ) {
     582                                                                saved.always( function() {
    567583                                                                        location.reload();
     584                                                                } );
     585                                                        }
     586                                                } else {
     587                                                        // Send new button status value.
     588                                                        $.ajax( {
     589                                                                url: 'https://platform-api.sharethis.com/v1.0/property/product',
     590                                                                method: 'POST',
     591                                                                async: false,
     592                                                                contentType: 'application/json; charset=utf-8',
     593                                                                data: theData,
     594                                                                success: function() {
     595                                                                        if ( 'turnon' === type || 'turnoff' === type ) {
     596                                                                                location.reload();
     597                                                                        }
    568598                                                                }
    569                                                         }
    570                                                 } );
     599                                                        } );
     600                                                }
    571601                                        }
    572602                                }
    … …  
    587617                                }
    588618                        } );
     619
     620                        return saved;
    589621                }
    590622        };
  • sharethis-reaction-buttons/trunk/php/class-plugin.php

    r2826768 r3736727  
    7070                $sb_active = in_array( 'sharethis-share-buttons/sharethis-share-buttons.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true );
    7171
    72                 if ( false === $sb_active && true === is_array( $propertyid ) && array() !== $propertyid ) {
     72                if ( self::is_demo_mode() ) {
     73                        $this->register_demo_assets();
     74                } elseif ( false === $sb_active && true === is_array( $propertyid ) && array() !== $propertyid ) {
    7375                        wp_register_script(
    7476                                "{$this->assets_prefix}-mu",
    … …  
    7981                        );
    8082                }
     83        }
     84
     85        /**
     86         * Register the demo mode front end script.
     87         *
     88         * Demo sites share one property, so the buttons are drawn from this site's
     89         * saved config instead of the config stored on the property.
     90         */
     91        private function register_demo_assets() {
     92                $config = get_option( 'sharethis_button_config' );
     93                $config = is_array( $config ) && isset( $config['inline-reaction'] ) ? $config['inline-reaction'] : null;
     94
     95                wp_register_script(
     96                        "{$this->assets_prefix}-mu-src",
     97                        '//platform-api.sharethis.com/js/sharethis.js?product=inline-reaction-buttons',
     98                        null,
     99                        SHARETHIS_REACTION_BUTTONS_VERSION,
     100                        false
     101                );
     102                wp_register_script(
     103                        "{$this->assets_prefix}-mu",
     104                        "{$this->dir_url}js/demo-mode.js",
     105                        array( "{$this->assets_prefix}-mu-src" ),
     106                        filemtime( "{$this->dir_path}js/demo-mode.js" ),
     107                        false
     108                );
     109                wp_add_inline_script(
     110                        "{$this->assets_prefix}-mu",
     111                        sprintf(
     112                                'ReactionDemoMode.boot( %s );',
     113                                wp_json_encode(
     114                                        array(
     115                                                'reaction' => 'true' === get_option( 'sharethis_inline-reaction' ) ? $config : null,
     116                                        )
     117                                )
     118                        )
     119                );
     120        }
     121
     122        /**
     123         * Helper to check if the plugin is running as a shared demo, such as the
     124         * WordPress.org Live Preview.
     125         *
     126         * Demo sites all point at one property, so config changes stay in the site
     127         * and are never written to the property.
     128         *
     129         * @return bool
     130         */
     131        public static function is_demo_mode() {
     132                $demo = defined( 'SHARETHIS_DEMO_MODE' ) && SHARETHIS_DEMO_MODE;
     133
     134                return (bool) apply_filters( 'sharethis_demo_mode', $demo );
    81135        }
    82136
  • sharethis-reaction-buttons/trunk/php/class-reaction-buttons.php

    r3513978 r3736727  
    290290                                                        'shareButtons'    => $share_buttons_exist,
    291291                                                        'nonce'           => wp_create_nonce( $this->plugin->meta_prefix ),
     292                                                        'demo'            => Plugin::is_demo_mode(),
    292293                                                )
    293294                                        )
  • sharethis-reaction-buttons/trunk/readme.txt

    r3657288 r3736727  
    77Requires at least: 5.9
    88Tested up to: 7.1
    9 Stable tag: 1.3.7
    10 Version: 1.3.7
     9Stable tag: 1.3.8
     10Version: 1.3.8
    1111License: GPLv2 or later
    1212
    … …  
    6868
    6969== Changelog ==
     70
     71= 1.3.8 =
     72* Add a Live Preview on WordPress.org so you can try the plugin in WordPress Playground before installing.
    7073
    7174= 1.3.7 =
  • sharethis-reaction-buttons/trunk/sharethis-reaction-buttons.php

    r3657288 r3736727  
    44 * Plugin URI: https://www.sharethis.com/platform/reaction-buttons-wordpress/
    55 * Description: Integrates the ShareThis Reaction Buttons directly into your website.
    6  * Version: 1.3.7
     6 * Version: 1.3.8
    77 * Author: ShareThis
    88 * Author URI: https://sharethis.com/
    … …  
    3232if ( ! defined( 'ABSPATH' ) ) exit;
    3333
    34 const SHARETHIS_REACTION_BUTTONS_VERSION = '1.3.7';
     34const SHARETHIS_REACTION_BUTTONS_VERSION = '1.3.8';
    3535
    3636if ( version_compare( phpversion(), '5.3', '>=' ) ) {
Note: See TracChangeset for help on using the changeset viewer.