Yoast_Notification_Center::display_notifications
Display the notifications.
Метод класса: Yoast_Notification_Center{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$Yoast_Notification_Center = new Yoast_Notification_Center(); $Yoast_Notification_Center->display_notifications( $echo_as_json );
- $echo_as_json(true|false)
- True when notifications should be printed directly.
По умолчанию: false
Код Yoast_Notification_Center::display_notifications() Yoast Notification Center::display notifications Yoast 26.3
public function display_notifications( $echo_as_json = false ) {
// Never display notifications for network admin.
if ( is_network_admin() ) {
return;
}
$sorted_notifications = $this->get_sorted_notifications();
$notifications = array_filter( $sorted_notifications, [ $this, 'is_notification_persistent' ] );
if ( empty( $notifications ) ) {
return;
}
array_walk( $notifications, [ $this, 'remove_notification' ] );
$notifications = array_unique( $notifications );
if ( $echo_as_json ) {
$notification_json = [];
foreach ( $notifications as $notification ) {
$notification_json[] = $notification->render();
}
// phpcs:ignore WordPress.Security.EscapeOutput -- Reason: WPSEO_Utils::format_json_encode is safe.
echo WPSEO_Utils::format_json_encode( $notification_json );
return;
}
foreach ( $notifications as $notification ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Reason: Temporarily disabled, see: https://github.com/Yoast/wordpress-seo-premium/issues/2510 and https://github.com/Yoast/wordpress-seo-premium/issues/2511.
echo $notification;
}
}