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.
Built from https://develop.svn.wordpress.org/trunk@42606


git-svn-id: http://core.svn.wordpress.org/trunk@42435 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2018-01-24 22:42:30 +00:00
parent ea6f648401
commit 1cda7b9667
6 changed files with 12 additions and 18 deletions

View File

@@ -73,7 +73,7 @@ if ( isset( $_REQUEST['action'] ) && 'add-site' == $_REQUEST['action'] ) {
$meta['WPLANG'] = ''; // en_US
} elseif ( in_array( $_POST['WPLANG'], get_available_languages() ) ) {
$meta['WPLANG'] = $_POST['WPLANG'];
} elseif ( current_user_can( 'install_languages' ) ) {
} elseif ( current_user_can( 'install_languages' ) && wp_can_install_language_pack() ) {
$language = wp_download_language_pack( wp_unslash( $_POST['WPLANG'] ) );
if ( $language ) {
$meta['WPLANG'] = $language;
@@ -259,7 +259,7 @@ if ( ! empty( $messages ) ) {
'selected' => $lang,
'languages' => $languages,
'translations' => $translations,
'show_available_translations' => current_user_can( 'install_languages' ),
'show_available_translations' => current_user_can( 'install_languages' ) && wp_can_install_language_pack(),
)
);
?>