NetworkAdmin.php
1.62 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
<?php
namespace AIOSEO\Plugin\Common\Admin;
// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Abstract class that Pro and Lite both extend.
*
* @since 4.2.5
*/
class NetworkAdmin extends Admin {
/**
* Construct method.
*
* @since 4.2.5
*/
public function __construct() {
include_once ABSPATH . 'wp-admin/includes/plugin.php';
if (
is_network_admin() &&
! is_plugin_active_for_network( plugin_basename( AIOSEO_FILE ) )
) {
return;
}
if ( wp_doing_ajax() || wp_doing_cron() ) {
return;
}
add_action( 'sanitize_comment_cookies', [ $this, 'init' ], 21 );
}
/**
* Initialize the admin.
*
* @since 4.2.5
*
* @return void
*/
public function init() {
add_action( 'network_admin_menu', [ $this, 'addNetworkMenu' ] );
$this->setPages();
}
/**
* Add the network menu inside of WordPress.
*
* @since 4.2.5
*
* @return void
*/
public function addNetworkMenu() {
$this->addMainMenu( 'aioseo' );
foreach ( $this->pages as $slug => $page ) {
if (
'aioseo-settings' !== $slug &&
'aioseo-tools' !== $slug &&
'aioseo-about' !== $slug &&
'aioseo-feature-manager' !== $slug
) {
continue;
}
$hook = add_submenu_page(
$this->pageSlug,
! empty( $page['page_title'] ) ? $page['page_title'] : $page['menu_title'],
$page['menu_title'],
$this->getPageRequiredCapability( $slug ),
$slug,
[ $this, 'page' ]
);
add_action( "load-{$hook}", [ $this, 'hooks' ] );
}
// Remove the "dashboard" submenu page that is not needed in the network admin.
remove_submenu_page( $this->pageSlug, $this->pageSlug );
}
}