| 1 |
<?php |
| 2 |
/** |
| 3 |
* WPSEO plugin file. |
| 4 |
* |
| 5 |
* @package WPSEO\Admin\Menu |
| 6 |
*/ |
| 7 |
|
| 8 |
/** |
| 9 |
* Network Admin Menu handler. |
| 10 |
*/ |
| 11 |
class WPSEO_Network_Admin_Menu extends WPSEO_Base_Menu { |
| 12 |
|
| 13 |
/** |
| 14 |
* Registers all hooks to WordPress. |
| 15 |
* |
| 16 |
* @return void |
| 17 |
*/ |
| 18 |
public function register_hooks() { |
| 19 |
// Needs the lower than default priority so other plugins can hook underneath it without issue. |
| 20 |
add_action( 'network_admin_menu', [ $this, 'register_settings_page' ], 5 ); |
| 21 |
} |
| 22 |
|
| 23 |
/** |
| 24 |
* Register the settings page for the Network settings. |
| 25 |
* |
| 26 |
* @return void |
| 27 |
*/ |
| 28 |
public function register_settings_page() { |
| 29 |
if ( ! $this->check_manage_capability() ) { |
| 30 |
return; |
| 31 |
} |
| 32 |
|
| 33 |
add_menu_page( |
| 34 |
__( 'Network Settings', 'wordpress-seo' ) . ' - Yoast SEO', |
| 35 |
'Yoast SEO', |
| 36 |
$this->get_manage_capability(), |
| 37 |
$this->get_page_identifier(), |
| 38 |
[ $this, 'network_config_page' ], |
| 39 |
$this->get_icon_svg(), |
| 40 |
); |
| 41 |
|
| 42 |
$submenu_pages = $this->get_submenu_pages(); |
| 43 |
$this->register_submenu_pages( $submenu_pages ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* Returns the list of registered submenu pages. |
| 48 |
* |
| 49 |
* @return array List of registered submenu pages. |
| 50 |
*/ |
| 51 |
public function get_submenu_pages() { |
| 52 |
|
| 53 |
// Submenu pages. |
| 54 |
$submenu_pages = [ |
| 55 |
$this->get_submenu_page( |
| 56 |
__( 'General', 'wordpress-seo' ), |
| 57 |
$this->get_page_identifier(), |
| 58 |
[ $this, 'network_config_page' ], |
| 59 |
), |
| 60 |
]; |
| 61 |
|
| 62 |
if ( WPSEO_Utils::allow_system_file_edit() === true ) { |
| 63 |
$submenu_pages[] = $this->get_submenu_page( __( 'Edit Files', 'wordpress-seo' ), 'wpseo_files' ); |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Filter: 'wpseo_network_submenu_pages' - Collects all network submenus that need to be shown. |
| 68 |
* |
| 69 |
* @internal For internal Yoast SEO use only. |
| 70 |
* |
| 71 |
* @param array $submenu_pages List with all submenu pages. |
| 72 |
*/ |
| 73 |
return (array) apply_filters( 'wpseo_network_submenu_pages', $submenu_pages ); |
| 74 |
} |
| 75 |
|
| 76 |
/** |
| 77 |
* Loads the form for the network configuration page. |
| 78 |
* |
| 79 |
* @return void |
| 80 |
*/ |
| 81 |
public function network_config_page() { |
| 82 |
require_once WPSEO_PATH . 'admin/pages/network.php'; |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Checks whether the current user has capabilities to manage all options. |
| 87 |
* |
| 88 |
* @return bool True if capabilities are sufficient, false otherwise. |
| 89 |
*/ |
| 90 |
protected function check_manage_capability() { |
| 91 |
return current_user_can( $this->get_manage_capability() ); |
| 92 |
} |
| 93 |
|
| 94 |
/** |
| 95 |
* Returns the capability that is required to manage all options. |
| 96 |
* |
| 97 |
* @return string Capability to check against. |
| 98 |
*/ |
| 99 |
protected function get_manage_capability() { |
| 100 |
return 'wpseo_manage_network_options'; |
| 101 |
} |
| 102 |
} |
| 103 |
|