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
This commit is contained in:
Dominik Schilling (ocean90)
2014-09-02 18:06:36 +00:00
parent 97921c9fa5
commit c680af75e8
3 changed files with 33 additions and 5 deletions

View File

@@ -204,9 +204,37 @@ function wp_download_language_pack( $download ) {
$skin = new Automatic_Upgrader_Skin;
$upgrader = new Language_Pack_Upgrader( $skin );
$translation->type = 'core';
/**
* @todo failures (such as non-direct FS)
*/
$result = $upgrader->upgrade( $translation, array( 'clear_update_cache' => false ) );
if ( ! $result || is_wp_error( $result ) ) {
return false;
}
return $translation->language;
}
/**
* Check if WordPress has access to the filesystem without asking for
* credentials.
*
* @since 4.0.0
*
* @return bool Returns true on success, false on failure.
*/
function wp_can_install_language_pack() {
if ( defined( 'DISALLOW_FILE_MODS' ) && DISALLOW_FILE_MODS ) {
return false;
}
require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
$skin = new Automatic_Upgrader_Skin;
$upgrader = new Language_Pack_Upgrader( $skin );
$check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );
if ( ! $check || is_wp_error( $check ) ) {
return false;
}
return true;
}