PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / trunk
Secure Custom Fields vtrunk
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 week ago Datastore 1 month ago Meta 1 year ago abilities 1 week ago admin 1 week ago ajax 1 month ago api 4 hours ago fields 4 hours ago forms 4 hours ago legacy 1 year ago locations 1 year ago post-types 2 months ago rest-api 1 week ago walkers 1 year ago acf-bidirectional-functions.php 1 year ago acf-field-functions.php 2 months ago acf-field-group-functions.php 7 months 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 7 months ago acf-internal-post-type-functions.php 7 months ago acf-meta-functions.php 2 weeks 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 week ago acf-utility-functions.php 1 year ago acf-value-functions.php 1 year ago acf-wp-functions.php 4 hours ago assets.php 1 week ago blocks-auto-inline-editing.php 2 months ago blocks.php 3 weeks ago class-acf-data.php 10 months ago class-acf-internal-post-type.php 1 week ago class-acf-options-page.php 1 year ago class-acf-site-health.php 3 months ago class-scf-json-schema-validator.php 6 months ago class-scf-schema-builder.php 2 months ago compatibility.php 1 year ago datastore.php 1 month ago deprecated.php 1 year ago fields.php 10 months ago index.php 1 year ago l10n.php 1 year ago local-fields.php 1 year ago local-json.php 1 month ago local-meta.php 1 year ago locations.php 1 year ago loop.php 10 months ago media.php 1 year ago rest-api.php 10 months ago revisions.php 1 month ago scf-ui-options-page-functions.php 1 year ago third-party.php 7 months ago upgrades.php 2 weeks ago validation.php 10 months ago wpml.php 1 year ago
l10n.php
147 lines
1 <?php
2
3 /**
4 * Determine the current locale desired for the request.
5 *
6 * @since ACF 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 ACF 5.0.0
20 *
21 * @param string|null $determined_locale 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 ACF 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 ACF 5.5.0
60 *
61 * @return string
62 */
63 function acf_get_locale() {
64
65 // Determine local.
66 $locale = determine_locale();
67
68 // Fallback to parent language for regions without translation.
69 // https://wpastra.com/docs/complete-list-wordpress-locale-codes/
70 $langs = array(
71 'az_TR' => 'az', // Azerbaijani (Turkey)
72 'zh_HK' => 'zh_TW', // Chinese (Hong Kong)
73 'fr_BE' => 'fr_FR', // French (Belgium)
74 'nn_NO' => 'nb_NO', // Norwegian (Nynorsk)
75 'fa_AF' => 'fa_IR', // Persian (Afghanistan)
76 'ru_UA' => 'ru_RU', // Russian (Ukraine)
77 );
78 if ( isset( $langs[ $locale ] ) ) {
79 $locale = $langs[ $locale ];
80 }
81
82 /**
83 * Filters the determined local.
84 *
85 * @date 8/1/19
86 * @since ACF 5.7.10
87 *
88 * @param string $locale The local.
89 */
90 return apply_filters( 'acf/get_locale', $locale );
91 }
92
93 /**
94 * acf_load_textdomain
95 *
96 * Loads the plugin's translated strings similar to load_plugin_textdomain().
97 *
98 * @date 8/1/19
99 * @since ACF 5.7.10
100 *
101 * @param string $locale The plugin's current locale.
102 * @return void
103 */
104 function acf_load_textdomain( $domain = 'secure-custom-fields' ) {
105
106 /**
107 * Filters a plugin's locale.
108 *
109 * @date 8/1/19
110 * @since ACF 5.7.10
111 *
112 * @param string $locale The plugin's current locale.
113 * @param string $domain Text domain. Unique identifier for retrieving translated strings.
114 */
115 $locale = apply_filters( 'plugin_locale', acf_get_locale(), $domain );
116 $mofile = $domain . '-' . $locale . '.mo';
117
118 // Load from plugin lang folder.
119 return load_textdomain( $domain, acf_get_path( 'lang/' . $mofile ) );
120 }
121
122 /**
123 * _acf_apply_language_cache_key
124 *
125 * Applies the current language to the cache key.
126 *
127 * @date 23/1/19
128 * @since ACF 5.7.11
129 *
130 * @param string $key The cache key.
131 * @return string
132 */
133 function _acf_apply_language_cache_key( $key ) {
134
135 // Get current language.
136 $current_language = acf_get_setting( 'current_language' );
137 if ( $current_language ) {
138 $key = "{$key}:{$current_language}";
139 }
140
141 // Return key.
142 return $key;
143 }
144
145 // Hook into filter.
146 add_filter( 'acf/get_cache_key', '_acf_apply_language_cache_key' );
147