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

Yoast / wordpress-seo / 81466e50d5021e6138376898d9ab9de6c4d88904

10 Jul 2025 11:31AM UTC coverage: 53.511% (+0.1%) from 53.412%
81466e50d5021e6138376898d9ab9de6c4d88904

Pull #22356

github

kyrylo-polozenko-newfold
update redirects page integration
Pull Request #22356: Feature/get redirects

8217 of 14373 branches covered (57.17%)

Branch coverage included in aggregate %.

3 of 42 new or added lines in 10 files covered. (7.14%)

3 existing lines in 3 files now uncovered.

30355 of 57710 relevant lines covered (52.6%)

41373.44 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\Integrations\Admin\Redirects_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( $page, [ Settings_Integration::PAGE, Academy_Integration::PAGE, Support_Integration::PAGE, Redirects_Page_Integration::PAGE ], true );
×
57
                $new_dashboard_page = ( $page === General_Page_Integration::PAGE && ! is_network_admin() );
×
58
                if ( $page_exceptions || $new_dashboard_page ) {
×
59
                        // Bail, this is managed in the applicable integration.
60
                        return;
×
61
                }
62
                add_action( 'admin_enqueue_scripts', [ $this, 'config_page_scripts' ] );
×
63
                add_action( 'admin_enqueue_scripts', [ $this, 'config_page_styles' ] );
×
64
        }
65

66
        /**
67
         * Loads the required styles for the config page.
68
         *
69
         * @return void
70
         */
71
        public function config_page_styles() {
×
72
                wp_enqueue_style( 'dashboard' );
×
73
                wp_enqueue_style( 'thickbox' );
×
74
                wp_enqueue_style( 'global' );
×
75
                wp_enqueue_style( 'wp-admin' );
×
76
                $this->asset_manager->enqueue_style( 'admin-css' );
×
77
                $this->asset_manager->enqueue_style( 'monorepo' );
×
78

79
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
80
                $page = isset( $_GET['page'] ) && is_string( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : '';
×
81
                if ( $page === 'wpseo_licenses' ) {
×
82
                        $this->asset_manager->enqueue_style( 'tailwind' );
×
83
                }
84
        }
85

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

96
                $alert_dismissal_action = YoastSEO()->classes->get( Alert_Dismissal_Action::class );
×
97
                $dismissed_alerts       = $alert_dismissal_action->all_dismissed();
×
98

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

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

112
                if ( in_array( $page, [ WPSEO_Admin::PAGE_IDENTIFIER, 'wpseo_workouts' ], true ) ) {
×
113
                        wp_enqueue_media();
×
114

115
                        $script_data['userEditUrl'] = add_query_arg( 'user_id', '{user_id}', admin_url( 'user-edit.php' ) );
×
116
                }
117

118
                if ( $page === 'wpseo_tools' ) {
×
119
                        $this->enqueue_tools_scripts();
×
120
                }
121

122
                $this->asset_manager->localize_script( 'settings', 'wpseoScriptData', $script_data );
×
123
                $this->asset_manager->enqueue_user_language_script();
×
124
        }
125

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

135
                if ( empty( $tool ) ) {
×
136
                        $this->asset_manager->enqueue_script( 'yoast-seo' );
×
137
                }
138

139
                if ( $tool === 'bulk-editor' ) {
×
140
                        $this->asset_manager->enqueue_script( 'bulk-editor' );
×
141
                }
142
        }
143

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

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