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