Skip to content

Commit c680af7

Browse files
committed
Install: Only show the language chooser when we have access to the filesystem without asking for credentials.
fixes #29397. git-svn-id: https://develop.svn.wordpress.org/trunk@29673 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 97921c9 commit c680af7

3 files changed

Lines changed: 33 additions & 5 deletions

File tree

src/wp-admin/includes/translation-install.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,37 @@ function wp_download_language_pack( $download ) {
204204
$skin = new Automatic_Upgrader_Skin;
205205
$upgrader = new Language_Pack_Upgrader( $skin );
206206
$translation->type = 'core';
207-
/**
208-
* @todo failures (such as non-direct FS)
209-
*/
210207
$result = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );
208+
209+
if ( ! $result || is_wp_error( $result ) ) {
210+
return false;
211+
}
212+
211213
return $translation->language;
212214
}
215+
216+
/**
217+
* Check if WordPress has access to the filesystem without asking for
218+
* credentials.
219+
*
220+
* @since 4.0.0
221+
*
222+
* @return bool Returns true on success, false on failure.
223+
*/
224+
function wp_can_install_language_pack() {
225+
if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
226+
return false;
227+
}
228+
229+
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
230+
$skin = new Automatic_Upgrader_Skin;
231+
$upgrader = new Language_Pack_Upgrader( $skin );
232+
233+
$check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
234+
235+
if ( ! $check || is_wp_error( $check ) ) {
236+
return false;
237+
}
238+
239+
return true;
240+
}

src/wp-admin/install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ function display_setup_form( $error = null ) {
189189
switch($step) {
190190
case 0: // Step 0
191191

192-
if ( empty( $langugage ) && ( $languages = wp_get_available_translations() ) ) {
192+
if ( wp_can_install_language_pack() && empty( $langugage ) && ( $languages = wp_get_available_translations() ) ) {
193193
display_header( 'language-chooser' );
194194
echo '<form id="setup" method="post" action="?step=1">';
195195
wp_install_language_form( $languages );

src/wp-admin/setup-config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ function setup_config_display_header( $body_classes = array() ) {
9393
}
9494
switch($step) {
9595
case -1:
96-
if ( empty( $language ) && ( $languages = wp_get_available_translations() ) ) {
96+
if ( wp_can_install_language_pack() && empty( $language ) && ( $languages = wp_get_available_translations() ) ) {
9797
setup_config_display_header( 'language-chooser' );
9898
echo '<form id="setup" method="post" action="?step=0">';
9999
wp_install_language_form( $languages );

0 commit comments

Comments
 (0)