@@ -1,10 +1,10 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * WordPress Translation API |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - * @subpackage i18n |
|
7 | - */ |
|
3 | + * WordPress Translation API |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + * @subpackage i18n |
|
7 | + */ |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Get the current locale. |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | function get_locale() { |
30 | 30 | global $locale, $wp_local_package; |
31 | 31 | |
32 | - if ( isset( $locale ) ) { |
|
32 | + if (isset($locale)) { |
|
33 | 33 | /** |
34 | 34 | * Filter WordPress install's locale ID. |
35 | 35 | * |
@@ -37,41 +37,41 @@ discard block |
||
37 | 37 | * |
38 | 38 | * @param string $locale The locale ID. |
39 | 39 | */ |
40 | - return apply_filters( 'locale', $locale ); |
|
40 | + return apply_filters('locale', $locale); |
|
41 | 41 | } |
42 | 42 | |
43 | - if ( isset( $wp_local_package ) ) { |
|
43 | + if (isset($wp_local_package)) { |
|
44 | 44 | $locale = $wp_local_package; |
45 | 45 | } |
46 | 46 | |
47 | 47 | // WPLANG was defined in wp-config. |
48 | - if ( defined( 'WPLANG' ) ) { |
|
48 | + if (defined('WPLANG')) { |
|
49 | 49 | $locale = WPLANG; |
50 | 50 | } |
51 | 51 | |
52 | 52 | // If multisite, check options. |
53 | - if ( is_multisite() ) { |
|
53 | + if (is_multisite()) { |
|
54 | 54 | // Don't check blog option when installing. |
55 | - if ( defined( 'WP_INSTALLING' ) || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) { |
|
56 | - $ms_locale = get_site_option( 'WPLANG' ); |
|
55 | + if (defined('WP_INSTALLING') || (false === $ms_locale = get_option('WPLANG'))) { |
|
56 | + $ms_locale = get_site_option('WPLANG'); |
|
57 | 57 | } |
58 | 58 | |
59 | - if ( $ms_locale !== false ) { |
|
59 | + if ($ms_locale !== false) { |
|
60 | 60 | $locale = $ms_locale; |
61 | 61 | } |
62 | 62 | } else { |
63 | - $db_locale = get_option( 'WPLANG' ); |
|
64 | - if ( $db_locale !== false ) { |
|
63 | + $db_locale = get_option('WPLANG'); |
|
64 | + if ($db_locale !== false) { |
|
65 | 65 | $locale = $db_locale; |
66 | 66 | } |
67 | 67 | } |
68 | 68 | |
69 | - if ( empty( $locale ) ) { |
|
69 | + if (empty($locale)) { |
|
70 | 70 | $locale = 'en_US'; |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** This filter is documented in wp-includes/l10n.php */ |
74 | - return apply_filters( 'locale', $locale ); |
|
74 | + return apply_filters('locale', $locale); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
88 | 88 | * @return string Translated text |
89 | 89 | */ |
90 | -function translate( $text, $domain = 'default' ) { |
|
91 | - $translations = get_translations_for_domain( $domain ); |
|
92 | - $translations = $translations->translate( $text ); |
|
90 | +function translate($text, $domain = 'default') { |
|
91 | + $translations = get_translations_for_domain($domain); |
|
92 | + $translations = $translations->translate($text); |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Filter text with its translation. |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | * @param string $text Text to translate. |
101 | 101 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
102 | 102 | */ |
103 | - return apply_filters( 'gettext', $translations, $text, $domain ); |
|
103 | + return apply_filters('gettext', $translations, $text, $domain); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -114,12 +114,12 @@ discard block |
||
114 | 114 | * @param string $string A pipe-delimited string. |
115 | 115 | * @return string Either $string or everything before the last pipe. |
116 | 116 | */ |
117 | -function before_last_bar( $string ) { |
|
118 | - $last_bar = strrpos( $string, '|' ); |
|
119 | - if ( false === $last_bar ) |
|
117 | +function before_last_bar($string) { |
|
118 | + $last_bar = strrpos($string, '|'); |
|
119 | + if (false === $last_bar) |
|
120 | 120 | return $string; |
121 | 121 | else |
122 | - return substr( $string, 0, $last_bar ); |
|
122 | + return substr($string, 0, $last_bar); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
@@ -135,9 +135,9 @@ discard block |
||
135 | 135 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
136 | 136 | * @return string Translated text on success, original text on failure. |
137 | 137 | */ |
138 | -function translate_with_gettext_context( $text, $context, $domain = 'default' ) { |
|
139 | - $translations = get_translations_for_domain( $domain ); |
|
140 | - $translations = $translations->translate( $text, $context ); |
|
138 | +function translate_with_gettext_context($text, $context, $domain = 'default') { |
|
139 | + $translations = get_translations_for_domain($domain); |
|
140 | + $translations = $translations->translate($text, $context); |
|
141 | 141 | /** |
142 | 142 | * Filter text with its translation based on context information. |
143 | 143 | * |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | * @param string $context Context information for the translators. |
149 | 149 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
150 | 150 | */ |
151 | - return apply_filters( 'gettext_with_context', $translations, $text, $context, $domain ); |
|
151 | + return apply_filters('gettext_with_context', $translations, $text, $context, $domain); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
162 | 162 | * @return string Translated text. |
163 | 163 | */ |
164 | -function __( $text, $domain = 'default' ) { |
|
165 | - return translate( $text, $domain ); |
|
164 | +function __($text, $domain = 'default') { |
|
165 | + return translate($text, $domain); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | /** |
@@ -176,8 +176,8 @@ discard block |
||
176 | 176 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
177 | 177 | * @return string Translated text on success, original text on failure. |
178 | 178 | */ |
179 | -function esc_attr__( $text, $domain = 'default' ) { |
|
180 | - return esc_attr( translate( $text, $domain ) ); |
|
179 | +function esc_attr__($text, $domain = 'default') { |
|
180 | + return esc_attr(translate($text, $domain)); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | /** |
@@ -191,8 +191,8 @@ discard block |
||
191 | 191 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
192 | 192 | * @return string Translated text |
193 | 193 | */ |
194 | -function esc_html__( $text, $domain = 'default' ) { |
|
195 | - return esc_html( translate( $text, $domain ) ); |
|
194 | +function esc_html__($text, $domain = 'default') { |
|
195 | + return esc_html(translate($text, $domain)); |
|
196 | 196 | } |
197 | 197 | |
198 | 198 | /** |
@@ -203,8 +203,8 @@ discard block |
||
203 | 203 | * @param string $text Text to translate. |
204 | 204 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
205 | 205 | */ |
206 | -function _e( $text, $domain = 'default' ) { |
|
207 | - echo translate( $text, $domain ); |
|
206 | +function _e($text, $domain = 'default') { |
|
207 | + echo translate($text, $domain); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | /** |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param string $text Text to translate. |
216 | 216 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
217 | 217 | */ |
218 | -function esc_attr_e( $text, $domain = 'default' ) { |
|
219 | - echo esc_attr( translate( $text, $domain ) ); |
|
218 | +function esc_attr_e($text, $domain = 'default') { |
|
219 | + echo esc_attr(translate($text, $domain)); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | * @param string $text Text to translate. |
228 | 228 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
229 | 229 | */ |
230 | -function esc_html_e( $text, $domain = 'default' ) { |
|
231 | - echo esc_html( translate( $text, $domain ) ); |
|
230 | +function esc_html_e($text, $domain = 'default') { |
|
231 | + echo esc_html(translate($text, $domain)); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
248 | 248 | * @return string Translated context string without pipe. |
249 | 249 | */ |
250 | -function _x( $text, $context, $domain = 'default' ) { |
|
251 | - return translate_with_gettext_context( $text, $context, $domain ); |
|
250 | +function _x($text, $context, $domain = 'default') { |
|
251 | + return translate_with_gettext_context($text, $context, $domain); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -261,8 +261,8 @@ discard block |
||
261 | 261 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
262 | 262 | * @return string Translated context string without pipe. |
263 | 263 | */ |
264 | -function _ex( $text, $context, $domain = 'default' ) { |
|
265 | - echo _x( $text, $context, $domain ); |
|
264 | +function _ex($text, $context, $domain = 'default') { |
|
265 | + echo _x($text, $context, $domain); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -275,8 +275,8 @@ discard block |
||
275 | 275 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
276 | 276 | * @return string Translated text |
277 | 277 | */ |
278 | -function esc_attr_x( $text, $context, $domain = 'default' ) { |
|
279 | - return esc_attr( translate_with_gettext_context( $text, $context, $domain ) ); |
|
278 | +function esc_attr_x($text, $context, $domain = 'default') { |
|
279 | + return esc_attr(translate_with_gettext_context($text, $context, $domain)); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
@@ -289,8 +289,8 @@ discard block |
||
289 | 289 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
290 | 290 | * @return string Translated text. |
291 | 291 | */ |
292 | -function esc_html_x( $text, $context, $domain = 'default' ) { |
|
293 | - return esc_html( translate_with_gettext_context( $text, $context, $domain ) ); |
|
292 | +function esc_html_x($text, $context, $domain = 'default') { |
|
293 | + return esc_html(translate_with_gettext_context($text, $context, $domain)); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | /** |
@@ -312,9 +312,9 @@ discard block |
||
312 | 312 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
313 | 313 | * @return string Either $single or $plural translated text. |
314 | 314 | */ |
315 | -function _n( $single, $plural, $number, $domain = 'default' ) { |
|
316 | - $translations = get_translations_for_domain( $domain ); |
|
317 | - $translation = $translations->translate_plural( $single, $plural, $number ); |
|
315 | +function _n($single, $plural, $number, $domain = 'default') { |
|
316 | + $translations = get_translations_for_domain($domain); |
|
317 | + $translation = $translations->translate_plural($single, $plural, $number); |
|
318 | 318 | /** |
319 | 319 | * Filter text with its translation when plural option is available. |
320 | 320 | * |
@@ -326,7 +326,7 @@ discard block |
||
326 | 326 | * @param string $number The number to compare against to use either $single or $plural. |
327 | 327 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
328 | 328 | */ |
329 | - return apply_filters( 'ngettext', $translation, $single, $plural, $number, $domain ); |
|
329 | + return apply_filters('ngettext', $translation, $single, $plural, $number, $domain); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | * @return string Either $single or $plural translated text with context. |
345 | 345 | */ |
346 | 346 | function _nx($single, $plural, $number, $context, $domain = 'default') { |
347 | - $translations = get_translations_for_domain( $domain ); |
|
348 | - $translation = $translations->translate_plural( $single, $plural, $number, $context ); |
|
347 | + $translations = get_translations_for_domain($domain); |
|
348 | + $translation = $translations->translate_plural($single, $plural, $number, $context); |
|
349 | 349 | /** |
350 | 350 | * Filter text with its translation while plural option and context are available. |
351 | 351 | * |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | * @param string $context Context information for the translators. |
359 | 359 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
360 | 360 | */ |
361 | - return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, $domain ); |
|
361 | + return apply_filters('ngettext_with_context', $translation, $single, $plural, $number, $context, $domain); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | * @param string $domain Optional. Text domain. Unique identifier for retrieving translated strings. |
385 | 385 | * @return array array($singular, $plural) |
386 | 386 | */ |
387 | -function _n_noop( $singular, $plural, $domain = null ) { |
|
388 | - return array( 0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null, 'domain' => $domain ); |
|
387 | +function _n_noop($singular, $plural, $domain = null) { |
|
388 | + return array(0 => $singular, 1 => $plural, 'singular' => $singular, 'plural' => $plural, 'context' => null, 'domain' => $domain); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * @param string|null $domain |
399 | 399 | * @return array |
400 | 400 | */ |
401 | -function _nx_noop( $singular, $plural, $context, $domain = null ) { |
|
402 | - return array( 0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain ); |
|
401 | +function _nx_noop($singular, $plural, $context, $domain = null) { |
|
402 | + return array(0 => $singular, 1 => $plural, 2 => $context, 'singular' => $singular, 'plural' => $plural, 'context' => $context, 'domain' => $domain); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
@@ -413,14 +413,14 @@ discard block |
||
413 | 413 | * a text domain passed to _n_noop() or _nx_noop(), it will override this value. |
414 | 414 | * @return string Either $single or $plural translated text. |
415 | 415 | */ |
416 | -function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) { |
|
417 | - if ( $nooped_plural['domain'] ) |
|
416 | +function translate_nooped_plural($nooped_plural, $count, $domain = 'default') { |
|
417 | + if ($nooped_plural['domain']) |
|
418 | 418 | $domain = $nooped_plural['domain']; |
419 | 419 | |
420 | - if ( $nooped_plural['context'] ) |
|
421 | - return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain ); |
|
420 | + if ($nooped_plural['context']) |
|
421 | + return _nx($nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain); |
|
422 | 422 | else |
423 | - return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain ); |
|
423 | + return _n($nooped_plural['singular'], $nooped_plural['plural'], $count, $domain); |
|
424 | 424 | } |
425 | 425 | |
426 | 426 | /** |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | * @param string $mofile Path to the .mo file. |
441 | 441 | * @return bool True on success, false on failure. |
442 | 442 | */ |
443 | -function load_textdomain( $domain, $mofile ) { |
|
443 | +function load_textdomain($domain, $mofile) { |
|
444 | 444 | global $l10n; |
445 | 445 | |
446 | 446 | /** |
@@ -452,9 +452,9 @@ discard block |
||
452 | 452 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
453 | 453 | * @param string $mofile Path to the MO file. |
454 | 454 | */ |
455 | - $plugin_override = apply_filters( 'override_load_textdomain', false, $domain, $mofile ); |
|
455 | + $plugin_override = apply_filters('override_load_textdomain', false, $domain, $mofile); |
|
456 | 456 | |
457 | - if ( true == $plugin_override ) { |
|
457 | + if (true == $plugin_override) { |
|
458 | 458 | return true; |
459 | 459 | } |
460 | 460 | |
@@ -466,7 +466,7 @@ discard block |
||
466 | 466 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
467 | 467 | * @param string $mofile Path to the .mo file. |
468 | 468 | */ |
469 | - do_action( 'load_textdomain', $domain, $mofile ); |
|
469 | + do_action('load_textdomain', $domain, $mofile); |
|
470 | 470 | |
471 | 471 | /** |
472 | 472 | * Filter MO file path for loading translations for a specific text domain. |
@@ -476,15 +476,15 @@ discard block |
||
476 | 476 | * @param string $mofile Path to the MO file. |
477 | 477 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
478 | 478 | */ |
479 | - $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain ); |
|
479 | + $mofile = apply_filters('load_textdomain_mofile', $mofile, $domain); |
|
480 | 480 | |
481 | - if ( !is_readable( $mofile ) ) return false; |
|
481 | + if ( ! is_readable($mofile)) return false; |
|
482 | 482 | |
483 | 483 | $mo = new MO(); |
484 | - if ( !$mo->import_from_file( $mofile ) ) return false; |
|
484 | + if ( ! $mo->import_from_file($mofile)) return false; |
|
485 | 485 | |
486 | - if ( isset( $l10n[$domain] ) ) |
|
487 | - $mo->merge_with( $l10n[$domain] ); |
|
486 | + if (isset($l10n[$domain])) |
|
487 | + $mo->merge_with($l10n[$domain]); |
|
488 | 488 | |
489 | 489 | $l10n[$domain] = &$mo; |
490 | 490 | |
@@ -501,7 +501,7 @@ discard block |
||
501 | 501 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
502 | 502 | * @return bool Whether textdomain was unloaded. |
503 | 503 | */ |
504 | -function unload_textdomain( $domain ) { |
|
504 | +function unload_textdomain($domain) { |
|
505 | 505 | global $l10n; |
506 | 506 | |
507 | 507 | /** |
@@ -512,9 +512,9 @@ discard block |
||
512 | 512 | * @param bool $override Whether to override unloading the text domain. Default false. |
513 | 513 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
514 | 514 | */ |
515 | - $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain ); |
|
515 | + $plugin_override = apply_filters('override_unload_textdomain', false, $domain); |
|
516 | 516 | |
517 | - if ( $plugin_override ) |
|
517 | + if ($plugin_override) |
|
518 | 518 | return true; |
519 | 519 | |
520 | 520 | /** |
@@ -524,10 +524,10 @@ discard block |
||
524 | 524 | * |
525 | 525 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
526 | 526 | */ |
527 | - do_action( 'unload_textdomain', $domain ); |
|
527 | + do_action('unload_textdomain', $domain); |
|
528 | 528 | |
529 | - if ( isset( $l10n[$domain] ) ) { |
|
530 | - unset( $l10n[$domain] ); |
|
529 | + if (isset($l10n[$domain])) { |
|
530 | + unset($l10n[$domain]); |
|
531 | 531 | return true; |
532 | 532 | } |
533 | 533 | |
@@ -547,27 +547,27 @@ discard block |
||
547 | 547 | * @param string $locale Optional. Locale to load. Default is the value of {@see get_locale()}. |
548 | 548 | * @return bool Whether the textdomain was loaded. |
549 | 549 | */ |
550 | -function load_default_textdomain( $locale = null ) { |
|
551 | - if ( null === $locale ) { |
|
550 | +function load_default_textdomain($locale = null) { |
|
551 | + if (null === $locale) { |
|
552 | 552 | $locale = get_locale(); |
553 | 553 | } |
554 | 554 | |
555 | 555 | // Unload previously loaded strings so we can switch translations. |
556 | - unload_textdomain( 'default' ); |
|
556 | + unload_textdomain('default'); |
|
557 | 557 | |
558 | - $return = load_textdomain( 'default', WP_LANG_DIR . "/$locale.mo" ); |
|
558 | + $return = load_textdomain('default', WP_LANG_DIR."/$locale.mo"); |
|
559 | 559 | |
560 | - if ( ( is_multisite() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) && ! file_exists( WP_LANG_DIR . "/admin-$locale.mo" ) ) { |
|
561 | - load_textdomain( 'default', WP_LANG_DIR . "/ms-$locale.mo" ); |
|
560 | + if ((is_multisite() || (defined('WP_INSTALLING_NETWORK') && WP_INSTALLING_NETWORK)) && ! file_exists(WP_LANG_DIR."/admin-$locale.mo")) { |
|
561 | + load_textdomain('default', WP_LANG_DIR."/ms-$locale.mo"); |
|
562 | 562 | return $return; |
563 | 563 | } |
564 | 564 | |
565 | - if ( is_admin() || defined( 'WP_INSTALLING' ) || ( defined( 'WP_REPAIRING' ) && WP_REPAIRING ) ) { |
|
566 | - load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" ); |
|
565 | + if (is_admin() || defined('WP_INSTALLING') || (defined('WP_REPAIRING') && WP_REPAIRING)) { |
|
566 | + load_textdomain('default', WP_LANG_DIR."/admin-$locale.mo"); |
|
567 | 567 | } |
568 | 568 | |
569 | - if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) |
|
570 | - load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" ); |
|
569 | + if (is_network_admin() || (defined('WP_INSTALLING_NETWORK') && WP_INSTALLING_NETWORK)) |
|
570 | + load_textdomain('default', WP_LANG_DIR."/admin-network-$locale.mo"); |
|
571 | 571 | |
572 | 572 | return $return; |
573 | 573 | } |
@@ -587,7 +587,7 @@ discard block |
||
587 | 587 | * Default false. |
588 | 588 | * @return bool True when textdomain is successfully loaded, false otherwise. |
589 | 589 | */ |
590 | -function load_plugin_textdomain( $domain, $deprecated = false, $plugin_rel_path = false ) { |
|
590 | +function load_plugin_textdomain($domain, $deprecated = false, $plugin_rel_path = false) { |
|
591 | 591 | $locale = get_locale(); |
592 | 592 | /** |
593 | 593 | * Filter a plugin's locale. |
@@ -597,25 +597,25 @@ discard block |
||
597 | 597 | * @param string $locale The plugin's current locale. |
598 | 598 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
599 | 599 | */ |
600 | - $locale = apply_filters( 'plugin_locale', $locale, $domain ); |
|
600 | + $locale = apply_filters('plugin_locale', $locale, $domain); |
|
601 | 601 | |
602 | - if ( false !== $plugin_rel_path ) { |
|
603 | - $path = WP_PLUGIN_DIR . '/' . trim( $plugin_rel_path, '/' ); |
|
604 | - } elseif ( false !== $deprecated ) { |
|
605 | - _deprecated_argument( __FUNCTION__, '2.7' ); |
|
606 | - $path = ABSPATH . trim( $deprecated, '/' ); |
|
602 | + if (false !== $plugin_rel_path) { |
|
603 | + $path = WP_PLUGIN_DIR.'/'.trim($plugin_rel_path, '/'); |
|
604 | + } elseif (false !== $deprecated) { |
|
605 | + _deprecated_argument(__FUNCTION__, '2.7'); |
|
606 | + $path = ABSPATH.trim($deprecated, '/'); |
|
607 | 607 | } else { |
608 | 608 | $path = WP_PLUGIN_DIR; |
609 | 609 | } |
610 | 610 | |
611 | 611 | // Load the textdomain according to the plugin first |
612 | - $mofile = $domain . '-' . $locale . '.mo'; |
|
613 | - if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) |
|
612 | + $mofile = $domain.'-'.$locale.'.mo'; |
|
613 | + if ($loaded = load_textdomain($domain, $path.'/'.$mofile)) |
|
614 | 614 | return $loaded; |
615 | 615 | |
616 | 616 | // Otherwise, load from the languages directory |
617 | - $mofile = WP_LANG_DIR . '/plugins/' . $mofile; |
|
618 | - return load_textdomain( $domain, $mofile ); |
|
617 | + $mofile = WP_LANG_DIR.'/plugins/'.$mofile; |
|
618 | + return load_textdomain($domain, $mofile); |
|
619 | 619 | } |
620 | 620 | |
621 | 621 | /** |
@@ -628,19 +628,19 @@ discard block |
||
628 | 628 | * Default empty string. |
629 | 629 | * @return bool True when textdomain is successfully loaded, false otherwise. |
630 | 630 | */ |
631 | -function load_muplugin_textdomain( $domain, $mu_plugin_rel_path = '' ) { |
|
631 | +function load_muplugin_textdomain($domain, $mu_plugin_rel_path = '') { |
|
632 | 632 | /** This filter is documented in wp-includes/l10n.php */ |
633 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
634 | - $path = trailingslashit( WPMU_PLUGIN_DIR . '/' . ltrim( $mu_plugin_rel_path, '/' ) ); |
|
633 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
634 | + $path = trailingslashit(WPMU_PLUGIN_DIR.'/'.ltrim($mu_plugin_rel_path, '/')); |
|
635 | 635 | |
636 | 636 | // Load the textdomain according to the plugin first |
637 | - $mofile = $domain . '-' . $locale . '.mo'; |
|
638 | - if ( $loaded = load_textdomain( $domain, $path . $mofile ) ) |
|
637 | + $mofile = $domain.'-'.$locale.'.mo'; |
|
638 | + if ($loaded = load_textdomain($domain, $path.$mofile)) |
|
639 | 639 | return $loaded; |
640 | 640 | |
641 | 641 | // Otherwise, load from the languages directory |
642 | - $mofile = WP_LANG_DIR . '/plugins/' . $mofile; |
|
643 | - return load_textdomain( $domain, $mofile ); |
|
642 | + $mofile = WP_LANG_DIR.'/plugins/'.$mofile; |
|
643 | + return load_textdomain($domain, $mofile); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * Default false. |
659 | 659 | * @return bool True when textdomain is successfully loaded, false otherwise. |
660 | 660 | */ |
661 | -function load_theme_textdomain( $domain, $path = false ) { |
|
661 | +function load_theme_textdomain($domain, $path = false) { |
|
662 | 662 | $locale = get_locale(); |
663 | 663 | /** |
664 | 664 | * Filter a theme's locale. |
@@ -668,19 +668,19 @@ discard block |
||
668 | 668 | * @param string $locale The theme's current locale. |
669 | 669 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
670 | 670 | */ |
671 | - $locale = apply_filters( 'theme_locale', $locale, $domain ); |
|
671 | + $locale = apply_filters('theme_locale', $locale, $domain); |
|
672 | 672 | |
673 | - if ( ! $path ) |
|
673 | + if ( ! $path) |
|
674 | 674 | $path = get_template_directory(); |
675 | 675 | |
676 | 676 | // Load the textdomain according to the theme |
677 | - $mofile = untrailingslashit( $path ) . "/{$locale}.mo"; |
|
678 | - if ( $loaded = load_textdomain( $domain, $mofile ) ) |
|
677 | + $mofile = untrailingslashit($path)."/{$locale}.mo"; |
|
678 | + if ($loaded = load_textdomain($domain, $mofile)) |
|
679 | 679 | return $loaded; |
680 | 680 | |
681 | 681 | // Otherwise, load from the languages directory |
682 | - $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo"; |
|
683 | - return load_textdomain( $domain, $mofile ); |
|
682 | + $mofile = WP_LANG_DIR."/themes/{$domain}-{$locale}.mo"; |
|
683 | + return load_textdomain($domain, $mofile); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | /** |
@@ -698,10 +698,10 @@ discard block |
||
698 | 698 | * Default false. |
699 | 699 | * @return bool True when the theme textdomain is successfully loaded, false otherwise. |
700 | 700 | */ |
701 | -function load_child_theme_textdomain( $domain, $path = false ) { |
|
702 | - if ( ! $path ) |
|
701 | +function load_child_theme_textdomain($domain, $path = false) { |
|
702 | + if ( ! $path) |
|
703 | 703 | $path = get_stylesheet_directory(); |
704 | - return load_theme_textdomain( $domain, $path ); |
|
704 | + return load_theme_textdomain($domain, $path); |
|
705 | 705 | } |
706 | 706 | |
707 | 707 | /** |
@@ -716,9 +716,9 @@ discard block |
||
716 | 716 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
717 | 717 | * @return NOOP_Translations A Translations instance. |
718 | 718 | */ |
719 | -function get_translations_for_domain( $domain ) { |
|
719 | +function get_translations_for_domain($domain) { |
|
720 | 720 | global $l10n; |
721 | - if ( !isset( $l10n[$domain] ) ) { |
|
721 | + if ( ! isset($l10n[$domain])) { |
|
722 | 722 | $l10n[$domain] = new NOOP_Translations; |
723 | 723 | } |
724 | 724 | return $l10n[$domain]; |
@@ -734,9 +734,9 @@ discard block |
||
734 | 734 | * @param string $domain Text domain. Unique identifier for retrieving translated strings. |
735 | 735 | * @return bool Whether there are translations. |
736 | 736 | */ |
737 | -function is_textdomain_loaded( $domain ) { |
|
737 | +function is_textdomain_loaded($domain) { |
|
738 | 738 | global $l10n; |
739 | - return isset( $l10n[$domain] ); |
|
739 | + return isset($l10n[$domain]); |
|
740 | 740 | } |
741 | 741 | |
742 | 742 | /** |
@@ -756,8 +756,8 @@ discard block |
||
756 | 756 | * @param string $name The role name. |
757 | 757 | * @return string Translated role name on success, original name on failure. |
758 | 758 | */ |
759 | -function translate_user_role( $name ) { |
|
760 | - return translate_with_gettext_context( before_last_bar($name), 'User role' ); |
|
759 | +function translate_user_role($name) { |
|
760 | + return translate_with_gettext_context(before_last_bar($name), 'User role'); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
@@ -771,15 +771,15 @@ discard block |
||
771 | 771 | * Default WP_LANG_DIR. |
772 | 772 | * @return array 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. |
773 | 773 | */ |
774 | -function get_available_languages( $dir = null ) { |
|
774 | +function get_available_languages($dir = null) { |
|
775 | 775 | $languages = array(); |
776 | 776 | |
777 | - $lang_files = glob( ( is_null( $dir) ? WP_LANG_DIR : $dir ) . '/*.mo' ); |
|
778 | - if ( $lang_files ) { |
|
779 | - foreach( $lang_files as $lang_file ) { |
|
780 | - $lang_file = basename( $lang_file, '.mo' ); |
|
781 | - if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) && |
|
782 | - 0 !== strpos( $lang_file, 'admin-' ) ) { |
|
777 | + $lang_files = glob((is_null($dir) ? WP_LANG_DIR : $dir).'/*.mo'); |
|
778 | + if ($lang_files) { |
|
779 | + foreach ($lang_files as $lang_file) { |
|
780 | + $lang_file = basename($lang_file, '.mo'); |
|
781 | + if (0 !== strpos($lang_file, 'continents-cities') && 0 !== strpos($lang_file, 'ms-') && |
|
782 | + 0 !== strpos($lang_file, 'admin-')) { |
|
783 | 783 | $languages[] = $lang_file; |
784 | 784 | } |
785 | 785 | } |
@@ -799,43 +799,43 @@ discard block |
||
799 | 799 | * @param string $type What to search for. Accepts 'plugins', 'themes', 'core'. |
800 | 800 | * @return array Array of language data. |
801 | 801 | */ |
802 | -function wp_get_installed_translations( $type ) { |
|
803 | - if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' ) |
|
802 | +function wp_get_installed_translations($type) { |
|
803 | + if ($type !== 'themes' && $type !== 'plugins' && $type !== 'core') |
|
804 | 804 | return array(); |
805 | 805 | |
806 | 806 | $dir = 'core' === $type ? '' : "/$type"; |
807 | 807 | |
808 | - if ( ! is_dir( WP_LANG_DIR ) ) |
|
808 | + if ( ! is_dir(WP_LANG_DIR)) |
|
809 | 809 | return array(); |
810 | 810 | |
811 | - if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) ) |
|
811 | + if ($dir && ! is_dir(WP_LANG_DIR.$dir)) |
|
812 | 812 | return array(); |
813 | 813 | |
814 | - $files = scandir( WP_LANG_DIR . $dir ); |
|
815 | - if ( ! $files ) |
|
814 | + $files = scandir(WP_LANG_DIR.$dir); |
|
815 | + if ( ! $files) |
|
816 | 816 | return array(); |
817 | 817 | |
818 | 818 | $language_data = array(); |
819 | 819 | |
820 | - foreach ( $files as $file ) { |
|
821 | - if ( '.' === $file[0] || is_dir( $file ) ) { |
|
820 | + foreach ($files as $file) { |
|
821 | + if ('.' === $file[0] || is_dir($file)) { |
|
822 | 822 | continue; |
823 | 823 | } |
824 | - if ( substr( $file, -3 ) !== '.po' ) { |
|
824 | + if (substr($file, -3) !== '.po') { |
|
825 | 825 | continue; |
826 | 826 | } |
827 | - if ( ! preg_match( '/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match ) ) { |
|
827 | + if ( ! preg_match('/(?:(.+)-)?([a-z]{2,3}(?:_[A-Z]{2})?(?:_[a-z0-9]+)?).po/', $file, $match)) { |
|
828 | 828 | continue; |
829 | 829 | } |
830 | - if ( ! in_array( substr( $file, 0, -3 ) . '.mo', $files ) ) { |
|
830 | + if ( ! in_array(substr($file, 0, -3).'.mo', $files)) { |
|
831 | 831 | continue; |
832 | 832 | } |
833 | 833 | |
834 | - list( , $textdomain, $language ) = $match; |
|
835 | - if ( '' === $textdomain ) { |
|
834 | + list(, $textdomain, $language) = $match; |
|
835 | + if ('' === $textdomain) { |
|
836 | 836 | $textdomain = 'default'; |
837 | 837 | } |
838 | - $language_data[ $textdomain ][ $language ] = wp_get_pomo_file_data( WP_LANG_DIR . "$dir/$file" ); |
|
838 | + $language_data[$textdomain][$language] = wp_get_pomo_file_data(WP_LANG_DIR."$dir/$file"); |
|
839 | 839 | } |
840 | 840 | return $language_data; |
841 | 841 | } |
@@ -848,16 +848,16 @@ discard block |
||
848 | 848 | * @param string $po_file Path to PO file. |
849 | 849 | * @return array PO file headers. |
850 | 850 | */ |
851 | -function wp_get_pomo_file_data( $po_file ) { |
|
852 | - $headers = get_file_data( $po_file, array( |
|
851 | +function wp_get_pomo_file_data($po_file) { |
|
852 | + $headers = get_file_data($po_file, array( |
|
853 | 853 | 'POT-Creation-Date' => '"POT-Creation-Date', |
854 | 854 | 'PO-Revision-Date' => '"PO-Revision-Date', |
855 | 855 | 'Project-Id-Version' => '"Project-Id-Version', |
856 | 856 | 'X-Generator' => '"X-Generator', |
857 | - ) ); |
|
858 | - foreach ( $headers as $header => $value ) { |
|
857 | + )); |
|
858 | + foreach ($headers as $header => $value) { |
|
859 | 859 | // Remove possible contextual '\n' and closing double quote. |
860 | - $headers[ $header ] = preg_replace( '~(\\\n)?"$~', '', $value ); |
|
860 | + $headers[$header] = preg_replace('~(\\\n)?"$~', '', $value); |
|
861 | 861 | } |
862 | 862 | return $headers; |
863 | 863 | } |
@@ -887,9 +887,9 @@ discard block |
||
887 | 887 | * } |
888 | 888 | * @return string HTML content only if 'echo' argument is 0. |
889 | 889 | */ |
890 | -function wp_dropdown_languages( $args = array() ) { |
|
890 | +function wp_dropdown_languages($args = array()) { |
|
891 | 891 | |
892 | - $args = wp_parse_args( $args, array( |
|
892 | + $args = wp_parse_args($args, array( |
|
893 | 893 | 'id' => '', |
894 | 894 | 'name' => '', |
895 | 895 | 'languages' => array(), |
@@ -897,11 +897,11 @@ discard block |
||
897 | 897 | 'selected' => '', |
898 | 898 | 'echo' => 1, |
899 | 899 | 'show_available_translations' => true, |
900 | - ) ); |
|
900 | + )); |
|
901 | 901 | |
902 | 902 | $translations = $args['translations']; |
903 | - if ( empty( $translations ) ) { |
|
904 | - require_once( ABSPATH . 'wp-admin/includes/translation-install.php' ); |
|
903 | + if (empty($translations)) { |
|
904 | + require_once(ABSPATH.'wp-admin/includes/translation-install.php'); |
|
905 | 905 | $translations = wp_get_available_translations(); |
906 | 906 | } |
907 | 907 | |
@@ -910,17 +910,17 @@ discard block |
||
910 | 910 | * $translations to get the native name. Fall back to locale. |
911 | 911 | */ |
912 | 912 | $languages = array(); |
913 | - foreach ( $args['languages'] as $locale ) { |
|
914 | - if ( isset( $translations[ $locale ] ) ) { |
|
915 | - $translation = $translations[ $locale ]; |
|
913 | + foreach ($args['languages'] as $locale) { |
|
914 | + if (isset($translations[$locale])) { |
|
915 | + $translation = $translations[$locale]; |
|
916 | 916 | $languages[] = array( |
917 | 917 | 'language' => $translation['language'], |
918 | 918 | 'native_name' => $translation['native_name'], |
919 | - 'lang' => current( $translation['iso'] ), |
|
919 | + 'lang' => current($translation['iso']), |
|
920 | 920 | ); |
921 | 921 | |
922 | 922 | // Remove installed language from available translations. |
923 | - unset( $translations[ $locale ] ); |
|
923 | + unset($translations[$locale]); |
|
924 | 924 | } else { |
925 | 925 | $languages[] = array( |
926 | 926 | 'language' => $locale, |
@@ -930,51 +930,51 @@ discard block |
||
930 | 930 | } |
931 | 931 | } |
932 | 932 | |
933 | - $translations_available = ( ! empty( $translations ) && $args['show_available_translations'] ); |
|
933 | + $translations_available = ( ! empty($translations) && $args['show_available_translations']); |
|
934 | 934 | |
935 | - $output = sprintf( '<select name="%s" id="%s">', esc_attr( $args['name'] ), esc_attr( $args['id'] ) ); |
|
935 | + $output = sprintf('<select name="%s" id="%s">', esc_attr($args['name']), esc_attr($args['id'])); |
|
936 | 936 | |
937 | 937 | // Holds the HTML markup. |
938 | 938 | $structure = array(); |
939 | 939 | |
940 | 940 | // List installed languages. |
941 | - if ( $translations_available ) { |
|
942 | - $structure[] = '<optgroup label="' . esc_attr_x( 'Installed', 'translations' ) . '">'; |
|
941 | + if ($translations_available) { |
|
942 | + $structure[] = '<optgroup label="'.esc_attr_x('Installed', 'translations').'">'; |
|
943 | 943 | } |
944 | 944 | $structure[] = '<option value="" lang="en" data-installed="1">English (United States)</option>'; |
945 | - foreach ( $languages as $language ) { |
|
945 | + foreach ($languages as $language) { |
|
946 | 946 | $structure[] = sprintf( |
947 | 947 | '<option value="%s" lang="%s"%s data-installed="1">%s</option>', |
948 | - esc_attr( $language['language'] ), |
|
949 | - esc_attr( $language['lang'] ), |
|
950 | - selected( $language['language'], $args['selected'], false ), |
|
951 | - esc_html( $language['native_name'] ) |
|
948 | + esc_attr($language['language']), |
|
949 | + esc_attr($language['lang']), |
|
950 | + selected($language['language'], $args['selected'], false), |
|
951 | + esc_html($language['native_name']) |
|
952 | 952 | ); |
953 | 953 | } |
954 | - if ( $translations_available ) { |
|
954 | + if ($translations_available) { |
|
955 | 955 | $structure[] = '</optgroup>'; |
956 | 956 | } |
957 | 957 | |
958 | 958 | // List available translations. |
959 | - if ( $translations_available ) { |
|
960 | - $structure[] = '<optgroup label="' . esc_attr_x( 'Available', 'translations' ) . '">'; |
|
961 | - foreach ( $translations as $translation ) { |
|
959 | + if ($translations_available) { |
|
960 | + $structure[] = '<optgroup label="'.esc_attr_x('Available', 'translations').'">'; |
|
961 | + foreach ($translations as $translation) { |
|
962 | 962 | $structure[] = sprintf( |
963 | 963 | '<option value="%s" lang="%s"%s>%s</option>', |
964 | - esc_attr( $translation['language'] ), |
|
965 | - esc_attr( current( $translation['iso'] ) ), |
|
966 | - selected( $translation['language'], $args['selected'], false ), |
|
967 | - esc_html( $translation['native_name'] ) |
|
964 | + esc_attr($translation['language']), |
|
965 | + esc_attr(current($translation['iso'])), |
|
966 | + selected($translation['language'], $args['selected'], false), |
|
967 | + esc_html($translation['native_name']) |
|
968 | 968 | ); |
969 | 969 | } |
970 | 970 | $structure[] = '</optgroup>'; |
971 | 971 | } |
972 | 972 | |
973 | - $output .= join( "\n", $structure ); |
|
973 | + $output .= join("\n", $structure); |
|
974 | 974 | |
975 | 975 | $output .= '</select>'; |
976 | 976 | |
977 | - if ( $args['echo'] ) { |
|
977 | + if ($args['echo']) { |
|
978 | 978 | echo $output; |
979 | 979 | } |
980 | 980 |
@@ -116,11 +116,12 @@ discard block |
||
116 | 116 | */ |
117 | 117 | function before_last_bar( $string ) { |
118 | 118 | $last_bar = strrpos( $string, '|' ); |
119 | - if ( false === $last_bar ) |
|
120 | - return $string; |
|
121 | - else |
|
122 | - return substr( $string, 0, $last_bar ); |
|
123 | -} |
|
119 | + if ( false === $last_bar ) { |
|
120 | + return $string; |
|
121 | + } else { |
|
122 | + return substr( $string, 0, $last_bar ); |
|
123 | + } |
|
124 | + } |
|
124 | 125 | |
125 | 126 | /** |
126 | 127 | * Retrieve the translation of $text in the context defined in $context. |
@@ -414,14 +415,16 @@ discard block |
||
414 | 415 | * @return string Either $single or $plural translated text. |
415 | 416 | */ |
416 | 417 | function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) { |
417 | - if ( $nooped_plural['domain'] ) |
|
418 | - $domain = $nooped_plural['domain']; |
|
418 | + if ( $nooped_plural['domain'] ) { |
|
419 | + $domain = $nooped_plural['domain']; |
|
420 | + } |
|
419 | 421 | |
420 | - if ( $nooped_plural['context'] ) |
|
421 | - return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain ); |
|
422 | - else |
|
423 | - return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain ); |
|
424 | -} |
|
422 | + if ( $nooped_plural['context'] ) { |
|
423 | + return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain ); |
|
424 | + } else { |
|
425 | + return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain ); |
|
426 | + } |
|
427 | + } |
|
425 | 428 | |
426 | 429 | /** |
427 | 430 | * Load a .mo file into the text domain $domain. |
@@ -478,13 +481,18 @@ discard block |
||
478 | 481 | */ |
479 | 482 | $mofile = apply_filters( 'load_textdomain_mofile', $mofile, $domain ); |
480 | 483 | |
481 | - if ( !is_readable( $mofile ) ) return false; |
|
484 | + if ( !is_readable( $mofile ) ) { |
|
485 | + return false; |
|
486 | + } |
|
482 | 487 | |
483 | 488 | $mo = new MO(); |
484 | - if ( !$mo->import_from_file( $mofile ) ) return false; |
|
489 | + if ( !$mo->import_from_file( $mofile ) ) { |
|
490 | + return false; |
|
491 | + } |
|
485 | 492 | |
486 | - if ( isset( $l10n[$domain] ) ) |
|
487 | - $mo->merge_with( $l10n[$domain] ); |
|
493 | + if ( isset( $l10n[$domain] ) ) { |
|
494 | + $mo->merge_with( $l10n[$domain] ); |
|
495 | + } |
|
488 | 496 | |
489 | 497 | $l10n[$domain] = &$mo; |
490 | 498 | |
@@ -514,8 +522,9 @@ discard block |
||
514 | 522 | */ |
515 | 523 | $plugin_override = apply_filters( 'override_unload_textdomain', false, $domain ); |
516 | 524 | |
517 | - if ( $plugin_override ) |
|
518 | - return true; |
|
525 | + if ( $plugin_override ) { |
|
526 | + return true; |
|
527 | + } |
|
519 | 528 | |
520 | 529 | /** |
521 | 530 | * Fires before the text domain is unloaded. |
@@ -566,8 +575,9 @@ discard block |
||
566 | 575 | load_textdomain( 'default', WP_LANG_DIR . "/admin-$locale.mo" ); |
567 | 576 | } |
568 | 577 | |
569 | - if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) |
|
570 | - load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" ); |
|
578 | + if ( is_network_admin() || ( defined( 'WP_INSTALLING_NETWORK' ) && WP_INSTALLING_NETWORK ) ) { |
|
579 | + load_textdomain( 'default', WP_LANG_DIR . "/admin-network-$locale.mo" ); |
|
580 | + } |
|
571 | 581 | |
572 | 582 | return $return; |
573 | 583 | } |
@@ -610,8 +620,9 @@ discard block |
||
610 | 620 | |
611 | 621 | // Load the textdomain according to the plugin first |
612 | 622 | $mofile = $domain . '-' . $locale . '.mo'; |
613 | - if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) |
|
614 | - return $loaded; |
|
623 | + if ( $loaded = load_textdomain( $domain, $path . '/'. $mofile ) ) { |
|
624 | + return $loaded; |
|
625 | + } |
|
615 | 626 | |
616 | 627 | // Otherwise, load from the languages directory |
617 | 628 | $mofile = WP_LANG_DIR . '/plugins/' . $mofile; |
@@ -635,8 +646,9 @@ discard block |
||
635 | 646 | |
636 | 647 | // Load the textdomain according to the plugin first |
637 | 648 | $mofile = $domain . '-' . $locale . '.mo'; |
638 | - if ( $loaded = load_textdomain( $domain, $path . $mofile ) ) |
|
639 | - return $loaded; |
|
649 | + if ( $loaded = load_textdomain( $domain, $path . $mofile ) ) { |
|
650 | + return $loaded; |
|
651 | + } |
|
640 | 652 | |
641 | 653 | // Otherwise, load from the languages directory |
642 | 654 | $mofile = WP_LANG_DIR . '/plugins/' . $mofile; |
@@ -670,13 +682,15 @@ discard block |
||
670 | 682 | */ |
671 | 683 | $locale = apply_filters( 'theme_locale', $locale, $domain ); |
672 | 684 | |
673 | - if ( ! $path ) |
|
674 | - $path = get_template_directory(); |
|
685 | + if ( ! $path ) { |
|
686 | + $path = get_template_directory(); |
|
687 | + } |
|
675 | 688 | |
676 | 689 | // Load the textdomain according to the theme |
677 | 690 | $mofile = untrailingslashit( $path ) . "/{$locale}.mo"; |
678 | - if ( $loaded = load_textdomain( $domain, $mofile ) ) |
|
679 | - return $loaded; |
|
691 | + if ( $loaded = load_textdomain( $domain, $mofile ) ) { |
|
692 | + return $loaded; |
|
693 | + } |
|
680 | 694 | |
681 | 695 | // Otherwise, load from the languages directory |
682 | 696 | $mofile = WP_LANG_DIR . "/themes/{$domain}-{$locale}.mo"; |
@@ -699,8 +713,9 @@ discard block |
||
699 | 713 | * @return bool True when the theme textdomain is successfully loaded, false otherwise. |
700 | 714 | */ |
701 | 715 | function load_child_theme_textdomain( $domain, $path = false ) { |
702 | - if ( ! $path ) |
|
703 | - $path = get_stylesheet_directory(); |
|
716 | + if ( ! $path ) { |
|
717 | + $path = get_stylesheet_directory(); |
|
718 | + } |
|
704 | 719 | return load_theme_textdomain( $domain, $path ); |
705 | 720 | } |
706 | 721 | |
@@ -800,20 +815,24 @@ discard block |
||
800 | 815 | * @return array Array of language data. |
801 | 816 | */ |
802 | 817 | function wp_get_installed_translations( $type ) { |
803 | - if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' ) |
|
804 | - return array(); |
|
818 | + if ( $type !== 'themes' && $type !== 'plugins' && $type !== 'core' ) { |
|
819 | + return array(); |
|
820 | + } |
|
805 | 821 | |
806 | 822 | $dir = 'core' === $type ? '' : "/$type"; |
807 | 823 | |
808 | - if ( ! is_dir( WP_LANG_DIR ) ) |
|
809 | - return array(); |
|
824 | + if ( ! is_dir( WP_LANG_DIR ) ) { |
|
825 | + return array(); |
|
826 | + } |
|
810 | 827 | |
811 | - if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) ) |
|
812 | - return array(); |
|
828 | + if ( $dir && ! is_dir( WP_LANG_DIR . $dir ) ) { |
|
829 | + return array(); |
|
830 | + } |
|
813 | 831 | |
814 | 832 | $files = scandir( WP_LANG_DIR . $dir ); |
815 | - if ( ! $files ) |
|
816 | - return array(); |
|
833 | + if ( ! $files ) { |
|
834 | + return array(); |
|
835 | + } |
|
817 | 836 | |
818 | 837 | $language_data = array(); |
819 | 838 |
@@ -1,9 +1,9 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * RSS 1 RDF Feed Template for displaying RSS 1 Posts feed. |
|
4 | - * |
|
5 | - * @package WordPress |
|
6 | - */ |
|
3 | + * RSS 1 RDF Feed Template for displaying RSS 1 Posts feed. |
|
4 | + * |
|
5 | + * @package WordPress |
|
6 | + */ |
|
7 | 7 | |
8 | 8 | header('Content-Type: ' . feed_content_type('rdf') . '; charset=' . get_option('blog_charset'), true); |
9 | 9 | $more = 1; |
@@ -5,13 +5,13 @@ discard block |
||
5 | 5 | * @package WordPress |
6 | 6 | */ |
7 | 7 | |
8 | -header('Content-Type: ' . feed_content_type('rdf') . '; charset=' . get_option('blog_charset'), true); |
|
8 | +header('Content-Type: '.feed_content_type('rdf').'; charset='.get_option('blog_charset'), true); |
|
9 | 9 | $more = 1; |
10 | 10 | |
11 | 11 | echo '<?xml version="1.0" encoding="'.get_option('blog_charset').'"?'.'>'; |
12 | 12 | |
13 | 13 | /** This action is documented in wp-includes/feed-rss2.php */ |
14 | -do_action( 'rss_tag_pre', 'rdf' ); |
|
14 | +do_action('rss_tag_pre', 'rdf'); |
|
15 | 15 | ?> |
16 | 16 | <rdf:RDF |
17 | 17 | xmlns="http://purl.org/rss/1.0/" |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @since 2.0.0 |
28 | 28 | */ |
29 | - do_action( 'rdf_ns' ); |
|
29 | + do_action('rdf_ns'); |
|
30 | 30 | ?> |
31 | 31 | > |
32 | 32 | <channel rdf:about="<?php bloginfo_rss("url") ?>"> |
@@ -36,11 +36,11 @@ discard block |
||
36 | 36 | <dc:date><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT'), false); ?></dc:date> |
37 | 37 | <sy:updatePeriod><?php |
38 | 38 | /** This filter is documented in wp-includes/feed-rss2.php */ |
39 | - echo apply_filters( 'rss_update_period', 'hourly' ); |
|
39 | + echo apply_filters('rss_update_period', 'hourly'); |
|
40 | 40 | ?></sy:updatePeriod> |
41 | 41 | <sy:updateFrequency><?php |
42 | 42 | /** This filter is documented in wp-includes/feed-rss2.php */ |
43 | - echo apply_filters( 'rss_update_frequency', '1' ); |
|
43 | + echo apply_filters('rss_update_frequency', '1'); |
|
44 | 44 | ?></sy:updateFrequency> |
45 | 45 | <sy:updateBase>2000-01-01T12:00+00:00</sy:updateBase> |
46 | 46 | <?php |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | * |
50 | 50 | * @since 2.0.0 |
51 | 51 | */ |
52 | - do_action( 'rdf_header' ); |
|
52 | + do_action('rdf_header'); |
|
53 | 53 | ?> |
54 | 54 | <items> |
55 | 55 | <rdf:Seq> |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * |
79 | 79 | * @since 2.0.0 |
80 | 80 | */ |
81 | - do_action( 'rdf_item' ); |
|
81 | + do_action('rdf_item'); |
|
82 | 82 | ?> |
83 | 83 | </item> |
84 | -<?php endwhile; ?> |
|
84 | +<?php endwhile; ?> |
|
85 | 85 | </rdf:RDF> |
@@ -68,10 +68,13 @@ |
||
68 | 68 | <?php the_category_rss('rdf') ?> |
69 | 69 | <?php if (get_option('rss_use_excerpt')) : ?> |
70 | 70 | <description><![CDATA[<?php the_excerpt_rss() ?>]]></description> |
71 | -<?php else : ?> |
|
71 | +<?php else { |
|
72 | + : ?> |
|
72 | 73 | <description><![CDATA[<?php the_excerpt_rss() ?>]]></description> |
73 | 74 | <content:encoded><![CDATA[<?php the_content_feed('rdf') ?>]]></content:encoded> |
74 | -<?php endif; ?> |
|
75 | +<?php endif; |
|
76 | +} |
|
77 | +?> |
|
75 | 78 | <?php |
76 | 79 | /** |
77 | 80 | * Fires at the end of each RDF feed item. |
@@ -1,22 +1,22 @@ |
||
1 | 1 | <?php |
2 | 2 | /** |
3 | - * The base configuration for WordPress |
|
4 | - * |
|
5 | - * The wp-config.php creation script uses this file during the |
|
6 | - * installation. You don't have to use the web site, you can |
|
7 | - * copy this file to "wp-config.php" and fill in the values. |
|
8 | - * |
|
9 | - * This file contains the following configurations: |
|
10 | - * |
|
11 | - * * MySQL settings |
|
12 | - * * Secret keys |
|
13 | - * * Database table prefix |
|
14 | - * * ABSPATH |
|
15 | - * |
|
16 | - * @link https://codex.wordpress.org/Editing_wp-config.php |
|
17 | - * |
|
18 | - * @package WordPress |
|
19 | - */ |
|
3 | + * The base configuration for WordPress |
|
4 | + * |
|
5 | + * The wp-config.php creation script uses this file during the |
|
6 | + * installation. You don't have to use the web site, you can |
|
7 | + * copy this file to "wp-config.php" and fill in the values. |
|
8 | + * |
|
9 | + * This file contains the following configurations: |
|
10 | + * |
|
11 | + * * MySQL settings |
|
12 | + * * Secret keys |
|
13 | + * * Database table prefix |
|
14 | + * * ABSPATH |
|
15 | + * |
|
16 | + * @link https://codex.wordpress.org/Editing_wp-config.php |
|
17 | + * |
|
18 | + * @package WordPress |
|
19 | + */ |
|
20 | 20 | |
21 | 21 | // ** MySQL settings - You can get this info from your web host ** // |
22 | 22 | /** The name of the database for WordPress */ |
@@ -46,14 +46,14 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @since 2.6.0 |
48 | 48 | */ |
49 | -define('AUTH_KEY', 'put your unique phrase here'); |
|
50 | -define('SECURE_AUTH_KEY', 'put your unique phrase here'); |
|
51 | -define('LOGGED_IN_KEY', 'put your unique phrase here'); |
|
52 | -define('NONCE_KEY', 'put your unique phrase here'); |
|
53 | -define('AUTH_SALT', 'put your unique phrase here'); |
|
49 | +define('AUTH_KEY', 'put your unique phrase here'); |
|
50 | +define('SECURE_AUTH_KEY', 'put your unique phrase here'); |
|
51 | +define('LOGGED_IN_KEY', 'put your unique phrase here'); |
|
52 | +define('NONCE_KEY', 'put your unique phrase here'); |
|
53 | +define('AUTH_SALT', 'put your unique phrase here'); |
|
54 | 54 | define('SECURE_AUTH_SALT', 'put your unique phrase here'); |
55 | -define('LOGGED_IN_SALT', 'put your unique phrase here'); |
|
56 | -define('NONCE_SALT', 'put your unique phrase here'); |
|
55 | +define('LOGGED_IN_SALT', 'put your unique phrase here'); |
|
56 | +define('NONCE_SALT', 'put your unique phrase here'); |
|
57 | 57 | |
58 | 58 | /**#@-*/ |
59 | 59 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * You can have multiple installations in one database if you give each |
64 | 64 | * a unique prefix. Only numbers, letters, and underscores please! |
65 | 65 | */ |
66 | -$table_prefix = 'wp_'; |
|
66 | +$table_prefix = 'wp_'; |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * For developers: WordPress debugging mode. |
@@ -82,8 +82,8 @@ discard block |
||
82 | 82 | /* That's all, stop editing! Happy blogging. */ |
83 | 83 | |
84 | 84 | /** Absolute path to the WordPress directory. */ |
85 | -if ( !defined('ABSPATH') ) |
|
86 | - define('ABSPATH', dirname(__FILE__) . '/'); |
|
85 | +if ( ! defined('ABSPATH')) |
|
86 | + define('ABSPATH', dirname(__FILE__).'/'); |
|
87 | 87 | |
88 | 88 | /** Sets up WordPress vars and included files. */ |
89 | -require_once(ABSPATH . 'wp-settings.php'); |
|
89 | +require_once(ABSPATH.'wp-settings.php'); |
@@ -82,8 +82,9 @@ |
||
82 | 82 | /* That's all, stop editing! Happy blogging. */ |
83 | 83 | |
84 | 84 | /** Absolute path to the WordPress directory. */ |
85 | -if ( !defined('ABSPATH') ) |
|
86 | - define('ABSPATH', dirname(__FILE__) . '/'); |
|
85 | +if ( !defined('ABSPATH') ) { |
|
86 | + define('ABSPATH', dirname(__FILE__) . '/'); |
|
87 | +} |
|
87 | 88 | |
88 | 89 | /** Sets up WordPress vars and included files. */ |
89 | 90 | require_once(ABSPATH . 'wp-settings.php'); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | /* Path to the WordPress codebase you'd like to test. Add a backslash in the end. */ |
4 | -define( 'ABSPATH', dirname( __FILE__ ) . '/src/' ); |
|
4 | +define('ABSPATH', dirname(__FILE__).'/src/'); |
|
5 | 5 | |
6 | 6 | // Test with multisite enabled. |
7 | 7 | // Alternatively, use the tests/phpunit/multisite.xml configuration file. |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | // define( 'WP_TESTS_FORCE_KNOWN_BUGS', true ); |
13 | 13 | |
14 | 14 | // Test with WordPress debug mode (default). |
15 | -define( 'WP_DEBUG', true ); |
|
15 | +define('WP_DEBUG', true); |
|
16 | 16 | |
17 | 17 | // ** MySQL settings ** // |
18 | 18 | |
@@ -23,19 +23,19 @@ discard block |
||
23 | 23 | // These tests will DROP ALL TABLES in the database with the prefix named below. |
24 | 24 | // DO NOT use a production database or one that is shared with something else. |
25 | 25 | |
26 | -define( 'DB_NAME', 'youremptytestdbnamehere' ); |
|
27 | -define( 'DB_USER', 'yourusernamehere' ); |
|
28 | -define( 'DB_PASSWORD', 'yourpasswordhere' ); |
|
29 | -define( 'DB_HOST', 'localhost' ); |
|
30 | -define( 'DB_CHARSET', 'utf8' ); |
|
31 | -define( 'DB_COLLATE', '' ); |
|
26 | +define('DB_NAME', 'youremptytestdbnamehere'); |
|
27 | +define('DB_USER', 'yourusernamehere'); |
|
28 | +define('DB_PASSWORD', 'yourpasswordhere'); |
|
29 | +define('DB_HOST', 'localhost'); |
|
30 | +define('DB_CHARSET', 'utf8'); |
|
31 | +define('DB_COLLATE', ''); |
|
32 | 32 | |
33 | -$table_prefix = 'wptests_'; // Only numbers, letters, and underscores please! |
|
33 | +$table_prefix = 'wptests_'; // Only numbers, letters, and underscores please! |
|
34 | 34 | |
35 | -define( 'WP_TESTS_DOMAIN', 'example.org' ); |
|
36 | -define( 'WP_TESTS_EMAIL', '[email protected]' ); |
|
37 | -define( 'WP_TESTS_TITLE', 'Test Blog' ); |
|
35 | +define('WP_TESTS_DOMAIN', 'example.org'); |
|
36 | +define('WP_TESTS_EMAIL', '[email protected]'); |
|
37 | +define('WP_TESTS_TITLE', 'Test Blog'); |
|
38 | 38 | |
39 | -define( 'WP_PHP_BINARY', 'php' ); |
|
39 | +define('WP_PHP_BINARY', 'php'); |
|
40 | 40 | |
41 | -define( 'WPLANG', '' ); |
|
41 | +define('WPLANG', ''); |