auto-patch 656-dev-dev01-2024-05-20T15_40_39

This commit is contained in:
root
2024-05-20 15:40:39 +00:00
parent 53b1c63251
commit e7933afaee
6 changed files with 79 additions and 83 deletions

View File

@@ -7,6 +7,11 @@
namespace ShareThisShareButtons; namespace ShareThisShareButtons;
define( 'ASSET_PREFIX', strtolower( preg_replace( '/\B([A-Z])/', '-$1', __NAMESPACE__ ) ) );
define( 'META_PREFIX', strtolower( preg_replace( '/\B([A-Z])/', '_$1', __NAMESPACE__ ) ) );
define( 'DIR_PATH', dirname( __FILE__ ) . '/' );
define( 'DIR_URL', '/wp-content/plugins/sharethis-share-buttons/' );
global $sharethis_share_buttons_plugin; global $sharethis_share_buttons_plugin;
require_once __DIR__ . '/php/class-plugin-base.php'; require_once __DIR__ . '/php/class-plugin-base.php';

View File

@@ -55,10 +55,10 @@ class Minute_Control {
// Enqueue the assets on editor pages. // Enqueue the assets on editor pages.
if ( in_array( $hook, array( 'post.php', 'post-new.php' ), true ) ) { if ( in_array( $hook, array( 'post.php', 'post-new.php' ), true ) ) {
wp_enqueue_style( "{$this->plugin->assets_prefix}-meta-box" ); wp_enqueue_style( ASSET_PREFIX . '-meta-box' );
wp_enqueue_script( "{$this->plugin->assets_prefix}-meta-box" ); wp_enqueue_script( ASSET_PREFIX . '-meta-box' );
wp_add_inline_script( wp_add_inline_script(
"{$this->plugin->assets_prefix}-meta-box", ASSET_PREFIX . '-meta-box',
sprintf( sprintf(
'MinuteControl.boot( %s );', 'MinuteControl.boot( %s );',
wp_json_encode( wp_json_encode(
@@ -79,10 +79,6 @@ class Minute_Control {
global $post_type; global $post_type;
switch ( $post_type ) { switch ( $post_type ) {
case 'post':
$iptype = 'post_';
$sptype = 'posts';
break;
case 'page': case 'page':
$iptype = 'page_'; $iptype = 'page_';
$sptype = 'pages'; $sptype = 'pages';
@@ -100,7 +96,7 @@ class Minute_Control {
$sticky_enable = get_option( 'sharethis_sticky' ); $sticky_enable = get_option( 'sharethis_sticky' );
// Include the meta box template. // Include the meta box template.
include_once "{$this->plugin->dir_path}/templates/minute-control/meta-box.php"; include_once DIR_PATH . 'templates/minute-control/meta-box.php';
} }
/** /**
@@ -281,7 +277,7 @@ class Minute_Control {
*/ */
public function set_sticky_visibility() { public function set_sticky_visibility() {
// Enqueue the blank style sheet. // Enqueue the blank style sheet.
wp_enqueue_style( "{$this->plugin->assets_prefix}-sticky" ); wp_enqueue_style( ASSET_PREFIX . '-sticky' );
// Get sticky settings. // Get sticky settings.
$settings = get_option( 'sharethis_sticky_settings' ); $settings = get_option( 'sharethis_sticky_settings' );
@@ -293,7 +289,7 @@ class Minute_Control {
$hide = $this->get_hide_status( $type, $value ); $hide = $this->get_hide_status( $type, $value );
if ( $hide ) { if ( $hide ) {
wp_add_inline_style( "{$this->plugin->assets_prefix}-sticky", $hide_sticky ); wp_add_inline_style( ASSET_PREFIX . '-sticky', $hide_sticky );
} }
} }
} }
@@ -493,7 +489,7 @@ class Minute_Control {
* @action enqueue_block_editor_assets * @action enqueue_block_editor_assets
*/ */
public function enqueue_custom_blocks() { public function enqueue_custom_blocks() {
wp_enqueue_script( "{$this->plugin->assets_prefix}-blocks", "{$this->plugin->dir_url}js/blocks.js", array( 'wp-blocks', 'wp-editor', 'wp-element', 'wp-components' ), time(), true ); wp_enqueue_script( ASSET_PREFIX . '-blocks', DIR_URL . 'js/blocks.js', array( 'wp-blocks', 'wp-editor', 'wp-element', 'wp-components' ), time(), true );
} }
/** /**

View File

@@ -11,19 +11,6 @@ namespace ShareThisShareButtons;
* Main plugin bootstrap file. * Main plugin bootstrap file.
*/ */
class Plugin extends Plugin_Base { class Plugin extends Plugin_Base {
/**
* Plugin assets prefix.
*
* @var string Lowercased dashed prefix.
*/
public $assets_prefix;
/**
* Plugin meta prefix.
*
* @var string Lowercased underscored prefix.
*/
public $meta_prefix;
/** /**
* Plugin constructor. * Plugin constructor.
@@ -45,10 +32,6 @@ class Plugin extends Plugin_Base {
foreach ( $classes as $instance ) { foreach ( $classes as $instance ) {
$this->add_doc_hooks( $instance ); $this->add_doc_hooks( $instance );
} }
// Define some prefixes to use througout the plugin.
$this->assets_prefix = strtolower( preg_replace( '/\B([A-Z])/', '-$1', __NAMESPACE__ ) );
$this->meta_prefix = strtolower( preg_replace( '/\B([A-Z])/', '_$1', __NAMESPACE__ ) );
} }
/** /**
@@ -64,7 +47,7 @@ class Plugin extends Plugin_Base {
if ( is_array( $propertyid ) && array() !== $propertyid ) { if ( is_array( $propertyid ) && array() !== $propertyid ) {
wp_register_script( wp_register_script(
"{$this->assets_prefix}-mu", ASSET_PREFIX . '-mu',
"//platform-api.sharethis.com/js/sharethis.js#property={$propertyid[0]}&product={$first_prod}-buttons&source=sharethis-share-buttons-wordpress", "//platform-api.sharethis.com/js/sharethis.js#property={$propertyid[0]}&product={$first_prod}-buttons&source=sharethis-share-buttons-wordpress",
array(), array(),
SHARETHIS_SHARE_BUTTONS_VERSION, SHARETHIS_SHARE_BUTTONS_VERSION,
@@ -74,10 +57,10 @@ class Plugin extends Plugin_Base {
// Register style sheet for sticky hiding. // Register style sheet for sticky hiding.
wp_register_style( wp_register_style(
"{$this->assets_prefix}-sticky", ASSET_PREFIX . '-sticky',
"{$this->dir_url}css/mu-style.css", DIR_URL . 'css/mu-style.css',
array(), array(),
filemtime( "{$this->dir_path}css/mu-style.css" ) filemtime( DIR_PATH . 'css/mu-style.css' )
); );
} }
@@ -88,37 +71,37 @@ class Plugin extends Plugin_Base {
*/ */
public function register_admin_assets() { public function register_admin_assets() {
wp_register_script( wp_register_script(
"{$this->assets_prefix}-mua", ASSET_PREFIX . '-mua',
'//platform-api.sharethis.com/js/sharethis.js?product=inline-share-buttons', '//platform-api.sharethis.com/js/sharethis.js?product=inline-share-buttons',
array(), array(),
SHARETHIS_SHARE_BUTTONS_VERSION, SHARETHIS_SHARE_BUTTONS_VERSION,
false false
); );
wp_register_script( wp_register_script(
"{$this->assets_prefix}-admin", ASSET_PREFIX . '-admin',
"{$this->dir_url}js/admin.js", DIR_URL . 'js/admin.js',
array( 'jquery', 'jquery-ui-sortable', 'wp-util', 'wp-color-picker' ), array( 'jquery', 'jquery-ui-sortable', 'wp-util', 'wp-color-picker' ),
filemtime( "{$this->dir_path}js/admin.js" ), filemtime( DIR_PATH . 'js/admin.js' ),
false false
); );
wp_register_script( wp_register_script(
"{$this->assets_prefix}-meta-box", ASSET_PREFIX . '-meta-box',
"{$this->dir_url}js/meta-box.js", DIR_URL . 'js/meta-box.js',
array( 'jquery', 'wp-util' ), array( 'jquery', 'wp-util' ),
filemtime( "{$this->dir_path}js/meta-box.js" ), filemtime( DIR_PATH . 'js/meta-box.js' ),
false false
); );
wp_register_style( wp_register_style(
"{$this->assets_prefix}-admin", ASSET_PREFIX . '-admin',
"{$this->dir_url}css/admin.css", DIR_URL . 'css/admin.css',
array( 'wp-color-picker' ), array( 'wp-color-picker' ),
filemtime( "{$this->dir_path}css/admin.css" ) filemtime( DIR_PATH . 'css/admin.css' )
); );
wp_register_style( wp_register_style(
"{$this->assets_prefix}-meta-box", ASSET_PREFIX . '-meta-box',
"{$this->dir_url}css/meta-box.css", DIR_URL . 'css/meta-box.css',
array(), array(),
filemtime( "{$this->dir_path}css/meta-box.css" ) filemtime( DIR_PATH . 'css/meta-box.css' )
); );
} }

View File

@@ -94,13 +94,13 @@ class Share_Buttons {
// Configure your buttons notice on activation. // Configure your buttons notice on activation.
register_activation_hook( register_activation_hook(
"{$this->plugin->dir_path}/sharethis-share-buttons.php", DIR_PATH . 'sharethis-share-buttons.php',
array( $this, 'st_activation_hook' ) array( $this, 'st_activation_hook' )
); );
// Clean up plugin information on deactivation. // Clean up plugin information on deactivation.
register_deactivation_hook( register_deactivation_hook(
"{$this->plugin->dir_path}/sharethis-share-buttons.php", DIR_PATH . 'sharethis-share-buttons.php',
array( $this, 'st_deactivation_hook' ) array( $this, 'st_deactivation_hook' )
); );
} }
@@ -167,9 +167,13 @@ class Share_Buttons {
), ),
), ),
); );
}
// Inline setting array. /**
$this->inline_setting_fields = array( * Set inline settings fields.
*/
public function inline_setting_fields() {
return array(
array( array(
'id_suffix' => 'inline_post_top', 'id_suffix' => 'inline_post_top',
'title' => esc_html__( 'Top of post body', 'sharethis-share-buttons' ), 'title' => esc_html__( 'Top of post body', 'sharethis-share-buttons' ),
@@ -226,9 +230,13 @@ class Share_Buttons {
), ),
), ),
); );
}
// Sticky setting array. /**
$this->sticky_setting_fields = array( * Settings fields.
*/
public function sticky_setting_fields() {
return array(
array( array(
'id_suffix' => 'sticky_home', 'id_suffix' => 'sticky_home',
'title' => esc_html__( 'Home Page', 'sharethis-share-buttons' ), 'title' => esc_html__( 'Home Page', 'sharethis-share-buttons' ),
@@ -349,7 +357,7 @@ class Share_Buttons {
* @action wp_enqueue_scripts * @action wp_enqueue_scripts
*/ */
public function enqueue_mu() { public function enqueue_mu() {
wp_enqueue_script( "{$this->plugin->assets_prefix}-mu" ); wp_enqueue_script( ASSET_PREFIX . '-mu' );
} }
/** /**
@@ -382,22 +390,22 @@ class Share_Buttons {
if ( '' === $property_id ) { if ( '' === $property_id ) {
wp_register_script( wp_register_script(
"{$this->plugin->assets_prefix}-credentials", ASSET_PREFIX . '-credentials',
$this->plugin->dir_url . 'js/set-credentials.js', DIR_URL . 'js/set-credentials.js',
array( 'jquery', 'wp-util' ), array( 'jquery', 'wp-util' ),
filemtime( "{$this->plugin->dir_path}js/set-credentials.js" ), filemtime( DIR_PATH . 'js/set-credentials.js' ),
false false
); );
// Only enqueue this script on the general settings page for credentials. // Only enqueue this script on the general settings page for credentials.
wp_enqueue_script( "{$this->plugin->assets_prefix}-credentials" ); wp_enqueue_script( ASSET_PREFIX . '-credentials' );
wp_add_inline_script( wp_add_inline_script(
"{$this->plugin->assets_prefix}-credentials", ASSET_PREFIX . '-credentials',
sprintf( sprintf(
'Credentials.boot( %s );', 'Credentials.boot( %s );',
wp_json_encode( wp_json_encode(
array( array(
'nonce' => wp_create_nonce( $this->plugin->meta_prefix ), 'nonce' => wp_create_nonce( META_PREFIX ),
'email' => get_bloginfo( 'admin_email' ), 'email' => get_bloginfo( 'admin_email' ),
'url' => str_replace( 'http://', '', str_replace( 'https://', '', site_url() ) ), 'url' => str_replace( 'http://', '', str_replace( 'https://', '', site_url() ) ),
'buttonConfig' => $button_config, 'buttonConfig' => $button_config,
@@ -413,8 +421,8 @@ class Share_Buttons {
} }
// Enqueue the styles globally throughout the ShareThis menus. // Enqueue the styles globally throughout the ShareThis menus.
wp_enqueue_style( "{$this->plugin->assets_prefix}-admin" ); wp_enqueue_style( ASSET_PREFIX . '-admin' );
wp_enqueue_script( "{$this->plugin->assets_prefix}-mua" ); wp_enqueue_script( ASSET_PREFIX . '-mua' );
if ( $first_exists && ( $inline || $sticky ) ) { if ( $first_exists && ( $inline || $sticky ) ) {
$first = $inline ? 'inline' : 'sticky'; $first = $inline ? 'inline' : 'sticky';
@@ -422,9 +430,9 @@ class Share_Buttons {
update_option( 'sharethis_first_product', $first ); update_option( 'sharethis_first_product', $first );
} }
wp_enqueue_script( "{$this->plugin->assets_prefix}-admin" ); wp_enqueue_script( ASSET_PREFIX . '-admin' );
wp_add_inline_script( wp_add_inline_script(
"{$this->plugin->assets_prefix}-admin", ASSET_PREFIX . '-admin',
sprintf( sprintf(
'ShareButtons.boot( %s );', 'ShareButtons.boot( %s );',
wp_json_encode( wp_json_encode(
@@ -436,7 +444,7 @@ class Share_Buttons {
'token' => $token, 'token' => $token,
'secret' => $secret, 'secret' => $secret,
'buttonConfig' => $button_config, 'buttonConfig' => $button_config,
'nonce' => wp_create_nonce( $this->plugin->meta_prefix ), 'nonce' => wp_create_nonce( META_PREFIX ),
'fresh' => get_option( 'sharethis_fract' ), 'fresh' => get_option( 'sharethis_fract' ),
'first' => get_option( 'sharethis_first_product', false ), 'first' => get_option( 'sharethis_first_product', false ),
) )
@@ -461,7 +469,7 @@ class Share_Buttons {
'gdpr' => 'true' === get_option( 'sharethis_gdpr' ) ? 'Enabled' : 'Disabled', 'gdpr' => 'true' === get_option( 'sharethis_gdpr' ) ? 'Enabled' : 'Disabled',
); );
include_once "{$this->plugin->dir_path}/templates/share-buttons/share-button-settings.php"; include_once DIR_PATH . '/templates/share-buttons/share-button-settings.php';
} }
/** /**
@@ -522,7 +530,7 @@ class Share_Buttons {
* @param string $type The setting type. * @param string $type The setting type.
*/ */
public function config_settings( $type ) { public function config_settings( $type ) {
$config_array = 'inline' === $type ? $this->inline_setting_fields : $this->sticky_setting_fields; $config_array = 'inline' === $type ? $this->inline_setting_fields() : $this->sticky_setting_fields();
// Display on off template for inline settings. // Display on off template for inline settings.
foreach ( $config_array as $setting ) { foreach ( $config_array as $setting ) {
@@ -568,7 +576,7 @@ class Share_Buttons {
// Display the list call back if specified. // Display the list call back if specified.
if ( 'onoff_cb' === $setting['callback'] ) { if ( 'onoff_cb' === $setting['callback'] ) {
include "{$this->plugin->dir_path}/templates/share-buttons/onoff-buttons.php"; include DIR_PATH . '/templates/share-buttons/onoff-buttons.php';
} else { } else {
$current_omit = $this->get_omit( $setting['type'] ); $current_omit = $this->get_omit( $setting['type'] );
@@ -643,7 +651,7 @@ class Share_Buttons {
* @param array $id The setting type. * @param array $id The setting type.
*/ */
public function enable_cb( $id ) { public function enable_cb( $id ) {
include "{$this->plugin->dir_path}/templates/share-buttons/enable-buttons.php"; include DIR_PATH . '/templates/share-buttons/enable-buttons.php';
} }
/** /**
@@ -654,7 +662,7 @@ class Share_Buttons {
* @param array $allowed The allowed html that an omit item can echo. * @param array $allowed The allowed html that an omit item can echo.
*/ */
public function list_cb( $type, $current_omit, $allowed ) { public function list_cb( $type, $current_omit, $allowed ) {
include "{$this->plugin->dir_path}/templates/share-buttons/list.php"; include DIR_PATH . '/templates/share-buttons/list.php';
} }
/** /**
@@ -663,7 +671,7 @@ class Share_Buttons {
* @param string $type The type of template to pull. * @param string $type The type of template to pull.
*/ */
public function shortcode_template( $type ) { public function shortcode_template( $type ) {
include "{$this->plugin->dir_path}/templates/share-buttons/shortcode-templatecode.php"; include DIR_PATH . '/templates/share-buttons/shortcode-templatecode.php';
} }
/** /**
@@ -727,7 +735,7 @@ class Share_Buttons {
'#d4c4fb', '#d4c4fb',
); );
include "{$this->plugin->dir_path}/templates/general/gdpr/gdpr-config.php"; include DIR_PATH . '/templates/general/gdpr/gdpr-config.php';
} else { } else {
$enabled = array( $enabled = array(
'inline' => 'true' === get_option( 'sharethis_inline' ) ? 'Enabled' : 'Disabled', 'inline' => 'true' === get_option( 'sharethis_inline' ) ? 'Enabled' : 'Disabled',
@@ -735,7 +743,7 @@ class Share_Buttons {
'gdpr' => 'true' === get_option( 'sharethis_gdpr' ) ? 'Enabled' : 'Disabled', 'gdpr' => 'true' === get_option( 'sharethis_gdpr' ) ? 'Enabled' : 'Disabled',
); );
include "{$this->plugin->dir_path}/templates/share-buttons/button-config.php"; include DIR_PATH . '/templates/share-buttons/button-config.php';
} }
} }
@@ -819,7 +827,7 @@ class Share_Buttons {
* @action wp_ajax_set_credentials * @action wp_ajax_set_credentials
*/ */
public function set_credentials() { public function set_credentials() {
check_ajax_referer( $this->plugin->meta_prefix, 'nonce' ); check_ajax_referer( META_PREFIX, 'nonce' );
if ( ! isset( $_POST['data'], $_POST['token'] ) || '' === $_POST['data'] ) { // WPCS: input var ok. if ( ! isset( $_POST['data'], $_POST['token'] ) || '' === $_POST['data'] ) { // WPCS: input var ok.
wp_send_json_error( 'Set credentials failed.' ); wp_send_json_error( 'Set credentials failed.' );
@@ -864,7 +872,7 @@ class Share_Buttons {
* @action wp_ajax_update_buttons * @action wp_ajax_update_buttons
*/ */
public function update_buttons() { public function update_buttons() {
check_ajax_referer( $this->plugin->meta_prefix, 'nonce' ); check_ajax_referer( META_PREFIX, 'nonce' );
if ( ! isset( $_POST['type'], $_POST['onoff'] ) ) { // phpcs:ignore input var ok. if ( ! isset( $_POST['type'], $_POST['onoff'] ) ) { // phpcs:ignore input var ok.
wp_send_json_error( 'Update buttons failed.' ); wp_send_json_error( 'Update buttons failed.' );
@@ -887,7 +895,7 @@ class Share_Buttons {
* @action wp_ajax_update_st_settings * @action wp_ajax_update_st_settings
*/ */
public function update_st_settings() { public function update_st_settings() {
check_ajax_referer( $this->plugin->meta_prefix, 'nonce' ); check_ajax_referer( META_PREFIX, 'nonce' );
if ( ! isset( $_POST['formData'], $_POST['button'] ) ) { // phpcs:ignore input var ok. if ( ! isset( $_POST['formData'], $_POST['button'] ) ) { // phpcs:ignore input var ok.
wp_send_json_error( 'Update settings failed.' ); wp_send_json_error( 'Update settings failed.' );
@@ -916,7 +924,7 @@ class Share_Buttons {
* @action wp_ajax_set_default_settings * @action wp_ajax_set_default_settings
*/ */
public function set_default_settings() { public function set_default_settings() {
check_ajax_referer( $this->plugin->meta_prefix, 'nonce' ); check_ajax_referer( META_PREFIX, 'nonce' );
if ( ! isset( $_POST['type'] ) ) { // WPCS: CRSF ok. input var ok. if ( ! isset( $_POST['type'] ) ) { // WPCS: CRSF ok. input var ok.
wp_send_json_error( 'Update buttons failed.' ); wp_send_json_error( 'Update buttons failed.' );
@@ -988,7 +996,7 @@ class Share_Buttons {
* @action wp_ajax_return_omit * @action wp_ajax_return_omit
*/ */
public function return_omit() { public function return_omit() {
check_ajax_referer( $this->plugin->meta_prefix, 'nonce' ); check_ajax_referer( META_PREFIX, 'nonce' );
$post = filter_input_array( $post = filter_input_array(
INPUT_POST, INPUT_POST,
@@ -1505,7 +1513,7 @@ class Share_Buttons {
* @action wp_ajax_set_button_config * @action wp_ajax_set_button_config
*/ */
public function set_button_config() { public function set_button_config() {
check_ajax_referer( $this->plugin->meta_prefix, 'nonce' ); check_ajax_referer( META_PREFIX, 'nonce' );
$post = filter_input_array( $post = filter_input_array(
INPUT_POST, INPUT_POST,
@@ -1610,7 +1618,7 @@ class Share_Buttons {
* @action wp_ajax_set_gdpr_config * @action wp_ajax_set_gdpr_config
*/ */
public function set_gdpr_config() { public function set_gdpr_config() {
check_ajax_referer( $this->plugin->meta_prefix, 'nonce' ); check_ajax_referer( META_PREFIX, 'nonce' );
$post = filter_input_array( $post = filter_input_array(
INPUT_POST, INPUT_POST,

View File

@@ -5,9 +5,9 @@ Tags: social buttons, sharethis, share this, social sharing, share buttons, soci
Author URI: https://sharethis.com/ Author URI: https://sharethis.com/
Author: ShareThis Author: ShareThis
Requires at least: 5.5 Requires at least: 5.5
Tested up to: 6.4.1 Tested up to: 6.5.2
Stable tag: 2.2.0 Stable tag: 2.3.0
Version: 2.2.0 Version: 2.3.0
License: GPLv2 or later License: GPLv2 or later
@@ -73,6 +73,10 @@ We cache your ShareThis platform button configurations (social networks, button
== Changelog == == Changelog ==
= 2.3.0 =
* Fix 8.2 deprecations.
* Test wp ver 6.5.2.
= 2.2.0 = = 2.2.0 =
* Add new social networks. * Add new social networks.

View File

@@ -3,7 +3,7 @@
* Plugin Name: ShareThis Share Buttons * Plugin Name: ShareThis Share Buttons
* Plugin URI: https://sharethis.com/ * Plugin URI: https://sharethis.com/
* Description: Grow your website traffic with share buttons for 40+ social channels including Facebook, LinkedIn, Twitter, WhatsApp, and more. * Description: Grow your website traffic with share buttons for 40+ social channels including Facebook, LinkedIn, Twitter, WhatsApp, and more.
* Version: 2.2.0 * Version: 2.3.0
* Author: ShareThis * Author: ShareThis
* Author URI: https://sharethis.com/ * Author URI: https://sharethis.com/
* Text Domain: sharethis-share-buttons * Text Domain: sharethis-share-buttons
@@ -28,7 +28,7 @@
/** /**
* Plugin version constant. * Plugin version constant.
*/ */
const SHARETHIS_SHARE_BUTTONS_VERSION = '2.2.0'; const SHARETHIS_SHARE_BUTTONS_VERSION = '2.3.0';
if ( version_compare( phpversion(), '5.3', '>=' ) ) { if ( version_compare( phpversion(), '5.3', '>=' ) ) {
require_once __DIR__ . '/instance.php'; require_once __DIR__ . '/instance.php';