Yoast_Notification_Center::add_notification
Add notification to the cookie.
Метод класса: Yoast_Notification_Center{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Yoast_Notification_Center = new Yoast_Notification_Center(); $Yoast_Notification_Center->add_notification( $notification );
- $notification(Yoast_Notification) (обязательный)
- Notification object instance.
Код Yoast_Notification_Center::add_notification() Yoast Notification Center::add notification Yoast 26.3
public function add_notification( Yoast_Notification $notification ) {
$callback = [ $this, __FUNCTION__ ];
$args = func_get_args();
if ( $this->queue_transaction( $callback, $args ) ) {
return;
}
// Don't add if the user can't see it.
if ( ! $notification->display_for_current_user() ) {
return;
}
$notification_id = $notification->get_id();
$user_id = $notification->get_user_id();
// Empty notifications are always added.
if ( $notification_id !== '' ) {
// If notification ID exists in notifications, don't add again.
$present_notification = $this->get_notification_by_id( $notification_id, $user_id );
if ( $present_notification !== null ) {
$this->remove_notification( $present_notification, false );
}
if ( $present_notification === null ) {
$this->new[] = $notification_id;
}
}
// Add to list.
$this->notifications[ $user_id ][] = $notification;
$this->notifications_need_storage = true;
}