wp/wp-includes/l10n.php
author ymh <ymh.work@gmail.com>
Thu, 29 Sep 2022 08:06:27 +0200
changeset 20 7b1b88e27a20
parent 19 3d72ae0968f4
child 21 48c4eec2b7e6
permissions -rw-r--r--
Modified Readme
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     3
 * Core Translation API
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 * @package WordPress
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @subpackage i18n
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
     7
 * @since 1.2.0
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    11
 * Retrieves the current locale.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    13
 * If the locale is set, then it will filter the locale in the {@see 'locale'}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    14
 * filter hook and return the value.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
 * If the locale is not set already, then the WPLANG constant is used if it is
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    17
 * defined. Then it is filtered through the {@see 'locale'} filter hook and
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    18
 * the value for the locale global set and the locale is returned.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
 * The process to get the locale should only be done once, but the locale will
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    21
 * always be filtered using the {@see 'locale'} hook.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    25
 * @global string $locale           The current locale.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    26
 * @global string $wp_local_package Locale code of the package.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    27
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    28
 * @return string The locale of the blog or from the {@see 'locale'} hook.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
function get_locale() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    31
	global $locale, $wp_local_package;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
	if ( isset( $locale ) ) {
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    34
		/** This filter is documented in wp-includes/l10n.php */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
		return apply_filters( 'locale', $locale );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    36
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    38
	if ( isset( $wp_local_package ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    39
		$locale = $wp_local_package;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    40
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    41
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    42
	// WPLANG was defined in wp-config.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    43
	if ( defined( 'WPLANG' ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
		$locale = WPLANG;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    45
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
	// If multisite, check options.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
	if ( is_multisite() ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
		// Don't check blog option when installing.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    50
		if ( wp_installing() ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    51
			$ms_locale = get_site_option( 'WPLANG' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    52
		} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    53
			$ms_locale = get_option( 'WPLANG' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    54
			if ( false === $ms_locale ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    55
				$ms_locale = get_site_option( 'WPLANG' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    56
			}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    57
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    59
		if ( false !== $ms_locale ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
			$locale = $ms_locale;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    61
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
	} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
		$db_locale = get_option( 'WPLANG' );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
    64
		if ( false !== $db_locale ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    65
			$locale = $db_locale;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    66
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    69
	if ( empty( $locale ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
		$locale = 'en_US';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    71
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    73
	/**
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    74
	 * Filters the locale ID of the WordPress installation.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    75
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    76
	 * @since 1.5.0
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    77
	 *
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    78
	 * @param string $locale The locale ID.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
    79
	 */
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
	return apply_filters( 'locale', $locale );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    84
 * Retrieves the locale of a user.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    85
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    86
 * If the user has a locale set to a non-empty string then it will be
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    87
 * returned. Otherwise it returns the locale of get_locale().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    88
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    89
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    90
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    91
 * @param int|WP_User $user_id User's ID or a WP_User object. Defaults to current user.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    92
 * @return string The locale of the user.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    93
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    94
function get_user_locale( $user_id = 0 ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    95
	$user = false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    96
	if ( 0 === $user_id && function_exists( 'wp_get_current_user' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    97
		$user = wp_get_current_user();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    98
	} elseif ( $user_id instanceof WP_User ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
    99
		$user = $user_id;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   100
	} elseif ( $user_id && is_numeric( $user_id ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   101
		$user = get_user_by( 'id', $user_id );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   102
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   103
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   104
	if ( ! $user ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   105
		return get_locale();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   106
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   107
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   108
	$locale = $user->locale;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   109
	return $locale ? $locale : get_locale();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   110
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   111
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   112
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   113
 * Determine the current locale desired for the request.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   114
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   115
 * @since 5.0.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   116
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   117
 * @global string $pagenow The filename of the current screen.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   118
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   119
 * @return string The determined locale.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   120
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   121
function determine_locale() {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   122
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   123
	 * Filters the locale for the current request prior to the default determination process.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   124
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   125
	 * Using this filter allows to override the default logic, effectively short-circuiting the function.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   126
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   127
	 * @since 5.0.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   128
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   129
	 * @param string|null $locale The locale to return and short-circuit. Default null.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   130
	 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   131
	$determined_locale = apply_filters( 'pre_determine_locale', null );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   132
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   133
	if ( ! empty( $determined_locale ) && is_string( $determined_locale ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   134
		return $determined_locale;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   135
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   136
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   137
	$determined_locale = get_locale();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   138
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   139
	if ( is_admin() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   140
		$determined_locale = get_user_locale();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   141
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   142
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   143
	if ( isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] && wp_is_json_request() ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   144
		$determined_locale = get_user_locale();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   145
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   146
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   147
	$wp_lang = '';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   148
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   149
	if ( ! empty( $_GET['wp_lang'] ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   150
		$wp_lang = sanitize_text_field( $_GET['wp_lang'] );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   151
	} elseif ( ! empty( $_COOKIE['wp_lang'] ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   152
		$wp_lang = sanitize_text_field( $_COOKIE['wp_lang'] );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   153
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   154
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   155
	if ( ! empty( $wp_lang ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   156
		$determined_locale = $wp_lang;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   157
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   158
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   159
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   160
	 * Filters the locale for the current request.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   161
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   162
	 * @since 5.0.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   163
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   164
	 * @param string $locale The locale.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   165
	 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   166
	return apply_filters( 'determine_locale', $determined_locale );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   167
}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   168
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   169
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
 * Retrieve the translation of $text.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   171
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
 * If there is no translation, or the text domain isn't loaded, the original text is returned.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   174
 * *Note:* Don't use translate() directly, use __() or related functions.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
 * @since 2.2.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   177
 * @since 5.5.0 Introduced gettext-{$domain} filter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
 * @param string $text   Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   181
 *                       Default 'default'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   182
 * @return string Translated text.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
function translate( $text, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
	$translations = get_translations_for_domain( $domain );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   186
	$translation  = $translations->translate( $text );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   187
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   189
	 * Filters text with its translation.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
	 * @since 2.0.11
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   193
	 * @param string $translation Translated text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   194
	 * @param string $text        Text to translate.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   195
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   197
	$translation = apply_filters( 'gettext', $translation, $text, $domain );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   198
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   199
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   200
	 * Filters text with its translation for a domain.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   201
	 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   202
	 * The dynamic portion of the hook name, `$domain`, refers to the text domain.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   203
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   204
	 * @since 5.5.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   205
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   206
	 * @param string $translation Translated text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   207
	 * @param string $text        Text to translate.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   208
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   209
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   210
	$translation = apply_filters( "gettext_{$domain}", $translation, $text, $domain );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   211
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   212
	return $translation;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
 * Remove last item on a pipe-delimited string.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
 * Meant for removing the last item in a string, such as 'Role name|User role'. The original
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
 * string will be returned if no pipe '|' characters are found in the string.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   222
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
 * @param string $string A pipe-delimited string.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
 * @return string Either $string or everything before the last pipe.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
function before_last_bar( $string ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
	$last_bar = strrpos( $string, '|' );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   228
	if ( false === $last_bar ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
		return $string;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   230
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
		return substr( $string, 0, $last_bar );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   232
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
 * Retrieve the translation of $text in the context defined in $context.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   238
 * If there is no translation, or the text domain isn't loaded, the original text is returned.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   240
 * *Note:* Don't use translate_with_gettext_context() directly, use _x() or related functions.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   241
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
 * @since 2.8.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   243
 * @since 5.5.0 Introduced gettext_with_context-{$domain} filter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
 * @param string $text    Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
 * @param string $context Context information for the translators.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   248
 *                        Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
 * @return string Translated text on success, original text on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
function translate_with_gettext_context( $text, $context, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
	$translations = get_translations_for_domain( $domain );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   253
	$translation  = $translations->translate( $text, $context );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   254
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   255
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   256
	 * Filters text with its translation based on context information.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
	 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   260
	 * @param string $translation Translated text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   261
	 * @param string $text        Text to translate.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   262
	 * @param string $context     Context information for the translators.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   263
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   264
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   265
	$translation = apply_filters( 'gettext_with_context', $translation, $text, $context, $domain );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   266
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   267
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   268
	 * Filters text with its translation based on context information for a domain.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   269
	 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   270
	 * The dynamic portion of the hook name, `$domain`, refers to the text domain.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   271
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   272
	 * @since 5.5.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   273
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   274
	 * @param string $translation Translated text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   275
	 * @param string $text        Text to translate.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   276
	 * @param string $context     Context information for the translators.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   277
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   278
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   279
	$translation = apply_filters( "gettext_with_context_{$domain}", $translation, $text, $context, $domain );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   280
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   281
	return $translation;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   285
 * Retrieve the translation of $text.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   286
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   287
 * If there is no translation, or the text domain isn't loaded, the original text is returned.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
 * @since 2.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
 * @param string $text   Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   293
 *                       Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
 * @return string Translated text.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
function __( $text, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
	return translate( $text, $domain );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
 * Retrieve the translation of $text and escapes it for safe use in an attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
 * If there is no translation, or the text domain isn't loaded, the original text is returned.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
 * @param string $text   Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   309
 *                       Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
 * @return string Translated text on success, original text on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   311
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   312
function esc_attr__( $text, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   313
	return esc_attr( translate( $text, $domain ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   314
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   315
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   316
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   317
 * Retrieve the translation of $text and escapes it for safe use in HTML output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   318
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   319
 * If there is no translation, or the text domain isn't loaded, the original text
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   320
 * is escaped and returned.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   321
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   322
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   323
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   324
 * @param string $text   Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   325
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   326
 *                       Default 'default'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   327
 * @return string Translated text.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   328
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   329
function esc_html__( $text, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   330
	return esc_html( translate( $text, $domain ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   331
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   332
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   333
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   334
 * Display translated text.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   335
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   336
 * @since 1.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   337
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   338
 * @param string $text   Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   339
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   340
 *                       Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   341
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   342
function _e( $text, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   343
	echo translate( $text, $domain );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   344
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   345
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   346
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   347
 * Display translated text that has been escaped for safe use in an attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   348
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   349
 * Encodes `< > & " '` (less than, greater than, ampersand, double quote, single quote).
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   350
 * Will never double encode entities.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   351
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   352
 * If you need the value for use in PHP, use esc_attr__().
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   353
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   354
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   355
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   356
 * @param string $text   Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   357
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   358
 *                       Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   359
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   360
function esc_attr_e( $text, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   361
	echo esc_attr( translate( $text, $domain ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   362
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   363
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   364
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   365
 * Display translated text that has been escaped for safe use in HTML output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   366
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   367
 * If there is no translation, or the text domain isn't loaded, the original text
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   368
 * is escaped and displayed.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   369
 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   370
 * If you need the value for use in PHP, use esc_html__().
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   371
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   372
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   373
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   374
 * @param string $text   Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   375
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   376
 *                       Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   377
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   378
function esc_html_e( $text, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   379
	echo esc_html( translate( $text, $domain ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   380
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   381
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   382
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   383
 * Retrieve translated string with gettext context.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   384
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   385
 * Quite a few times, there will be collisions with similar translatable text
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   386
 * found in more than two places, but with different translated context.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   387
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   388
 * By including the context in the pot file, translators can translate the two
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   389
 * strings differently.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   390
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   391
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   392
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   393
 * @param string $text    Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   394
 * @param string $context Context information for the translators.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   395
 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   396
 *                        Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   397
 * @return string Translated context string without pipe.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   398
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   399
function _x( $text, $context, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   400
	return translate_with_gettext_context( $text, $context, $domain );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   401
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   402
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   403
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   404
 * Display translated string with gettext context.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   405
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   406
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   407
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   408
 * @param string $text    Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   409
 * @param string $context Context information for the translators.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   410
 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   411
 *                        Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   412
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   413
function _ex( $text, $context, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   414
	echo _x( $text, $context, $domain );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   415
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   416
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   417
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   418
 * Translate string with gettext context, and escapes it for safe use in an attribute.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   419
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   420
 * If there is no translation, or the text domain isn't loaded, the original text
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   421
 * is escaped and returned.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   422
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   423
 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   424
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   425
 * @param string $text    Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
 * @param string $context Context information for the translators.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   428
 *                        Default 'default'.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   429
 * @return string Translated text.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
function esc_attr_x( $text, $context, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
	return esc_attr( translate_with_gettext_context( $text, $context, $domain ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
 * Translate string with gettext context, and escapes it for safe use in HTML output.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   437
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   438
 * If there is no translation, or the text domain isn't loaded, the original text
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   439
 * is escaped and returned.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   440
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
 * @param string $text    Text to translate.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   444
 * @param string $context Context information for the translators.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   446
 *                        Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
 * @return string Translated text.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
function esc_html_x( $text, $context, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
	return esc_html( translate_with_gettext_context( $text, $context, $domain ) );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   454
 * Translates and retrieves the singular or plural form based on the supplied number.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   456
 * Used when you want to use the appropriate form of a string based on whether a
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   457
 * number is singular or plural.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   458
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   459
 * Example:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   460
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   461
 *     printf( _n( '%s person', '%s people', $count, 'text-domain' ), number_format_i18n( $count ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
 * @since 2.8.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   464
 * @since 5.5.0 Introduced ngettext-{$domain} filter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   466
 * @param string $single The text to be used if the number is singular.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   467
 * @param string $plural The text to be used if the number is plural.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   468
 * @param int    $number The number to compare against to use either the singular or plural form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   470
 *                       Default 'default'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   471
 * @return string The translated singular or plural form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   473
function _n( $single, $plural, $number, $domain = 'default' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
	$translations = get_translations_for_domain( $domain );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   475
	$translation  = $translations->translate_plural( $single, $plural, $number );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   476
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   478
	 * Filters the singular or plural form of a string.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
	 * @since 2.2.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
	 * @param string $translation Translated text.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   483
	 * @param string $single      The text to be used if the number is singular.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   484
	 * @param string $plural      The text to be used if the number is plural.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   485
	 * @param string $number      The number to compare against to use either the singular or plural form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   488
	$translation = apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   489
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   490
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   491
	 * Filters the singular or plural form of a string for a domain.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   492
	 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   493
	 * The dynamic portion of the hook name, `$domain`, refers to the text domain.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   494
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   495
	 * @since 5.5.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   496
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   497
	 * @param string $translation Translated text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   498
	 * @param string $single      The text to be used if the number is singular.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   499
	 * @param string $plural      The text to be used if the number is plural.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   500
	 * @param string $number      The number to compare against to use either the singular or plural form.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   501
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   502
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   503
	$translation = apply_filters( "ngettext_{$domain}", $translation, $single, $plural, $number, $domain );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   504
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   505
	return $translation;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   509
 * Translates and retrieves the singular or plural form based on the supplied number, with gettext context.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   510
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   511
 * This is a hybrid of _n() and _x(). It supports context and plurals.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   513
 * Used when you want to use the appropriate form of a string with context based on whether a
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   514
 * number is singular or plural.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   515
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   516
 * Example of a generic phrase which is disambiguated via the context parameter:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   517
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   518
 *     printf( _nx( '%s group', '%s groups', $people, 'group of people', 'text-domain' ), number_format_i18n( $people ) );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   519
 *     printf( _nx( '%s group', '%s groups', $animals, 'group of animals', 'text-domain' ), number_format_i18n( $animals ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
 * @since 2.8.0
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   522
 * @since 5.5.0 Introduced ngettext_with_context-{$domain} filter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   524
 * @param string $single  The text to be used if the number is singular.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   525
 * @param string $plural  The text to be used if the number is plural.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   526
 * @param int    $number  The number to compare against to use either the singular or plural form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
 * @param string $context Context information for the translators.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
 * @param string $domain  Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   529
 *                        Default 'default'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   530
 * @return string The translated singular or plural form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   532
function _nx( $single, $plural, $number, $context, $domain = 'default' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
	$translations = get_translations_for_domain( $domain );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   534
	$translation  = $translations->translate_plural( $single, $plural, $number, $context );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   535
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   537
	 * Filters the singular or plural form of a string with gettext context.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
	 * @since 2.8.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   540
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   541
	 * @param string $translation Translated text.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   542
	 * @param string $single      The text to be used if the number is singular.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   543
	 * @param string $plural      The text to be used if the number is plural.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   544
	 * @param string $number      The number to compare against to use either the singular or plural form.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   545
	 * @param string $context     Context information for the translators.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
	 */
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   548
	$translation = apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   549
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   550
	/**
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   551
	 * Filters the singular or plural form of a string with gettext context for a domain.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   552
	 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   553
	 * The dynamic portion of the hook name, `$domain`, refers to the text domain.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   554
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   555
	 * @since 5.5.0
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   556
	 *
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   557
	 * @param string $translation Translated text.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   558
	 * @param string $single      The text to be used if the number is singular.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   559
	 * @param string $plural      The text to be used if the number is plural.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   560
	 * @param string $number      The number to compare against to use either the singular or plural form.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   561
	 * @param string $context     Context information for the translators.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   562
	 * @param string $domain      Text domain. Unique identifier for retrieving translated strings.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   563
	 */
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   564
	$translation = apply_filters( "ngettext_with_context_{$domain}", $translation, $single, $plural, $number, $context, $domain );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   565
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   566
	return $translation;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   570
 * Registers plural strings in POT file, but does not translate them.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
 * Used when you want to keep structures with translatable plural
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   573
 * strings and use them later when the number is known.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
 * Example:
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   576
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   577
 *     $message = _n_noop( '%s post', '%s posts', 'text-domain' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   578
 *     ...
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   579
 *     printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   581
 * @since 2.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   582
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   583
 * @param string $singular Singular form to be localized.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   584
 * @param string $plural   Plural form to be localized.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
 * @param string $domain   Optional. Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   586
 *                         Default null.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   587
 * @return array {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   588
 *     Array of translation information for the strings.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   589
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   590
 *     @type string $0        Singular form to be localized. No longer used.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   591
 *     @type string $1        Plural form to be localized. No longer used.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   592
 *     @type string $singular Singular form to be localized.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   593
 *     @type string $plural   Plural form to be localized.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   594
 *     @type null   $context  Context information for the translators.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   595
 *     @type string $domain   Text domain.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   596
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   597
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   598
function _n_noop( $singular, $plural, $domain = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   599
	return array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   600
		0          => $singular,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   601
		1          => $plural,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   602
		'singular' => $singular,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   603
		'plural'   => $plural,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   604
		'context'  => null,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   605
		'domain'   => $domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   606
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   607
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   608
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   609
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   610
 * Registers plural strings with gettext context in POT file, but does not translate them.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   611
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   612
 * Used when you want to keep structures with translatable plural
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   613
 * strings and use them later when the number is known.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   614
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   615
 * Example of a generic phrase which is disambiguated via the context parameter:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   616
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   617
 *     $messages = array(
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   618
 *          'people'  => _nx_noop( '%s group', '%s groups', 'people', 'text-domain' ),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   619
 *          'animals' => _nx_noop( '%s group', '%s groups', 'animals', 'text-domain' ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   620
 *     );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   621
 *     ...
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   622
 *     $message = $messages[ $type ];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   623
 *     printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   624
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   625
 * @since 2.8.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   626
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   627
 * @param string $singular Singular form to be localized.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   628
 * @param string $plural   Plural form to be localized.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   629
 * @param string $context  Context information for the translators.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   630
 * @param string $domain   Optional. Text domain. Unique identifier for retrieving translated strings.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   631
 *                         Default null.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   632
 * @return array {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   633
 *     Array of translation information for the strings.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   634
 *
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   635
 *     @type string      $0        Singular form to be localized. No longer used.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   636
 *     @type string      $1        Plural form to be localized. No longer used.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   637
 *     @type string      $2        Context information for the translators. No longer used.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   638
 *     @type string      $singular Singular form to be localized.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   639
 *     @type string      $plural   Plural form to be localized.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   640
 *     @type string      $context  Context information for the translators.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
   641
 *     @type string|null $domain   Text domain.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   642
 * }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   643
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   644
function _nx_noop( $singular, $plural, $context, $domain = null ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   645
	return array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   646
		0          => $singular,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   647
		1          => $plural,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   648
		2          => $context,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   649
		'singular' => $singular,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   650
		'plural'   => $plural,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   651
		'context'  => $context,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   652
		'domain'   => $domain,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   653
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   654
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   655
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   657
 * Translates and retrieves the singular or plural form of a string that's been registered
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   658
 * with _n_noop() or _nx_noop().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   659
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   660
 * Used when you want to use a translatable plural string once the number is known.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   661
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   662
 * Example:
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   663
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   664
 *     $message = _n_noop( '%s post', '%s posts', 'text-domain' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   665
 *     ...
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   666
 *     printf( translate_nooped_plural( $message, $count, 'text-domain' ), number_format_i18n( $count ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   667
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   668
 * @since 3.1.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   669
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   670
 * @param array  $nooped_plural Array with singular, plural, and context keys, usually the result of _n_noop() or _nx_noop().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   671
 * @param int    $count         Number of objects.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   672
 * @param string $domain        Optional. Text domain. Unique identifier for retrieving translated strings. If $nooped_plural contains
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   673
 *                              a text domain passed to _n_noop() or _nx_noop(), it will override this value. Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   674
 * @return string Either $single or $plural translated text.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   675
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   676
function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   677
	if ( $nooped_plural['domain'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   678
		$domain = $nooped_plural['domain'];
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   679
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   680
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   681
	if ( $nooped_plural['context'] ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
		return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   683
	} else {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
		return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   685
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   686
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
 * Load a .mo file into the text domain $domain.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
 * If the text domain already exists, the translations will be merged. If both
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
 * sets have the same string, the translation from the original value will be taken.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
 * On success, the .mo file will be placed in the $l10n global by $domain
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
 * and will be a MO object.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
 * @since 1.5.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   699
 * @global MO[] $l10n          An array of all currently loaded text domains.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   700
 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   701
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
 * @param string $mofile Path to the .mo file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
 * @return bool True on success, false on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
function load_textdomain( $domain, $mofile ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   707
	global $l10n, $l10n_unloaded;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   708
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   709
	$l10n_unloaded = (array) $l10n_unloaded;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   712
	 * Filters whether to override the .mo file loading.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
	 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   716
	 * @param bool   $override Whether to override the .mo file loading. Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   717
	 * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   718
	 * @param string $mofile   Path to the MO file.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
	$plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
   722
	if ( true === (bool) $plugin_override ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   723
		unset( $l10n_unloaded[ $domain ] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   724
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   725
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   726
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   727
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   728
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   729
	 * Fires before the MO translation file is loaded.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   730
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   731
	 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   732
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   733
	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   734
	 * @param string $mofile Path to the .mo file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   735
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   736
	do_action( 'load_textdomain', $domain, $mofile );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   737
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   738
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   739
	 * Filters MO file path for loading translations for a specific text domain.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   740
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   741
	 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   742
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   743
	 * @param string $mofile Path to the MO file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   744
	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   745
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   746
	$mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   747
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   748
	if ( ! is_readable( $mofile ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   749
		return false;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   750
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   751
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   752
	$mo = new MO();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   753
	if ( ! $mo->import_from_file( $mofile ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   754
		return false;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   755
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   756
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   757
	if ( isset( $l10n[ $domain ] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   758
		$mo->merge_with( $l10n[ $domain ] );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   759
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   760
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   761
	unset( $l10n_unloaded[ $domain ] );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   762
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   763
	$l10n[ $domain ] = &$mo;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   764
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   765
	return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   766
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
 * Unload translations for a text domain.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   773
 * @global MO[] $l10n          An array of all currently loaded text domains.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   774
 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   775
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
 * @return bool Whether textdomain was unloaded.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
function unload_textdomain( $domain ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   780
	global $l10n, $l10n_unloaded;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   781
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   782
	$l10n_unloaded = (array) $l10n_unloaded;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   783
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   784
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   785
	 * Filters whether to override the text domain unloading.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   786
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   787
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   788
	 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   789
	 * @param bool   $override Whether to override the text domain unloading. Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   790
	 * @param string $domain   Text domain. Unique identifier for retrieving translated strings.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   791
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   792
	$plugin_override = apply_filters( 'override_unload_textdomain', false, $domain );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   793
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   794
	if ( $plugin_override ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   795
		$l10n_unloaded[ $domain ] = true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   796
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   797
		return true;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   798
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   799
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   800
	/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   801
	 * Fires before the text domain is unloaded.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   802
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   803
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   804
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   805
	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   806
	 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   807
	do_action( 'unload_textdomain', $domain );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   808
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   809
	if ( isset( $l10n[ $domain ] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   810
		unset( $l10n[ $domain ] );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   811
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   812
		$l10n_unloaded[ $domain ] = true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   813
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   814
		return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   815
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   816
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   817
	return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   818
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   819
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   820
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   821
 * Load default translated strings based on locale.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   822
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   823
 * Loads the .mo file in WP_LANG_DIR constant path from WordPress root.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   824
 * The translated (.mo) file is named based on the locale.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   825
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   826
 * @see load_textdomain()
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   827
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   828
 * @since 1.5.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   829
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   830
 * @param string $locale Optional. Locale to load. Default is the value of get_locale().
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   831
 * @return bool Whether the textdomain was loaded.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   832
 */
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   833
function load_default_textdomain( $locale = null ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   834
	if ( null === $locale ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   835
		$locale = determine_locale();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   836
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   837
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   838
	// Unload previously loaded strings so we can switch translations.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   839
	unload_textdomain( 'default' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   840
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   841
	$return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   842
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   843
	if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists( WP_LANG_DIR . "/admin-$locale.mo" ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   844
		load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   845
		return $return;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   846
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   847
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   848
	if ( is_admin() || wp_installing() || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   849
		load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   850
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   851
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   852
	if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   853
		load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   854
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   855
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   856
	return $return;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   857
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   858
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   859
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   860
 * Loads a plugin's translated strings.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   861
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   862
 * If the path is not given then it will be the root of the plugin directory.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   863
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   864
 * The .mo file should be named based on the text domain with a dash, and then the locale exactly.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   865
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   866
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   867
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   868
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   869
 * @param string       $domain          Unique identifier for retrieving translated strings
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   870
 * @param string|false $deprecated      Optional. Deprecated. Use the $plugin_rel_path parameter instead.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   871
 *                                      Default false.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   872
 * @param string|false $plugin_rel_path Optional. Relative path to WP_PLUGIN_DIR where the .mo file resides.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   873
 *                                      Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   874
 * @return bool True when textdomain is successfully loaded, false otherwise.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   875
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   876
function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   877
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   878
	 * Filters a plugin's locale.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   879
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   880
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   881
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   882
	 * @param string $locale The plugin's current locale.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   883
	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   884
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   885
	$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   886
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   887
	$mofile = $domain . '-' . $locale . '.mo';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   888
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   889
	// Try to load from the languages directory first.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   890
	if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   891
		return true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   892
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   893
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   894
	if ( false !== $plugin_rel_path ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   895
		$path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   896
	} elseif ( false !== $deprecated ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   897
		_deprecated_argument( __FUNCTION__, '2.7.0' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   898
		$path = ABSPATH . trim( $deprecated, '/' );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   899
	} else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   900
		$path = WP_PLUGIN_DIR;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   901
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   902
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   903
	return load_textdomain( $domain, $path . '/' . $mofile );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   904
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   905
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   906
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   907
 * Load the translated strings for a plugin residing in the mu-plugins directory.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   908
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   909
 * @since 3.0.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   910
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   911
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   912
 * @param string $domain             Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   913
 * @param string $mu_plugin_rel_path Optional. Relative to `WPMU_PLUGIN_DIR` directory in which the .mo
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   914
 *                                   file resides. Default empty string.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   915
 * @return bool True when textdomain is successfully loaded, false otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   916
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   917
function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   918
	/** This filter is documented in wp-includes/l10n.php */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   919
	$locale = apply_filters( 'plugin_locale', determine_locale(), $domain );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   920
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   921
	$mofile = $domain . '-' . $locale . '.mo';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   922
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   923
	// Try to load from the languages directory first.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   924
	if ( load_textdomain( $domain, WP_LANG_DIR . '/plugins/' . $mofile ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   925
		return true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   926
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   927
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   928
	$path = WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   929
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   930
	return load_textdomain( $domain, $path . '/' . $mofile );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   931
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   932
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   933
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   934
 * Load the theme's translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   935
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   936
 * If the current locale exists as a .mo file in the theme's root directory, it
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   937
 * will be included in the translated strings by the $domain.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   938
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   939
 * The .mo files must be named based on the locale exactly.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   940
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   941
 * @since 1.5.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   942
 * @since 4.6.0 The function now tries to load the .mo file from the languages directory first.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   943
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   944
 * @param string       $domain Text domain. Unique identifier for retrieving translated strings.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   945
 * @param string|false $path   Optional. Path to the directory containing the .mo file.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   946
 *                             Default false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   947
 * @return bool True when textdomain is successfully loaded, false otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   948
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   949
function load_theme_textdomain( $domain, $path = false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   950
	/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   951
	 * Filters a theme's locale.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   952
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   953
	 * @since 3.0.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   954
	 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   955
	 * @param string $locale The theme's current locale.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   956
	 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   957
	 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   958
	$locale = apply_filters( 'theme_locale', determine_locale(), $domain );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   959
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   960
	$mofile = $domain . '-' . $locale . '.mo';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   961
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   962
	// Try to load from the languages directory first.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   963
	if ( load_textdomain( $domain, WP_LANG_DIR . '/themes/' . $mofile ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   964
		return true;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   965
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   966
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   967
	if ( ! $path ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   968
		$path = get_template_directory();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   969
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   970
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   971
	return load_textdomain( $domain, $path . '/' . $locale . '.mo' );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   972
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   973
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   974
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   975
 * Load the child themes translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   976
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   977
 * If the current locale exists as a .mo file in the child themes
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   978
 * root directory, it will be included in the translated strings by the $domain.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   979
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   980
 * The .mo files must be named based on the locale exactly.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   981
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   982
 * @since 2.9.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   983
 *
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   984
 * @param string       $domain Text domain. Unique identifier for retrieving translated strings.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   985
 * @param string|false $path   Optional. Path to the directory containing the .mo file.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
   986
 *                             Default false.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   987
 * @return bool True when the theme textdomain is successfully loaded, false otherwise.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   988
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   989
function load_child_theme_textdomain( $domain, $path = false ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   990
	if ( ! $path ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   991
		$path = get_stylesheet_directory();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   992
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   993
	return load_theme_textdomain( $domain, $path );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   994
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   995
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   996
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   997
 * Loads the script translated strings.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   998
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
   999
 * @since 5.0.0
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1000
 * @since 5.0.2 Uses load_script_translations() to load translation data.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1001
 * @since 5.1.0 The `$domain` parameter was made optional.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1002
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1003
 * @see WP_Scripts::set_translations()
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1004
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1005
 * @param string $handle Name of the script to register a translation domain to.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1006
 * @param string $domain Optional. Text domain. Default 'default'.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1007
 * @param string $path   Optional. The full file path to the directory containing translation files.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1008
 * @return string|false The translated strings in JSON encoding on success,
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1009
 *                      false if the script textdomain could not be loaded.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1010
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1011
function load_script_textdomain( $handle, $domain = 'default', $path = null ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1012
	$wp_scripts = wp_scripts();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1013
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1014
	if ( ! isset( $wp_scripts->registered[ $handle ] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1015
		return false;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1016
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1017
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1018
	$path   = untrailingslashit( $path );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1019
	$locale = determine_locale();
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1020
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1021
	// If a path was given and the handle file exists simply return it.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1022
	$file_base       = 'default' === $domain ? $locale : $domain . '-' . $locale;
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1023
	$handle_filename = $file_base . '-' . $handle . '.json';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1024
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1025
	if ( $path ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1026
		$translations = load_script_translations( $path . '/' . $handle_filename, $handle, $domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1027
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1028
		if ( $translations ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1029
			return $translations;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1030
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1031
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1032
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1033
	$src = $wp_scripts->registered[ $handle ]->src;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1034
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1035
	if ( ! preg_match( '|^(https?:)?//|', $src ) && ! ( $wp_scripts->content_url && 0 === strpos( $src, $wp_scripts->content_url ) ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1036
		$src = $wp_scripts->base_url . $src;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1037
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1038
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1039
	$relative       = false;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1040
	$languages_path = WP_LANG_DIR;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1041
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1042
	$src_url     = wp_parse_url( $src );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1043
	$content_url = wp_parse_url( content_url() );
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1044
	$plugins_url = wp_parse_url( plugins_url() );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1045
	$site_url    = wp_parse_url( site_url() );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1046
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1047
	// If the host is the same or it's a relative URL.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1048
	if (
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1049
		( ! isset( $content_url['path'] ) || strpos( $src_url['path'], $content_url['path'] ) === 0 ) &&
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1050
		( ! isset( $src_url['host'] ) || ! isset( $content_url['host'] ) || $src_url['host'] === $content_url['host'] )
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1051
	) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1052
		// Make the src relative the specific plugin or theme.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1053
		if ( isset( $content_url['path'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1054
			$relative = substr( $src_url['path'], strlen( $content_url['path'] ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1055
		} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1056
			$relative = $src_url['path'];
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1057
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1058
		$relative = trim( $relative, '/' );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1059
		$relative = explode( '/', $relative );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1060
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1061
		$languages_path = WP_LANG_DIR . '/' . $relative[0];
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1062
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1063
		$relative = array_slice( $relative, 2 ); // Remove plugins/<plugin name> or themes/<theme name>.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1064
		$relative = implode( '/', $relative );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1065
	} elseif (
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1066
		( ! isset( $plugins_url['path'] ) || strpos( $src_url['path'], $plugins_url['path'] ) === 0 ) &&
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1067
		( ! isset( $src_url['host'] ) || ! isset( $plugins_url['host'] ) || $src_url['host'] === $plugins_url['host'] )
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1068
	) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1069
		// Make the src relative the specific plugin.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1070
		if ( isset( $plugins_url['path'] ) ) {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1071
			$relative = substr( $src_url['path'], strlen( $plugins_url['path'] ) );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1072
		} else {
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1073
			$relative = $src_url['path'];
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1074
		}
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1075
		$relative = trim( $relative, '/' );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1076
		$relative = explode( '/', $relative );
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1077
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1078
		$languages_path = WP_LANG_DIR . '/plugins';
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1079
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1080
		$relative = array_slice( $relative, 1 ); // Remove <plugin name>.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1081
		$relative = implode( '/', $relative );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1082
	} elseif ( ! isset( $src_url['host'] ) || ! isset( $site_url['host'] ) || $src_url['host'] === $site_url['host'] ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1083
		if ( ! isset( $site_url['path'] ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1084
			$relative = trim( $src_url['path'], '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1085
		} elseif ( ( strpos( $src_url['path'], trailingslashit( $site_url['path'] ) ) === 0 ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1086
			// Make the src relative to the WP root.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1087
			$relative = substr( $src_url['path'], strlen( $site_url['path'] ) );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1088
			$relative = trim( $relative, '/' );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1089
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1090
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1091
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1092
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1093
	 * Filters the relative path of scripts used for finding translation files.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1094
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1095
	 * @since 5.0.2
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1096
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1097
	 * @param string|false $relative The relative path of the script. False if it could not be determined.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1098
	 * @param string       $src      The full source URL of the script.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1099
	 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1100
	$relative = apply_filters( 'load_script_textdomain_relative_path', $relative, $src );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1101
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1102
	// If the source is not from WP.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1103
	if ( false === $relative ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1104
		return load_script_translations( false, $handle, $domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1105
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1106
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1107
	// Translations are always based on the unminified filename.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1108
	if ( substr( $relative, -7 ) === '.min.js' ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1109
		$relative = substr( $relative, 0, -7 ) . '.js';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1110
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1111
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1112
	$md5_filename = $file_base . '-' . md5( $relative ) . '.json';
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1113
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1114
	if ( $path ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1115
		$translations = load_script_translations( $path . '/' . $md5_filename, $handle, $domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1116
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1117
		if ( $translations ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1118
			return $translations;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1119
		}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1120
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1121
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1122
	$translations = load_script_translations( $languages_path . '/' . $md5_filename, $handle, $domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1123
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1124
	if ( $translations ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1125
		return $translations;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1126
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1127
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1128
	return load_script_translations( false, $handle, $domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1129
}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1130
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1131
/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1132
 * Loads the translation data for the given script handle and text domain.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1133
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1134
 * @since 5.0.2
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1135
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1136
 * @param string|false $file   Path to the translation file to load. False if there isn't one.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1137
 * @param string       $handle Name of the script to register a translation domain to.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1138
 * @param string       $domain The text domain.
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1139
 * @return string|false The JSON-encoded translated strings for the given script handle and text domain.
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1140
 *                      False if there are none.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1141
 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1142
function load_script_translations( $file, $handle, $domain ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1143
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1144
	 * Pre-filters script translations for the given file, script handle and text domain.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1145
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1146
	 * Returning a non-null value allows to override the default logic, effectively short-circuiting the function.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1147
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1148
	 * @since 5.0.2
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1149
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1150
	 * @param string|false|null $translations JSON-encoded translation data. Default null.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1151
	 * @param string|false      $file         Path to the translation file to load. False if there isn't one.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1152
	 * @param string            $handle       Name of the script to register a translation domain to.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1153
	 * @param string            $domain       The text domain.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1154
	 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1155
	$translations = apply_filters( 'pre_load_script_translations', null, $file, $handle, $domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1156
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1157
	if ( null !== $translations ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1158
		return $translations;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1159
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1160
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1161
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1162
	 * Filters the file path for loading script translations for the given script handle and text domain.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1163
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1164
	 * @since 5.0.2
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1165
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1166
	 * @param string|false $file   Path to the translation file to load. False if there isn't one.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1167
	 * @param string       $handle Name of the script to register a translation domain to.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1168
	 * @param string       $domain The text domain.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1169
	 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1170
	$file = apply_filters( 'load_script_translation_file', $file, $handle, $domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1171
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1172
	if ( ! $file || ! is_readable( $file ) ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1173
		return false;
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1174
	}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1175
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1176
	$translations = file_get_contents( $file );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1177
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1178
	/**
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1179
	 * Filters script translations for the given file, script handle and text domain.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1180
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1181
	 * @since 5.0.2
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1182
	 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1183
	 * @param string $translations JSON-encoded translation data.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1184
	 * @param string $file         Path to the translation file that was loaded.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1185
	 * @param string $handle       Name of the script to register a translation domain to.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1186
	 * @param string $domain       The text domain.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1187
	 */
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1188
	return apply_filters( 'load_script_translations', $translations, $file, $handle, $domain );
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1189
}
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1190
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1191
/**
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1192
 * Loads plugin and theme textdomains just-in-time.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1193
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1194
 * When a textdomain is encountered for the first time, we try to load
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1195
 * the translation file from `wp-content/languages`, removing the need
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1196
 * to call load_plugin_texdomain() or load_theme_texdomain().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1197
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1198
 * @since 4.6.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1199
 * @access private
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1200
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1201
 * @see get_translations_for_domain()
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1202
 * @global MO[] $l10n_unloaded An array of all text domains that have been unloaded again.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1203
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1204
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1205
 * @return bool True when the textdomain is successfully loaded, false otherwise.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1206
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1207
function _load_textdomain_just_in_time( $domain ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1208
	global $l10n_unloaded;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1209
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1210
	$l10n_unloaded = (array) $l10n_unloaded;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1211
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1212
	// Short-circuit if domain is 'default' which is reserved for core.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1213
	if ( 'default' === $domain || isset( $l10n_unloaded[ $domain ] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1214
		return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1215
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1216
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1217
	$translation_path = _get_path_to_translation( $domain );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1218
	if ( false === $translation_path ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1219
		return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1220
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1221
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1222
	return load_textdomain( $domain, $translation_path );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1223
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1224
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1225
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1226
 * Gets the path to a translation file for loading a textdomain just in time.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1227
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1228
 * Caches the retrieved results internally.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1229
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1230
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1231
 * @access private
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1232
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1233
 * @see _load_textdomain_just_in_time()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1234
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1235
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1236
 * @param bool   $reset  Whether to reset the internal cache. Used by the switch to locale functionality.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1237
 * @return string|false The path to the translation file or false if no translation file was found.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1238
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1239
function _get_path_to_translation( $domain, $reset = false ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1240
	static $available_translations = array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1241
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1242
	if ( true === $reset ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1243
		$available_translations = array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1244
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1245
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1246
	if ( ! isset( $available_translations[ $domain ] ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1247
		$available_translations[ $domain ] = _get_path_to_translation_from_lang_dir( $domain );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1248
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1249
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1250
	return $available_translations[ $domain ];
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1251
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1252
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1253
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1254
 * Gets the path to a translation file in the languages directory for the current locale.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1255
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1256
 * Holds a cached list of available .mo files to improve performance.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1257
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1258
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1259
 * @access private
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1260
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1261
 * @see _get_path_to_translation()
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1262
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1263
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1264
 * @return string|false The path to the translation file or false if no translation file was found.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1265
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1266
function _get_path_to_translation_from_lang_dir( $domain ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1267
	static $cached_mofiles = null;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1268
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1269
	if ( null === $cached_mofiles ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1270
		$cached_mofiles = array();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1271
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1272
		$locations = array(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1273
			WP_LANG_DIR . '/plugins',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1274
			WP_LANG_DIR . '/themes',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1275
		);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1276
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1277
		foreach ( $locations as $location ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1278
			$mofiles = glob( $location . '/*.mo' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1279
			if ( $mofiles ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1280
				$cached_mofiles = array_merge( $cached_mofiles, $mofiles );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1281
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1282
		}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1283
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1284
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1285
	$locale = determine_locale();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1286
	$mofile = "{$domain}-{$locale}.mo";
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1287
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1288
	$path = WP_LANG_DIR . '/plugins/' . $mofile;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1289
	if ( in_array( $path, $cached_mofiles, true ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1290
		return $path;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1291
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1292
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1293
	$path = WP_LANG_DIR . '/themes/' . $mofile;
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1294
	if ( in_array( $path, $cached_mofiles, true ) ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1295
		return $path;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1296
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1297
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1298
	return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1299
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1300
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1301
/**
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1302
 * Return the Translations instance for a text domain.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1303
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1304
 * If there isn't one, returns empty Translations instance.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1305
 *
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1306
 * @since 2.8.0
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1307
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1308
 * @global MO[] $l10n
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1309
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1310
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1311
 * @return Translations|NOOP_Translations A Translations instance.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1312
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1313
function get_translations_for_domain( $domain ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1314
	global $l10n;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1315
	if ( isset( $l10n[ $domain ] ) || ( _load_textdomain_just_in_time( $domain ) && isset( $l10n[ $domain ] ) ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1316
		return $l10n[ $domain ];
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1317
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1318
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1319
	static $noop_translations = null;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1320
	if ( null === $noop_translations ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1321
		$noop_translations = new NOOP_Translations;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1322
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1323
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1324
	return $noop_translations;
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1325
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1326
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1327
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1328
 * Whether there are translations for the text domain.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1329
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1330
 * @since 3.0.0
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1331
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1332
 * @global MO[] $l10n
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1333
 *
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1334
 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1335
 * @return bool Whether there are translations.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1336
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1337
function is_textdomain_loaded( $domain ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1338
	global $l10n;
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1339
	return isset( $l10n[ $domain ] );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1340
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1341
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1342
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1343
 * Translates role name.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1344
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1345
 * Since the role names are in the database and not in the source there
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1346
 * are dummy gettext calls to get them into the POT file and this function
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1347
 * properly translates them back.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1348
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1349
 * The before_last_bar() call is needed, because older installations keep the roles
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1350
 * using the old context format: 'Role name|User role' and just skipping the
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1351
 * content after the last bar is easier than fixing them in the DB. New installations
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1352
 * won't suffer from that problem.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1353
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1354
 * @since 2.8.0
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1355
 * @since 5.2.0 Added the `$domain` parameter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1356
 *
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1357
 * @param string $name   The role name.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1358
 * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings.
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1359
 *                       Default 'default'.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1360
 * @return string Translated role name on success, original name on failure.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1361
 */
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1362
function translate_user_role( $name, $domain = 'default' ) {
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1363
	return translate_with_gettext_context( before_last_bar( $name ), 'User role', $domain );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1364
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1365
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1366
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1367
 * Get all available languages based on the presence of *.mo files in a given directory.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1368
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1369
 * The default directory is WP_LANG_DIR.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1370
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1371
 * @since 3.0.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1372
 * @since 4.7.0 The results are now filterable with the {@see 'get_available_languages'} filter.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1373
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1374
 * @param string $dir A directory to search for language files.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1375
 *                    Default WP_LANG_DIR.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1376
 * @return string[] An array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1377
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1378
function get_available_languages( $dir = null ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1379
	$languages = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1380
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1381
	$lang_files = glob( ( is_null( $dir ) ? WP_LANG_DIR : $dir ) . '/*.mo' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1382
	if ( $lang_files ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1383
		foreach ( $lang_files as $lang_file ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1384
			$lang_file = basename( $lang_file, '.mo' );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1385
			if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1386
				0 !== strpos( $lang_file, 'admin-' ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1387
				$languages[] = $lang_file;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1388
			}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1389
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1390
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1391
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1392
	/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1393
	 * Filters the list of available language codes.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1394
	 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1395
	 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1396
	 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1397
	 * @param string[] $languages An array of available language codes.
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1398
	 * @param string   $dir       The directory where the language files were found.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1399
	 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1400
	return apply_filters( 'get_available_languages', $languages, $dir );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1401
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1402
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1403
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1404
 * Get installed translations.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1405
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1406
 * Looks in the wp-content/languages directory for translations of
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1407
 * plugins or themes.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1408
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1409
 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1410
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1411
 * @param string $type What to search for. Accepts 'plugins', 'themes', 'core'.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1412
 * @return array Array of language data.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1413
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1414
function wp_get_installed_translations( $type ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1415
	if ( 'themes' !== $type && 'plugins' !== $type && 'core' !== $type ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1416
		return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1417
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1418
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1419
	$dir = 'core' === $type ? '' : "/$type";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1420
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1421
	if ( ! is_dir( WP_LANG_DIR ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1422
		return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1423
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1424
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1425
	if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1426
		return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1427
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1428
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1429
	$files = scandir( WP_LANG_DIR . $dir );
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1430
	if ( ! $files ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1431
		return array();
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1432
	}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1433
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1434
	$language_data = array();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1435
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1436
	foreach ( $files as $file ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1437
		if ( '.' === $file[0] || is_dir( WP_LANG_DIR . "$dir/$file" ) ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1438
			continue;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1439
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1440
		if ( substr( $file, -3 ) !== '.po' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1441
			continue;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1442
		}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1443
		if ( ! preg_match( '/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1444
			continue;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1445
		}
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1446
		if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files, true ) ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1447
			continue;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1448
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1449
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1450
		list( , $textdomain, $language ) = $match;
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1451
		if ( '' === $textdomain ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1452
			$textdomain = 'default';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1453
		}
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1454
		$language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1455
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1456
	return $language_data;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1457
}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1458
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1459
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1460
 * Extract headers from a PO file.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1461
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1462
 * @since 3.7.0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1463
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1464
 * @param string $po_file Path to PO file.
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1465
 * @return string[] Array of PO file header values keyed by header name.
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1466
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1467
function wp_get_pomo_file_data( $po_file ) {
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1468
	$headers = get_file_data(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1469
		$po_file,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1470
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1471
			'POT-Creation-Date'  => '"POT-Creation-Date',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1472
			'PO-Revision-Date'   => '"PO-Revision-Date',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1473
			'Project-Id-Version' => '"Project-Id-Version',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1474
			'X-Generator'        => '"X-Generator',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1475
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1476
	);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1477
	foreach ( $headers as $header => $value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1478
		// Remove possible contextual '\n' and closing double quote.
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1479
		$headers[ $header ] = preg_replace( '~(\\\n)?"$~', '', $value );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1480
	}
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1481
	return $headers;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
  1482
}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1483
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1484
/**
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1485
 * Language selector.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1486
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1487
 * @since 4.0.0
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1488
 * @since 4.3.0 Introduced the `echo` argument.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1489
 * @since 4.7.0 Introduced the `show_option_site_default` argument.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1490
 * @since 5.1.0 Introduced the `show_option_en_us` argument.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1491
 * @since 5.9.0 Introduced the `explicit_option_en_us` argument.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1492
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1493
 * @see get_available_languages()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1494
 * @see wp_get_available_translations()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1495
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1496
 * @param string|array $args {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1497
 *     Optional. Array or string of arguments for outputting the language selector.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1498
 *
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1499
 *     @type string   $id                           ID attribute of the select element. Default 'locale'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1500
 *     @type string   $name                         Name attribute of the select element. Default 'locale'.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1501
 *     @type array    $languages                    List of installed languages, contain only the locales.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1502
 *                                                  Default empty array.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1503
 *     @type array    $translations                 List of available translations. Default result of
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1504
 *                                                  wp_get_available_translations().
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1505
 *     @type string   $selected                     Language which should be selected. Default empty.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1506
 *     @type bool|int $echo                         Whether to echo the generated markup. Accepts 0, 1, or their
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1507
 *                                                  boolean equivalents. Default 1.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1508
 *     @type bool     $show_available_translations  Whether to show available translations. Default true.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1509
 *     @type bool     $show_option_site_default     Whether to show an option to fall back to the site's locale. Default false.
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1510
 *     @type bool     $show_option_en_us            Whether to show an option for English (United States). Default true.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1511
 *     @type bool     $explicit_option_en_us        Whether the English (United States) option uses an explicit value of en_US
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1512
 *                                                  instead of an empty value. Default false.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1513
 * }
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1514
 * @return string HTML dropdown list of languages.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1515
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1516
function wp_dropdown_languages( $args = array() ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1517
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1518
	$parsed_args = wp_parse_args(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1519
		$args,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1520
		array(
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1521
			'id'                          => 'locale',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1522
			'name'                        => 'locale',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1523
			'languages'                   => array(),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1524
			'translations'                => array(),
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1525
			'selected'                    => '',
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1526
			'echo'                        => 1,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1527
			'show_available_translations' => true,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1528
			'show_option_site_default'    => false,
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1529
			'show_option_en_us'           => true,
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1530
			'explicit_option_en_us'       => false,
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1531
		)
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1532
	);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1533
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1534
	// Bail if no ID or no name.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1535
	if ( ! $parsed_args['id'] || ! $parsed_args['name'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1536
		return;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1537
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1538
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1539
	// English (United States) uses an empty string for the value attribute.
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1540
	if ( 'en_US' === $parsed_args['selected'] && ! $parsed_args['explicit_option_en_us'] ) {
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1541
		$parsed_args['selected'] = '';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1542
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1543
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1544
	$translations = $parsed_args['translations'];
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1545
	if ( empty( $translations ) ) {
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1546
		require_once ABSPATH . 'wp-admin/includes/translation-install.php';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1547
		$translations = wp_get_available_translations();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1548
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1549
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1550
	/*
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1551
	 * $parsed_args['languages'] should only contain the locales. Find the locale in
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1552
	 * $translations to get the native name. Fall back to locale.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1553
	 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1554
	$languages = array();
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1555
	foreach ( $parsed_args['languages'] as $locale ) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1556
		if ( isset( $translations[ $locale ] ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1557
			$translation = $translations[ $locale ];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1558
			$languages[] = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1559
				'language'    => $translation['language'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1560
				'native_name' => $translation['native_name'],
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1561
				'lang'        => current( $translation['iso'] ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1562
			);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1563
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1564
			// Remove installed language from available translations.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1565
			unset( $translations[ $locale ] );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1566
		} else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1567
			$languages[] = array(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1568
				'language'    => $locale,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1569
				'native_name' => $locale,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1570
				'lang'        => '',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1571
			);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1572
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1573
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1574
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1575
	$translations_available = ( ! empty( $translations ) && $parsed_args['show_available_translations'] );
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1576
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1577
	// Holds the HTML markup.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1578
	$structure = array();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1579
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1580
	// List installed languages.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1581
	if ( $translations_available ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1582
		$structure[] = '<optgroup label="' . esc_attr_x( 'Installed', 'translations' ) . '">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1583
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1584
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1585
	// Site default.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1586
	if ( $parsed_args['show_option_site_default'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1587
		$structure[] = sprintf(
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1588
			'<option value="site-default" data-installed="1"%s>%s</option>',
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1589
			selected( 'site-default', $parsed_args['selected'], false ),
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1590
			_x( 'Site Default', 'default site language' )
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1591
		);
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1592
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1593
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1594
	if ( $parsed_args['show_option_en_us'] ) {
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1595
		$value       = ( $parsed_args['explicit_option_en_us'] ) ? 'en_US' : '';
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1596
		$structure[] = sprintf(
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1597
			'<option value="%s" lang="en" data-installed="1"%s>English (United States)</option>',
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1598
			esc_attr( $value ),
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1599
			selected( '', $parsed_args['selected'], false )
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1600
		);
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1601
	}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1602
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1603
	// List installed languages.
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1604
	foreach ( $languages as $language ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1605
		$structure[] = sprintf(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1606
			'<option value="%s" lang="%s"%s data-installed="1">%s</option>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1607
			esc_attr( $language['language'] ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1608
			esc_attr( $language['lang'] ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1609
			selected( $language['language'], $parsed_args['selected'], false ),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1610
			esc_html( $language['native_name'] )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1611
		);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1612
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1613
	if ( $translations_available ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1614
		$structure[] = '</optgroup>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1615
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1616
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1617
	// List available translations.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1618
	if ( $translations_available ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1619
		$structure[] = '<optgroup label="' . esc_attr_x( 'Available', 'translations' ) . '">';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1620
		foreach ( $translations as $translation ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1621
			$structure[] = sprintf(
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1622
				'<option value="%s" lang="%s"%s>%s</option>',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1623
				esc_attr( $translation['language'] ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1624
				esc_attr( current( $translation['iso'] ) ),
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1625
				selected( $translation['language'], $parsed_args['selected'], false ),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1626
				esc_html( $translation['native_name'] )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1627
			);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1628
		}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1629
		$structure[] = '</optgroup>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1630
	}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1631
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1632
	// Combine the output string.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1633
	$output  = sprintf( '<select name="%s" id="%s">', esc_attr( $parsed_args['name'] ), esc_attr( $parsed_args['id'] ) );
18
be944660c56a Site enmi version 09/2022
ymh <ymh.work@gmail.com>
parents: 16
diff changeset
  1634
	$output .= implode( "\n", $structure );
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1635
	$output .= '</select>';
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1636
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1637
	if ( $parsed_args['echo'] ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1638
		echo $output;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1639
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1640
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1641
	return $output;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1642
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1643
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1644
/**
9
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1645
 * Determines whether the current locale is right-to-left (RTL).
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1646
 *
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1647
 * For more information on this and similar theme functions, check out
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1648
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
177826044cd9 upgrade wordpress to 5.2.3
ymh <ymh.work@gmail.com>
parents: 7
diff changeset
  1649
 * Conditional Tags} article in the Theme Developer Handbook.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1650
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1651
 * @since 3.0.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1652
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1653
 * @global WP_Locale $wp_locale WordPress date and time locale object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1654
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1655
 * @return bool Whether locale is RTL.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1656
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1657
function is_rtl() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1658
	global $wp_locale;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1659
	if ( ! ( $wp_locale instanceof WP_Locale ) ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1660
		return false;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1661
	}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1662
	return $wp_locale->is_rtl();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1663
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1664
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1665
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1666
 * Switches the translations according to the given locale.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1667
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1668
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1669
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1670
 * @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1671
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1672
 * @param string $locale The locale.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1673
 * @return bool True on success, false on failure.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1674
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1675
function switch_to_locale( $locale ) {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1676
	/* @var WP_Locale_Switcher $wp_locale_switcher */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1677
	global $wp_locale_switcher;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1678
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1679
	return $wp_locale_switcher->switch_to_locale( $locale );
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1680
}
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1681
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1682
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1683
 * Restores the translations according to the previous locale.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1684
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1685
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1686
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1687
 * @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1688
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1689
 * @return string|false Locale on success, false on error.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1690
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1691
function restore_previous_locale() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1692
	/* @var WP_Locale_Switcher $wp_locale_switcher */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1693
	global $wp_locale_switcher;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1694
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1695
	return $wp_locale_switcher->restore_previous_locale();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1696
}
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1697
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1698
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1699
 * Restores the translations according to the original locale.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1700
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1701
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1702
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1703
 * @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1704
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1705
 * @return string|false Locale on success, false on error.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1706
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1707
function restore_current_locale() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1708
	/* @var WP_Locale_Switcher $wp_locale_switcher */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1709
	global $wp_locale_switcher;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1710
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1711
	return $wp_locale_switcher->restore_current_locale();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1712
}
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1713
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1714
/**
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1715
 * Whether switch_to_locale() is in effect.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1716
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1717
 * @since 4.7.0
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1718
 *
16
a86126ab1dd4 update enmi-conf
ymh <ymh.work@gmail.com>
parents: 9
diff changeset
  1719
 * @global WP_Locale_Switcher $wp_locale_switcher WordPress locale switcher object.
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1720
 *
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1721
 * @return bool True if the locale has been switched, false otherwise.
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1722
 */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1723
function is_locale_switched() {
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1724
	/* @var WP_Locale_Switcher $wp_locale_switcher */
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1725
	global $wp_locale_switcher;
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1726
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1727
	return $wp_locale_switcher->is_switched();
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
  1728
}
19
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1729
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1730
/**
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1731
 * Translates the provided settings value using its i18n schema.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1732
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1733
 * @since 5.9.0
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1734
 * @access private
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1735
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1736
 * @param string|string[]|array[]|object $i18n_schema I18n schema for the setting.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1737
 * @param string|string[]|array[]        $settings    Value for the settings.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1738
 * @param string                         $textdomain  Textdomain to use with translations.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1739
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1740
 * @return string|string[]|array[] Translated settings.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1741
 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1742
function translate_settings_using_i18n_schema( $i18n_schema, $settings, $textdomain ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1743
	if ( empty( $i18n_schema ) || empty( $settings ) || empty( $textdomain ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1744
		return $settings;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1745
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1746
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1747
	if ( is_string( $i18n_schema ) && is_string( $settings ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1748
		return translate_with_gettext_context( $settings, $i18n_schema, $textdomain );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1749
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1750
	if ( is_array( $i18n_schema ) && is_array( $settings ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1751
		$translated_settings = array();
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1752
		foreach ( $settings as $value ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1753
			$translated_settings[] = translate_settings_using_i18n_schema( $i18n_schema[0], $value, $textdomain );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1754
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1755
		return $translated_settings;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1756
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1757
	if ( is_object( $i18n_schema ) && is_array( $settings ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1758
		$group_key           = '*';
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1759
		$translated_settings = array();
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1760
		foreach ( $settings as $key => $value ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1761
			if ( isset( $i18n_schema->$key ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1762
				$translated_settings[ $key ] = translate_settings_using_i18n_schema( $i18n_schema->$key, $value, $textdomain );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1763
			} elseif ( isset( $i18n_schema->$group_key ) ) {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1764
				$translated_settings[ $key ] = translate_settings_using_i18n_schema( $i18n_schema->$group_key, $value, $textdomain );
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1765
			} else {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1766
				$translated_settings[ $key ] = $value;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1767
			}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1768
		}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1769
		return $translated_settings;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1770
	}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1771
	return $settings;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1772
}
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1773
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1774
/**
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1775
 * Retrieves the list item separator based on the locale.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1776
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1777
 * @since 6.0.0
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1778
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1779
 * @global WP_Locale $wp_locale WordPress date and time locale object.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1780
 *
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1781
 * @return string Locale-specific list item separator.
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1782
 */
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1783
function wp_get_list_item_separator() {
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1784
	global $wp_locale;
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1785
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1786
	return $wp_locale->get_list_item_separator();
3d72ae0968f4 upgrade wordpress to 6.0.2
ymh <ymh.work@gmail.com>
parents: 18
diff changeset
  1787
}