diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/translation-install.php --- a/wp/wp-admin/includes/translation-install.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/translation-install.php Tue Dec 15 13:49:49 2020 +0100 @@ -17,10 +17,11 @@ * @return object|WP_Error On success an object of translations, WP_Error on failure. */ function translations_api( $type, $args = null ) { - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version + // Include an unmodified $wp_version. + require ABSPATH . WPINC . '/version.php'; - if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ) ) ) { - return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) ); + if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) { + return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) ); } /** @@ -35,8 +36,10 @@ $res = apply_filters( 'translations_api', false, $type, $args ); if ( false === $res ) { - $url = $http_url = 'http://api.wordpress.org/translations/' . $type . '/1.0/'; - if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) { + $url = 'http://api.wordpress.org/translations/' . $type . '/1.0/'; + $http_url = $url; + $ssl = wp_http_supports( array( 'ssl' ) ); + if ( $ssl ) { $url = set_url_scheme( $url, 'https' ); } @@ -45,12 +48,12 @@ 'body' => array( 'wp_version' => $wp_version, 'locale' => get_locale(), - 'version' => $args['version'], // Version of plugin, theme or core + 'version' => $args['version'], // Version of plugin, theme or core. ), ); if ( 'core' !== $type ) { - $options['body']['slug'] = $args['slug']; // Plugin or theme slug + $options['body']['slug'] = $args['slug']; // Plugin or theme slug. } $request = wp_remote_post( $url, $options ); @@ -58,9 +61,9 @@ if ( $ssl && is_wp_error( $request ) ) { trigger_error( sprintf( - /* translators: %s: support forums URL */ + /* translators: %s: Support forums URL. */ __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), - __( 'https://wordpress.org/support/' ) + __( 'https://wordpress.org/support/forums/' ) ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE ); @@ -72,9 +75,9 @@ $res = new WP_Error( 'translations_api_failed', sprintf( - /* translators: %s: support forums URL */ + /* translators: %s: Support forums URL. */ __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), - __( 'https://wordpress.org/support/' ) + __( 'https://wordpress.org/support/forums/' ) ), $request->get_error_message() ); @@ -84,9 +87,9 @@ $res = new WP_Error( 'translations_api_failed', sprintf( - /* translators: %s: support forums URL */ + /* translators: %s: Support forums URL. */ __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the support forums.' ), - __( 'https://wordpress.org/support/' ) + __( 'https://wordpress.org/support/forums/' ) ), wp_remote_retrieve_body( $request ) ); @@ -113,15 +116,19 @@ * * @see translations_api() * - * @return array Array of translations, each an array of data. If the API response results - * in an error, an empty array will be returned. + * @return array[] Array of translations, each an array of data, keyed by the language. If the API response results + * in an error, an empty array will be returned. */ function wp_get_available_translations() { - if ( ! wp_installing() && false !== ( $translations = get_site_transient( 'available_translations' ) ) ) { - return $translations; + if ( ! wp_installing() ) { + $translations = get_site_transient( 'available_translations' ); + if ( false !== $translations ) { + return $translations; + } } - include( ABSPATH . WPINC . '/version.php' ); // include an unmodified $wp_version + // Include an unmodified $wp_version. + require ABSPATH . WPINC . '/version.php'; $api = translations_api( 'core', array( 'version' => $wp_version ) ); @@ -147,9 +154,9 @@ * * @since 4.0.0 * - * @global string $wp_local_package + * @global string $wp_local_package Locale code of the package. * - * @param array $languages Array of available languages (populated via the Translation API). + * @param array[] $languages Array of available languages (populated via the Translation API). */ function wp_install_language_form( $languages ) { global $wp_local_package; @@ -168,8 +175,8 @@ '' . "\n", esc_attr( $language['language'] ), esc_attr( current( $language['iso'] ) ), - esc_attr( $language['strings']['continue'] ), - in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '', + esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ), + in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '', esc_html( $language['native_name'] ) ); @@ -182,8 +189,8 @@ '' . "\n", esc_attr( $language['language'] ), esc_attr( current( $language['iso'] ) ), - esc_attr( $language['strings']['continue'] ), - in_array( $language['language'], $installed_languages ) ? ' data-installed="1"' : '', + esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ), + in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '', esc_html( $language['native_name'] ) ); } @@ -204,7 +211,7 @@ */ function wp_download_language_pack( $download ) { // Check if the translation is already installed. - if ( in_array( $download, get_available_languages() ) ) { + if ( in_array( $download, get_available_languages(), true ) ) { return $download; }