Yoast_Notification_Center::remove_notification
Remove notification after it has been displayed.
Метод класса: Yoast_Notification_Center{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Yoast_Notification_Center = new Yoast_Notification_Center(); $Yoast_Notification_Center->remove_notification( $notification, $resolve );
- $notification(Yoast_Notification) (обязательный)
- Notification to remove.
- $resolve(true|false)
- Resolve as fixed.
По умолчанию: true
Код Yoast_Notification_Center::remove_notification() Yoast Notification Center::remove notification Yoast 26.3
public function remove_notification( Yoast_Notification $notification, $resolve = true ) {
$callback = [ $this, __FUNCTION__ ];
$args = func_get_args();
if ( $this->queue_transaction( $callback, $args ) ) {
return;
}
$index = false;
// ID of the user to show the notification for, defaults to current user id.
$user_id = $notification->get_user_id();
$notifications = $this->get_notifications_for_user( $user_id );
// Match persistent Notifications by ID, non persistent by item in the array.
if ( $notification->is_persistent() ) {
foreach ( $notifications as $current_index => $present_notification ) {
if ( $present_notification->get_id() === $notification->get_id() ) {
$index = $current_index;
break;
}
}
}
else {
$index = array_search( $notification, $notifications, true );
}
if ( $index === false ) {
return;
}
if ( $notification->is_persistent() && $resolve ) {
++$this->resolved;
$this->clear_dismissal( $notification );
}
unset( $notifications[ $index ] );
$this->notifications[ $user_id ] = array_values( $notifications );
$this->notifications_need_storage = true;
}