rebase from live enviornment

This commit is contained in:
Rachit Bhargava
2024-01-09 22:14:20 -05:00
parent ff0b49a046
commit 3a22fcaa4a
15968 changed files with 2344674 additions and 45234 deletions

View File

@@ -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;