Skip to content

Commit e1a245e

Browse files
authored
Avoid PHP warnings when javascript is output prior to locale initialisation.
This can happen when `wp_die()` is called during the bootstrap process of WordPress, notably, as part of the customizer previewer.
1 parent 072e6a5 commit e1a245e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

o2.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -942,6 +942,10 @@ public function remove_cached_incompatible_oembed( $html, $url, $args ) {
942942
* @return string|array - The translations object.
943943
*/
944944
function get_i18n_moment( $locale, $json_encode = true ) {
945+
if ( ! $locale ) {
946+
$locale = new WP_Locale;
947+
}
948+
945949
$moment = array(
946950
'months' => array_values( $locale->month ),
947951
'monthsShort' => array_values( $locale->month_abbrev ),

0 commit comments

Comments
 (0)