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

Yoast / wordpress-seo / 0a731db3c07f378783fa4c8a98a311251563afc3

12 Nov 2025 09:39AM UTC coverage: 52.975%. First build
0a731db3c07f378783fa4c8a98a311251563afc3

push

github

thijsoo
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into feature/schema_aggregator

8497 of 15696 branches covered (54.13%)

Branch coverage included in aggregate %.

154 of 269 new or added lines in 36 files covered. (57.25%)

32187 of 61102 relevant lines covered (52.68%)

39085.39 hits per line

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

39.22
/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\Helpers\User_Helper;
10
use Yoast\WP\SEO\Integrations\Integration_Interface;
11
use Yoast\WP\SEO\Introductions\Infrastructure\Wistia_Embed_Permission_Repository;
12

13
/**
14
 * Redirects_Page_Integration class.
15
 */
16
class Redirects_Page_Integration implements Integration_Interface {
17

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

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

30
        /**
31
         * The user helper.
32
         *
33
         * @var User_Helper
34
         */
35
        private $user_helper;
36

37
        /**
38
         * The Wistia embed permission repository.
39
         *
40
         * @var Wistia_Embed_Permission_Repository
41
         */
42
        private $wistia_embed_permission_repository;
43

44
        /**
45
         * Constructor.
46
         *
47
         * @param Current_Page_Helper                $current_page_helper                The current page helper.
48
         * @param User_Helper                        $user_helper                        The user helper.
49
         * @param Wistia_Embed_Permission_Repository $wistia_embed_permission_repository The Wistia embed permission
50
         *                                                                               repository.
51
         */
NEW
52
        public function __construct(
×
53
                Current_Page_Helper $current_page_helper,
54
                User_Helper $user_helper,
55
                Wistia_Embed_Permission_Repository $wistia_embed_permission_repository
56
        ) {
NEW
57
                $this->current_page_helper                = $current_page_helper;
×
NEW
58
                $this->user_helper                        = $user_helper;
×
NEW
59
                $this->wistia_embed_permission_repository = $wistia_embed_permission_repository;
×
60
        }
61

62
        /**
63
         * Sets up the hooks.
64
         *
65
         * @return void
66
         */
67
        public function register_hooks() {
2✔
68
                \add_filter( 'wpseo_submenu_pages', [ $this, 'add_submenu_page' ], 9 );
2✔
69
                if ( $this->current_page_helper->get_current_yoast_seo_page() === self::PAGE ) {
2✔
70
                        \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
2✔
71
                        \add_action( 'in_admin_header', [ $this, 'remove_notices' ], \PHP_INT_MAX );
2✔
72
                }
73
        }
74

75
        /**
76
         * Returns the conditionals based on which this loadable should be active.
77
         *
78
         * In this case: only when on an admin page and Premium is not active.
79
         *
80
         * @return array The conditionals.
81
         */
82
        public static function get_conditionals() {
2✔
83
                return [
2✔
84
                        Admin_Conditional::class,
2✔
85
                        Premium_Inactive_Conditional::class,
2✔
86
                ];
2✔
87
        }
88

89
        /**
90
         * Adds the redirects submenu page.
91
         *
92
         * @param array $submenu_pages The Yoast SEO submenu pages.
93
         *
94
         * @return array The filtered submenu pages.
95
         */
96
        public function add_submenu_page( $submenu_pages ) {
2✔
97
                $submenu_pages[] = [
2✔
98
                        'wpseo_dashboard',
2✔
99
                        '',
2✔
100
                        \__( 'Redirects', 'wordpress-seo' ) . ' <span class="yoast-badge yoast-premium-badge"></span>',
2✔
101
                        'edit_others_posts',
2✔
102
                        self::PAGE,
2✔
103
                        [ $this, 'display' ],
2✔
104
                ];
2✔
105

106
                return $submenu_pages;
2✔
107
        }
108

109
        /**
110
         * Enqueue assets on the redirects page.
111
         *
112
         * @return void
113
         */
114
        public function enqueue_assets() {
×
115
                $asset_manager = new WPSEO_Admin_Asset_Manager();
×
116
                $asset_manager->enqueue_script( 'redirects' );
×
117
                $asset_manager->enqueue_style( 'redirects' );
×
NEW
118
                $user_id = $this->user_helper->get_current_user_id();
×
119
                $asset_manager->localize_script(
×
120
                        'redirects',
×
121
                        'wpseoScriptData',
×
122
                        [
×
NEW
123
                                'preferences'           => [
×
124
                                        'isRtl'                 => \is_rtl(),
×
125
                                        'isComingFromToolsPage' => $this->is_coming_from_tools_page(),
×
126
                                ],
×
NEW
127
                                'linkParams'            => \YoastSEO()->helpers->short_link->get_query_params(),
×
NEW
128
                                'pluginUrl'             => \plugins_url( '', \WPSEO_FILE ),
×
NEW
129
                                'wistiaEmbedPermission' => $this->wistia_embed_permission_repository->get_value_for_user( $user_id ),
×
130
                        ]
×
131
                );
×
132
        }
133

134
        /**
135
         * Displays the redirects page.
136
         *
137
         * @return void
138
         */
139
        public function display() {
×
140
                require \WPSEO_PATH . 'admin/pages/redirects.php';
×
141
        }
142

143
        /**
144
         * Removes all current WP notices.
145
         *
146
         * @return void
147
         */
148
        public function remove_notices() {
×
149
                \remove_all_actions( 'admin_notices' );
×
150
                \remove_all_actions( 'user_admin_notices' );
×
151
                \remove_all_actions( 'network_admin_notices' );
×
152
                \remove_all_actions( 'all_admin_notices' );
×
153
        }
154

155
        /**
156
         * Checks whether the user is coming from the tools page.
157
         *
158
         * @return bool
159
         */
160
        public function is_coming_from_tools_page() {
×
161
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are simply checking against a set value.
162
                return isset( $_GET['from_tools'] ) && $_GET['from_tools'] === '1';
×
163
        }
164
}
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