mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Multisite: Introduce a setup_network
capability for setting up multisite.
`setup_network` is a new meta capability that brings more granular control over the permissions to setup a multisite environment. In a non-multisite environment it falls back to `manage_options` while in a multisite it falls back to `manage_network_options`. The introduction of this capability furthermore allows replacing an `is_super_admin()` check. Props ashokkumar24 for the original patch. Fixes #39206. See #37616. Built from https://develop.svn.wordpress.org/trunk@40390 git-svn-id: http://core.svn.wordpress.org/trunk@40297 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
72c19648bc
commit
00e8704288
@ -244,7 +244,7 @@ $menu[75] = array( __('Tools'), 'edit_posts', 'tools.php', '', 'menu-top menu-ic
|
||||
if ( is_multisite() && !is_main_site() )
|
||||
$submenu['tools.php'][25] = array( __('Delete Site'), 'delete_site', 'ms-delete-site.php' );
|
||||
if ( ! is_multisite() && defined('WP_ALLOW_MULTISITE') && WP_ALLOW_MULTISITE )
|
||||
$submenu['tools.php'][50] = array(__('Network Setup'), 'manage_options', 'network.php');
|
||||
$submenu['tools.php'][50] = array(__('Network Setup'), 'setup_network', 'network.php');
|
||||
|
||||
$menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings' );
|
||||
$submenu['options-general.php'][10] = array(_x('General', 'settings screen'), 'manage_options', 'options-general.php');
|
||||
|
@ -15,7 +15,7 @@ define( 'WP_INSTALLING_NETWORK', true );
|
||||
/** WordPress Administration Bootstrap */
|
||||
require_once( dirname( __FILE__ ) . '/admin.php' );
|
||||
|
||||
if ( ! is_super_admin() ) {
|
||||
if ( ! current_user_can( 'setup_network' ) ) {
|
||||
wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ $submenu['plugins.php'][15] = array( _x('Editor', 'plugin editor'), 'edit_plugin
|
||||
$menu[25] = array(__('Settings'), 'manage_network_options', 'settings.php', '', 'menu-top menu-icon-settings', 'menu-settings', 'dashicons-admin-settings');
|
||||
if ( defined( 'MULTISITE' ) && defined( 'WP_ALLOW_MULTISITE' ) && WP_ALLOW_MULTISITE ) {
|
||||
$submenu['settings.php'][5] = array( __('Network Settings'), 'manage_network_options', 'settings.php' );
|
||||
$submenu['settings.php'][10] = array( __('Network Setup'), 'manage_network_options', 'setup.php' );
|
||||
$submenu['settings.php'][10] = array( __('Network Setup'), 'setup_network', 'setup.php' );
|
||||
}
|
||||
unset($update_data);
|
||||
|
||||
|
@ -480,6 +480,13 @@ function map_meta_cap( $cap, $user_id ) {
|
||||
case 'manage_network_options':
|
||||
$caps[] = $cap;
|
||||
break;
|
||||
case 'setup_network':
|
||||
if ( is_multisite() ) {
|
||||
$caps[] = 'manage_network_options';
|
||||
} else {
|
||||
$caps[] = 'manage_options';
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// Handle meta capabilities for custom post types.
|
||||
global $post_type_meta_caps;
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.8-alpha-40387';
|
||||
$wp_version = '4.8-alpha-40390';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user