diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 8a7897a909..3acfe7318e 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -163,8 +163,12 @@ function wp_timezone() { * @return string The date, translated if locale specifies it. */ function date_i18n( $format, $timestamp_with_offset = false, $gmt = false ) { + $timestamp = $timestamp_with_offset; + // If timestamp is omitted it should be current time (summed with offset, unless `$gmt` is true). - $timestamp = $timestamp_with_offset ? $timestamp_with_offset : current_time( 'timestamp', $gmt ); + if ( ! is_numeric( $timestamp ) ) { + $timestamp = current_time( 'timestamp', $gmt ); + } /* * This is a legacy implementation quirk that the returned timestamp is also with offset. @@ -218,13 +222,15 @@ function date_i18n( $format, $timestamp_with_offset = false, $gmt = false ) { * @param int $timestamp Optional. Unix timestamp. Defaults to current time. * @param DateTimeZone $timezone Optional. Timezone to output result in. Defaults to timezone * from site settings. - * @return string The date, translated if locale specifies it. + * @return string|false The date, translated if locale specifies it. False on invalid timestamp input. */ function wp_date( $format, $timestamp = null, $timezone = null ) { global $wp_locale; - if ( ! $timestamp ) { + if ( null === $timestamp ) { $timestamp = time(); + } elseif ( ! is_numeric( $timestamp ) ) { + return false; } if ( ! $timezone ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index c63586ae5d..5f3d8ba250 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45913'; +$wp_version = '5.3-alpha-45914'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.