diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index cac5e771ae..c3837c531f 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -549,34 +549,8 @@ function redirect_user_to_blog() { add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 ); function wpmu_menu() { - global $menu, $submenu, $current_user; - - $menu_perms = get_site_option( "menu_items" ); - if( is_array( $menu_perms ) == false ) - $menu_perms = array(); - if( $menu_perms[ 'plugins' ] != 1 ) { - if( !is_site_admin() ) { - unset( $menu['65'] ); // Plugins - unset( $submenu[ 'plugins.php' ] ); - } elseif ( strpos( $_SERVER[ 'PHP_SELF' ], 'wp-admin/plugins.php' ) ) { - $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '' . __( 'Activate' ) . '' ); - $message = str_replace( "'", "\'", "

$message

" ); - add_action( 'admin_notices', create_function( '', "echo '$message';" ) ); - } - } elseif ( !is_site_admin() ) { - $menu[65] = array( sprintf( __('Plugins %s'), "" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' ); - } - if( !get_site_option( 'add_new_users' ) ) { - if( !is_site_admin() ) { - unset( $submenu['users.php'][10] ); - } else { - $submenu['users.php'][10] = array(__('Add New') . ' *', 'create_users', 'wpmu-options.php#addnewusers'); - } - } - unset( $submenu['tools.php'][20] ); // core upgrade - unset( $submenu['options-general.php'][45] ); // Misc + // deprecated. See #11763 } -add_action( '_admin_menu', 'wpmu_menu' ); function mu_options( $options ) { if ( defined( 'POST_BY_EMAIL' ) ) { diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 1fdb4c58b6..7b94c6d320 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -109,14 +109,17 @@ $update_count = 0; if ( !empty($update_plugins->response) ) $update_count = count( $update_plugins->response ); -$menu[65] = array( sprintf( __('Plugins %s'), "" . number_format_i18n($update_count) . "" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' ); - $submenu['plugins.php'][5] = array( __('Installed'), 'activate_plugins', 'plugins.php' ); - if ( is_super_admin() ) { - /* translators: add new plugin */ - $submenu['plugins.php'][10] = array(_x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php'); - } - if ( !is_multisite() ) - $submenu['plugins.php'][15] = array( __('Editor'), 'edit_plugins', 'plugin-editor.php' ); +$menu_perms = get_site_option('menu_items', array()); +if ( is_super_admin() || is_multisite() && $menu_perms['plugins'] ) { + $menu[65] = array( sprintf( __('Plugins %s'), "" . number_format_i18n($update_count) . "" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' ); + $submenu['plugins.php'][5] = array( __('Installed'), 'activate_plugins', 'plugins.php' ); + if ( is_super_admin() ) { + /* translators: add new plugin */ + $submenu['plugins.php'][10] = array(_x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php'); + } + if ( !is_multisite() ) + $submenu['plugins.php'][15] = array( __('Editor'), 'edit_plugins', 'plugin-editor.php' ); +} if ( current_user_can('edit_users') ) $menu[70] = array( __('Users'), 'edit_users', 'users.php', '', 'menu-top', 'menu-users', 'div' ); @@ -126,7 +129,11 @@ else if ( current_user_can('edit_users') ) { $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php. $submenu['users.php'][5] = array(__('Authors & Users'), 'edit_users', 'users.php'); - $submenu['users.php'][10] = array(_x('Add New', 'user'), 'create_users', 'user-new.php'); + if ( !is_multisite() ) + $submenu['users.php'][10] = array(_x('Add New', 'user'), 'create_users', 'user-new.php'); + elseif ( is_super_admin() || get_site_option( 'add_new_users' ) ) + $submenu['users.php'][10] = array(__('Add New') . ' *', 'create_users', 'ms-options.php#addnewusers'); + $submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php'); } else { $_wp_real_parent_file['users.php'] = 'profile.php'; @@ -137,7 +144,8 @@ $menu[75] = array( __('Tools'), 'read', 'tools.php', '', 'menu-top', 'menu-tools $submenu['tools.php'][5] = array( __('Tools'), 'read', 'tools.php' ); $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' ); $submenu['tools.php'][15] = array( __('Export'), 'import', 'export.php' ); - $submenu['tools.php'][20] = array( __('Upgrade'), 'install_plugins', 'update-core.php'); + if ( is_super_admin() ) + $submenu['tools.php'][20] = array( __('Upgrade'), 'install_plugins', 'update-core.php'); $menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top', 'menu-settings', 'div' ); $submenu['options-general.php'][10] = array(__('General'), 'manage_options', 'options-general.php'); @@ -147,7 +155,8 @@ $menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', $submenu['options-general.php'][30] = array(__('Media'), 'manage_options', 'options-media.php'); $submenu['options-general.php'][35] = array(__('Privacy'), 'manage_options', 'options-privacy.php'); $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php'); - $submenu['options-general.php'][45] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php'); + if ( is_super_admin() ) + $submenu['options-general.php'][45] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php'); $_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 185f68f21f..e94439de3e 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -236,6 +236,15 @@ $help .= '

' . sprintf(__('You can find additional plugins for your site by us add_contextual_help('plugins', $help); +if ( is_multisite() && is_super_admin() ) { + $menu_perms = get_site_option('menu_items', array()); + if ( !$menu_perms['plugins'] ) { + $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '' . __( 'Activate' ) . '' ); + $message = str_replace( "'", "\'", "

$message

" ); + add_action( 'admin_notices', create_function( '', "echo '$message';" ) ); + } +} + $title = __('Manage Plugins'); require_once('admin-header.php');