• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / d5c0395617268a4e44627c6847bf3faa0a6cc695

15 Apr 2025 07:12AM UTC coverage: 52.454% (-2.1%) from 54.595%
d5c0395617268a4e44627c6847bf3faa0a6cc695

push

github

web-flow
Merge pull request #22077 from Yoast/feature/drop-php-7.2-7.3

Drop compatibility with PHP 7.2 and 7.3

7826 of 13877 branches covered (56.4%)

Branch coverage included in aggregate %.

29028 of 56382 relevant lines covered (51.48%)

42273.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/helpers/notification-helper.php
1
<?php
2

3
namespace Yoast\WP\SEO\Helpers;
4

5
use Yoast_Notification;
6
use Yoast_Notification_Center;
7

8
/**
9
 * A helper object for notifications.
10
 */
11
class Notification_Helper {
12

13
        /**
14
         * Restores a notification (wrapper function).
15
         *
16
         * @codeCoverageIgnore
17
         *
18
         * @param Yoast_Notification $notification The notification to restore.
19
         *
20
         * @return bool True if restored, false otherwise.
21
         */
22
        public function restore_notification( Yoast_Notification $notification ) {
23
                return Yoast_Notification_Center::restore_notification( $notification );
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
                                ];
×
70
                        },
71
                        $all_notifications
72
                );
73
        }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc