Merged in release/release-1.09 (pull request #10)
Release/release 1.09 * Install missing plugins * rs set to 1 * rebase pantheon for aws * rebase pantheon for aws * prod config change * prod config change * fix campaing issue * revert Approved-by: Jay Sharma
This commit is contained in:
committed by
Jay Sharma
parent
779393381f
commit
22f10a9edd
@@ -72,7 +72,7 @@ class Yoast_Notification {
|
||||
private $defaults = [
|
||||
'type' => self::UPDATED,
|
||||
'id' => '',
|
||||
'user_id' => null,
|
||||
'user' => null,
|
||||
'nonce' => null,
|
||||
'priority' => 0.5,
|
||||
'data_json' => [],
|
||||
@@ -112,14 +112,10 @@ 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() {
|
||||
\_deprecated_function( __METHOD__, 'Yoast SEO 21.6' );
|
||||
return null;
|
||||
return $this->options['user'];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -130,7 +126,10 @@ class Yoast_Notification {
|
||||
* @return int The user id
|
||||
*/
|
||||
public function get_user_id() {
|
||||
return ( $this->options['user_id'] ?? get_current_user_id() );
|
||||
if ( $this->get_user() !== null ) {
|
||||
return $this->get_user()->ID;
|
||||
}
|
||||
return get_current_user_id();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,7 +220,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;
|
||||
}
|
||||
|
||||
@@ -281,15 +280,7 @@ class Yoast_Notification {
|
||||
* @return bool
|
||||
*/
|
||||
private function has_capability( $capability ) {
|
||||
$user_id = $this->options['user_id'];
|
||||
if ( ! is_numeric( $user_id ) ) {
|
||||
return false;
|
||||
}
|
||||
$user = get_user_by( 'id', $user_id );
|
||||
if ( ! $user ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$user = $this->options['user'];
|
||||
return $user->has_cap( $capability );
|
||||
}
|
||||
|
||||
@@ -405,9 +396,9 @@ class Yoast_Notification {
|
||||
$options['capabilities'] = [ 'wpseo_manage_options' ];
|
||||
}
|
||||
|
||||
// Set to the id of the current user if not supplied.
|
||||
if ( $options['user_id'] === null ) {
|
||||
$options['user_id'] = get_current_user_id();
|
||||
// Set to the current user if not supplied.
|
||||
if ( $options['user'] === null ) {
|
||||
$options['user'] = wp_get_current_user();
|
||||
}
|
||||
|
||||
return $options;
|
||||
|
||||
Reference in New Issue
Block a user