| 1 |
<?php |
| 2 |
|
| 3 |
namespace Yoast\WP\SEO\Integrations\Admin; |
| 4 |
|
| 5 |
use Yoast\WP\SEO\Conditionals\Admin_Conditional; |
| 6 |
use Yoast\WP\SEO\Integrations\Integration_Interface; |
| 7 |
|
| 8 |
/** |
| 9 |
* Old_Configuration_Integration class |
| 10 |
*/ |
| 11 |
class Old_Configuration_Integration implements Integration_Interface { |
| 12 |
|
| 13 |
/** |
| 14 |
* {@inheritDoc} |
| 15 |
*/ |
| 16 |
public static function get_conditionals() { |
| 17 |
return [ Admin_Conditional::class ]; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* {@inheritDoc} |
| 22 |
*/ |
| 23 |
public function register_hooks() { |
| 24 |
\add_filter( 'admin_menu', [ $this, 'add_submenu_page' ], 11 ); |
| 25 |
\add_action( 'admin_init', [ $this, 'redirect_to_new_configuration' ] ); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Adds the old configuration submenu page. |
| 30 |
* |
| 31 |
* @param array $submenu_pages The Yoast SEO submenu pages. |
| 32 |
* |
| 33 |
* @return array the filtered submenu pages. |
| 34 |
*/ |
| 35 |
public function add_submenu_page( $submenu_pages ) { |
| 36 |
\add_submenu_page( |
| 37 |
'options.php', |
| 38 |
\__( 'Old Configuration Wizard', 'wordpress-seo' ), |
| 39 |
'', |
| 40 |
'manage_options', |
| 41 |
'wpseo_configurator', |
| 42 |
[ $this, 'render_page' ], |
| 43 |
); |
| 44 |
|
| 45 |
return $submenu_pages; |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Renders the old configuration page. |
| 50 |
* |
| 51 |
* @return void |
| 52 |
*/ |
| 53 |
public function render_page() { |
| 54 |
// This page is never to be displayed. |
| 55 |
} |
| 56 |
|
| 57 |
/** |
| 58 |
* Redirects from the old configuration page to the new configuration page. |
| 59 |
* |
| 60 |
* @return void |
| 61 |
*/ |
| 62 |
public function redirect_to_new_configuration() { |
| 63 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Data is not processed or saved. |
| 64 |
if ( ! isset( $_GET['page'] ) || $_GET['page'] !== 'wpseo_configurator' ) { |
| 65 |
return; |
| 66 |
} |
| 67 |
$redirect_url = 'admin.php?page=wpseo_dashboard#/first-time-configuration'; |
| 68 |
\wp_safe_redirect( \admin_url( $redirect_url ), 302, 'Yoast SEO' ); |
| 69 |
exit(); |
| 70 |
} |
| 71 |
} |
| 72 |
|