Make WordPress Core

Ticket #39677: 39677.diff

File 39677.diff, 7.3 KB (added by flixos90, 8 years ago)
  • src/wp-admin/includes/schema.php

     
    621621        populate_roles_270();
    622622        populate_roles_280();
    623623        populate_roles_300();
     624        populate_roles_480();
    624625}
    625626
    626627/**
     
    861862        }
    862863}
    863864
     865/**
     866 * Create and modify WordPress roles for WordPress 4.8.
     867 *
     868 * @since 4.8.0
     869 */
     870function populate_roles_480() {
     871        $role = get_role( 'administrator' );
     872
     873        if ( !empty( $role ) ) {
     874                $role->add_cap( 'install_translations' );
     875                $role->add_cap( 'update_translations' );
     876        }
     877}
     878
    864879if ( !function_exists( 'install_network' ) ) :
    865880/**
    866881 * Install Network.
  • src/wp-admin/network/settings.php

     
    6363        );
    6464
    6565        // Handle translation install.
    66         if ( ! empty( $_POST['WPLANG'] ) && wp_can_install_language_pack() ) {  // @todo: Skip if already installed
     66        if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_translations' ) && wp_can_install_language_pack() ) {  // @todo: Skip if already installed
    6767                $language = wp_download_language_pack( $_POST['WPLANG'] );
    6868                if ( $language ) {
    6969                        $_POST['WPLANG'] = $language;
     
    342342                                                        'selected'     => $lang,
    343343                                                        'languages'    => $languages,
    344344                                                        'translations' => $translations,
    345                                                         'show_available_translations' => wp_can_install_language_pack(),
     345                                                        'show_available_translations' => current_user_can( 'install_translations' ) && wp_can_install_language_pack(),
    346346                                                ) );
    347347                                                ?>
    348348                                        </td>
  • src/wp-admin/network/site-new.php

     
    6565        if ( isset( $_POST['WPLANG'] ) ) {
    6666                if ( '' === $_POST['WPLANG'] ) {
    6767                        $meta['WPLANG'] = ''; // en_US
    68                 } elseif ( wp_can_install_language_pack() ) {
     68                } elseif ( current_user_can( 'install_translations' ) && wp_can_install_language_pack() ) {
    6969                        $language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
    7070                        if ( $language ) {
    7171                                $meta['WPLANG'] = $language;
     
    233233                                                'selected'                    => $lang,
    234234                                                'languages'                   => $languages,
    235235                                                'translations'                => $translations,
    236                                                 'show_available_translations' => wp_can_install_language_pack(),
     236                                                'show_available_translations' => current_user_can( 'install_translations' ) && wp_can_install_language_pack(),
    237237                                        ) );
    238238                                        ?>
    239239                                </td>
  • src/wp-admin/options-general.php

     
    144144                                'selected'     => $locale,
    145145                                'languages'    => $languages,
    146146                                'translations' => $translations,
    147                                 'show_available_translations' => ( ! is_multisite() || is_super_admin() ) && wp_can_install_language_pack(),
     147                                'show_available_translations' => current_user_can( 'install_translations' ) && wp_can_install_language_pack(),
    148148                        ) );
    149149
    150150                        // Add note about deprecated WPLANG constant.
  • src/wp-admin/options.php

     
    182182                }
    183183
    184184                // Handle translation install.
    185                 if ( ! empty( $_POST['WPLANG'] ) && ( ! is_multisite() || is_super_admin() ) ) { // @todo: Skip if already installed
     185                if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_translations' ) ) { // @todo: Skip if already installed
    186186                        require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
    187187
    188188                        if ( wp_can_install_language_pack() ) {
  • src/wp-admin/update-core.php

     
    608608        echo ' &nbsp; <a class="button" href="' . esc_url( self_admin_url('update-core.php?force-check=1') ) . '">' . __( 'Check Again' ) . '</a>';
    609609        echo '</p>';
    610610
    611         if ( $core = current_user_can( 'update_core' ) )
     611        if ( current_user_can( 'update_core' ) ) {
    612612                core_upgrade_preamble();
    613         if ( $plugins = current_user_can( 'update_plugins' ) )
     613        }
     614        if ( current_user_can( 'update_plugins' ) ) {
    614615                list_plugin_updates();
    615         if ( $themes = current_user_can( 'update_themes' ) )
     616        }
     617        if ( current_user_can( 'update_themes' ) ) {
    616618                list_theme_updates();
    617         if ( $core || $plugins || $themes )
     619        }
     620        if ( current_user_can( 'update_translations' ) ) {
    618621                list_translation_updates();
    619         unset( $core, $plugins, $themes );
     622        }
     623
    620624        /**
    621625         * Fires after the core, plugin, and theme update tables.
    622626         *
     
    729733
    730734} elseif ( 'do-translation-upgrade' == $action ) {
    731735
    732         if ( ! current_user_can( 'update_core' ) && ! current_user_can( 'update_plugins' ) && ! current_user_can( 'update_themes' ) )
     736        if ( ! current_user_can( 'update_translations' ) )
    733737                wp_die( __( 'Sorry, you are not allowed to update this site.' ) );
    734738
    735739        check_admin_referer( 'upgrade-translations' );
  • src/wp-includes/capabilities.php

     
    378378        case 'install_themes':
    379379        case 'upload_themes':
    380380        case 'update_core':
    381                 // Disallow anything that creates, deletes, or updates core, plugin, or theme files.
     381        case 'update_translations':
     382        case 'install_translations':
     383                // Disallow anything that creates, deletes, or updates core, plugin, theme, or translation files.
    382384                // Files in uploads are excepted.
    383385                if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
    384386                        $caps[] = 'do_not_allow';
  • tests/phpunit/tests/user/capabilities.php

     
    8484                        'remove_users'           => array( 'administrator' ),
    8585                        'switch_themes'          => array( 'administrator' ),
    8686                        'edit_dashboard'         => array( 'administrator' ),
     87                        'install_translations'   => array( 'administrator' ),
     88                        'update_translations'    => array( 'administrator' ),
    8789
    8890                        'moderate_comments'      => array( 'administrator', 'editor' ),
    8991                        'manage_categories'      => array( 'administrator', 'editor' ),
     
    154156                        'update_core'            => array(),
    155157                        'update_plugins'         => array(),
    156158                        'update_themes'          => array(),
     159                        'install_translations'   => array(),
     160                        'update_translations'    => array(),
    157161
    158162                        'edit_theme_options'     => array( 'administrator' ),
    159163                        'export'                 => array( 'administrator' ),
     
    416420                        $expected['delete_users'],
    417421                        $expected['create_users'],
    418422                        $expected['manage_links'],
     423                        $expected['install_translations'],
     424                        $expected['update_translations'],
    419425                        // Singular object meta capabilities (where an object ID is passed) are not tested:
    420426                        $expected['remove_user'],
    421427                        $expected['promote_user'],