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

Yoast / wordpress-seo / 8e3a4b2a113fe1853c6ea16ab3daa16ce7b7de5f

29 Sep 2025 12:51PM UTC coverage: 53.21% (-0.02%) from 53.233%
8e3a4b2a113fe1853c6ea16ab3daa16ce7b7de5f

Pull #22606

github

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

8388 of 15525 branches covered (54.03%)

Branch coverage included in aggregate %.

1 of 35 new or added lines in 4 files covered. (2.86%)

5 existing lines in 1 file now uncovered.

31768 of 59942 relevant lines covered (53.0%)

39839.56 hits per line

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

60.87
/src/integrations/admin/redirect-integration.php
1
<?php
2

3
namespace Yoast\WP\SEO\Integrations\Admin;
4

5
use Yoast\WP\SEO\Conditionals\Admin_Conditional;
6
use Yoast\WP\SEO\Helpers\Redirect_Helper;
7
use Yoast\WP\SEO\Integrations\Integration_Interface;
8

9
/**
10
 * Class Redirect_Integration.
11
 */
12
class Redirect_Integration implements Integration_Interface {
13

14
        /**
15
         * The redirect helper.
16
         *
17
         * @var Redirect_Helper
18
         */
19
        private $redirect;
20

21
        /**
22
         * Sets the helpers.
23
         *
24
         * @param Redirect_Helper $redirect The redirect helper.
25
         */
26
        public function __construct( Redirect_Helper $redirect ) {
2✔
27
                $this->redirect = $redirect;
2✔
28
        }
29

30
        /**
31
         * Returns the conditionals based in which this loadable should be active.
32
         *
33
         * @return array
34
         */
35
        public static function get_conditionals() {
2✔
36
                return [ Admin_Conditional::class ];
2✔
37
        }
38

39
        /**
40
         * Initializes the integration.
41
         *
42
         * This is the place to register hooks and filters.
43
         *
44
         * @return void
45
         */
46
        public function register_hooks() {
2✔
47
                \add_action( 'wp_loaded', [ $this, 'old_settings_redirect' ] );
2✔
48
                \add_action( 'wp_loaded', [ $this, 'redirection_redirect' ] );
2✔
49
        }
50

51
        /**
52
         * Redirect to new settings URLs. We're adding this, so that not-updated add-ons don't point to non-existent pages.
53
         *
54
         * @return void
55
         */
56
        public function old_settings_redirect() {
4✔
57
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
58
                if ( ! isset( $_GET['page'] ) ) {
4✔
UNCOV
59
                        return;
×
60
                }
61
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
62
                $current_page = \sanitize_text_field( \wp_unslash( $_GET['page'] ) );
4✔
63

64
                switch ( $current_page ) {
65
                        case 'wpseo_titles':
4✔
66
                                $this->redirect->do_safe_redirect( \admin_url( 'admin.php?page=wpseo_page_settings#/site-representation' ), 301 );
2✔
67
                                return;
2✔
68
                        default:
69
                                return;
2✔
70
                }
71
        }
72

73
        /**
74
         * Redirect to Yoast redirection page, from the respective WP tools page.
75
         *
76
         * @return void
77
         */
NEW
78
        public function redirection_redirect() {
×
79
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
NEW
80
                if ( ! isset( $_GET['page'] ) ) {
×
NEW
81
                        return;
×
82
                }
83
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information.
NEW
84
                $current_page = \sanitize_text_field( \wp_unslash( $_GET['page'] ) );
×
85

86
                switch ( $current_page ) {
NEW
UNCOV
87
                        case 'wpseo_redirects_tools':
×
NEW
UNCOV
88
                                $this->redirect->do_safe_redirect( \admin_url( 'admin.php?page=wpseo_redirects&from_tools=1' ) );
×
NEW
UNCOV
89
                                return;
×
90
                        default:
NEW
UNCOV
91
                                return;
×
92
                }
93
        }
94
}
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