Make WordPress Core

Changeset 12618


Ignore:
Timestamp:
01/07/2010 12:17:13 AM (15 years ago)
Author:
ryan
Message:

Move wpmu_menu() logic into menu.php. Props Denis-de-Bernardy. fixes #11763

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ms.php

    r12613 r12618  
    550550
    551551function wpmu_menu() {
    552     global $menu, $submenu, $current_user;
    553 
    554     $menu_perms = get_site_option( "menu_items" );
    555     if( is_array( $menu_perms ) == false )
    556         $menu_perms = array();
    557     if( $menu_perms[ 'plugins' ] != 1 ) {
    558         if( !is_site_admin() ) {
    559             unset( $menu['65'] ); // Plugins
    560             unset( $submenu[ 'plugins.php' ] );
    561         } elseif ( strpos( $_SERVER[ 'PHP_SELF' ], 'wp-admin/plugins.php' ) ) {
    562             $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href="wpmu-options.php#menu">' . __( 'Activate' ) . '</a>' );
    563             $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
    564             add_action( 'admin_notices', create_function( '', "echo '$message';" ) );
    565         }
    566     } elseif ( !is_site_admin() ) {
    567         $menu[65] = array( sprintf( __('Plugins %s'), "" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' );
    568     }
    569     if( !get_site_option( 'add_new_users' ) ) {
    570         if( !is_site_admin() ) {
    571             unset( $submenu['users.php'][10] );
    572         } else {
    573             $submenu['users.php'][10] = array(__('Add New') . ' <strong>*</strong>', 'create_users', 'wpmu-options.php#addnewusers');
    574         }
    575     }
    576     unset( $submenu['tools.php'][20] ); // core upgrade
    577     unset( $submenu['options-general.php'][45] ); // Misc
    578 }
    579 add_action( '_admin_menu', 'wpmu_menu' );
     552    // deprecated. See #11763
     553}
    580554
    581555function mu_options( $options ) {
  • trunk/wp-admin/menu.php

    r12614 r12618  
    110110    $update_count = count( $update_plugins->response );
    111111
    112 $menu[65] = array( sprintf( __('Plugins %s'), "<span class='update-plugins count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' );
    113     $submenu['plugins.php'][5]  = array( __('Installed'), 'activate_plugins', 'plugins.php' );
    114     if ( is_super_admin() ) {
    115         /* translators: add new plugin */
    116         $submenu['plugins.php'][10] = array(_x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php');
    117     }
    118     if ( !is_multisite() )
    119         $submenu['plugins.php'][15] = array( __('Editor'), 'edit_plugins', 'plugin-editor.php' );
     112$menu_perms = get_site_option('menu_items', array());
     113if ( is_super_admin() || is_multisite() && $menu_perms['plugins'] ) {
     114    $menu[65] = array( sprintf( __('Plugins %s'), "<span class='update-plugins count-$update_count'><span class='plugin-count'>" . number_format_i18n($update_count) . "</span></span>" ), 'activate_plugins', 'plugins.php', '', 'menu-top', 'menu-plugins', 'div' );
     115        $submenu['plugins.php'][5]  = array( __('Installed'), 'activate_plugins', 'plugins.php' );
     116        if ( is_super_admin() ) {
     117            /* translators: add new plugin */
     118            $submenu['plugins.php'][10] = array(_x('Add New', 'plugin'), 'install_plugins', 'plugin-install.php');
     119        }
     120        if ( !is_multisite() )
     121            $submenu['plugins.php'][15] = array( __('Editor'), 'edit_plugins', 'plugin-editor.php' );
     122}
    120123
    121124if ( current_user_can('edit_users') )
     
    127130    $_wp_real_parent_file['profile.php'] = 'users.php'; // Back-compat for plugins adding submenus to profile.php.
    128131    $submenu['users.php'][5] = array(__('Authors &amp; Users'), 'edit_users', 'users.php');
    129     $submenu['users.php'][10] = array(_x('Add New', 'user'), 'create_users', 'user-new.php');
     132    if ( !is_multisite() )
     133        $submenu['users.php'][10] = array(_x('Add New', 'user'), 'create_users', 'user-new.php');
     134    elseif ( is_super_admin() || get_site_option( 'add_new_users' ) )
     135        $submenu['users.php'][10] = array(__('Add New') . ' <strong>*</strong>', 'create_users', 'ms-options.php#addnewusers');
     136       
    130137    $submenu['users.php'][15] = array(__('Your Profile'), 'read', 'profile.php');
    131138} else {
     
    138145    $submenu['tools.php'][10] = array( __('Import'), 'import', 'import.php' );
    139146    $submenu['tools.php'][15] = array( __('Export'), 'import', 'export.php' );
    140     $submenu['tools.php'][20] = array( __('Upgrade'), 'install_plugins',  'update-core.php');
     147    if ( is_super_admin() )
     148        $submenu['tools.php'][20] = array( __('Upgrade'), 'install_plugins',  'update-core.php');
    141149
    142150$menu[80] = array( __('Settings'), 'manage_options', 'options-general.php', '', 'menu-top', 'menu-settings', 'div' );
     
    148156    $submenu['options-general.php'][35] = array(__('Privacy'), 'manage_options', 'options-privacy.php');
    149157    $submenu['options-general.php'][40] = array(__('Permalinks'), 'manage_options', 'options-permalink.php');
    150     $submenu['options-general.php'][45] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
     158    if ( is_super_admin() )
     159        $submenu['options-general.php'][45] = array(__('Miscellaneous'), 'manage_options', 'options-misc.php');
    151160
    152161$_wp_last_utility_menu = 80; // The index of the last top-level menu in the utility menu group
  • trunk/wp-admin/plugins.php

    r12616 r12618  
    237237add_contextual_help('plugins', $help);
    238238
     239if ( is_multisite() && is_super_admin() ) {
     240    $menu_perms = get_site_option('menu_items', array());
     241    if ( !$menu_perms['plugins'] ) {
     242        $message = sprintf( __( 'The plugins page is not visible to normal users. It must be activated first. %s' ), '<a href="ms-options.php#menu">' . __( 'Activate' ) . '</a>' );
     243        $message = str_replace( "'", "\'", "<div class='error'><p>$message</p></div>" );
     244        add_action( 'admin_notices', create_function( '', "echo '$message';" ) );
     245    }
     246}
     247
    239248$title = __('Manage Plugins');
    240249require_once('admin-header.php');
Note: See TracChangeset for help on using the changeset viewer.