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

Yoast / wordpress-seo / a281fe93e575b8c7849342bf945b139f474b651b

30 Sep 2025 08:00AM UTC coverage: 53.211% (-0.02%) from 53.233%
a281fe93e575b8c7849342bf945b139f474b651b

Pull #22606

github

web-flow
Merge 748c2f3a0 into 8f5eaca29
Pull Request #22606: Add redirection tools page

8388 of 15525 branches covered (54.03%)

Branch coverage included in aggregate %.

1 of 34 new or added lines in 4 files covered. (2.94%)

5 existing lines in 1 file now uncovered.

31768 of 59941 relevant lines covered (53.0%)

39840.23 hits per line

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

43.48
/src/integrations/admin/redirects-page-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\Conditionals\Premium_Inactive_Conditional;
8
use Yoast\WP\SEO\Helpers\Current_Page_Helper;
9
use Yoast\WP\SEO\Integrations\Integration_Interface;
10

11
/**
12
 * Redirects_Page_Integration class.
13
 */
14
class Redirects_Page_Integration implements Integration_Interface {
15

16
        /**
17
         * The page identifier.
18
         */
19
        public const PAGE = 'wpseo_redirects';
20

21
        /**
22
         * The current page helper.
23
         *
24
         * @var Current_Page_Helper
25
         */
26
        private $current_page_helper;
27

28
        /**
29
         * Constructor.
30
         *
31
         * @param Current_Page_Helper $current_page_helper The current page helper.
32
         */
33
        public function __construct( Current_Page_Helper $current_page_helper ) {
×
34
                $this->current_page_helper = $current_page_helper;
×
35
        }
36

37
        /**
38
         * Sets up the hooks.
39
         *
40
         * @return void
41
         */
42
        public function register_hooks() {
2✔
43
                \add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], 9 );
2✔
44
                if ( $this->current_page_helper->get_current_yoast_seo_page() === self::PAGE ) {
2✔
45
                        \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
2✔
46
                        \add_action( 'in_admin_header', [ $this, 'remove_notices' ], \PHP_INT_MAX );
2✔
47
                }
48
        }
49

50
        /**
51
         * Returns the conditionals based on which this loadable should be active.
52
         *
53
         * In this case: only when on an admin page and Premium is not active.
54
         *
55
         * @return array The conditionals.
56
         */
57
        public static function get_conditionals() {
2✔
58
                return [
2✔
59
                        Admin_Conditional::class,
2✔
60
                        Premium_Inactive_Conditional::class,
2✔
61
                ];
2✔
62
        }
63

64
        /**
65
         * Adds the redirects submenu page.
66
         *
67
         * @param array $submenu_pages The Yoast SEO submenu pages.
68
         *
69
         * @return array The filtered submenu pages.
70
         */
71
        public function add_submenu_page( $submenu_pages ) {
2✔
72
                $submenu_pages[] = [
2✔
73
                        'wpseo_dashboard',
2✔
74
                        '',
2✔
75
                        \__( 'Redirects', 'wordpress-seo' ) . ' <span class="yoast-badge yoast-premium-badge"></span>',
2✔
76
                        'edit_others_posts',
2✔
77
                        self::PAGE,
2✔
78
                        [ $this, 'display' ],
2✔
79
                ];
2✔
80

81
                return $submenu_pages;
2✔
82
        }
83

84
        /**
85
         * Enqueue assets on the redirects page.
86
         *
87
         * @return void
88
         */
89
        public function enqueue_assets() {
×
90
                $asset_manager = new WPSEO_Admin_Asset_Manager();
×
91
                $asset_manager->enqueue_script( 'redirects' );
×
92
                $asset_manager->enqueue_style( 'redirects' );
×
93

94
                $asset_manager->localize_script(
×
95
                        'redirects',
×
96
                        'wpseoScriptData',
×
97
                        [
×
98
                                'preferences' => [
×
NEW
99
                                        'isRtl'                 => \is_rtl(),
×
NEW
100
                                        'isComingFromToolsPage' => $this->is_coming_from_tools_page(),
×
101
                                ],
×
102
                                'linkParams'  => \YoastSEO()->helpers->short_link->get_query_params(),
×
103
                        ]
×
104
                );
×
105
        }
106

107
        /**
108
         * Displays the redirects page.
109
         *
110
         * @return void
111
         */
112
        public function display() {
×
113
                require \WPSEO_PATH . 'admin/pages/redirects.php';
×
114
        }
115

116
        /**
117
         * Removes all current WP notices.
118
         *
119
         * @return void
120
         */
121
        public function remove_notices() {
×
122
                \remove_all_actions( 'admin_notices' );
×
123
                \remove_all_actions( 'user_admin_notices' );
×
124
                \remove_all_actions( 'network_admin_notices' );
×
125
                \remove_all_actions( 'all_admin_notices' );
×
126
        }
127

128
        /**
129
         * Checks whether the user is coming from the tools page.
130
         *
131
         * @return bool
132
         */
NEW
133
        public function is_coming_from_tools_page() {
×
134
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are simply checking against a set value.
NEW
135
                return isset( $_GET['from_tools'] ) && $_GET['from_tools'] === '1';
×
136
        }
137
}
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