WordPress.org

Make WordPress Core

Ticket #25219: 25219.2.diff

File 25219.2.diff, 7.0 KB (added by iandunn, 7 years ago)
  • src/wp-admin/includes/theme.php

     
    111111function theme_update_available( $theme ) {
    112112        static $themes_update;
    113113
    114         if ( !current_user_can('update_themes' ) )
     114        if ( ! current_user_can( 'view_theme_updates' ) )
    115115                return;
    116116
    117117        if ( !isset($themes_update) )
  • src/wp-admin/includes/update.php

     
    119119}
    120120
    121121function core_update_footer( $msg = '' ) {
    122         if ( !current_user_can('update_core') )
     122        if ( ! current_user_can( 'view_core_updates' ) )
    123123                return sprintf( __( 'Version %s' ), get_bloginfo( 'version', 'display' ) );
    124124
    125125        $cur = get_preferred_from_update_core();
     
    180180function update_right_now_message() {
    181181        $msg = sprintf( __( 'You are using <span class="b">WordPress %s</span>.' ), get_bloginfo( 'version', 'display' ) );
    182182
    183         if ( current_user_can('update_core') ) {
     183        if ( current_user_can( 'view_core_updates' ) ) {
    184184                $cur = get_preferred_from_update_core();
    185185
    186186                if ( isset( $cur->response ) && $cur->response == 'upgrade' )
     
    205205}
    206206
    207207function wp_plugin_update_rows() {
    208         if ( !current_user_can('update_plugins' ) )
     208        if ( ! current_user_can( 'view_plugin_updates' ) )
    209209                return;
    210210
    211211        $plugins = get_site_transient( 'update_plugins' );
  • src/wp-admin/menu.php

     
    3434        $update_data = wp_get_update_data();
    3535
    3636if ( ! is_multisite() ) {
    37         if ( current_user_can( 'update_core' ) )
    38                 $cap = 'update_core';
    39         elseif ( current_user_can( 'update_plugins' ) )
    40                 $cap = 'update_plugins';
     37        if ( current_user_can( 'view_core_updates' ) )
     38                $cap = 'view_core_updates';
     39        elseif ( current_user_can( 'view_plugin_updates' ) )
     40                $cap = 'view_plugin_updates';
    4141        else
    42                 $cap = 'update_themes';
     42                $cap = 'view_theme_updates';
    4343        $submenu[ 'index.php' ][10] = array( sprintf( __('Updates %s'), "<span class='update-plugins count-{$update_data['counts']['total']}' title='{$update_data['title']}'><span class='update-count'>" . number_format_i18n($update_data['counts']['total']) . "</span></span>" ), $cap, 'update-core.php');
    4444        unset( $cap );
    4545}
     
    155155}
    156156
    157157$count = '';
    158 if ( ! is_multisite() && current_user_can( 'update_plugins' ) ) {
     158if ( ! is_multisite() && current_user_can( 'view_plugin_updates' ) ) {
    159159        if ( ! isset( $update_data ) )
    160160                $update_data = wp_get_update_data();
    161161        $count = "<span class='update-plugins count-{$update_data['counts']['plugins']}'><span class='plugin-count'>" . number_format_i18n($update_data['counts']['plugins']) . "</span></span>";
  • src/wp-admin/update-core.php

     
    1818        exit();
    1919}
    2020
    21 if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_themes' ) && ! current_user_can( 'update_plugins' ) )
     21if ( ! current_user_can( 'view_core_updates' ) && ! current_user_can( 'view_theme_updates' ) && ! current_user_can( 'view_plugin_updates' ) )
    2222        wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
    2323
    2424function list_core_update( $update ) {
     
    457457        echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php') ) . '">' . __( 'Check Again' ) . '</a>';
    458458        echo '</p>';
    459459
    460         if ( current_user_can( 'update_core' ) )
     460        if ( current_user_can( 'view_core_updates' ) )
    461461                core_upgrade_preamble();
    462         if ( current_user_can( 'update_plugins' ) )
     462        if ( current_user_can( 'view_plugin_updates' ) )
    463463                list_plugin_updates();
    464         if ( current_user_can( 'update_themes' ) )
     464        if ( current_user_can( 'view_theme_updates' ) )
    465465                list_theme_updates();
    466466        do_action('core_upgrade_preamble');
    467467        echo '</div>';
     
    469469
    470470} elseif ( 'do-core-upgrade' == $action || 'do-core-reinstall' == $action ) {
    471471
    472         if ( ! current_user_can( 'update_core' ) )
     472        if ( ! current_user_can( 'view_core_updates' ) )
    473473                wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
    474474
    475475        check_admin_referer('upgrade-core');
     
    494494
    495495} elseif ( 'do-plugin-upgrade' == $action ) {
    496496
    497         if ( ! current_user_can( 'update_plugins' ) )
     497        if ( ! current_user_can( 'view_plugin_updates' ) )
    498498                wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
    499499
    500500        check_admin_referer('upgrade-core');
     
    523523
    524524} elseif ( 'do-theme-upgrade' == $action ) {
    525525
    526         if ( ! current_user_can( 'update_themes' ) )
     526        if ( ! current_user_can( 'view_theme_updates' ) )
    527527                wp_die( __( 'You do not have sufficient permissions to update this site.' ) );
    528528
    529529        check_admin_referer('upgrade-core');
  • src/wp-includes/capabilities.php

     
    12211221                else
    12221222                        $caps[] = $cap;
    12231223                break;
     1224        case 'view_plugin_updates':
     1225        case 'view_theme_updates':
     1226        case 'view_core_updates':
     1227                if ( is_multisite() && ! is_super_admin( $user_id ) )
     1228                        $caps[] = 'do_not_allow';
     1229                else
     1230                        $caps[] = 'manage_options';
     1231                break;
    12241232        case 'activate_plugins':
    12251233                $caps[] = $cap;
    12261234                if ( is_multisite() ) {
  • src/wp-includes/update.php

     
    358358function wp_get_update_data() {
    359359        $counts = array( 'plugins' => 0, 'themes' => 0, 'wordpress' => 0 );
    360360
    361         if ( current_user_can( 'update_plugins' ) ) {
     361        if ( current_user_can( 'view_plugin_updates' ) ) {
    362362                $update_plugins = get_site_transient( 'update_plugins' );
    363363                if ( ! empty( $update_plugins->response ) )
    364364                        $counts['plugins'] = count( $update_plugins->response );
    365365        }
    366366
    367         if ( current_user_can( 'update_themes' ) ) {
     367        if ( current_user_can( 'view_theme_updates' ) ) {
    368368                $update_themes = get_site_transient( 'update_themes' );
    369369                if ( ! empty( $update_themes->response ) )
    370370                        $counts['themes'] = count( $update_themes->response );
    371371        }
    372372
    373         if ( function_exists( 'get_core_updates' ) && current_user_can( 'update_core' ) ) {
     373        if ( function_exists( 'get_core_updates' ) && current_user_can( 'view_core_updates' ) ) {
    374374                $update_wordpress = get_core_updates( array('dismissed' => false) );
    375                 if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array('development', 'latest') ) && current_user_can('update_core') )
     375                if ( ! empty( $update_wordpress ) && ! in_array( $update_wordpress[0]->response, array( 'development', 'latest' ) ) && current_user_can( 'view_core_updates' ) )
    376376                        $counts['wordpress'] = 1;
    377377        }
    378378