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

@@ -94,13 +94,13 @@ class Share_Buttons {
// Configure your buttons notice on activation.
register_activation_hook(
"{$this->plugin->dir_path}/sharethis-share-buttons.php",
DIR_PATH . 'sharethis-share-buttons.php',
array( $this, 'st_activation_hook' )
);
// Clean up plugin information on deactivation.
register_deactivation_hook(
"{$this->plugin->dir_path}/sharethis-share-buttons.php",
DIR_PATH . 'sharethis-share-buttons.php',
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(
'id_suffix' => 'inline_post_top',
'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(
'id_suffix' => 'sticky_home',
'title' => esc_html__( 'Home Page', 'sharethis-share-buttons' ),
@@ -349,7 +357,7 @@ class Share_Buttons {
* @action wp_enqueue_scripts
*/
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 ) {
wp_register_script(
"{$this->plugin->assets_prefix}-credentials",
$this->plugin->dir_url . 'js/set-credentials.js',
ASSET_PREFIX . '-credentials',
DIR_URL . 'js/set-credentials.js',
array( 'jquery', 'wp-util' ),
filemtime( "{$this->plugin->dir_path}js/set-credentials.js" ),
filemtime( DIR_PATH . 'js/set-credentials.js' ),
false
);
// 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(
"{$this->plugin->assets_prefix}-credentials",
ASSET_PREFIX . '-credentials',
sprintf(
'Credentials.boot( %s );',
wp_json_encode(
array(
'nonce' => wp_create_nonce( $this->plugin->meta_prefix ),
'nonce' => wp_create_nonce( META_PREFIX ),
'email' => get_bloginfo( 'admin_email' ),
'url' => str_replace( 'http://', '', str_replace( 'https://', '', site_url() ) ),
'buttonConfig' => $button_config,
@@ -413,8 +421,8 @@ class Share_Buttons {
}
// Enqueue the styles globally throughout the ShareThis menus.
wp_enqueue_style( "{$this->plugin->assets_prefix}-admin" );
wp_enqueue_script( "{$this->plugin->assets_prefix}-mua" );
wp_enqueue_style( ASSET_PREFIX . '-admin' );
wp_enqueue_script( ASSET_PREFIX . '-mua' );
if ( $first_exists && ( $inline || $sticky ) ) {
$first = $inline ? 'inline' : 'sticky';
@@ -422,9 +430,9 @@ class Share_Buttons {
update_option( 'sharethis_first_product', $first );
}
wp_enqueue_script( "{$this->plugin->assets_prefix}-admin" );
wp_enqueue_script( ASSET_PREFIX . '-admin' );
wp_add_inline_script(
"{$this->plugin->assets_prefix}-admin",
ASSET_PREFIX . '-admin',
sprintf(
'ShareButtons.boot( %s );',
wp_json_encode(
@@ -436,7 +444,7 @@ class Share_Buttons {
'token' => $token,
'secret' => $secret,
'buttonConfig' => $button_config,
'nonce' => wp_create_nonce( $this->plugin->meta_prefix ),
'nonce' => wp_create_nonce( META_PREFIX ),
'fresh' => get_option( 'sharethis_fract' ),
'first' => get_option( 'sharethis_first_product', false ),
)
@@ -461,7 +469,7 @@ class Share_Buttons {
'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.
*/
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.
foreach ( $config_array as $setting ) {
@@ -568,7 +576,7 @@ class Share_Buttons {
// Display the list call back if specified.
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 {
$current_omit = $this->get_omit( $setting['type'] );
@@ -643,7 +651,7 @@ class Share_Buttons {
* @param array $id The setting type.
*/
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.
*/
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.
*/
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',
);
include "{$this->plugin->dir_path}/templates/general/gdpr/gdpr-config.php";
include DIR_PATH . '/templates/general/gdpr/gdpr-config.php';
} else {
$enabled = array(
'inline' => 'true' === get_option( 'sharethis_inline' ) ? 'Enabled' : 'Disabled',
@@ -735,7 +743,7 @@ class Share_Buttons {
'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
*/
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.
wp_send_json_error( 'Set credentials failed.' );
@@ -864,7 +872,7 @@ class Share_Buttons {
* @action wp_ajax_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.
wp_send_json_error( 'Update buttons failed.' );
@@ -887,7 +895,7 @@ class Share_Buttons {
* @action wp_ajax_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.
wp_send_json_error( 'Update settings failed.' );
@@ -916,7 +924,7 @@ class Share_Buttons {
* @action wp_ajax_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.
wp_send_json_error( 'Update buttons failed.' );
@@ -988,7 +996,7 @@ class Share_Buttons {
* @action wp_ajax_return_omit
*/
public function return_omit() {
check_ajax_referer( $this->plugin->meta_prefix, 'nonce' );
check_ajax_referer( META_PREFIX, 'nonce' );
$post = filter_input_array(
INPUT_POST,
@@ -1505,7 +1513,7 @@ class Share_Buttons {
* @action wp_ajax_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(
INPUT_POST,
@@ -1610,7 +1618,7 @@ class Share_Buttons {
* @action wp_ajax_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(
INPUT_POST,