PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.4.0-beta2
Secure Custom Fields v6.4.0-beta2
6.9.5 6.9.4 6.9.3 6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / l10n.php
secure-custom-fields / includes Last commit date
Blocks 1 year ago admin 1 year ago ajax 1 year ago api 1 year ago fields 1 year ago forms 1 year ago legacy 1 year ago locations 1 year ago post-types 1 year ago rest-api 1 year ago walkers 1 year ago acf-bidirectional-functions.php 1 year ago acf-field-functions.php 1 year ago acf-field-group-functions.php 1 year ago acf-form-functions.php 1 year ago acf-helper-functions.php 1 year ago acf-hook-functions.php 1 year ago acf-input-functions.php 1 year ago acf-internal-post-type-functions.php 1 year ago acf-meta-functions.php 1 year ago acf-post-functions.php 1 year ago acf-post-type-functions.php 1 year ago acf-taxonomy-functions.php 1 year ago acf-user-functions.php 1 year ago acf-utility-functions.php 1 year ago acf-value-functions.php 1 year ago acf-wp-functions.php 1 year ago assets.php 1 year ago class-acf-data.php 1 year ago class-acf-internal-post-type.php 1 year ago class-acf-site-health.php 1 year ago compatibility.php 1 year ago deprecated.php 1 year ago fields.php 1 year ago index.php 1 year ago l10n.php 1 year ago local-fields.php 1 year ago local-json.php 1 year ago local-meta.php 1 year ago locations.php 1 year ago loop.php 1 year ago media.php 1 year ago rest-api.php 1 year ago revisions.php 1 year ago third-party.php 1 year ago upgrades.php 1 year ago validation.php 1 year ago wpml.php 1 year ago
l10n.php
148 lines
1 <?php
2
3 /**
4 * Determine the current locale desired for the request.
5 *
6 * @since 5.0.0
7 *
8 * @global string $pagenow
9 *
10 * @return string The determined locale.
11 */
12 if ( ! function_exists( 'determine_locale' ) ) :
13 function determine_locale() {
14 /**
15 * Filters the locale for the current request prior to the default determination process.
16 *
17 * Using this filter allows to override the default logic, effectively short-circuiting the function.
18 *
19 * @since 5.0.0
20 *
21 * @param string|null The locale to return and short-circuit, or null as default.
22 */
23 $determined_locale = apply_filters( 'pre_determine_locale', null );
24 if ( ! empty( $determined_locale ) && is_string( $determined_locale ) ) {
25 return $determined_locale;
26 }
27
28 $determined_locale = get_locale();
29
30 if ( function_exists( 'get_user_locale' ) && is_admin() ) {
31 $determined_locale = get_user_locale();
32 }
33
34 // phpcs:disable WordPress.Security.NonceVerification.Recommended -- Copied from WordPress core.
35 if ( function_exists( 'get_user_locale' ) && isset( $_GET['_locale'] ) && 'user' === $_GET['_locale'] ) {
36 $determined_locale = get_user_locale();
37 }
38
39 if ( ! empty( $_GET['wp_lang'] ) && ! empty( $GLOBALS['pagenow'] ) && 'wp-login.php' === $GLOBALS['pagenow'] ) {
40 $determined_locale = sanitize_text_field( $_GET['wp_lang'] );
41 }
42 // phpcs:enable WordPress.Security.NonceVerification.Recommended
43
44 /**
45 * Filters the locale for the current request.
46 *
47 * @since 5.0.0
48 *
49 * @param string $locale The locale.
50 */
51 return apply_filters( 'determine_locale', $determined_locale );
52 }
53 endif;
54
55 /**
56 * Returns the current locale.
57 *
58 * @date 16/12/16
59 * @since 5.5.0
60 *
61 * @param void
62 * @return string
63 */
64 function acf_get_locale() {
65
66 // Determine local.
67 $locale = determine_locale();
68
69 // Fallback to parent language for regions without translation.
70 // https://wpastra.com/docs/complete-list-wordpress-locale-codes/
71 $langs = array(
72 'az_TR' => 'az', // Azerbaijani (Turkey)
73 'zh_HK' => 'zh_TW', // Chinese (Hong Kong)
74 'fr_BE' => 'fr_FR', // French (Belgium)
75 'nn_NO' => 'nb_NO', // Norwegian (Nynorsk)
76 'fa_AF' => 'fa_IR', // Persian (Afghanistan)
77 'ru_UA' => 'ru_RU', // Russian (Ukraine)
78 );
79 if ( isset( $langs[ $locale ] ) ) {
80 $locale = $langs[ $locale ];
81 }
82
83 /**
84 * Filters the determined local.
85 *
86 * @date 8/1/19
87 * @since 5.7.10
88 *
89 * @param string $locale The local.
90 */
91 return apply_filters( 'acf/get_locale', $locale );
92 }
93
94 /**
95 * acf_load_textdomain
96 *
97 * Loads the plugin's translated strings similar to load_plugin_textdomain().
98 *
99 * @date 8/1/19
100 * @since 5.7.10
101 *
102 * @param string $locale The plugin's current locale.
103 * @return void
104 */
105 function acf_load_textdomain( $domain = 'acf' ) {
106
107 /**
108 * Filters a plugin's locale.
109 *
110 * @date 8/1/19
111 * @since 5.7.10
112 *
113 * @param string $locale The plugin's current locale.
114 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
115 */
116 $locale = apply_filters( 'plugin_locale', acf_get_locale(), $domain );
117 $mofile = $domain . '-' . $locale . '.mo';
118
119 // Load from plugin lang folder.
120 return load_textdomain( $domain, acf_get_path( 'lang/' . $mofile ) );
121 }
122
123 /**
124 * _acf_apply_language_cache_key
125 *
126 * Applies the current language to the cache key.
127 *
128 * @date 23/1/19
129 * @since 5.7.11
130 *
131 * @param string $key The cache key.
132 * @return string
133 */
134 function _acf_apply_language_cache_key( $key ) {
135
136 // Get current language.
137 $current_language = acf_get_setting( 'current_language' );
138 if ( $current_language ) {
139 $key = "{$key}:{$current_language}";
140 }
141
142 // Return key.
143 return $key;
144 }
145
146 // Hook into filter.
147 add_filter( 'acf/get_cache_key', '_acf_apply_language_cache_key' );
148