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

Yoast / wordpress-seo / 5066322038

pending completion
5066322038

push

github

GitHub
Merge pull request #20316 from Yoast/JRF/ghactions-run-more-selectively

2550 of 29012 relevant lines covered (8.79%)

0.32 hits per line

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

0.0
/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\Integrations\Integration_Interface;
10

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

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

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

30
        /**
31
         * {@inheritDoc}
32
         */
33
        public static function get_conditionals() {
34
                return [ Admin_Conditional::class ];
×
35
        }
36

37
        /**
38
         * Installation_Success_Integration constructor.
39
         *
40
         * @param Options_Helper $options_helper The options helper.
41
         * @param Product_Helper $product_helper The product helper.
42
         */
43
        public function __construct( Options_Helper $options_helper, Product_Helper $product_helper ) {
44
                $this->options_helper = $options_helper;
×
45
                $this->product_helper = $product_helper;
×
46
        }
47

48
        /**
49
         * {@inheritDoc}
50
         */
51
        public function register_hooks() {
52
                \add_filter( 'admin_menu', [ $this, 'add_submenu_page' ], 9 );
×
53
                \add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_assets' ] );
×
54
                \add_action( 'admin_init', [ $this, 'maybe_redirect' ] );
×
55
        }
56

57
        /**
58
         * Redirects to the installation success page if an installation has just occurred.
59
         *
60
         * @return void
61
         */
62
        public function maybe_redirect() {
63
                if ( \defined( 'DOING_AJAX' ) && \DOING_AJAX ) {
×
64
                        return;
×
65
                }
66

67
                if ( ! $this->options_helper->get( 'should_redirect_after_install_free', false ) ) {
×
68
                        return;
×
69
                }
70
                $this->options_helper->set( 'should_redirect_after_install_free', false );
×
71

72
                if ( ! empty( $this->options_helper->get( 'activation_redirect_timestamp_free', 0 ) ) ) {
×
73
                        return;
×
74
                }
75
                $this->options_helper->set( 'activation_redirect_timestamp_free', \time() );
×
76

77
                // phpcs:ignore WordPress.Security.NonceVerification -- This is not a form.
78
                if ( isset( $_REQUEST['activate-multi'] ) && $_REQUEST['activate-multi'] === 'true' ) {
×
79
                        return;
×
80
                }
81

82
                if ( $this->product_helper->is_premium() ) {
×
83
                        return;
×
84
                }
85

86
                if ( \is_network_admin() || \is_plugin_active_for_network( \WPSEO_BASENAME ) ) {
×
87
                        return;
×
88
                }
89

90
                \wp_safe_redirect( \admin_url( 'admin.php?page=wpseo_installation_successful_free' ), 302, 'Yoast SEO' );
×
91
                $this->terminate_execution();
×
92
        }
93

94
        /**
95
         * Adds the installation success submenu page.
96
         *
97
         * @param array $submenu_pages The Yoast SEO submenu pages.
98
         *
99
         * @return array the filtered submenu pages.
100
         */
101
        public function add_submenu_page( $submenu_pages ) {
102
                \add_submenu_page(
×
103
                        '',
×
104
                        \__( 'Installation Successful', 'wordpress-seo' ),
×
105
                        '',
×
106
                        'manage_options',
×
107
                        'wpseo_installation_successful_free',
×
108
                        [ $this, 'render_page' ]
×
109
                );
×
110

111
                return $submenu_pages;
×
112
        }
113

114
        /**
115
         * Enqueue assets on the Installation success page.
116
         */
117
        public function enqueue_assets() {
118
                // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved.
119
                if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_installation_successful_free' ) {
×
120
                        return;
×
121
                }
122

123
                $asset_manager = new WPSEO_Admin_Asset_Manager();
×
124
                $asset_manager->enqueue_script( 'installation-success' );
×
125
                $asset_manager->enqueue_style( 'tailwind' );
×
126
                $asset_manager->enqueue_style( 'monorepo' );
×
127

128
                $asset_manager->localize_script(
×
129
                        'installation-success',
×
130
                        'wpseoInstallationSuccess',
×
131
                        [
×
132
                                'pluginUrl'                 => \esc_url( \plugins_url( '', \WPSEO_FILE ) ),
×
133
                                'firstTimeConfigurationUrl' => \esc_url( \admin_url( 'admin.php?page=wpseo_dashboard#top#first-time-configuration' ) ),
×
134
                        ]
×
135
                );
×
136
        }
137

138
        /**
139
         * Renders the installation success page.
140
         */
141
        public function render_page() {
142
                echo '<div id="wpseo-installation-successful-free" class="yoast"></div>';
×
143
        }
144

145
        /**
146
         * Wrap the `exit` function to make unit testing easier.
147
         */
148
        public function terminate_execution() {
149
                exit;
×
150
        }
151
}
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