Make WordPress Core


Ignore:
Timestamp:
08/31/2020 03:56:41 PM (4 years ago)
Author:
SergeyBiryukov
Message:

Date/Time: Make sure get_the_date() and related functions return correct time if the format was specified as false.

Technically, the $format argument should always be a string, but passing false used to work before [47808], so this restores backward compatibility.

The list of affected functions:

  • get_the_date()
  • get_the_time()
  • get_comment_date()
  • get_comment_time()

Props wittich, Rarst, akabarikalpesh, SergeyBiryukov.
Fixes #51184.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/general-template.php

    r48870 r48912  
    25262526    }
    25272527
    2528     if ( '' === $format ) {
    2529         $the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
    2530     } else {
    2531         $the_date = get_post_time( $format, false, $post, true );
    2532     }
     2528    if ( ! is_string( $format ) || '' === $format ) {
     2529        $format = get_option( 'date_format' );
     2530    }
     2531
     2532    $the_date = get_post_time( $format, false, $post, true );
    25332533
    25342534    /**
     
    26552655    }
    26562656
    2657     if ( '' === $format ) {
    2658         $the_time = get_post_time( get_option( 'time_format' ), false, $post, true );
    2659     } else {
    2660         $the_time = get_post_time( $format, false, $post, true );
    2661     }
     2657    if ( ! is_string( $format ) || '' === $format ) {
     2658        $format = get_option( 'time_format' );
     2659    }
     2660
     2661    $the_time = get_post_time( $format, false, $post, true );
    26622662
    26632663    /**
Note: See TracChangeset for help on using the changeset viewer.