Yoast_Notification_Center::get_notification_by_id()publicYoast 1.0

Get the notification by ID and user ID.

Метод класса: Yoast_Notification_Center{}

Хуков нет.

Возвращает

Yoast_Notification|null.

Использование

$Yoast_Notification_Center = new Yoast_Notification_Center();
$Yoast_Notification_Center->get_notification_by_id( $notification_id, $user_id );
$notification_id(строка) (обязательный)
The ID of the notification to search for.
$user_id(int|null)
The ID of the user.
По умолчанию: null

Код Yoast_Notification_Center::get_notification_by_id() Yoast 22.3

public function get_notification_by_id( $notification_id, $user_id = null ) {
	$user_id = self::get_user_id( $user_id );

	$notifications = $this->get_notifications_for_user( $user_id );

	foreach ( $notifications as $notification ) {
		if ( $notification_id === $notification->get_id() ) {
			return $notification;
		}
	}

	return null;
}