PHP 8.2.31
Preview: translation-install.php Size: 10.82 KB
/home/nshryvcy/radiantskinclinics.org/wp-admin/includes/translation-install.php

<?php
/**
 * WordPress Translation Installation Administration API
 *
 * @package WordPress
 * @subpackage Administration
 */


/**
 * Retrieve translations from WordPress Translation API.
 *
 * @since 4.0.0
 *
 * @param string       $type Type of translations. Accepts 'plugins', 'themes', 'core'.
 * @param array|object $args Translation API arguments. Optional.
 * @return array|WP_Error {
 *     On success an associative array of translations, WP_Error on failure.
 *
 *     @type array $translations {
 *         List of translations, each an array of data.
 *
 *         @type array ...$0 {
 *             @type string   $language     Language code.
 *             @type string   $version      WordPress version.
 *             @type string   $updated      Date the translation was last updated, in MySQL datetime format.
 *             @type string   $english_name English name of the language.
 *             @type string   $native_name  Native name of the language.
 *             @type string   $package      URL to download the translation package.
 *             @type string[] $iso          Array of ISO language codes.
 *             @type array    $strings      Array of translated strings used in the installation process.
 *         }
 *     }
 * }
 */
function translations_api( $type, $args = null ) {
	if ( ! in_array( $type, array( 'plugins', 'themes', 'core' ), true ) ) {
		return new WP_Error( 'invalid_type', __( 'Invalid translation type.' ) );
	}

	/**
	 * Allows a plugin to override the WordPress.org Translation Installation API entirely.
	 *
	 * @since 4.0.0
	 *
	 * @param false|array $result The result array. Default false.
	 * @param string      $type   The type of translations being requested.
	 * @param object      $args   Translation API arguments.
	 */
	$res = apply_filters( 'translations_api', false, $type, $args );

	if ( false === $res ) {
		$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' );
		}

		$options = array(
			'timeout' => 3,
			'body'    => array(
				'wp_version' => wp_get_wp_version(),
				'locale'     => get_locale(),
				'version'    => $args['version'], // Version of plugin, theme or core.
			),
		);

		if ( 'core' !== $type ) {
			$options['body']['slug'] = $args['slug']; // Plugin or theme slug.
		}

		$request = wp_remote_post( $url, $options );

		if ( $ssl && is_wp_error( $request ) ) {
			wp_trigger_error(
				__FUNCTION__,
				sprintf(
					/* translators: %s: Support forums URL. */
					__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
					__( '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
			);

			$request = wp_remote_post( $http_url, $options );
		}

		if ( is_wp_error( $request ) ) {
			$res = new WP_Error(
				'translations_api_failed',
				sprintf(
					/* translators: %s: Support forums URL. */
					__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
					__( 'https://wordpress.org/support/forums/' )
				),
				$request->get_error_message()
			);
		} else {
			$res = json_decode( wp_remote_retrieve_body( $request ), true );
			if ( ! is_object( $res ) && ! is_array( $res ) ) {
				$res = new WP_Error(
					'translations_api_failed',
					sprintf(
						/* translators: %s: Support forums URL. */
						__( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server&#8217;s configuration. If you continue to have problems, please try the <a href="%s">support forums</a>.' ),
						__( 'https://wordpress.org/support/forums/' )
					),
					wp_remote_retrieve_body( $request )
				);
			}
		}
	}

	/**
	 * Filters the Translation Installation API response results.
	 *
	 * @since 4.0.0
	 *
	 * @param array|WP_Error $res  {
	 *     On success an associative array of translations, WP_Error on failure.
	 *
	 *     @type array $translations {
	 *         List of translations, each an array of data.
	 *
	 *         @type array ...$0 {
	 *             @type string   $language     Language code.
	 *             @type string   $version      WordPress version.
	 *             @type string   $updated      Date the translation was last updated, in MySQL datetime format.
	 *             @type string   $english_name English name of the language.
	 *             @type string   $native_name  Native name of the language.
	 *             @type string   $package      URL to download the translation package.
	 *             @type string[] $iso          Array of ISO language codes.
	 *             @type array    $strings      Array of translated strings used in the installation process.
	 *         }
	 *     }
	 * }
	 * @param string         $type The type of translations being requested.
	 * @param object         $args Translation API arguments.
	 */
	return apply_filters( 'translations_api_result', $res, $type, $args );
}

/**
 * Get available translations from the WordPress.org API.
 *
 * @since 4.0.0
 *
 * @see translations_api()
 *
 * @return array {
 *     Array of translations keyed by the language code, each an associative array of data.
 *     If the API response results in an error, an empty array will be returned.
 *
 *     @type array ...$0 {
 *         @type string   $language     Language code.
 *         @type string   $version      WordPress version.
 *         @type string   $updated      Date the translation was last updated, in MySQL datetime format.
 *         @type string   $english_name English name of the language.
 *         @type string   $native_name  Native name of the language.
 *         @type string   $package      URL to download the translation package.
 *         @type string[] $iso          Array of ISO language codes.
 *         @type array    $strings      Array of translated strings used in the installation process.
 *     }
 * }
 */
function wp_get_available_translations() {
	if ( ! wp_installing() ) {
		$translations = get_site_transient( 'available_translations' );
		if ( false !== $translations ) {
			return $translations;
		}
	}

	$api = translations_api( 'core', array( 'version' => wp_get_wp_version() ) );

	if ( is_wp_error( $api ) || empty( $api['translations'] ) ) {
		return array();
	}

	$translations = array();
	// Key the array with the language code.
	foreach ( $api['translations'] as $translation ) {
		$translations[ $translation['language'] ] = $translation;
	}

	if ( ! defined( 'WP_INSTALLING' ) ) {
		set_site_transient( 'available_translations', $translations, 3 * HOUR_IN_SECONDS );
	}

	return $translations;
}

/**
 * Output the select form for the language selection on the installation screen.
 *
 * @since 4.0.0
 *
 * @global string $wp_local_package Locale code of the package.
 *
 * @param array[] $languages Array of available languages (populated via the Translation API).
 */
function wp_install_language_form( $languages ) {
	global $wp_local_package;

	$installed_languages = get_available_languages();

	echo "<label class='screen-reader-text' for='language'>Select a default language</label>\n";
	echo "<select size='14' name='language' id='language'>\n";
	echo '<option value="" lang="en" selected="selected" data-continue="Continue" data-installed="1">English (United States)</option>';
	echo "\n";

	if ( ! empty( $wp_local_package ) && isset( $languages[ $wp_local_package ] ) ) {
		if ( isset( $languages[ $wp_local_package ] ) ) {
			$language = $languages[ $wp_local_package ];
			printf(
				'<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
				esc_attr( $language['language'] ),
				esc_attr( current( $language['iso'] ) ),
				esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ),
				in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
				esc_html( $language['native_name'] )
			);

			unset( $languages[ $wp_local_package ] );
		}
	}

	foreach ( $languages as $language ) {
		printf(
			'<option value="%s" lang="%s" data-continue="%s"%s>%s</option>' . "\n",
			esc_attr( $language['language'] ),
			esc_attr( current( $language['iso'] ) ),
			esc_attr( $language['strings']['continue'] ? $language['strings']['continue'] : 'Continue' ),
			in_array( $language['language'], $installed_languages, true ) ? ' data-installed="1"' : '',
			esc_html( $language['native_name'] )
		);
	}
	echo "</select>\n";
	echo '<p class="step"><span class="spinner"></span><input id="language-continue" type="submit" class="button button-primary button-large" value="Continue" /></p>';
}

/**
 * Download a language pack.
 *
 * @since 4.0.0
 *
 * @see wp_get_available_translations()
 *
 * @param string $download Language code to download.
 * @return string|false Returns the language code if successfully downloaded
 *                      (or already installed), or false on failure.
 */
function wp_download_language_pack( $download ) {
	// Check if the translation is already installed.
	if ( in_array( $download, get_available_languages(), true ) ) {
		return $download;
	}

	if ( ! wp_is_file_mod_allowed( 'download_language_pack' ) ) {
		return false;
	}

	// Confirm the translation is one we can download.
	$translations = wp_get_available_translations();
	if ( ! $translations ) {
		return false;
	}
	foreach ( $translations as $translation ) {
		if ( $translation['language'] === $download ) {
			$translation_to_load = true;
			break;
		}
	}

	if ( empty( $translation_to_load ) ) {
		return false;
	}
	$translation = (object) $translation;

	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
	$skin              = new Automatic_Upgrader_Skin();
	$upgrader          = new Language_Pack_Upgrader( $skin );
	$translation->type = 'core';
	$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 ( ! wp_is_file_mod_allowed( 'can_install_language_pack' ) ) {
		return false;
	}

	require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
	$skin     = new Automatic_Upgrader_Skin();
	$upgrader = new Language_Pack_Upgrader( $skin );
	$upgrader->init();

	$check = $upgrader->fs_connect( array( WP_CONTENT_DIR, WP_LANG_DIR ) );

	if ( ! $check || is_wp_error( $check ) ) {
		return false;
	}

	return true;
}

Directory Contents

Dirs: 1 × Files: 107

Name Size Perms Modified Actions
html-api DIR
- drwxr-xr-x 2026-04-30 05:16:59
Edit Download
7.85 KB lrw-r--r-- 2026-03-09 03:49:38
Edit Download
3.54 KB lrw-r--r-- 2023-07-11 09:03:24
Edit Download
149.19 KB lrw-r--r-- 2026-03-10 15:43:18
Edit Download
11.40 KB lrw-r--r-- 2026-03-14 02:44:48
Edit Download
3.58 KB lrw-r--r-- 2023-06-22 18:36:26
Edit Download
2.53 KB lrw-r--r-- 2024-05-02 21:20:10
Edit Download
2.60 KB lrw-r--r-- 2024-05-02 21:20:10
Edit Download
6.50 KB lrw-r--r-- 2026-01-05 21:04:58
Edit Download
14.84 KB lrw-r--r-- 2026-02-13 23:34:42
Edit Download
21.20 KB lrw-r--r-- 2026-05-13 11:20:44
Edit Download
48.03 KB lrw-r--r-- 2026-05-13 11:20:44
Edit Download
4.07 KB lrw-r--r-- 2024-03-07 10:58:16
Edit Download
5.30 KB lrw-r--r-- 2019-11-01 18:57:02
Edit Download
8.28 KB lrw-r--r-- 2022-03-22 20:25:04
Edit Download
26.70 KB lrw-r--r-- 2026-03-19 13:31:50
Edit Download
2.80 KB lrw-r--r-- 2024-05-02 21:20:10
Edit Download
15.16 KB lrw-r--r-- 2026-01-09 07:48:52
Edit Download
192.08 KB lrw-r--r-- 2024-12-13 03:23:16
Edit Download
11.67 KB lrw-r--r-- 2026-01-09 07:48:52
Edit Download
3.20 KB lrw-r--r-- 2023-06-14 10:34:28
Edit Download
22.70 KB lrw-r--r-- 2026-01-09 07:48:52
Edit Download
12.67 KB lrw-r--r-- 2026-01-09 07:48:52
Edit Download
4.08 KB lrw-r--r-- 2024-02-27 01:35:08
Edit Download
26.16 KB lrw-r--r-- 2026-02-13 23:34:42
Edit Download
4.97 KB lrw-r--r-- 2026-01-19 22:00:58
Edit Download
5.65 KB lrw-r--r-- 2026-03-10 16:34:44
Edit Download
13.96 KB lrw-r--r-- 2026-03-10 16:34:44
Edit Download
4.09 KB lrw-r--r-- 2023-06-22 18:36:26
Edit Download
6.79 KB lrw-r--r-- 2024-02-17 02:47:12
Edit Download
60.45 KB lrw-r--r-- 2025-06-03 20:51:34
Edit Download
33.80 KB lrw-r--r-- 2026-05-08 06:21:42
Edit Download
18.21 KB lrw-r--r-- 2026-01-09 09:22:50
Edit Download
70.27 KB lrw-r--r-- 2026-02-17 11:05:42
Edit Download
23.84 KB lrw-r--r-- 2024-02-17 02:47:12
Edit Download
18.17 KB lrw-r--r-- 2026-02-09 21:54:42
Edit Download
22.73 KB lrw-r--r-- 2025-11-27 02:52:32
Edit Download
18.06 KB lrw-r--r-- 2025-11-27 02:52:32
Edit Download
22.84 KB lrw-r--r-- 2026-02-20 07:25:46
Edit Download
7.64 KB lrw-r--r-- 2026-02-17 11:05:42
Edit Download
4.49 KB lrw-r--r-- 2026-01-05 21:04:58
Edit Download
9.29 KB lrw-r--r-- 2026-02-17 11:05:42
Edit Download
1.46 KB lrw-r--r-- 2020-11-14 21:54:08
Edit Download
51.84 KB lrw-r--r-- 2026-02-17 11:05:42
Edit Download
26.40 KB lrw-r--r-- 2026-03-03 12:18:44
Edit Download
22.23 KB lrw-r--r-- 2026-02-20 04:52:14
Edit Download
29.52 KB lrw-r--r-- 2026-02-23 11:06:42
Edit Download
15.32 KB lrw-r--r-- 2026-01-06 10:57:56
Edit Download
24.39 KB lrw-r--r-- 2026-01-13 02:17:00
Edit Download
56.75 KB lrw-r--r-- 2026-02-19 17:44:52
Edit Download
1.42 KB lrw-r--r-- 2022-10-04 07:47:16
Edit Download
63.46 KB lrw-r--r-- 2026-05-13 11:20:44
Edit Download
5.43 KB lrw-r--r-- 2022-03-11 00:22:02
Edit Download
5.58 KB lrw-r--r-- 2023-09-08 13:32:24
Edit Download
31.90 KB lrw-r--r-- 2025-08-27 14:34:28
Edit Download
14.44 KB lrw-r--r-- 2025-10-03 01:48:36
Edit Download
36.56 KB lrw-r--r-- 2026-04-27 06:20:42
Edit Download
14.00 KB lrw-r--r-- 2024-11-04 20:25:18
Edit Download
128.17 KB lrw-r--r-- 2026-02-21 02:13:48
Edit Download
6.26 KB lrw-r--r-- 2024-03-03 01:15:14
Edit Download
20.58 KB lrw-r--r-- 2026-02-26 03:52:44
Edit Download
15.33 KB lrw-r--r-- 2026-05-13 11:20:44
Edit Download
10.10 KB lrw-r--r-- 2026-01-09 09:22:50
Edit Download
6.90 KB lrw-r--r-- 2026-01-05 21:04:58
Edit Download
1.44 KB lrw-r--r-- 2019-10-08 21:19:04
Edit Download
47.23 KB lrw-r--r-- 2025-12-24 22:08:34
Edit Download
18.56 KB lrw-r--r-- 2026-01-06 10:57:56
Edit Download
6.08 KB lrw-r--r-- 2025-10-31 22:57:30
Edit Download
20.06 KB lrw-r--r-- 2022-09-20 03:24:12
Edit Download
5.70 KB lrw-r--r-- 2026-01-09 09:22:50
Edit Download
68.73 KB lrw-r--r-- 2026-05-08 06:21:42
Edit Download
40.77 KB lrw-r--r-- 2026-01-05 21:04:58
Edit Download
1.44 KB lrw-r--r-- 2021-12-07 17:20:02
Edit Download
285 B lrw-r--r-- 2026-05-26 18:13:28
Edit Download
25.37 KB lrw-r--r-- 2025-12-24 11:48:32
Edit Download
95.62 KB lrw-r--r-- 2026-03-12 01:01:46
Edit Download
42.96 KB lrw-r--r-- 2026-05-07 08:49:44
Edit Download
44.11 KB lrw-r--r-- 2026-03-14 20:00:54
Edit Download
6.46 KB lrw-r--r-- 2024-07-27 04:27:16
Edit Download
3.71 KB lrw-r--r-- 2022-10-04 07:47:16
Edit Download
117.12 KB lrw-r--r-- 2026-03-05 15:18:46
Edit Download
9.41 KB lrw-r--r-- 2026-03-06 02:08:44
Edit Download
65.29 KB lrw-r--r-- 2026-05-13 11:20:44
Edit Download
45.35 KB lrw-r--r-- 2026-05-08 19:59:44
Edit Download
1.27 KB lrw-r--r-- 2022-09-20 06:51:10
Edit Download
3.68 KB lrw-r--r-- 2022-09-20 06:51:10
Edit Download
33.45 KB lrw-r--r-- 2026-03-21 02:37:00
Edit Download
47.98 KB lrw-r--r-- 2026-03-24 09:58:00
Edit Download
26.40 KB lrw-r--r-- 2026-02-27 03:57:34
Edit Download
1.12 KB lrw-r--r-- 2023-09-21 05:27:26
Edit Download
4.14 KB lrw-r--r-- 2026-01-05 21:04:58
Edit Download
38.13 KB lrw-r--r-- 2026-01-09 09:22:50
Edit Download
91.09 KB lrw-r--r-- 2026-02-23 10:34:46
Edit Download
80.33 KB lrw-r--r-- 2026-05-13 11:20:44
Edit Download
32.66 KB lrw-r--r-- 2025-12-26 18:16:34
Edit Download
16.24 KB lrw-r--r-- 2026-04-28 15:23:44
Edit Download
44.51 KB lrw-r--r-- 2026-05-08 19:59:44
Edit Download
6.24 KB lrw-r--r-- 2026-01-15 05:00:00
Edit Download
8.28 KB lrw-r--r-- 2025-11-25 06:34:30
Edit Download
97.35 KB lrw-r--r-- 2026-02-19 14:43:48
Edit Download
6.83 KB lrw-r--r-- 2024-02-27 01:35:08
Edit Download
46.42 KB lrw-r--r-- 2026-02-23 10:34:46
Edit Download
10.82 KB lrw-r--r-- 2024-09-11 16:08:20
Edit Download
71.07 KB lrw-r--r-- 2026-05-19 21:16:42
Edit Download
34.03 KB lrw-r--r-- 2026-02-07 11:06:44
Edit Download
113.96 KB lrw-r--r-- 2026-02-15 13:02:42
Edit Download
23.39 KB lrw-r--r-- 2026-03-24 06:19:56
Edit Download
10.30 KB lrw-r--r-- 2026-02-19 03:03:44
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).