| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin\Menu |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Registers the regular admin menu and network admin menu implementations. |
| 10 |
*/ |
| 11 |
class WPSEO_Menu implements WPSEO_WordPress_Integration { |
| 12 |
|
| 13 |
/** |
| 14 |
* The page identifier used in WordPress to register the admin page. |
| 15 |
* |
| 16 |
* !DO NOT CHANGE THIS! |
| 17 |
* |
| 18 |
* @var string |
| 19 |
*/ |
| 20 |
public const PAGE_IDENTIFIER = 'wpseo_dashboard'; |
| 21 |
|
| 22 |
/** |
| 23 |
* List of classes that add admin functionality. |
| 24 |
* |
| 25 |
* @var array |
| 26 |
*/ |
| 27 |
protected $admin_features; |
| 28 |
|
| 29 |
/** |
| 30 |
* Registers all hooks to WordPress. |
| 31 |
* |
| 32 |
* @return void |
| 33 |
*/ |
| 34 |
public function register_hooks() { |
| 35 |
$admin_menu = new WPSEO_Admin_Menu( $this ); |
| 36 |
$admin_menu->register_hooks(); |
| 37 |
|
| 38 |
if ( WPSEO_Utils::is_plugin_network_active() ) { |
| 39 |
$network_admin_menu = new WPSEO_Network_Admin_Menu( $this ); |
| 40 |
$network_admin_menu->register_hooks(); |
| 41 |
} |
| 42 |
|
| 43 |
$capability_normalizer = new WPSEO_Submenu_Capability_Normalize(); |
| 44 |
$capability_normalizer->register_hooks(); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Returns the main menu page identifier. |
| 49 |
* |
| 50 |
* @return string Page identifier to use. |
| 51 |
*/ |
| 52 |
public function get_page_identifier() { |
| 53 |
return self::PAGE_IDENTIFIER; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Loads the requested admin settings page. |
| 58 |
* |
| 59 |
* @return void |
| 60 |
*/ |
| 61 |
public function load_page() { |
| 62 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. |
| 63 |
if ( isset( $_GET['page'] ) && is_string( $_GET['page'] ) ) { |
| 64 |
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Reason: We are not processing form information. |
| 65 |
$page = sanitize_text_field( wp_unslash( $_GET['page'] ) ); |
| 66 |
$this->show_page( $page ); |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Shows an admin settings page. |
| 72 |
* |
| 73 |
* @param string $page Page to display. |
| 74 |
* |
| 75 |
* @return void |
| 76 |
*/ |
| 77 |
protected function show_page( $page ) { |
| 78 |
switch ( $page ) { |
| 79 |
case 'wpseo_tools': |
| 80 |
require_once WPSEO_PATH . 'admin/pages/tools.php'; |
| 81 |
break; |
| 82 |
|
| 83 |
case 'wpseo_files': |
| 84 |
require_once WPSEO_PATH . 'admin/views/tool-file-editor.php'; |
| 85 |
break; |
| 86 |
|
| 87 |
default: |
| 88 |
break; |
| 89 |
} |
| 90 |
} |
| 91 |
} |
| 92 |
|