Yoast_Notification_Center::retrieve_notifications_from_storage()privateYoast 1.0

Retrieve the notifications from storage and fill the relevant property.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

// private - только в коде основоного (родительского) класса
$result = $this->retrieve_notifications_from_storage( $user_id );
$user_id(int) (обязательный)
The ID of the user to retrieve notifications for.

Код Yoast_Notification_Center::retrieve_notifications_from_storage() Yoast 22.3

private function retrieve_notifications_from_storage( $user_id ) {
	if ( $this->notifications_retrieved ) {
		return;
	}

	$this->notifications_retrieved = true;

	$stored_notifications = get_user_option( self::STORAGE_KEY, $user_id );

	// Check if notifications are stored.
	if ( empty( $stored_notifications ) ) {
		return;
	}

	if ( is_array( $stored_notifications ) ) {
		$notifications = array_map( [ $this, 'array_to_notification' ], $stored_notifications );

		// Apply array_values to ensure we get a 0-indexed array.
		$notifications = array_values( array_filter( $notifications, [ $this, 'filter_notification_current_user' ] ) );

		$this->notifications[ $user_id ] = $notifications;
	}
}