PluginProbe
Yoast SEO – Advanced SEO with real-time guidance and built-in AI / trunk
Yoast SEO – Advanced SEO with real-time guidance and built-in AI vtrunk
28.5 28.4 28.3 28.2 28.1 28.0 27.9 27.8 27.7 27.6 27.5 trunk 18.0 18.1 18.2 18.3 18.4 18.4.1 18.5 18.5.1 18.6 18.7 18.8 18.9 19.0 All 129 releases
← All changes | src/integrations/admin/installation-success-integration.php +47 -12 18.9 → trunk View file →
@@ -5,8 +5,9 @@
5 5 use WPSEO_Admin_Asset_Manager;
6 6 use Yoast\WP\SEO\Conditionals\Admin_Conditional;
7 7 use Yoast\WP\SEO\Helpers\Options_Helper;
8 8 use Yoast\WP\SEO\Helpers\Product_Helper;
9 +use Yoast\WP\SEO\Helpers\Short_Link_Helper;
9 10 use Yoast\WP\SEO\Integrations\Integration_Interface;
10 11
11 12 /**
12 13 * Installation_Success_Integration class
@@ -27,8 +28,15 @@
27 28 */
28 29 protected $product_helper;
29 30
30 31 /**
32 + * The shortlinker.
33 + *
34 + * @var Short_Link_Helper
35 + */
36 + private $shortlinker;
37 +
38 + /**
31 39 * {@inheritDoc}
32 40 */
33 41 public static function get_conditionals() {
34 42 return [ Admin_Conditional::class ];
@@ -36,14 +44,16 @@
36 44
37 45 /**
38 46 * Installation_Success_Integration constructor.
39 47 *
40 - * @param Options_Helper $options_helper The options helper.
41 - * @param Product_Helper $product_helper The product helper.
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.
42 51 */
43 - public function __construct( Options_Helper $options_helper, Product_Helper $product_helper ) {
52 + public function __construct( Options_Helper $options_helper, Product_Helper $product_helper, Short_Link_Helper $shortlinker ) {
44 53 $this->options_helper = $options_helper;
45 54 $this->product_helper = $product_helper;
55 + $this->shortlinker = $shortlinker;
46 56 }
47 57
48 58 /**
49 59 * {@inheritDoc}
@@ -59,8 +69,16 @@
59 69 *
60 70 * @return void
61 71 */
62 72 public function maybe_redirect() {
73 + if ( \wp_doing_ajax() || \wp_doing_cron() || \wp_is_serving_rest_request() || \wp_is_json_request() ) {
74 + return;
75 + }
76 +
77 + if ( ! \current_user_can( 'manage_options' ) ) {
78 + return;
79 + }
80 +
63 81 if ( ! $this->options_helper->get( 'should_redirect_after_install_free', false ) ) {
64 82 return;
65 83 }
66 84 $this->options_helper->set( 'should_redirect_after_install_free', false );
@@ -82,8 +100,17 @@
82 100 if ( \is_network_admin() || \is_plugin_active_for_network( \WPSEO_BASENAME ) ) {
83 101 return;
84 102 }
85 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 ) ) {
110 + return;
111 + }
112 +
86 113 \wp_safe_redirect( \admin_url( 'admin.php?page=wpseo_installation_successful_free' ), 302, 'Yoast SEO' );
87 114 $this->terminate_execution();
88 115 }
89 116
@@ -95,14 +122,14 @@
95 122 * @return array the filtered submenu pages.
96 123 */
97 124 public function add_submenu_page( $submenu_pages ) {
98 125 \add_submenu_page(
99 - null,
126 + 'options.php',
100 127 \__( 'Installation Successful', 'wordpress-seo' ),
101 - null,
128 + '',
102 129 'manage_options',
103 130 'wpseo_installation_successful_free',
104 - [ $this, 'render_page' ]
131 + [ $this, 'render_page' ],
105 132 );
106 133
107 134 return $submenu_pages;
108 135 }
@@ -108,8 +135,10 @@
108 135 }
109 136
110 137 /**
111 138 * Enqueue assets on the Installation success page.
139 + *
140 + * @return void
112 141 */
113 142 public function enqueue_assets() {
114 143 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Date is not processed or saved.
115 144 if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_installation_successful_free' ) {
@@ -117,25 +146,29 @@
117 146 }
118 147
119 148 $asset_manager = new WPSEO_Admin_Asset_Manager();
120 149 $asset_manager->enqueue_script( 'installation-success' );
121 - $asset_manager->enqueue_style( 'tailwind' );
150 + $asset_manager->enqueue_style( 'installation-success' );
122 151 $asset_manager->enqueue_style( 'monorepo' );
123 152
153 + $ftc_url = \esc_url( \admin_url( 'admin.php?page=wpseo_dashboard#/first-time-configuration' ) );
154 +
124 155 $asset_manager->localize_script(
125 156 'installation-success',
126 157 'wpseoInstallationSuccess',
127 158 [
128 159 'pluginUrl' => \esc_url( \plugins_url( '', \WPSEO_FILE ) ),
129 - 'configurationWorkoutUrl' => \esc_url( \admin_url( 'admin.php?page=wpseo_dashboard#top#first-time-configuration' ) ),
130 - 'canDoConfigurationWorkout' => \current_user_can( 'wpseo_manage_options' ),
131 - 'canEditWordPressOptions' => \current_user_can( 'manage_options' ),
132 - ]
160 + 'firstTimeConfigurationUrl' => $ftc_url,
161 + 'dashboardUrl' => \esc_url( \admin_url( 'admin.php?page=wpseo_dashboard' ) ),
162 + 'explorePremiumUrl' => $this->shortlinker->build( 'https://yoa.st/ftc-premium-link' ),
163 + ],
133 164 );
134 165 }
135 166
136 167 /**
137 168 * Renders the installation success page.
169 + *
170 + * @return void
138 171 */
139 172 public function render_page() {
140 173 echo '<div id="wpseo-installation-successful-free" class="yoast"></div>';
141 174 }
@@ -141,9 +174,11 @@
141 174 }
142 175
143 176 /**
144 177 * Wrap the `exit` function to make unit testing easier.
178 + *
179 + * @return void
145 180 */
146 181 public function terminate_execution() {
147 - exit;
182 + exit();
148 183 }
149 184 }