Merge pull request #28322 from aheckler/patch-1

Return default date and time formats if options are empty
This commit is contained in:
Roy Ho 2020-11-23 13:52:00 -08:00 committed by GitHub
commit 36108a2c83
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 2 deletions

View File

@ -638,7 +638,12 @@ function wc_let_to_num( $size ) {
* @return string
*/
function wc_date_format() {
return apply_filters( 'woocommerce_date_format', get_option( 'date_format' ) );
$date_format = get_option( 'date_format' );
if ( empty( $date_format ) ) {
// Return default date format if the option is empty.
$date_format = 'F j, Y';
}
return apply_filters( 'woocommerce_date_format', $date_format );
}
/**
@ -647,7 +652,12 @@ function wc_date_format() {
* @return string
*/
function wc_time_format() {
return apply_filters( 'woocommerce_time_format', get_option( 'time_format' ) );
$time_format = get_option( 'time_format' );
if ( empty( $time_format ) ) {
// Return default time format if the option is empty.
$time_format = 'g:i a';
}
return apply_filters( 'woocommerce_time_format', $time_format );
}
/**