From 7cca74505239ca24f41071a47bb3ad11b39cc221 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Thu, 1 Oct 2020 17:41:18 +0000 Subject: [PATCH] WP Date: Add timezone abbreviation to wp-date settings. Props mkaz. Fixes #50624. git-svn-id: https://develop.svn.wordpress.org/trunk@49083 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index f97cac5d33..48b6e7587a 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -323,6 +323,15 @@ function wp_default_packages_inline_scripts( $scripts ) { ) ); + // Calculate the timezone abbr (EDT, PST) if possible. + $timezone_string = get_option( 'timezone_string', 'UTC' ); + $timezone_abbr = ''; + + if ( ! empty( $timezone_string ) ) { + $timezone_date = new DateTime( null, new DateTimeZone( $timezone_string ) ); + $timezone_abbr = $timezone_date->format( 'T' ); + } + $scripts->add_inline_script( 'wp-date', sprintf( @@ -355,7 +364,8 @@ function wp_default_packages_inline_scripts( $scripts ) { ), 'timezone' => array( 'offset' => get_option( 'gmt_offset', 0 ), - 'string' => get_option( 'timezone_string', 'UTC' ), + 'string' => $timezone_string, + 'abbr' => $timezone_abbr, ), ) )