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

Yoast / wordpress-seo / dd6e866a9e6d253114633104d9e3858d807178ba

19 Jun 2024 10:03AM UTC coverage: 48.628% (-4.3%) from 52.936%
dd6e866a9e6d253114633104d9e3858d807178ba

push

github

web-flow
Merge pull request #21431 from Yoast/21429-update-copy-in-the-introduction-and-consent-modals

Updates the copy for the introduction and consent modals

7441 of 13454 branches covered (55.31%)

Branch coverage included in aggregate %.

0 of 3 new or added lines in 2 files covered. (0.0%)

3718 existing lines in 107 files now uncovered.

25100 of 53464 relevant lines covered (46.95%)

62392.47 hits per line

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

0.0
/src/helpers/first-time-configuration-notice-helper.php
1
<?php
2

3
namespace Yoast\WP\SEO\Helpers;
4

5
/**
6
 * A helper to determine the status of ftc and front-end related configuration.
7
 */
8
class First_Time_Configuration_Notice_Helper {
9

10
        /**
11
         * The options' helper.
12
         *
13
         * @var Options_Helper
14
         */
15
        private $options_helper;
16

17
        /**
18
         * The indexing helper.
19
         *
20
         * @var Indexing_Helper
21
         */
22
        private $indexing_helper;
23

24
        /**
25
         * Whether we show the alternate mesage.
26
         *
27
         * @var bool
28
         */
29
        private $show_alternate_message;
30

31
        /**
32
         * First_Time_Configuration_Notice_Integration constructor.
33
         *
34
         * @param Options_Helper  $options_helper  The options helper.
35
         * @param Indexing_Helper $indexing_helper The indexing helper.
36
         */
UNCOV
37
        public function __construct(
×
38
                Options_Helper $options_helper,
39
                Indexing_Helper $indexing_helper
40
        ) {
UNCOV
41
                $this->options_helper         = $options_helper;
×
UNCOV
42
                $this->indexing_helper        = $indexing_helper;
×
UNCOV
43
                $this->show_alternate_message = false;
×
44
        }
45

46
        /**
47
         * Determines whether and where the "First-time SEO Configuration" admin notice should be displayed.
48
         *
49
         * @return bool Whether the "First-time SEO Configuration" admin notice should be displayed.
50
         */
UNCOV
51
        public function should_display_first_time_configuration_notice() {
×
UNCOV
52
                if ( ! $this->options_helper->get( 'dismiss_configuration_workout_notice', false ) === false ) {
×
UNCOV
53
                        return false;
×
54
                }
UNCOV
55
                if ( ! $this->on_wpseo_admin_page_or_dashboard() ) {
×
UNCOV
56
                        return false;
×
57
                }
58

59
                return $this->first_time_configuration_not_finished();
×
60
        }
61

62
        /**
63
         * Gets the first time configuration title based on the show_alternate_message boolean
64
         *
65
         * @return string
66
         */
UNCOV
67
        public function get_first_time_configuration_title() {
×
UNCOV
68
                return ( ! $this->show_alternate_message ) ? \__( 'First-time SEO configuration', 'wordpress-seo' ) : \__( 'SEO configuration', 'wordpress-seo' );
×
69
        }
70

71
        /**
72
         * Determines if the first time configuration is completely finished.
73
         *
74
         * @return bool
75
         */
UNCOV
76
        public function first_time_configuration_not_finished() {
×
UNCOV
77
                if ( ! $this->user_can_do_first_time_configuration() ) {
×
UNCOV
78
                        return false;
×
79
                }
80

UNCOV
81
                if ( $this->is_first_time_configuration_finished() ) {
×
UNCOV
82
                        return false;
×
83
                }
84

UNCOV
85
                if ( $this->options_helper->get( 'first_time_install', false ) !== false ) {
×
UNCOV
86
                        return ! $this->are_site_representation_name_and_logo_set() || $this->indexing_helper->get_unindexed_count() > 0;
×
87
                }
88

UNCOV
89
                if ( $this->indexing_helper->is_initial_indexing() === false ) {
×
UNCOV
90
                        return false;
×
91
                }
92

UNCOV
93
                if ( $this->indexing_helper->is_finished_indexables_indexing() === true ) {
×
UNCOV
94
                        return false;
×
95
                }
96

UNCOV
97
                $this->show_alternate_message = true;
×
98

UNCOV
99
                return ! $this->are_site_representation_name_and_logo_set();
×
100
        }
101

102
        /**
103
         * Whether the user can do the first-time configuration.
104
         *
105
         * @return bool Whether the current user can do the first-time configuration.
106
         */
UNCOV
107
        private function user_can_do_first_time_configuration() {
×
UNCOV
108
                return \current_user_can( 'wpseo_manage_options' );
×
109
        }
110

111
        /**
112
         * Whether the user is currently visiting one of our admin pages or the WordPress dashboard.
113
         *
114
         * @return bool Whether the current page is a Yoast SEO admin page
115
         */
UNCOV
116
        private function on_wpseo_admin_page_or_dashboard() {
×
UNCOV
117
                $pagenow = $GLOBALS['pagenow'];
×
118

119
                // Show on the WP Dashboard.
UNCOV
120
                if ( $pagenow === 'index.php' ) {
×
121
                        return true;
×
122
                }
123

UNCOV
124
                $page_from_get = \filter_input( \INPUT_GET, 'page' );
×
125

126
                // Show on Yoast SEO pages, with some exceptions.
UNCOV
127
                if ( $pagenow === 'admin.php' && \strpos( $page_from_get, 'wpseo' ) === 0 ) {
×
128
                        $exceptions = [
129
                                'wpseo_installation_successful',
×
130
                                'wpseo_installation_successful_free',
131
                        ];
132

133
                        if ( ! \in_array( $page_from_get, $exceptions, true ) ) {
×
134
                                return true;
×
135
                        }
136
                }
137

UNCOV
138
                return false;
×
139
        }
140

141
        /**
142
         * Whether all steps of the first-time configuration have been finished.
143
         *
144
         * @return bool Whether the first-time configuration has been finished.
145
         */
UNCOV
146
        private function is_first_time_configuration_finished() {
×
UNCOV
147
                $configuration_finished_steps = $this->options_helper->get( 'configuration_finished_steps', [] );
×
148

UNCOV
149
                return \count( $configuration_finished_steps ) === 3;
×
150
        }
151

152
        /**
153
         * Whether the site representation name and logo have been set.
154
         *
155
         * @return bool  Whether the site representation name and logo have been set.
156
         */
UNCOV
157
        private function are_site_representation_name_and_logo_set() {
×
UNCOV
158
                $company_or_person = $this->options_helper->get( 'company_or_person', '' );
×
159

UNCOV
160
                if ( $company_or_person === '' ) {
×
161
                        return false;
×
162
                }
163

UNCOV
164
                if ( $company_or_person === 'company' ) {
×
UNCOV
165
                        return ! empty( $this->options_helper->get( 'company_name' ) ) && ! empty( $this->options_helper->get( 'company_logo', '' ) );
×
166
                }
167

168
                return ! empty( $this->options_helper->get( 'company_or_person_user_id' ) ) && ! empty( $this->options_helper->get( 'person_logo', '' ) );
×
169
        }
170

171
        /**
172
         * Getter for the show alternate message boolean.
173
         *
174
         * @return bool
175
         */
UNCOV
176
        public function should_show_alternate_message() {
×
UNCOV
177
                return $this->show_alternate_message;
×
178
        }
179
}
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

© 2025 Coveralls, Inc