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

Yoast / wordpress-seo / 7f13637735c91788cfc2d1721395816a9e9168c3

25 Jun 2025 01:57PM UTC coverage: 53.893% (+0.2%) from 53.652%
7f13637735c91788cfc2d1721395816a9e9168c3

push

github

web-flow
Merge pull request #22374 from Yoast/636-redesign-upgrades-page

Redesign upgrades page

8246 of 14334 branches covered (57.53%)

Branch coverage included in aggregate %.

128 of 180 new or added lines in 26 files covered. (71.11%)

2 existing lines in 1 file now uncovered.

30472 of 57509 relevant lines covered (52.99%)

41518.05 hits per line

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

0.0
/admin/class-config.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Admin
6
 */
7

8
use Yoast\WP\SEO\Actions\Alert_Dismissal_Action;
9
use Yoast\WP\SEO\General\User_Interface\General_Page_Integration;
10
use Yoast\WP\SEO\Integrations\Academy_Integration;
11
use Yoast\WP\SEO\Integrations\Settings_Integration;
12
use Yoast\WP\SEO\Integrations\Support_Integration;
13
use Yoast\WP\SEO\Plans\User_Interface\Plans_Page_Integration;
14
use Yoast\WP\SEO\Promotions\Application\Promotion_Manager;
15

16
/**
17
 * Class WPSEO_Admin_Pages.
18
 *
19
 * Class with functionality for the Yoast SEO admin pages.
20
 */
21
class WPSEO_Admin_Pages {
22

23
        /**
24
         * The option in use for the current admin page.
25
         *
26
         * @var string
27
         */
28
        public $currentoption = 'wpseo';
29

30
        /**
31
         * Holds the asset manager.
32
         *
33
         * @var WPSEO_Admin_Asset_Manager
34
         */
35
        private $asset_manager;
36

37
        /**
38
         * Class constructor, which basically only hooks the init function on the init hook.
39
         */
40
        public function __construct() {
×
41
                add_action( 'init', [ $this, 'init' ], 20 );
×
42

43
                $this->asset_manager = new WPSEO_Admin_Asset_Manager();
×
44
        }
45

46
        /**
47
         * Make sure the needed scripts are loaded for admin pages.
48
         *
49
         * @return void
50
         */
51
        public function init() {
×
52
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
53
                $page = isset( $_GET['page'] ) && is_string( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
×
54

55
                // Don't load the scripts for the following pages.
NEW
56
                $page_exceptions    = in_array(
×
NEW
57
                        $page,
×
NEW
58
                        [
×
NEW
59
                                Settings_Integration::PAGE,
×
NEW
60
                                Academy_Integration::PAGE,
×
NEW
61
                                Support_Integration::PAGE,
×
NEW
62
                                Plans_Page_Integration::PAGE,
×
NEW
63
                        ],
×
NEW
64
                        true
×
NEW
65
                );
×
66
                $new_dashboard_page = ( $page === General_Page_Integration::PAGE && ! is_network_admin() );
×
67
                if ( $page_exceptions || $new_dashboard_page ) {
×
68
                        // Bail, this is managed in the applicable integration.
69
                        return;
×
70
                }
71
                add_action( 'admin_enqueue_scripts', [ $this, 'config_page_scripts' ] );
×
72
                add_action( 'admin_enqueue_scripts', [ $this, 'config_page_styles' ] );
×
73
        }
74

75
        /**
76
         * Loads the required styles for the config page.
77
         *
78
         * @return void
79
         */
80
        public function config_page_styles() {
×
81
                wp_enqueue_style( 'dashboard' );
×
82
                wp_enqueue_style( 'thickbox' );
×
83
                wp_enqueue_style( 'global' );
×
84
                wp_enqueue_style( 'wp-admin' );
×
85
                $this->asset_manager->enqueue_style( 'admin-css' );
×
86
                $this->asset_manager->enqueue_style( 'monorepo' );
×
87
        }
88

89
        /**
90
         * Loads the required scripts for the config page.
91
         *
92
         * @return void
93
         */
94
        public function config_page_scripts() {
×
95
                $this->asset_manager->enqueue_script( 'settings' );
×
96
                wp_enqueue_script( 'dashboard' );
×
97
                wp_enqueue_script( 'thickbox' );
×
98

99
                $alert_dismissal_action = YoastSEO()->classes->get( Alert_Dismissal_Action::class );
×
100
                $dismissed_alerts       = $alert_dismissal_action->all_dismissed();
×
101

102
                $script_data = [
×
103
                        'dismissedAlerts'                => $dismissed_alerts,
×
104
                        'isRtl'                          => is_rtl(),
×
105
                        'isPremium'                      => YoastSEO()->helpers->product->is_premium(),
×
NEW
106
                        'currentPromotions'              => YoastSEO()->classes->get( Promotion_Manager::class )
×
NEW
107
                                ->get_current_promotions(),
×
108
                        'webinarIntroFirstTimeConfigUrl' => $this->get_webinar_shortlink(),
×
109
                        'linkParams'                     => WPSEO_Shortlinker::get_query_params(),
×
110
                        'pluginUrl'                      => plugins_url( '', WPSEO_FILE ),
×
111
                ];
×
112

113
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
114
                $page = isset( $_GET['page'] ) && is_string( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
×
115

116
                if ( in_array( $page, [ WPSEO_Admin::PAGE_IDENTIFIER, 'wpseo_workouts' ], true ) ) {
×
117
                        wp_enqueue_media();
×
118

119
                        $script_data['userEditUrl'] = add_query_arg( 'user_id', '{user_id}', admin_url( 'user-edit.php' ) );
×
120
                }
121

122
                if ( $page === 'wpseo_tools' ) {
×
123
                        $this->enqueue_tools_scripts();
×
124
                }
125

126
                $this->asset_manager->localize_script( 'settings', 'wpseoScriptData', $script_data );
×
127
                $this->asset_manager->enqueue_user_language_script();
×
128
        }
129

130
        /**
131
         * Enqueues and handles all the tool dependencies.
132
         *
133
         * @return void
134
         */
135
        private function enqueue_tools_scripts() {
×
136
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
137
                $tool = isset( $_GET['tool'] ) && is_string( $_GET['tool'] ) ? sanitize_text_field( wp_unslash( $_GET['tool'] ) ) : '';
×
138

139
                if ( empty( $tool ) ) {
×
140
                        $this->asset_manager->enqueue_script( 'yoast-seo' );
×
141
                }
142

143
                if ( $tool === 'bulk-editor' ) {
×
144
                        $this->asset_manager->enqueue_script( 'bulk-editor' );
×
145
                }
146
        }
147

148
        /**
149
         * Returns the appropriate shortlink for the Webinar.
150
         *
151
         * @return string The shortlink for the Webinar.
152
         */
153
        private function get_webinar_shortlink() {
×
154
                if ( YoastSEO()->helpers->product->is_premium() ) {
×
155
                        return WPSEO_Shortlinker::get( 'https://yoa.st/webinar-intro-first-time-config-premium' );
×
156
                }
157

158
                return WPSEO_Shortlinker::get( 'https://yoa.st/webinar-intro-first-time-config' );
×
159
        }
160
}
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