WordPress.org

Make WordPress Core

Changeset 42606


Ignore:
Timestamp:
01/24/2018 10:41:58 PM (22 months ago)
Author:
SergeyBiryukov
Message:

Role/Capability: Make install_languages capability check less restrictive.

A user should still be able to have the capability, even when language packs cannot be automatically installed. The automatic installation part is separate from that now.

Props flixos90.
Fixes #42697.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/network/settings.php

    r42343 r42606  
    110110
    111111    // Handle translation installation.
    112     if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) ) {
     112    if ( ! empty( $_POST['WPLANG'] ) && current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
    113113        $language = wp_download_language_pack( $_POST['WPLANG'] );
    114114        if ( $language ) {
     
    420420                                'languages'    => $languages,
    421421                                'translations' => $translations,
    422                                 'show_available_translations' => current_user_can( 'install_languages' ),
     422                                'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
    423423                            )
    424424                        );
  • trunk/src/wp-admin/network/site-new.php

    r42343 r42606  
    7474        } elseif ( in_array( $_POST['WPLANG'], get_available_languages() ) ) {
    7575            $meta['WPLANG'] = $_POST['WPLANG'];
    76         } elseif ( current_user_can( 'install_languages' ) ) {
     76        } elseif ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
    7777            $language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
    7878            if ( $language ) {
     
    260260                            'languages'                   => $languages,
    261261                            'translations'                => $translations,
    262                             'show_available_translations' => current_user_can( 'install_languages' ),
     262                            'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
    263263                        )
    264264                    );
  • trunk/src/wp-admin/options-general.php

    r42343 r42606  
    178178                    'languages'                   => $languages,
    179179                    'translations'                => $translations,
    180                     'show_available_translations' => current_user_can( 'install_languages' ),
     180                    'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
    181181                )
    182182            );
  • trunk/src/wp-admin/options.php

    r42343 r42606  
    188188            require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
    189189
    190             $language = wp_download_language_pack( $_POST['WPLANG'] );
    191             if ( $language ) {
    192                 $_POST['WPLANG'] = $language;
     190            if ( wp_can_install_language_pack() ) {
     191                $language = wp_download_language_pack( $_POST['WPLANG'] );
     192                if ( $language ) {
     193                    $_POST['WPLANG'] = $language;
     194                }
    193195            }
    194196        }
  • trunk/src/wp-includes/capabilities.php

    r42343 r42606  
    440440        case 'install_languages':
    441441        case 'update_languages':
    442             if ( ! function_exists( 'request_filesystem_credentials' ) ) {
    443                 require_once( ABSPATH . 'wp-admin/includes/file.php' );
    444             }
    445 
    446             if ( ! function_exists( 'wp_can_install_language_pack' ) ) {
    447                 require_once( ABSPATH . 'wp-admin/includes/translation-install.php' );
    448             }
    449 
    450             if ( ! wp_can_install_language_pack() ) {
     442            if ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
    451443                $caps[] = 'do_not_allow';
    452444            } elseif ( is_multisite() && ! is_super_admin( $user_id ) ) {
Note: See TracChangeset for help on using the changeset viewer.