Yoast_Notification_Center::maybe_dismiss_notification
Checks if the notification is being dismissed.
Метод класса: Yoast_Notification_Center{}
Хуков нет.
Возвращает
true|false. True if dismissed.
Использование
$result = Yoast_Notification_Center::maybe_dismiss_notification( $notification, $meta_value );
- $notification(Yoast_Notification) (обязательный)
- Notification to check dismissal of.
- $meta_value(строка)
- Value to set the meta value to if dismissed.
По умолчанию: 'seen'
Код Yoast_Notification_Center::maybe_dismiss_notification() Yoast Notification Center::maybe dismiss notification Yoast 26.7
public static function maybe_dismiss_notification( Yoast_Notification $notification, $meta_value = 'seen' ) {
// Only persistent notifications are dismissible.
if ( ! $notification->is_persistent() ) {
return false;
}
// If notification is already dismissed, we're done.
if ( self::is_notification_dismissed( $notification ) ) {
return true;
}
$dismissal_key = $notification->get_dismissal_key();
$notification_id = $notification->get_id();
$is_dismissing = ( $dismissal_key === self::get_user_input( 'notification' ) );
if ( ! $is_dismissing ) {
$is_dismissing = ( $notification_id === self::get_user_input( 'notification' ) );
}
// Fallback to ?dismissal_key=1&nonce=bla when JavaScript fails.
if ( ! $is_dismissing ) {
$is_dismissing = ( self::get_user_input( $dismissal_key ) === '1' );
}
if ( ! $is_dismissing ) {
return false;
}
$user_nonce = self::get_user_input( 'nonce' );
if ( wp_verify_nonce( $user_nonce, $notification_id ) === false ) {
return false;
}
return self::dismiss_notification( $notification, $meta_value );
}