Skip to content

Commit

Permalink
PHP lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mkaz committed Jul 8, 2020
1 parent 5488c66 commit d973b15
Showing 1 changed file with 36 additions and 37 deletions.
73 changes: 36 additions & 37 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ function gutenberg_add_dom_rect_polyfill( $scripts ) {
* The script registration occurs in core wp-includes/script-loader.php
* wp_default_packages_inline_scripts()
*
*
* @since 8.6.0
*
* @param WP_Scripts $scripts WP_Scripts object.
Expand All @@ -350,54 +349,54 @@ function gutenberg_add_date_settings_timezone( $scripts ) {
if ( did_action( 'init' ) ) {
global $wp_locale;

// calcualte the timezone abbr (EDT, PST) if possible
$timezone_string = get_option('timezone_string', 'UTC');
// calcualte the timezone abbr (EDT, PST) if possible.
$timezone_string = get_option( 'timezone_string', 'UTC' );
if ( empty( $timezone_string ) ) {
$timezone_abbr = '';
} else {
$timezone_date = new DateTime(null, new DateTimeZone($timezone_string));
$timezone_abbr = $timezone_date->format('T');
$timezone_date = new DateTime( null, new DateTimeZone( $timezone_string ) );
$timezone_abbr = $timezone_date->format( 'T' );
}

$scripts->add_inline_script(
'wp-date',
sprintf(
'wp.date.setSettings( %s );',
wp_json_encode(
array(
'l10n' => array(
'locale' => get_user_locale(),
'months' => array_values( $wp_locale->month ),
'monthsShort' => array_values( $wp_locale->month_abbrev ),
'weekdays' => array_values( $wp_locale->weekday ),
'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
'meridiem' => (object) $wp_locale->meridiem,
'relative' => array(
/* translators: %s: Duration. */
'future' => __( '%s from now' ),
/* translators: %s: Duration. */
'past' => __( '%s ago' ),
),
),
'formats' => array(
/* translators: Time format, see https://www.php.net/date */
'time' => get_option( 'time_format', __( 'g:i a' ) ),
/* translators: Date format, see https://www.php.net/date */
'date' => get_option( 'date_format', __( 'F j, Y' ) ),
/* translators: Date/Time format, see https://www.php.net/date */
'datetime' => __( 'F j, Y g:i a' ),
/* translators: Abbreviated date/time format, see https://www.php.net/date */
'datetimeAbbreviated' => __( 'M j, Y g:i a' ),
),
'timezone' => array(
'offset' => get_option( 'gmt_offset', 0 ),
'string' => get_option( 'timezone_string', 'UTC' ),
'abbr' => $timezone_abbr,
),
)
array(
'l10n' => array(
'locale' => get_user_locale(),
'months' => array_values( $wp_locale->month ),
'monthsShort' => array_values( $wp_locale->month_abbrev ),
'weekdays' => array_values( $wp_locale->weekday ),
'weekdaysShort' => array_values( $wp_locale->weekday_abbrev ),
'meridiem' => (object) $wp_locale->meridiem,
'relative' => array(
/* translators: %s: Duration. */
'future' => __( '%s from now', 'default' ),
/* translators: %s: Duration. */
'past' => __( '%s ago', 'default' ),
),
),
'formats' => array(
/* translators: Time format, see https://www.php.net/date */
'time' => get_option( 'time_format', __( 'g:i a', 'default' ) ),
/* translators: Date format, see https://www.php.net/date */
'date' => get_option( 'date_format', __( 'F j, Y', 'default' ) ),
/* translators: Date/Time format, see https://www.php.net/date */
'datetime' => __( 'F j, Y g:i a', 'default' ),
/* translators: Abbreviated date/time format, see https://www.php.net/date */
'datetimeAbbreviated' => __( 'M j, Y g:i a', 'default' ),
),
'timezone' => array(
'offset' => get_option( 'gmt_offset', 0 ),
'string' => get_option( 'timezone_string', 'UTC' ),
'abbr' => $timezone_abbr,
),
)
)
),
'after'
'after'
);
}
}
Expand Down

0 comments on commit d973b15

Please sign in to comment.