PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / 28.5
Yoast SEO – Advanced SEO with real-time guidance and built-in AI v28.5
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/helpers/notification-helper.php +50 -0 18.428.5 View file →
@@ -21,5 +21,55 @@
21 21 */
22 22 public function restore_notification( Yoast_Notification $notification ) {
23 23 return Yoast_Notification_Center::restore_notification( $notification );
24 24 }
25 +
26 + /**
27 + * Return the notifications sorted on type and priority. (wrapper function)
28 + *
29 + * @codeCoverageIgnore
30 + *
31 + * @return Yoast_Notification[] Sorted Notifications
32 + */
33 + public function get_sorted_notifications() {
34 + $notification_center = Yoast_Notification_Center::get();
35 +
36 + return $notification_center->get_sorted_notifications();
37 + }
38 +
39 + /**
40 + * Check if the user has dismissed a notification. (wrapper function)
41 + *
42 + * @codeCoverageIgnore
43 + *
44 + * @param Yoast_Notification $notification The notification to check for dismissal.
45 + * @param int|null $user_id User ID to check on.
46 + *
47 + * @return bool
48 + */
49 + private function is_notification_dismissed( Yoast_Notification $notification, $user_id = null ) {
50 + return Yoast_Notification_Center::is_notification_dismissed( $notification, $user_id );
51 + }
52 +
53 + /**
54 + * Parses all the notifications to an array with just id, message, nonce, type and dismissed.
55 + *
56 + * @return array<string, string|bool>
57 + */
58 + public function get_alerts(): array {
59 + $all_notifications = $this->get_sorted_notifications();
60 +
61 + return \array_map(
62 + function ( $notification ) {
63 + return [
64 + 'id' => $notification->get_id(),
65 + 'message' => $notification->get_message(),
66 + 'nonce' => $notification->get_nonce(),
67 + 'type' => $notification->get_type(),
68 + 'dismissed' => $this->is_notification_dismissed( $notification ),
69 + 'resolveNonce' => $notification->get_resolve_nonce(),
70 + ];
71 + },
72 + $all_notifications,
73 + );
74 + }
25 75 }