WordPress.org

Make WordPress Core

Ticket #28577: 28577.3.diff

File 28577.3.diff, 3.5 KB (added by michalzuber, 3 years ago)

Renamed wp_get_available_translations() to wp_get_available_languages(), removed unused $options from upgrade.php, started error notification

  • wp-admin/includes/upgrade.php

    diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php
    index 6e4fd80..996b05b 100644
    a b function wp_install_language_form( $body ) { 
    21832183} 
    21842184 
    21852185/** 
    2186  * @todo rename, move 
     2186 * Get available languages from translations API 
     2187 * 
     2188 * @return boolean|array 
    21872189 */ 
    2188 function wp_get_available_translations() { 
     2190function wp_get_available_languages() { 
    21892191        $url = 'http://api.wordpress.org/translations/core/1.0/'; 
    21902192        if ( wp_http_supports( array( 'ssl' ) ) ) { 
    21912193                $url = set_url_scheme( $url, 'https' ); 
    function wp_get_available_translations() { 
    22132215function wp_install_download_language_pack( $language ) { 
    22142216        // Check if the language is already installed. 
    22152217        $available_languages = get_available_languages(); 
    2216         if ( in_array( $language->language, $available_languages ) ) { 
    2217                 return $language->language; 
     2218        if ( in_array( $language, $available_languages ) ) { 
     2219                return $language; 
    22182220        } 
    22192221 
    22202222        // Confirm the language is one we can download. 
    2221         $body = wp_get_available_translations(); 
     2223        $body = wp_get_available_languages(); 
    22222224        $loading_language = false; 
    22232225        if ( $body ) { 
    22242226                foreach ( $body['languages'] as $language ) { 
    function wp_install_download_language_pack( $language ) { 
    22372239        require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; 
    22382240        $skin = new Automatic_Upgrader_Skin; 
    22392241        $upgrader = new Language_Pack_Upgrader( $skin ); 
    2240         $options = array( 'clear_update_cache' => false ); 
    22412242        $language->type = 'core'; 
    22422243        /** 
    22432244         * @todo failures (such as non-direct FS) 
    22442245         */ 
    2245         $upgrader->upgrade( $language, array( 'clear_update_cache' => false ) ); 
     2246        $res = $upgrader->upgrade( $language, array( 'clear_update_cache' => false ) ); 
     2247        if ( is_null( $res ) ) 
     2248                return new WP_Error('fs_unavailable', $upgrader->strings['fs_unavailable'] ); 
     2249 
    22462250        return $language->language; 
    22472251} 
    22482252 
  • wp-admin/install.php

    diff --git a/wp-admin/install.php b/wp-admin/install.php
    index a2cc028..9ef5c77 100644
    a b if ( ! is_string( $wpdb->base_prefix ) || '' === $wpdb->base_prefix ) { 
    179179switch($step) { 
    180180        case 0: // Step 0 
    181181 
    182                 if ( empty( $_GET['language'] ) && ( $body = wp_get_available_translations() ) ) { 
     182                if ( empty( $_GET['language'] ) && ( $body = wp_get_available_languages() ) ) { 
    183183                        display_header( 'language-chooser' ); 
    184184                        echo '<form id="setup" method="post" action="?step=1">'; 
    185185                        wp_install_language_form( $body ); 
  • wp-admin/setup-config.php

    diff --git a/wp-admin/setup-config.php b/wp-admin/setup-config.php
    index 199078a..3dd8e89 100644
    a b function setup_config_display_header( $body_classes = array() ) { 
    8686switch($step) { 
    8787        case -1: 
    8888 
    89                 if ( empty( $_GET['language'] ) && ( $body = wp_get_available_translations() ) ) { 
     89                if ( empty( $_GET['language'] ) && ( $body = wp_get_available_languages() ) ) { 
    9090                        setup_config_display_header( 'language-chooser' ); 
    9191                        echo '<form id="setup" method="post" action="?step=0">'; 
    9292                        wp_install_language_form( $body ); 
    switch($step) { 
    9999        case 0: 
    100100                if ( ! empty( $_REQUEST['language'] ) ) { 
    101101                        $loaded_language = wp_install_download_language_pack( $_REQUEST['language'] ); 
    102                         if ( $loaded_language ) { 
     102 
     103                        if ( is_object( $loaded_language ) && 'WP_Error' === get_class( $loaded_language ) ) 
     104                                wp_die($loaded_language); 
     105 
     106                        if ( $loaded_language ) 
    103107                                wp_install_load_language( $loaded_language ); 
    104                         } 
    105108                } 
    106109 
    107110                setup_config_display_header();