From 9da53b8b494b3cc8a18f6bf82ed3a22851bc83a5 Mon Sep 17 00:00:00 2001 From: youknowriad Date: Thu, 8 Feb 2024 07:06:02 +0000 Subject: [PATCH] Script Loader: Add a timezone offset display value to wp.date.setSettings. Fixes a bug in the editor where the offset values are displayed as decimals rather than minutes. Props afercia, get_dave. Fixes #60105. git-svn-id: https://develop.svn.wordpress.org/trunk@57556 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/script-loader.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index 25977a9bd7..771c6bc777 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -419,6 +419,8 @@ function wp_default_packages_inline_scripts( $scripts ) { $timezone_abbr = $timezone_date->format( 'T' ); } + $gmt_offset = get_option( 'gmt_offset', 0 ); + $scripts->add_inline_script( 'wp-date', sprintf( @@ -475,9 +477,10 @@ function wp_default_packages_inline_scripts( $scripts ) { 'datetimeAbbreviated' => __( 'M j, Y g:i a' ), ), 'timezone' => array( - 'offset' => (float) get_option( 'gmt_offset', 0 ), - 'string' => $timezone_string, - 'abbr' => $timezone_abbr, + 'offset' => (float) $gmt_offset, + 'offsetFormatted' => str_replace( array( '.25', '.5', '.75' ), array( ':15', ':30', ':45' ), (string) $gmt_offset ), + 'string' => $timezone_string, + 'abbr' => $timezone_abbr, ), ) )