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

Yoast / wordpress-seo / 7cd8af37a7bbbd7b964cfa8db91dfdc0d3c167de

27 Mar 2026 10:12AM UTC coverage: 52.787% (-1.1%) from 53.917%
7cd8af37a7bbbd7b964cfa8db91dfdc0d3c167de

Pull #23062

github

web-flow
Merge 77b1c5f2b into 70d176237
Pull Request #23062: Register Yoast SEO abilities about analysis scores

8535 of 16034 branches covered (53.23%)

Branch coverage included in aggregate %.

143 of 307 new or added lines in 5 files covered. (46.58%)

794 existing lines in 37 files now uncovered.

33679 of 63936 relevant lines covered (52.68%)

46793.79 hits per line

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

65.08
/src/integrations/admin/installation-success-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\Helpers\Options_Helper;
8
use Yoast\WP\SEO\Helpers\Product_Helper;
9
use Yoast\WP\SEO\Helpers\Short_Link_Helper;
10
use Yoast\WP\SEO\Integrations\Integration_Interface;
11

12
/**
13
 * Installation_Success_Integration class
14
 */
15
class Installation_Success_Integration implements Integration_Interface {
16

17
        /**
18
         * The options helper.
19
         *
20
         * @var Options_Helper
21
         */
22
        protected $options_helper;
23

24
        /**
25
         * The product helper.
26
         *
27
         * @var Product_Helper
28
         */
29
        protected $product_helper;
30

31
        /**
32
         * The shortlinker.
33
         *
34
         * @var Short_Link_Helper
35
         */
36
        private $shortlinker;
37

38
        /**
39
         * {@inheritDoc}
40
         */
41
        public static function get_conditionals() {
2✔
42
                return [ Admin_Conditional::class ];
2✔
43
        }
44

45
        /**
46
         * Installation_Success_Integration constructor.
47
         *
48
         * @param Options_Helper    $options_helper The options helper.
49
         * @param Product_Helper    $product_helper The product helper.
50
         * @param Short_Link_Helper $shortlinker    The shortlinker.
51
         */
52
        public function __construct( Options_Helper $options_helper, Product_Helper $product_helper, Short_Link_Helper $shortlinker ) {
2✔
53
                $this->options_helper = $options_helper;
2✔
54
                $this->product_helper = $product_helper;
2✔
55
                $this->shortlinker    = $shortlinker;
2✔
56
        }
57

58
        /**
59
         * {@inheritDoc}
60
         */
61
        public function register_hooks() {
2✔
62
                \add_filter( 'admin_menu', [ $this, 'add_submenu_page' ], 9 );
2✔
63
                \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
2✔
64
                \add_action( 'admin_init', [ $this, 'maybe_redirect' ] );
2✔
65
        }
66

67
        /**
68
         * Redirects to the installation success page if an installation has just occurred.
69
         *
70
         * @return void
71
         */
72
        public function maybe_redirect() {
26✔
73
                if ( \wp_doing_ajax() || \wp_doing_cron() || \wp_is_serving_rest_request() || \wp_is_json_request() ) {
26✔
74
                        return;
8✔
75
                }
76

77
                if ( ! \current_user_can( 'manage_options' ) ) {
18✔
78
                        return;
2✔
79
                }
80

81
                if ( ! $this->options_helper->get( 'should_redirect_after_install_free', false ) ) {
16✔
82
                        return;
2✔
83
                }
84
                $this->options_helper->set( 'should_redirect_after_install_free', false );
14✔
85

86
                if ( ! empty( $this->options_helper->get( 'activation_redirect_timestamp_free', 0 ) ) ) {
14✔
87
                        return;
2✔
88
                }
89
                $this->options_helper->set( 'activation_redirect_timestamp_free', \time() );
12✔
90

91
                // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
92
                if ( isset( $_REQUEST['activate-multi'] ) && $_REQUEST['activate-multi'] === 'true' ) {
12✔
93
                        return;
2✔
94
                }
95

96
                if ( $this->product_helper->is_premium() ) {
10✔
97
                        return;
2✔
98
                }
99

100
                if ( \is_network_admin() || \is_plugin_active_for_network( \WPSEO_BASENAME ) ) {
8✔
101
                        return;
4✔
102
                }
103

104
                /**
105
                 * Filter: 'wpseo_should_redirect_after_install' - Allows skipping the redirect to the installation success page.
106
                 *
107
                 * @param bool $should_redirect Whether to redirect. Default true.
108
                 */
109
                if ( ! \apply_filters( 'wpseo_should_redirect_after_install', true ) ) {
4✔
110
                        return;
2✔
111
                }
112

113
                \wp_safe_redirect( \admin_url( 'admin.php?page=wpseo_installation_successful_free' ), 302, 'Yoast SEO' );
2✔
114
                $this->terminate_execution();
2✔
115
        }
116

117
        /**
118
         * Adds the installation success submenu page.
119
         *
120
         * @param array $submenu_pages The Yoast SEO submenu pages.
121
         *
122
         * @return array the filtered submenu pages.
123
         */
124
        public function add_submenu_page( $submenu_pages ) {
2✔
125
                \add_submenu_page(
2✔
126
                        'options.php',
2✔
127
                        \__( 'Installation Successful', 'wordpress-seo' ),
2✔
128
                        '',
2✔
129
                        'manage_options',
2✔
130
                        'wpseo_installation_successful_free',
2✔
131
                        [ $this, 'render_page' ],
2✔
132
                );
2✔
133

134
                return $submenu_pages;
2✔
135
        }
136

137
        /**
138
         * Enqueue assets on the Installation success page.
139
         *
140
         * @return void
141
         */
142
        public function enqueue_assets() {
×
143
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved.
144
                if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_installation_successful_free' ) {
×
145
                        return;
×
146
                }
147

148
                $asset_manager = new WPSEO_Admin_Asset_Manager();
×
149
                $asset_manager->enqueue_script( 'installation-success' );
×
150
                $asset_manager->enqueue_style( 'installation-success' );
×
151
                $asset_manager->enqueue_style( 'monorepo' );
×
152

UNCOV
153
                $ftc_url = \esc_url( \admin_url( 'admin.php?page=wpseo_dashboard#/first-time-configuration' ) );
×
154

UNCOV
155
                $asset_manager->localize_script(
×
UNCOV
156
                        'installation-success',
×
UNCOV
157
                        'wpseoInstallationSuccess',
×
UNCOV
158
                        [
×
159
                                'pluginUrl'                 => \esc_url( \plugins_url( '', \WPSEO_FILE ) ),
×
160
                                'firstTimeConfigurationUrl' => $ftc_url,
×
UNCOV
161
                                'dashboardUrl'              => \esc_url( \admin_url( 'admin.php?page=wpseo_dashboard' ) ),
×
UNCOV
162
                                'explorePremiumUrl'         => $this->shortlinker->build( 'https://yoa.st/ftc-premium-link' ),
×
UNCOV
163
                        ],
×
UNCOV
164
                );
×
165
        }
166

167
        /**
168
         * Renders the installation success page.
169
         *
170
         * @return void
171
         */
UNCOV
172
        public function render_page() {
×
UNCOV
173
                echo '<div id="wpseo-installation-successful-free" class="yoast"></div>';
×
174
        }
175

176
        /**
177
         * Wrap the `exit` function to make unit testing easier.
178
         *
179
         * @return void
180
         */
UNCOV
181
        public function terminate_execution() {
×
UNCOV
182
                exit();
×
183
        }
184
}
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