Make WordPress Core

Changeset 48918


Ignore:
Timestamp:
08/31/2020 06:28:42 PM (4 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.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r48912 r48918  
    553553    $comment = get_comment( $comment_ID );
    554554
    555     if ( ! is_string( $format ) || '' === $format ) {
    556         $format = get_option( 'date_format' );
    557     }
    558 
    559     $date = mysql2date( $format, $comment->comment_date );
     555    $_format = ! empty( $format ) ? $format : get_option( 'date_format' );
     556
     557    $date = mysql2date( $_format, $comment->comment_date );
    560558
    561559    /**
     
    10471045    $comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
    10481046
    1049     if ( ! is_string( $format ) || '' === $format ) {
    1050         $format = get_option( 'time_format' );
    1051     }
    1052 
    1053     $date = mysql2date( $format, $comment_date, $translate );
     1047    $_format = ! empty( $format ) ? $format : get_option( 'time_format' );
     1048
     1049    $date = mysql2date( $_format, $comment_date, $translate );
    10541050
    10551051    /**
  • 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.