Make WordPress Core


Ignore:
Timestamp:
08/31/2020 06:28:42 PM (6 years ago)
Author:
SergeyBiryukov
Message:

Date/Time: In get_the_date() and related functions, pass the original, unmodified $format value to the filters.

Additionally, simplify the $format argument checks for consistency with similar checks in get_the_modified_date() and get_the_modified_time().

Follow-up to [48912].

Props Rarst.
See #51184.

File:
1 edited

Legend:

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

    r48912 r48918  
    25262526        }
    25272527
    2528         if ( ! is_string( $format ) || '' === $format ) {
    2529                 $format = get_option( 'date_format' );
    2530         }
    2531 
    2532         $the_date = get_post_time( $format, false, $post, true );
     2528        $_format = ! empty( $format ) ? $format : get_option( 'date_format' );
     2529
     2530        $the_date = get_post_time( $_format, false, $post, true );
    25332531
    25342532        /**
    … …  
    25962594                // For backward compatibility, failures go through the filter below.
    25972595                $the_time = false;
    2598         } elseif ( empty( $format ) ) {
    2599                 $the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true );
    26002596        } else {
    2601                 $the_time = get_post_modified_time( $format, false, $post, true );
     2597                $_format = ! empty( $format ) ? $format : get_option( 'date_format' );
     2598
     2599                $the_time = get_post_modified_time( $_format, false, $post, true );
    26022600        }
    26032601
    … …  
    26552653        }
    26562654
    2657         if ( ! is_string( $format ) || '' === $format ) {
    2658                 $format = get_option( 'time_format' );
    2659         }
    2660 
    2661         $the_time = get_post_time( $format, false, $post, true );
     2655        $_format = ! empty( $format ) ? $format : get_option( 'time_format' );
     2656
     2657        $the_time = get_post_time( $_format, false, $post, true );
    26622658
    26632659        /**
    … …  
    28442840                // For backward compatibility, failures go through the filter below.
    28452841                $the_time = false;
    2846         } elseif ( empty( $format ) ) {
    2847                 $the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true );
    28482842        } else {
    2849                 $the_time = get_post_modified_time( $format, false, $post, true );
     2843                $_format = ! empty( $format ) ? $format : get_option( 'time_format' );
     2844
     2845                $the_time = get_post_modified_time( $_format, false, $post, true );
    28502846        }
    28512847
Note: See TracChangeset for help on using the changeset viewer.