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

Yoast / whip / 7300735247

22 Dec 2023 02:07PM UTC coverage: 31.683% (+3.0%) from 28.713%
7300735247

push

github

web-flow
Merge pull request #157 from Yoast/move-to-namespace-v2

Move source classes to the `Yoast\WHIPv2` namespace

30 of 114 new or added lines in 18 files covered. (26.32%)

96 of 303 relevant lines covered (31.68%)

2.66 hits per line

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

50.0
/src/WPMessageDismissListener.php
1
<?php
2

3
namespace Yoast\WHIPv2;
4

5
use Yoast\WHIPv2\Interfaces\Listener;
6

7
/**
8
 * Listener for dismissing a message.
9
 *
10
 * @phpcs:disable Yoast.NamingConventions.ObjectNameDepth.MaxExceeded -- Sniff does not count acronyms correctly.
11
 */
12
class WPMessageDismissListener implements Listener {
13

14
        /**
15
         * The name of the dismiss action expected to be passed via $_GET.
16
         *
17
         * @var string
18
         */
19
        const ACTION_NAME = 'whip_dismiss';
20

21
        /**
22
         * The object for dismissing a message.
23
         *
24
         * @var MessageDismisser
25
         */
26
        protected $dismisser;
27

28
        /**
29
         * Sets the dismisser attribute.
30
         *
31
         * @param MessageDismisser $dismisser The object for dismissing a message.
32
         */
NEW
33
        public function __construct( MessageDismisser $dismisser ) {
×
34
                $this->dismisser = $dismisser;
×
35
        }
36

37
        /**
38
         * Listens to a GET request to fetch the required attributes.
39
         *
40
         * @return void
41
         */
42
        public function listen() {
12✔
43

44
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is verified in the dismisser.
45
                $action = ( isset( $_GET['action'] ) && \is_string( $_GET['action'] ) ) ? \sanitize_text_field( \wp_unslash( $_GET['action'] ) ) : null;
12✔
46
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Nonce is verified in the dismisser.
47
                $nonce = ( isset( $_GET['nonce'] ) && \is_string( $_GET['nonce'] ) ) ? \sanitize_text_field( \wp_unslash( $_GET['nonce'] ) ) : '';
12✔
48

49
                if ( $action === self::ACTION_NAME && $this->dismisser->verifyNonce( $nonce, self::ACTION_NAME ) ) {
12✔
50
                        $this->dismisser->dismiss();
3✔
51
                }
1✔
52
        }
8✔
53

54
        /**
55
         * Creates an url for dismissing the notice.
56
         *
57
         * @return string The url for dismissing the message.
58
         */
59
        public function getDismissURL() {
×
NEW
60
                return \sprintf(
×
NEW
61
                        \admin_url( 'index.php?action=%1$s&nonce=%2$s' ),
×
62
                        self::ACTION_NAME,
×
NEW
63
                        \wp_create_nonce( self::ACTION_NAME )
×
64
                );
65
        }
66
}
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