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

Yoast / wordpress-seo / 646bfe405d9e65d791e6271ec57fbb44827ed577

25 Jul 2025 08:54AM UTC coverage: 53.377% (-0.5%) from 53.858%
646bfe405d9e65d791e6271ec57fbb44827ed577

Pull #22455

github

web-flow
Merge 685a51ab8 into e79f37f17
Pull Request #22455: fix: styles for redirects page

7946 of 14027 branches covered (56.65%)

Branch coverage included in aggregate %.

1 of 2 new or added lines in 1 file covered. (50.0%)

17 existing lines in 2 files now uncovered.

29984 of 57033 relevant lines covered (52.57%)

41864.11 hits per line

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

97.87
/src/integrations/admin/first-time-configuration-notice-integration.php
1
<?php
2

3
namespace Yoast\WP\SEO\Integrations\Admin;
4

5
use WPSEO_Admin_Asset_Manager;
6
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
7
use Yoast\WP\SEO\Helpers\First_Time_Configuration_Notice_Helper;
8
use Yoast\WP\SEO\Helpers\Options_Helper;
9
use Yoast\WP\SEO\Integrations\Integration_Interface;
10
use Yoast\WP\SEO\Presenters\Admin\Notice_Presenter;
11

12
/**
13
 * First_Time_Configuration_Notice_Integration class
14
 */
15
class First_Time_Configuration_Notice_Integration implements Integration_Interface {
16

17
        /**
18
         * The options' helper.
19
         *
20
         * @var Options_Helper
21
         */
22
        private $options_helper;
23

24
        /**
25
         * The admin asset manager.
26
         *
27
         * @var WPSEO_Admin_Asset_Manager
28
         */
29
        private $admin_asset_manager;
30

31
        /**
32
         * The first time configuration notice helper.
33
         *
34
         * @var First_Time_Configuration_Notice_Helper
35
         */
36
        private $first_time_configuration_notice_helper;
37

38
        /**
39
         * {@inheritDoc}
40
         */
41
        public static function get_conditionals() {
2✔
42
                return [ Admin_Conditional::class ];
2✔
43
        }
44

45
        /**
46
         * First_Time_Configuration_Notice_Integration constructor.
47
         *
48
         * @param Options_Helper                         $options_helper                         The options helper.
49
         * @param First_Time_Configuration_Notice_Helper $first_time_configuration_notice_helper The first time configuration notice helper.
50
         * @param WPSEO_Admin_Asset_Manager              $admin_asset_manager                    The admin asset manager.
51
         */
52
        public function __construct(
16✔
53
                Options_Helper $options_helper,
54
                First_Time_Configuration_Notice_Helper $first_time_configuration_notice_helper,
55
                WPSEO_Admin_Asset_Manager $admin_asset_manager
56
        ) {
57
                $this->options_helper                         = $options_helper;
16✔
58
                $this->admin_asset_manager                    = $admin_asset_manager;
16✔
59
                $this->first_time_configuration_notice_helper = $first_time_configuration_notice_helper;
16✔
60
        }
61

62
        /**
63
         * {@inheritDoc}
64
         */
65
        public function register_hooks() {
2✔
66
                \add_action( 'wp_ajax_dismiss_first_time_configuration_notice', [ $this, 'dismiss_first_time_configuration_notice' ] );
2✔
67
                \add_action( 'admin_notices', [ $this, 'first_time_configuration_notice' ] );
2✔
68
        }
69

70
        /**
71
         * Dismisses the First-time configuration notice.
72
         *
73
         * @return bool
74
         */
75
        public function dismiss_first_time_configuration_notice() {
4✔
76
                // Check for nonce.
77
                if ( ! \check_ajax_referer( 'wpseo-dismiss-first-time-configuration-notice', 'nonce', false ) ) {
4✔
78
                        return false;
2✔
79
                }
80
                return $this->options_helper->set( 'dismiss_configuration_workout_notice', true );
2✔
81
        }
82

83
        /**
84
         * Determines whether and where the "First-time SEO Configuration" admin notice should be displayed.
85
         *
86
         * @return bool Whether the "First-time SEO Configuration" admin notice should be displayed.
87
         */
88
        public function should_display_first_time_configuration_notice() {
8✔
89
                return $this->first_time_configuration_notice_helper->should_display_first_time_configuration_notice();
8✔
90
        }
91

92
        /**
93
         * Displays an admin notice when the first-time configuration has not been finished yet.
94
         *
95
         * @return void
96
         */
97
        public function first_time_configuration_notice() {
6✔
98
                if ( ! $this->should_display_first_time_configuration_notice() ) {
6✔
99
                        return;
2✔
100
                }
101

102
                // Don't show on redirects page.
103
                if ( isset( $_GET['page'] ) && $_GET['page'] === 'wpseo-redirects' ) {
4✔
NEW
UNCOV
104
                        return;
×
105
                }
106

107
                $this->admin_asset_manager->enqueue_style( 'monorepo' );
4✔
108

109
                $title    = $this->first_time_configuration_notice_helper->get_first_time_configuration_title();
4✔
110
                $link_url = \esc_url( \self_admin_url( 'admin.php?page=wpseo_dashboard#/first-time-configuration' ) );
4✔
111

112
                if ( ! $this->first_time_configuration_notice_helper->should_show_alternate_message() ) {
4✔
113
                        $content = \sprintf(
2✔
114
                                /* translators: 1: Link start tag to the first-time configuration, 2: Yoast SEO, 3: Link closing tag. */
115
                                \__( 'Get started quickly with the %1$s%2$s First-time configuration%3$s and configure Yoast SEO with the optimal SEO settings for your site!', 'wordpress-seo' ),
2✔
116
                                '<a href="' . $link_url . '">',
2✔
117
                                'Yoast SEO',
2✔
118
                                '</a>'
2✔
119
                        );
2✔
120
                }
121
                else {
122
                        $content = \sprintf(
2✔
123
                                /* translators: 1: Link start tag to the first-time configuration, 2: Link closing tag. */
124
                                \__( 'We noticed that you haven\'t fully configured Yoast SEO yet. Optimize your SEO settings even further by using our improved %1$s First-time configuration%2$s.', 'wordpress-seo' ),
2✔
125
                                '<a href="' . $link_url . '">',
2✔
126
                                '</a>'
2✔
127
                        );
2✔
128
                }
129

130
                $notice = new Notice_Presenter(
4✔
131
                        $title,
4✔
132
                        $content,
4✔
133
                        'mirrored_fit_bubble_woman_1_optim.svg',
4✔
134
                        null,
4✔
135
                        true,
4✔
136
                        'yoast-first-time-configuration-notice'
4✔
137
                );
4✔
138

139
                //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Output from present() is considered safe.
140
                echo $notice->present();
4✔
141

142
                // Enable permanently dismissing the notice.
143
                echo '<script>
4✔
144
                                jQuery( document ).ready( function() {
145
                                        jQuery( "body" ).on( "click", "#yoast-first-time-configuration-notice .notice-dismiss", function() {
146
                                                jQuery( "#yoast-first-time-configuration-notice" ).hide();
147
                                                const data = {
148
                                                        "action": "dismiss_first_time_configuration_notice",
149
                                                        "nonce": "' . \esc_js( \wp_create_nonce( 'wpseo-dismiss-first-time-configuration-notice' ) ) . '"
4✔
150
                                                };
151
                                                jQuery.post( ajaxurl, data, function( response ) {});
152
                                        } );
153
                                } );
154
                                </script>';
4✔
155
        }
156
}
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