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

Yoast / wordpress-seo / b0a18fb1e1db07a099b536084e6d4fe2fdb24aaa

10 Oct 2025 12:23PM UTC coverage: 53.356% (+0.1%) from 53.233%
b0a18fb1e1db07a099b536084e6d4fe2fdb24aaa

push

github

FAMarfuaty
Merge branch 'trunk' of github.com:Yoast/wordpress-seo into feature/off-the-bat-analysis

8480 of 15636 branches covered (54.23%)

Branch coverage included in aggregate %.

18 of 58 new or added lines in 9 files covered. (31.03%)

2 existing lines in 2 files now uncovered.

31979 of 60192 relevant lines covered (53.13%)

39465.18 hits per line

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

61.02
/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() {
14✔
73
                if ( \defined( 'DOING_AJAX' ) && \DOING_AJAX ) {
14✔
74
                        return;
×
75
                }
76

77
                if ( ! $this->options_helper->get( 'should_redirect_after_install_free', false ) ) {
14✔
78
                        return;
2✔
79
                }
80
                $this->options_helper->set( 'should_redirect_after_install_free', false );
12✔
81

82
                if ( ! empty( $this->options_helper->get( 'activation_redirect_timestamp_free', 0 ) ) ) {
12✔
83
                        return;
2✔
84
                }
85
                $this->options_helper->set( 'activation_redirect_timestamp_free', \time() );
10✔
86

87
                // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
88
                if ( isset( $_REQUEST['activate-multi'] ) && $_REQUEST['activate-multi'] === 'true' ) {
10✔
89
                        return;
2✔
90
                }
91

92
                if ( $this->product_helper->is_premium() ) {
8✔
93
                        return;
2✔
94
                }
95

96
                if ( \is_network_admin() || \is_plugin_active_for_network( \WPSEO_BASENAME ) ) {
6✔
97
                        return;
4✔
98
                }
99

100
                \wp_safe_redirect( \admin_url( 'admin.php?page=wpseo_installation_successful_free' ), 302, 'Yoast SEO' );
2✔
101
                $this->terminate_execution();
2✔
102
        }
103

104
        /**
105
         * Adds the installation success submenu page.
106
         *
107
         * @param array $submenu_pages The Yoast SEO submenu pages.
108
         *
109
         * @return array the filtered submenu pages.
110
         */
111
        public function add_submenu_page( $submenu_pages ) {
2✔
112
                \add_submenu_page(
2✔
113
                        '',
2✔
114
                        \__( 'Installation Successful', 'wordpress-seo' ),
2✔
115
                        '',
2✔
116
                        'manage_options',
2✔
117
                        'wpseo_installation_successful_free',
2✔
118
                        [ $this, 'render_page' ]
2✔
119
                );
2✔
120

121
                return $submenu_pages;
2✔
122
        }
123

124
        /**
125
         * Enqueue assets on the Installation success page.
126
         *
127
         * @return void
128
         */
129
        public function enqueue_assets() {
×
130
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved.
131
                if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_installation_successful_free' ) {
×
132
                        return;
×
133
                }
134

135
                $asset_manager = new WPSEO_Admin_Asset_Manager();
×
136
                $asset_manager->enqueue_script( 'installation-success' );
×
NEW
137
                $asset_manager->enqueue_style( 'installation-success' );
×
138
                $asset_manager->enqueue_style( 'monorepo' );
×
139

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

142
                $asset_manager->localize_script(
×
143
                        'installation-success',
×
144
                        'wpseoInstallationSuccess',
×
145
                        [
×
146
                                'pluginUrl'                 => \esc_url( \plugins_url( '', \WPSEO_FILE ) ),
×
147
                                'firstTimeConfigurationUrl' => $ftc_url,
×
148
                                'dashboardUrl'              => \esc_url( \admin_url( 'admin.php?page=wpseo_dashboard' ) ),
×
NEW
149
                                'explorePremiumUrl'         => $this->shortlinker->build( 'https://yoa.st/ftc-premium-link' ),
×
150
                        ]
×
151
                );
×
152
        }
153

154
        /**
155
         * Renders the installation success page.
156
         *
157
         * @return void
158
         */
159
        public function render_page() {
×
160
                echo '<div id="wpseo-installation-successful-free" class="yoast"></div>';
×
161
        }
162

163
        /**
164
         * Wrap the `exit` function to make unit testing easier.
165
         *
166
         * @return void
167
         */
168
        public function terminate_execution() {
×
169
                exit;
×
170
        }
171
}
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