WordPress.org

Make WordPress Core

Ticket #27181: 27181.2.patch

File 27181.2.patch, 1001 bytes (added by TobiasBg, 8 years ago)

Simplify/Cleanup get_the_date() and fix return type

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

    diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php
    index 5eb3e3d..2f69148 100644
    function the_date( $d = '', $before = '', $after = '', $echo = true ) { 
    14301430 * @since 3.0.0
    14311431 *
    14321432 * @param string $d Optional. PHP date format defaults to the date_format option if not specified.
    1433  * @return string|null Null if displaying, string if retrieving.
     1433 * @return string Date the current $post was written.
    14341434 */
    14351435function get_the_date( $d = '' ) {
    14361436        $post = get_post();
    1437         $the_date = '';
    14381437
    1439         if ( '' == $d )
    1440                 $the_date .= mysql2date(get_option('date_format'), $post->post_date);
    1441         else
    1442                 $the_date .= mysql2date($d, $post->post_date);
     1438        if ( '' == $d ) {
     1439                $d = get_option( 'date_format' );
     1440        }
     1441        $the_date = mysql2date( $d, $post->post_date );
    14431442
    1444         return apply_filters('get_the_date', $the_date, $d);
     1443        return apply_filters( 'get_the_date', $the_date, $d );
    14451444}
    14461445
    14471446/**