Make WordPress Core


Ignore:
Timestamp:
08/31/2020 06:56:22 PM (6 years ago)
Author:
desrosj
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.
Merges [48912] to the 5.5 branch.
Fixes #51184.

Location:
branches/5.5
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.5

  • branches/5.5/src/wp-includes/general-template.php

    r48871 r48921  
    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.