run:R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:52
R W Run
DIR
2026-03-11 16:18:51
R W Run
DIR
2026-03-11 16:18:51
R W Run
23.8 KB
2026-03-11 16:18:51
R W Run
7.8 KB
2026-03-11 16:18:52
R W Run
36.1 KB
2026-03-11 16:18:51
R W Run
11.9 KB
2026-03-11 16:18:52
R W Run
18.94 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:52
R W Run
28.6 KB
2026-03-11 16:18:51
R W Run
316 By
2026-03-11 16:18:51
R W Run
12.9 KB
2026-03-11 16:18:51
R W Run
61.02 KB
2026-03-11 16:18:52
R W Run
15 KB
2026-03-11 16:18:51
R W Run
112.05 KB
2026-03-11 16:18:51
R W Run
12.47 KB
2026-03-11 16:18:51
R W Run
15.07 KB
2026-03-11 16:18:52
R W Run
9.84 KB
2026-03-11 16:18:52
R W Run
13.17 KB
2026-03-11 16:18:52
R W Run
33.83 KB
2026-03-11 16:18:51
R W Run
42.63 KB
2026-03-11 16:18:51
R W Run
55.71 KB
2026-03-11 16:18:52
R W Run
12.53 KB
2026-03-11 16:18:51
R W Run
2.55 KB
2026-03-11 16:18:52
R W Run
28.92 KB
2026-03-11 16:18:52
R W Run
539 By
2026-03-11 16:18:51
R W Run
367 By
2026-03-11 16:18:52
R W Run
42.65 KB
2026-03-11 16:18:51
R W Run
401 By
2026-03-11 16:18:51
R W Run
6.61 KB
2026-03-11 16:18:51
R W Run
664 By
2026-03-11 16:18:52
R W Run
20.63 KB
2026-03-11 16:18:51
R W Run
2.18 KB
2026-03-11 16:18:52
R W Run
453 By
2026-03-11 16:18:52
R W Run
457 By
2026-03-11 16:18:51
R W Run
36.83 KB
2026-03-11 16:18:52
R W Run
2.41 KB
2026-03-11 16:18:52
R W Run
8.28 KB
2026-03-11 16:18:51
R W Run
13.89 KB
2026-03-11 16:18:51
R W Run
11.76 KB
2026-03-11 16:18:51
R W Run
2.65 KB
2026-03-11 16:18:51
R W Run
7.43 KB
2026-03-11 16:18:51
R W Run
17.46 KB
2026-03-11 16:18:51
R W Run
5.14 KB
2026-03-11 16:18:52
R W Run
16.7 KB
2026-03-11 16:18:51
R W Run
8.28 KB
2026-03-11 16:18:52
R W Run
2.92 KB
2026-03-11 16:18:52
R W Run
1.32 KB
2026-03-11 16:18:51
R W Run
4.6 KB
2026-03-11 16:18:52
R W Run
11.62 KB
2026-03-11 16:18:52
R W Run
2.5 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
11.25 KB
2026-03-11 16:18:52
R W Run
5.32 KB
2026-03-11 16:18:51
R W Run
10.99 KB
2026-03-11 16:18:52
R W Run
68.32 KB
2026-03-11 16:18:51
R W Run
6.34 KB
2026-03-11 16:18:51
R W Run
5.49 KB
2026-03-11 16:18:51
R W Run
1.99 KB
2026-03-11 16:18:52
R W Run
7.02 KB
2026-03-11 16:18:51
R W Run
4.91 KB
2026-03-11 16:18:52
R W Run
16.86 KB
2026-03-11 16:18:51
R W Run
24.23 KB
2026-03-11 16:18:51
R W Run
3.97 KB
2026-03-11 16:18:51
R W Run
47.66 KB
2026-03-11 16:18:51
R W Run
9.22 KB
2026-03-11 16:18:51
R W Run
25.51 KB
2026-03-11 16:18:51
R W Run
198.38 KB
2026-03-11 16:18:52
R W Run
56.65 KB
2026-03-11 16:18:51
R W Run
10.46 KB
2026-03-11 16:18:51
R W Run
10.95 KB
2026-03-11 16:18:52
R W Run
29.26 KB
2026-03-11 16:18:51
R W Run
70.91 KB
2026-03-11 16:18:52
R W Run
35.3 KB
2026-03-11 16:18:52
R W Run
16.61 KB
2026-03-11 16:18:52
R W Run
2.57 KB
2026-03-11 16:18:52
R W Run
39.83 KB
2026-03-11 16:18:51
R W Run
70.64 KB
2026-03-11 16:18:51
R W Run
15.56 KB
2026-03-11 16:18:52
R W Run
7.33 KB
2026-03-11 16:18:52
R W Run
253 By
2026-03-11 16:18:51
R W Run
7.96 KB
2026-03-11 16:18:52
R W Run
3.23 KB
2026-03-11 16:18:52
R W Run
969 By
2026-03-11 16:18:52
R W Run
16.28 KB
2026-03-11 16:18:51
R W Run
7.22 KB
2026-03-11 16:18:51
R W Run
12.95 KB
2026-03-11 16:18:51
R W Run
6.53 KB
2026-03-11 16:18:51
R W Run
3.42 KB
2026-03-11 16:18:52
R W Run
5.84 KB
2026-03-11 16:18:51
R W Run
1.97 KB
2026-03-11 16:18:51
R W Run
4.3 KB
2026-03-11 16:18:52
R W Run
2.91 KB
2026-03-11 16:18:51
R W Run
16.46 KB
2026-03-11 16:18:52
R W Run
40.6 KB
2026-03-11 16:18:51
R W Run
20.22 KB
2026-03-11 16:18:51
R W Run
36.11 KB
2026-03-11 16:18:52
R W Run
17.01 KB
2026-03-11 16:18:51
R W Run
7.27 KB
2026-03-11 16:18:52
R W Run
6.62 KB
2026-03-11 16:18:52
R W Run
16.49 KB
2026-03-11 16:18:52
R W Run
1.79 KB
2026-03-11 16:18:52
R W Run
29.82 KB
2026-03-11 16:18:51
R W Run
6.67 KB
2026-03-11 16:18:52
R W Run
8.98 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:51
R W Run
12.01 KB
2026-03-11 16:18:51
R W Run
17.11 KB
2026-03-11 16:18:51
R W Run
6.74 KB
2026-03-11 16:18:52
R W Run
30.93 KB
2026-03-11 16:18:51
R W Run
4.99 KB
2026-03-11 16:18:51
R W Run
4.25 KB
2026-03-11 16:18:51
R W Run
24.72 KB
2026-03-11 16:18:51
R W Run
29.96 KB
2026-03-11 16:18:52
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
160 KB
2026-03-11 16:18:51
R W Run
6.72 KB
2026-03-11 16:18:52
R W Run
10.92 KB
2026-03-11 16:18:51
R W Run
4.77 KB
2026-03-11 16:18:51
R W Run
3.38 KB
2026-03-11 16:18:51
R W Run
11.18 KB
2026-03-11 16:18:51
R W Run
62.19 KB
2026-03-11 16:18:51
R W Run
2.46 KB
2026-03-11 16:18:51
R W Run
9.17 KB
2026-03-11 16:18:51
R W Run
32.15 KB
2026-03-11 16:18:51
R W Run
34.05 KB
2026-03-11 16:18:52
R W Run
7.15 KB
2026-03-11 16:18:51
R W Run
3.47 KB
2026-03-11 16:18:52
R W Run
1.87 KB
2026-03-11 16:18:52
R W Run
30.91 KB
2026-03-11 16:18:51
R W Run
7.29 KB
2026-03-11 16:18:52
R W Run
7.35 KB
2026-03-11 16:18:51
R W Run
12.54 KB
2026-03-11 16:18:51
R W Run
19.12 KB
2026-03-11 16:18:51
R W Run
18.12 KB
2026-03-11 16:18:52
R W Run
39.99 KB
2026-03-11 16:18:52
R W Run
5.17 KB
2026-03-11 16:18:52
R W Run
979 By
2026-03-11 16:18:51
R W Run
18.44 KB
2026-03-11 16:18:52
R W Run
10.24 KB
2026-03-11 16:18:51
R W Run
1.77 KB
2026-03-11 16:18:52
R W Run
34.9 KB
2026-03-11 16:18:51
R W Run
7.19 KB
2026-03-11 16:18:52
R W Run
160.5 KB
2026-03-11 16:18:51
R W Run
64.27 KB
2026-03-11 16:18:51
R W Run
27.95 KB
2026-03-11 16:18:51
R W Run
4.69 KB
2026-03-11 16:18:51
R W Run
2.94 KB
2026-03-11 16:18:51
R W Run
43.13 KB
2026-03-11 16:18:52
R W Run
2.25 KB
2026-03-11 16:18:52
R W Run
22.5 KB
2026-03-11 16:18:51
R W Run
13.01 KB
2026-03-11 16:18:52
R W Run
3.27 KB
2026-03-11 16:18:51
R W Run
18 KB
2026-03-11 16:18:51
R W Run
210.4 KB
2026-03-11 16:18:52
R W Run
25.86 KB
2026-03-11 16:18:52
R W Run
115.85 KB
2026-03-11 16:18:51
R W Run
373 By
2026-03-11 16:18:52
R W Run
343 By
2026-03-11 16:18:52
R W Run
338 By
2026-03-11 16:18:51
R W Run
100.73 KB
2026-03-11 16:18:52
R W Run
130.93 KB
2026-03-11 16:18:51
R W Run
19.1 KB
2026-03-11 16:18:51
R W Run
17.41 KB
2026-03-11 16:18:52
R W Run
41.98 KB
2026-03-11 16:18:52
R W Run
400 By
2026-03-11 16:18:52
R W Run
11.1 KB
2026-03-11 16:18:52
R W Run
37.02 KB
2026-03-11 16:18:51
R W Run
2.24 KB
2026-03-11 16:18:51
R W Run
188.13 KB
2026-03-11 16:18:51
R W Run
338 By
2026-03-11 16:18:51
R W Run
38 KB
2026-03-11 16:18:51
R W Run
4.02 KB
2026-03-11 16:18:52
R W Run
5.38 KB
2026-03-11 16:18:51
R W Run
3.05 KB
2026-03-11 16:18:52
R W Run
2.61 KB
2026-03-11 16:18:51
R W Run
1.16 KB
2026-03-11 16:18:52
R W Run
4.04 KB
2026-03-11 16:18:51
R W Run
3.71 KB
2026-03-11 16:18:51
R W Run
24.6 KB
2026-03-11 16:18:51
R W Run
9.56 KB
2026-03-11 16:18:51
R W Run
346.43 KB
2026-03-11 16:18:52
R W Run
281.84 KB
2026-03-11 16:18:52
R W Run
14.95 KB
2026-03-11 16:18:51
R W Run
8.44 KB
2026-03-11 16:18:52
R W Run
168.95 KB
2026-03-11 16:18:52
R W Run
20.71 KB
2026-03-11 16:18:52
R W Run
25.27 KB
2026-03-11 16:18:51
R W Run
5.72 KB
2026-03-11 16:18:51
R W Run
4.63 KB
2026-03-11 16:18:52
R W Run
81.73 KB
2026-03-11 16:18:51
R W Run
67.18 KB
2026-03-11 16:18:51
R W Run
156.36 KB
2026-03-11 16:18:52
R W Run
55.19 KB
2026-03-11 16:18:51
R W Run
162 By
2026-03-11 16:18:51
R W Run
61.72 KB
2026-03-11 16:18:51
R W Run
216.06 KB
2026-03-11 16:18:52
R W Run
65.09 KB
2026-03-11 16:18:51
R W Run
25.24 KB
2026-03-11 16:18:52
R W Run
4.81 KB
2026-03-11 16:18:51
R W Run
6.48 KB
2026-03-11 16:18:52
R W Run
21.25 KB
2026-03-11 16:18:51
R W Run
2.79 KB
2026-03-11 16:18:52
R W Run
89.69 KB
2026-03-11 16:18:52
R W Run
19.42 KB
2026-03-11 16:18:52
R W Run
3.69 KB
2026-03-11 16:18:52
R W Run
4.11 KB
2026-03-11 16:18:51
R W Run
40.74 KB
2026-03-11 16:18:51
R W Run
25.38 KB
2026-03-11 16:18:51
R W Run
43.31 KB
2026-03-11 16:18:52
R W Run
102.57 KB
2026-03-11 16:18:52
R W Run
6.18 KB
2026-03-11 16:18:51
R W Run
124.47 KB
2026-03-11 16:18:52
R W Run
35.65 KB
2026-03-11 16:18:52
R W Run
6.94 KB
2026-03-11 16:18:52
R W Run
67.04 KB
2026-03-11 16:18:52
R W Run
10.62 KB
2026-03-11 16:18:51
R W Run
289.35 KB
2026-03-11 16:18:52
R W Run
36.23 KB
2026-03-11 16:18:51
R W Run
200 By
2026-03-11 16:18:52
R W Run
200 By
2026-03-11 16:18:52
R W Run
98.29 KB
2026-03-11 16:18:52
R W Run
30.02 KB
2026-03-11 16:18:52
R W Run
19.03 KB
2026-03-11 16:18:52
R W Run
5.06 KB
2026-03-11 16:18:52
R W Run
255 By
2026-03-11 16:18:51
R W Run
22.66 KB
2026-03-11 16:18:52
R W Run
154.63 KB
2026-03-11 16:18:51
R W Run
9.68 KB
2026-03-11 16:18:51
R W Run
258 By
2026-03-11 16:18:51
R W Run
23.49 KB
2026-03-11 16:18:51
R W Run
3.16 KB
2026-03-11 16:18:51
R W Run
8.4 KB
2026-03-11 16:18:52
R W Run
441 By
2026-03-11 16:18:51
R W Run
7.39 KB
2026-03-11 16:18:51
R W Run
173 KB
2026-03-11 16:18:52
R W Run
544 By
2026-03-11 16:18:52
R W Run
4.17 KB
2026-03-11 16:18:51
R W Run
35.97 KB
2026-03-11 16:18:52
R W Run
1.69 KB
2026-03-11 16:18:51
R W Run
2.84 KB
2026-03-11 16:18:52
R W Run
6.09 KB
2026-03-11 16:18:51
R W Run
8.71 KB
2026-03-11 16:18:51
R W Run
131.84 KB
2026-03-11 16:18:51
R W Run
37.45 KB
2026-03-11 16:18:51
R W Run
173.89 KB
2026-03-11 16:18:51
R W Run
7.09 KB
2026-03-11 16:18:51
R W Run
6.41 KB
2026-03-11 16:18:51
R W Run
1.08 KB
2026-03-11 16:18:51
R W Run
69.46 KB
2026-03-11 16:18:52
R W Run
445 By
2026-03-11 16:18:51
R W Run
799 By
2026-03-11 16:18:52
R W Run
error_log
📄class-wp-textdomain-registry.php
1<?php
2/**
3 * Locale API: WP_Textdomain_Registry class.
4 *
5 * This file uses rtrim() instead of untrailingslashit() and trailingslashit()
6 * to avoid formatting.php dependency.
7 *
8 * @package WordPress
9 * @subpackage i18n
10 * @since 6.1.0
11 */
12
13/**
14 * Core class used for registering text domains.
15 *
16 * @since 6.1.0
17 */
18#[AllowDynamicProperties]
19class WP_Textdomain_Registry {
20 /**
21 * List of domains and all their language directory paths for each locale.
22 *
23 * @since 6.1.0
24 *
25 * @var array
26 */
27 protected $all = array();
28
29 /**
30 * List of domains and their language directory path for the current (most recent) locale.
31 *
32 * @since 6.1.0
33 *
34 * @var array
35 */
36 protected $current = array();
37
38 /**
39 * List of domains and their custom language directory paths.
40 *
41 * @see load_plugin_textdomain()
42 * @see load_theme_textdomain()
43 *
44 * @since 6.1.0
45 *
46 * @var array
47 */
48 protected $custom_paths = array();
49
50 /**
51 * Holds a cached list of available .mo files to improve performance.
52 *
53 * @since 6.1.0
54 * @since 6.5.0 This property is no longer used.
55 *
56 * @var array
57 *
58 * @deprecated
59 */
60 protected $cached_mo_files = array();
61
62 /**
63 * Holds a cached list of domains with translations to improve performance.
64 *
65 * @since 6.2.0
66 *
67 * @var string[]
68 */
69 protected $domains_with_translations = array();
70
71 /**
72 * Initializes the registry.
73 *
74 * Hooks into the {@see 'upgrader_process_complete'} filter
75 * to invalidate MO files caches.
76 *
77 * @since 6.5.0
78 */
79 public function init() {
80 add_action( 'upgrader_process_complete', array( $this, 'invalidate_mo_files_cache' ), 10, 2 );
81 }
82
83 /**
84 * Returns the languages directory path for a specific domain and locale.
85 *
86 * @since 6.1.0
87 *
88 * @param string $domain Text domain.
89 * @param string $locale Locale.
90 *
91 * @return string|false Languages directory path or false if there is none available.
92 */
93 public function get( $domain, $locale ) {
94 $path = $this->all[ $domain ][ $locale ] ?? $this->get_path_from_lang_dir( $domain, $locale );
95
96 /**
97 * Filters the determined languages directory path for a specific domain and locale.
98 *
99 * @since 6.6.0
100 *
101 * @param string|false $path Languages directory path for the given domain and locale.
102 * @param string $domain Text domain.
103 * @param string $locale Locale.
104 */
105 return apply_filters( 'lang_dir_for_domain', $path, $domain, $locale );
106 }
107
108 /**
109 * Determines whether any MO file paths are available for the domain.
110 *
111 * This is the case if a path has been set for the current locale,
112 * or if there is no information stored yet, in which case
113 * {@see _load_textdomain_just_in_time()} will fetch the information first.
114 *
115 * @since 6.1.0
116 *
117 * @param string $domain Text domain.
118 * @return bool Whether any MO file paths are available for the domain.
119 */
120 public function has( $domain ) {
121 return (
122 isset( $this->current[ $domain ] ) ||
123 empty( $this->all[ $domain ] ) ||
124 in_array( $domain, $this->domains_with_translations, true )
125 );
126 }
127
128 /**
129 * Sets the language directory path for a specific domain and locale.
130 *
131 * Also sets the 'current' property for direct access
132 * to the path for the current (most recent) locale.
133 *
134 * @since 6.1.0
135 *
136 * @param string $domain Text domain.
137 * @param string $locale Locale.
138 * @param string|false $path Language directory path or false if there is none available.
139 */
140 public function set( $domain, $locale, $path ) {
141 $this->all[ $domain ][ $locale ] = $path ? rtrim( $path, '/' ) . '/' : false;
142 $this->current[ $domain ] = $this->all[ $domain ][ $locale ];
143 }
144
145 /**
146 * Sets the custom path to the plugin's/theme's languages directory.
147 *
148 * Used by {@see load_plugin_textdomain()} and {@see load_theme_textdomain()}.
149 *
150 * @since 6.1.0
151 *
152 * @param string $domain Text domain.
153 * @param string $path Language directory path.
154 */
155 public function set_custom_path( $domain, $path ) {
156 // If just-in-time loading was triggered before, reset the entry so it can be tried again.
157
158 if ( isset( $this->all[ $domain ] ) ) {
159 $this->all[ $domain ] = array_filter( $this->all[ $domain ] );
160 }
161
162 if ( empty( $this->current[ $domain ] ) ) {
163 unset( $this->current[ $domain ] );
164 }
165
166 $this->custom_paths[ $domain ] = rtrim( $path, '/' );
167 }
168
169 /**
170 * Retrieves translation files from the specified path.
171 *
172 * Allows early retrieval through the {@see 'pre_get_mo_files_from_path'} filter to optimize
173 * performance, especially in directories with many files.
174 *
175 * @since 6.5.0
176 *
177 * @param string $path The directory path to search for translation files.
178 * @return array Array of translation file paths. Can contain .mo and .l10n.php files.
179 */
180 public function get_language_files_from_path( $path ) {
181 $path = rtrim( $path, '/' ) . '/';
182
183 /**
184 * Filters the translation files retrieved from a specified path before the actual lookup.
185 *
186 * Returning a non-null value from the filter will effectively short-circuit
187 * the MO files lookup, returning that value instead.
188 *
189 * This can be useful in situations where the directory contains a large number of files
190 * and the default glob() function becomes expensive in terms of performance.
191 *
192 * @since 6.5.0
193 *
194 * @param null|array $files List of translation files. Default null.
195 * @param string $path The path from which translation files are being fetched.
196 */
197 $files = apply_filters( 'pre_get_language_files_from_path', null, $path );
198
199 if ( null !== $files ) {
200 return $files;
201 }
202
203 $cache_key = md5( $path );
204 $files = wp_cache_get( $cache_key, 'translation_files' );
205
206 if ( false === $files ) {
207 $files = glob( $path . '*.mo' );
208 if ( false === $files ) {
209 $files = array();
210 }
211
212 $php_files = glob( $path . '*.l10n.php' );
213 if ( is_array( $php_files ) ) {
214 $files = array_merge( $files, $php_files );
215 }
216
217 wp_cache_set( $cache_key, $files, 'translation_files', HOUR_IN_SECONDS );
218 }
219
220 return $files;
221 }
222
223 /**
224 * Invalidate the cache for .mo files.
225 *
226 * This function deletes the cache entries related to .mo files when triggered
227 * by specific actions, such as the completion of an upgrade process.
228 *
229 * @since 6.5.0
230 *
231 * @param WP_Upgrader $upgrader Unused. WP_Upgrader instance. In other contexts this might be a
232 * Theme_Upgrader, Plugin_Upgrader, Core_Upgrade, or Language_Pack_Upgrader instance.
233 * @param array $hook_extra {
234 * Array of bulk item update data.
235 *
236 * @type string $action Type of action. Default 'update'.
237 * @type string $type Type of update process. Accepts 'plugin', 'theme', 'translation', or 'core'.
238 * @type bool $bulk Whether the update process is a bulk update. Default true.
239 * @type array $plugins Array of the basename paths of the plugins' main files.
240 * @type array $themes The theme slugs.
241 * @type array $translations {
242 * Array of translations update data.
243 *
244 * @type string $language The locale the translation is for.
245 * @type string $type Type of translation. Accepts 'plugin', 'theme', or 'core'.
246 * @type string $slug Text domain the translation is for. The slug of a theme/plugin or
247 * 'default' for core translations.
248 * @type string $version The version of a theme, plugin, or core.
249 * }
250 * }
251 */
252 public function invalidate_mo_files_cache( $upgrader, $hook_extra ) {
253 if (
254 ! isset( $hook_extra['type'] ) ||
255 'translation' !== $hook_extra['type'] ||
256 array() === $hook_extra['translations']
257 ) {
258 return;
259 }
260
261 $translation_types = array_unique( wp_list_pluck( $hook_extra['translations'], 'type' ) );
262
263 foreach ( $translation_types as $type ) {
264 switch ( $type ) {
265 case 'plugin':
266 wp_cache_delete( md5( WP_LANG_DIR . '/plugins/' ), 'translation_files' );
267 break;
268 case 'theme':
269 wp_cache_delete( md5( WP_LANG_DIR . '/themes/' ), 'translation_files' );
270 break;
271 default:
272 wp_cache_delete( md5( WP_LANG_DIR . '/' ), 'translation_files' );
273 break;
274 }
275 }
276 }
277
278 /**
279 * Returns possible language directory paths for a given text domain.
280 *
281 * @since 6.2.0
282 *
283 * @param string $domain Text domain.
284 * @return string[] Array of language directory paths.
285 */
286 private function get_paths_for_domain( $domain ) {
287 $locations = array(
288 WP_LANG_DIR . '/plugins',
289 WP_LANG_DIR . '/themes',
290 );
291
292 if ( isset( $this->custom_paths[ $domain ] ) ) {
293 $locations[] = $this->custom_paths[ $domain ];
294 }
295
296 return $locations;
297 }
298
299 /**
300 * Gets the path to the language directory for the current domain and locale.
301 *
302 * Checks the plugins and themes language directories as well as any
303 * custom directory set via {@see load_plugin_textdomain()} or {@see load_theme_textdomain()}.
304 *
305 * @since 6.1.0
306 *
307 * @see _get_path_to_translation_from_lang_dir()
308 *
309 * @param string $domain Text domain.
310 * @param string $locale Locale.
311 * @return string|false Language directory path or false if there is none available.
312 */
313 private function get_path_from_lang_dir( $domain, $locale ) {
314 $locations = $this->get_paths_for_domain( $domain );
315
316 $found_location = false;
317
318 foreach ( $locations as $location ) {
319 $files = $this->get_language_files_from_path( $location );
320
321 $mo_path = "$location/$domain-$locale.mo";
322 $php_path = "$location/$domain-$locale.l10n.php";
323
324 foreach ( $files as $file_path ) {
325 if (
326 ! in_array( $domain, $this->domains_with_translations, true ) &&
327 str_starts_with( str_replace( "$location/", '', $file_path ), "$domain-" )
328 ) {
329 $this->domains_with_translations[] = $domain;
330 }
331
332 if ( $file_path === $mo_path || $file_path === $php_path ) {
333 $found_location = rtrim( $location, '/' ) . '/';
334 break 2;
335 }
336 }
337 }
338
339 if ( $found_location ) {
340 $this->set( $domain, $locale, $found_location );
341
342 return $found_location;
343 }
344
345 /*
346 * If no path is found for the given locale and a custom path has been set
347 * using load_plugin_textdomain/load_theme_textdomain, use that one.
348 */
349 if ( isset( $this->custom_paths[ $domain ] ) ) {
350 $fallback_location = rtrim( $this->custom_paths[ $domain ], '/' ) . '/';
351 $this->set( $domain, $locale, $fallback_location );
352 return $fallback_location;
353 }
354
355 $this->set( $domain, $locale, false );
356
357 return false;
358 }
359}
360
Ui Ux Design – Teachers Night Out

Get in Touch

© 2024 Teachers Night Out. All Rights Reserved.