PHP 8.1.33
Preview: translation-install.php Size: 10.82 KB
/home/jambtst2015/public_html/www.securiskbrokers.com/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: 0 × Files: 107

Name Size Perms Modified Actions
7.89 KB lrw-r--r-- 2024-10-21 03:25:16
Edit Download
3.54 KB lrw-r--r-- 2023-07-11 09:03:24
Edit Download
148.07 KB lrw-r--r-- 2024-09-18 02:41:14
Edit Download
11.34 KB lrw-r--r-- 2023-05-03 14:03:22
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.59 KB lrw-r--r-- 2024-05-02 21:20:10
Edit Download
14.83 KB lrw-r--r-- 2024-10-06 03:25:12
Edit Download
21.11 KB lrw-r--r-- 2024-09-06 18:36:20
Edit Download
47.91 KB lrw-r--r-- 2024-09-06 18:36:20
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.66 KB lrw-r--r-- 2024-02-12 17:07:10
Edit Download
2.80 KB lrw-r--r-- 2024-05-02 21:20:10
Edit Download
15.20 KB lrw-r--r-- 2024-04-30 12:39:08
Edit Download
192.09 KB lrw-r--r-- 2024-03-31 09:52:16
Edit Download
11.77 KB lrw-r--r-- 2024-10-03 04:25:16
Edit Download
3.20 KB lrw-r--r-- 2023-06-14 10:34:28
Edit Download
22.70 KB lrw-r--r-- 2024-10-03 04:25:16
Edit Download
12.44 KB lrw-r--r-- 2024-10-03 04:25:16
Edit Download
4.08 KB lrw-r--r-- 2024-02-27 01:35:08
Edit Download
26.08 KB lrw-r--r-- 2024-10-03 04:25:16
Edit Download
4.97 KB lrw-r--r-- 2024-08-14 03:37:16
Edit Download
5.50 KB lrw-r--r-- 2023-09-08 13:32:24
Edit Download
13.85 KB lrw-r--r-- 2024-10-21 23:55:16
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
59.70 KB lrw-r--r-- 2024-10-03 04:25:16
Edit Download
32.15 KB lrw-r--r-- 2024-08-13 01:28:14
Edit Download
18.33 KB lrw-r--r-- 2023-09-12 19:23:18
Edit Download
63.76 KB lrw-r--r-- 2024-10-28 01:59:12
Edit Download
23.84 KB lrw-r--r-- 2024-02-17 02:47:12
Edit Download
17.72 KB lrw-r--r-- 2024-02-17 02:47:12
Edit Download
22.56 KB lrw-r--r-- 2024-02-17 02:47:12
Edit Download
18.05 KB lrw-r--r-- 2024-02-17 02:47:12
Edit Download
22.76 KB lrw-r--r-- 2024-02-17 02:47:12
Edit Download
7.29 KB lrw-r--r-- 2023-08-14 13:59:20
Edit Download
4.47 KB lrw-r--r-- 2023-06-14 16:57:20
Edit Download
9.02 KB lrw-r--r-- 2024-07-17 19:43:16
Edit Download
1.46 KB lrw-r--r-- 2020-11-14 21:54:08
Edit Download
51.63 KB lrw-r--r-- 2024-09-30 22:24:14
Edit Download
25.03 KB lrw-r--r-- 2024-07-17 19:43:16
Edit Download
21.51 KB lrw-r--r-- 2024-07-17 19:43:16
Edit Download
27.67 KB lrw-r--r-- 2024-07-17 19:43:16
Edit Download
14.93 KB lrw-r--r-- 2024-07-17 19:43:16
Edit Download
24.21 KB lrw-r--r-- 2024-07-17 19:43:16
Edit Download
56.43 KB lrw-r--r-- 2024-09-03 22:19:14
Edit Download
1.42 KB lrw-r--r-- 2022-10-04 07:47:16
Edit Download
62.45 KB lrw-r--r-- 2024-09-09 18:37:18
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
32.01 KB lrw-r--r-- 2024-09-03 22:19:14
Edit Download
13.65 KB lrw-r--r-- 2023-09-22 23:58:16
Edit Download
36.45 KB lrw-r--r-- 2024-06-15 16:34:14
Edit Download
13.24 KB lrw-r--r-- 2024-08-22 02:23:16
Edit Download
119.50 KB lrw-r--r-- 2024-10-03 04:25:16
Edit Download
6.26 KB lrw-r--r-- 2024-03-03 01:15:14
Edit Download
20.69 KB lrw-r--r-- 2024-06-15 16:34:14
Edit Download
15.42 KB lrw-r--r-- 2024-07-17 19:43:16
Edit Download
10.10 KB lrw-r--r-- 2024-07-17 19:43:16
Edit Download
6.94 KB lrw-r--r-- 2024-05-02 21:20:10
Edit Download
1.44 KB lrw-r--r-- 2019-10-08 21:19:04
Edit Download
46.58 KB lrw-r--r-- 2024-10-19 03:37:20
Edit Download
18.61 KB lrw-r--r-- 2024-01-10 16:57:16
Edit Download
5.98 KB lrw-r--r-- 2022-07-21 02:15:10
Edit Download
20.06 KB lrw-r--r-- 2022-09-20 03:24:12
Edit Download
5.73 KB lrw-r--r-- 2024-07-27 04:27:16
Edit Download
68.08 KB lrw-r--r-- 2024-10-03 04:25:16
Edit Download
40.80 KB lrw-r--r-- 2024-01-10 16:57:16
Edit Download
1.44 KB lrw-r--r-- 2021-12-07 17:20:02
Edit Download
307 B lrw-r--r-- 2025-10-17 03:02:14
Edit Download
24.97 KB lrw-r--r-- 2024-04-16 00:03:10
Edit Download
95.19 KB lrw-r--r-- 2024-09-03 22:19:14
Edit Download
42.82 KB lrw-r--r-- 2024-10-10 03:32:22
Edit Download
42.40 KB lrw-r--r-- 2024-11-11 20:46:16
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
116.08 KB lrw-r--r-- 2024-09-30 09:19:16
Edit Download
9.39 KB lrw-r--r-- 2023-11-06 14:27:24
Edit Download
64.54 KB lrw-r--r-- 2024-07-21 22:58:16
Edit Download
45.38 KB lrw-r--r-- 2024-09-03 22:19:14
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.16 KB lrw-r--r-- 2024-05-11 18:47:06
Edit Download
47.76 KB lrw-r--r-- 2024-09-03 22:19:14
Edit Download
26.35 KB lrw-r--r-- 2024-05-10 03:09:14
Edit Download
1.12 KB lrw-r--r-- 2023-09-21 05:27:26
Edit Download
4.15 KB lrw-r--r-- 2024-02-27 01:18:10
Edit Download
38.55 KB lrw-r--r-- 2024-08-09 04:18:16
Edit Download
90.75 KB lrw-r--r-- 2024-09-03 22:19:14
Edit Download
79.77 KB lrw-r--r-- 2024-09-04 02:43:14
Edit Download
32.68 KB lrw-r--r-- 2023-06-22 18:36:26
Edit Download
16.11 KB lrw-r--r-- 2024-10-29 01:26:18
Edit Download
41.66 KB lrw-r--r-- 2024-08-24 03:17:14
Edit Download
6.23 KB lrw-r--r-- 2024-06-15 16:34:14
Edit Download
8.23 KB lrw-r--r-- 2023-03-10 12:04:20
Edit Download
96.31 KB lrw-r--r-- 2024-10-13 23:09:12
Edit Download
6.83 KB lrw-r--r-- 2024-02-27 01:35:08
Edit Download
46.62 KB lrw-r--r-- 2024-07-27 04:27:16
Edit Download
10.82 KB lrw-r--r-- 2024-09-11 16:08:20
Edit Download
67.71 KB lrw-r--r-- 2024-11-12 00:21:18
Edit Download
33.62 KB lrw-r--r-- 2024-07-27 04:27:16
Edit Download
111.22 KB lrw-r--r-- 2024-10-04 17:19:18
Edit Download
22.96 KB lrw-r--r-- 2023-11-17 18:29:26
Edit Download
10.66 KB lrw-r--r-- 2023-09-09 13:28:26
Edit Download

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