Merged in feature/117-dev-dev01 (pull request #8)
auto-patch 117-dev-dev01-2023-12-15T16_09_06 * auto-patch 117-dev-dev01-2023-12-15T16_09_06
This commit is contained in:
@@ -15,14 +15,14 @@ class WPSEO_Gutenberg_Compatibility {
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const CURRENT_RELEASE = '17.0.1';
|
||||
const CURRENT_RELEASE = '17.1.3';
|
||||
|
||||
/**
|
||||
* The minimally supported version of Gutenberg by the plugin.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
const MINIMUM_SUPPORTED = '17.0.1';
|
||||
const MINIMUM_SUPPORTED = '17.1.3';
|
||||
|
||||
/**
|
||||
* Holds the current version.
|
||||
|
||||
@@ -716,7 +716,6 @@ class Yoast_Notification_Center {
|
||||
* @return void
|
||||
*/
|
||||
private function retrieve_notifications_from_storage( $user_id ) {
|
||||
|
||||
if ( $this->notifications_retrieved ) {
|
||||
return;
|
||||
}
|
||||
@@ -732,6 +731,7 @@ class Yoast_Notification_Center {
|
||||
|
||||
if ( is_array( $stored_notifications ) ) {
|
||||
$notifications = array_map( [ $this, 'array_to_notification' ], $stored_notifications );
|
||||
|
||||
// Apply array_values to ensure we get a 0-indexed array.
|
||||
$notifications = array_values( array_filter( $notifications, [ $this, 'filter_notification_current_user' ] ) );
|
||||
|
||||
@@ -841,6 +841,13 @@ class Yoast_Notification_Center {
|
||||
$notification_data['message'] = $notification_data['message']->present();
|
||||
}
|
||||
|
||||
if ( isset( $notification_data['options']['user'] ) ) {
|
||||
$notification_data['options']['user_id'] = $notification_data['options']['user']->ID;
|
||||
unset( $notification_data['options']['user'] );
|
||||
|
||||
$this->notifications_need_storage = true;
|
||||
}
|
||||
|
||||
return new Yoast_Notification(
|
||||
$notification_data['message'],
|
||||
$notification_data['options']
|
||||
|
||||
@@ -72,7 +72,7 @@ class Yoast_Notification {
|
||||
private $defaults = [
|
||||
'type' => self::UPDATED,
|
||||
'id' => '',
|
||||
'user' => null,
|
||||
'user_id' => null,
|
||||
'nonce' => null,
|
||||
'priority' => 0.5,
|
||||
'data_json' => [],
|
||||
@@ -112,10 +112,14 @@ class Yoast_Notification {
|
||||
/**
|
||||
* Retrieve the user to show the notification for.
|
||||
*
|
||||
* @deprecated 21.6
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @return WP_User The user to show this notification for.
|
||||
*/
|
||||
public function get_user() {
|
||||
return $this->options['user'];
|
||||
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,10 +130,7 @@ class Yoast_Notification {
|
||||
* @return int The user id
|
||||
*/
|
||||
public function get_user_id() {
|
||||
if ( $this->get_user() !== null ) {
|
||||
return $this->get_user()->ID;
|
||||
}
|
||||
return get_current_user_id();
|
||||
return ( $this->options['user_id'] ?? get_current_user_id() );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,7 +221,7 @@ class Yoast_Notification {
|
||||
*/
|
||||
public function match_capabilities() {
|
||||
// Super Admin can do anything.
|
||||
if ( is_multisite() && is_super_admin( $this->options['user']->ID ) ) {
|
||||
if ( is_multisite() && is_super_admin( $this->options['user_id'] ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -280,7 +281,15 @@ class Yoast_Notification {
|
||||
* @return bool
|
||||
*/
|
||||
private function has_capability( $capability ) {
|
||||
$user = $this->options['user'];
|
||||
$user_id = $this->options['user_id'];
|
||||
if ( ! is_numeric( $user_id ) ) {
|
||||
return false;
|
||||
}
|
||||
$user = get_user_by( 'id', $user_id );
|
||||
if ( ! $user ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $user->has_cap( $capability );
|
||||
}
|
||||
|
||||
@@ -396,9 +405,9 @@ class Yoast_Notification {
|
||||
$options['capabilities'] = [ 'wpseo_manage_options' ];
|
||||
}
|
||||
|
||||
// Set to the current user if not supplied.
|
||||
if ( $options['user'] === null ) {
|
||||
$options['user'] = wp_get_current_user();
|
||||
// Set to the id of the current user if not supplied.
|
||||
if ( $options['user_id'] === null ) {
|
||||
$options['user_id'] = get_current_user_id();
|
||||
}
|
||||
|
||||
return $options;
|
||||
|
||||
@@ -893,7 +893,8 @@ class WPSEO_Metabox extends WPSEO_Meta {
|
||||
'has_taxonomies' => $this->current_post_type_has_taxonomies(),
|
||||
],
|
||||
'shortcodes' => [
|
||||
'wpseo_shortcode_tags' => $this->get_valid_shortcode_tags(),
|
||||
'wpseo_shortcode_tags' => $this->get_valid_shortcode_tags(),
|
||||
'wpseo_filter_shortcodes_nonce' => \wp_create_nonce( 'wpseo-filter-shortcodes' ),
|
||||
],
|
||||
];
|
||||
|
||||
|
||||
@@ -164,7 +164,8 @@ class WPSEO_Taxonomy {
|
||||
'scope' => $this->determine_scope(),
|
||||
],
|
||||
'shortcodes' => [
|
||||
'wpseo_shortcode_tags' => $this->get_valid_shortcode_tags(),
|
||||
'wpseo_shortcode_tags' => $this->get_valid_shortcode_tags(),
|
||||
'wpseo_filter_shortcodes_nonce' => \wp_create_nonce( 'wpseo-filter-shortcodes' ),
|
||||
],
|
||||
],
|
||||
'worker' => [
|
||||
|
||||
Reference in New Issue
Block a user