WordPress.org

Make WordPress Core

Changeset 40404


Ignore:
Timestamp:
04/10/17 21:10:48 (3 months ago)
Author:
flixos90
Message:

Multisite: Introduce an upgrade_network capability.

Prior to this change, a mix of is_super_admin() calls and manage_network capability checks was used to determine whether the current user could upgrade the network. With this changeset a dedicated capability is introduced that allows more granular handling.

Props dhanendran for the original patch.
Fixes #39205. See #37616.

Location:
trunk
Files:
5 edited

Legend:

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

    r40351 r40404  
    786786    global $wp_db_version, $pagenow; 
    787787 
    788     if ( ! is_super_admin() ) { 
     788    if ( ! current_user_can( 'upgrade_network' ) ) { 
    789789        return false; 
    790790    } 
  • trunk/src/wp-admin/network/menu.php

    r40390 r40404  
    2020} 
    2121 
    22 $submenu['index.php'][15] = array( __( 'Upgrade Network' ), 'manage_network', 'upgrade.php' ); 
     22$submenu['index.php'][15] = array( __( 'Upgrade Network' ), 'upgrade_network', 'upgrade.php' ); 
    2323 
    2424$menu[4] = array( '', 'read', 'separator1', '', 'wp-menu-separator' ); 
  • trunk/src/wp-admin/network/upgrade.php

    r38819 r40404  
    3333require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    3434 
    35 if ( ! current_user_can( 'manage_network' ) ) 
     35if ( ! current_user_can( 'upgrade_network' ) ) { 
    3636    wp_die( __( 'Sorry, you are not allowed to access this page.' ), 403 ); 
     37} 
    3738 
    3839echo '<div class="wrap">'; 
  • trunk/src/wp-includes/capabilities.php

    r40394 r40404  
    479479    case 'manage_network_themes': 
    480480    case 'manage_network_options': 
     481    case 'upgrade_network': 
    481482        $caps[] = $cap; 
    482483        break; 
  • trunk/tests/phpunit/tests/user/capabilities.php

    r40390 r40404  
    227227            'manage_network_options' => array(), 
    228228            'delete_site'            => array(), 
     229            'upgrade_network'        => array(), 
    229230 
    230231            'setup_network'          => array( 'administrator' ), 
     
    260261            'upload_themes'          => array(), 
    261262            'edit_css'               => array(), 
     263            'upgrade_network'        => array(), 
    262264 
    263265            'customize'              => array( 'administrator' ), 
Note: See TracChangeset for help on using the changeset viewer.