Make WordPress Core

Ticket #28310: 28310.diff

File 28310.diff, 3.0 KB (added by GaryJ, 11 years ago)
  • src/wp-includes/general-template.php

    diff --git src/wp-includes/general-template.php src/wp-includes/general-template.php
    index f88a5f7..db2cdc0 100644
    function the_date( $d = '', $before = '', $after = '', $echo = true ) { 
    17181718 *
    17191719 * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
    17201720 * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
    1721  * @return string Date the current post was written.
     1721 * @return string Date the current post was written or empty string if post could not be determined.
    17221722 */
    17231723function get_the_date( $d = '', $post = null ) {
    17241724        $post = get_post( $post );
    17251725
     1726        if ( ! $post ) {
     1727                return '';
     1728        }
     1729
    17261730        if ( '' == $d ) {
    17271731                $the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
    17281732        } else {
    function the_time( $d = '' ) { 
    18321836 *                          was written. Either 'G', 'U', or php date format defaults
    18331837 *                          to the value specified in the time_format option. Default empty.
    18341838 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
    1835  * @return string|int Formatted date string, or Unix timestamp.
     1839 * @return string|int Formatted date string, Unix timestamp or empty string if post
     1840 *                          could not be determined.
    18361841 */
    18371842function get_the_time( $d = '', $post = null ) {
    18381843        $post = get_post($post);
    18391844
     1845        if ( ! $post ) {
     1846                return '';
     1847        }
     1848
    18401849        if ( '' == $d )
    18411850                $the_time = get_post_time(get_option('time_format'), false, $post, true);
    18421851        else
    function get_the_time( $d = '', $post = null ) { 
    18661875 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
    18671876 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
    18681877 * @param bool        $translate Whether to translate the time string. Default false.
    1869  * @return string|int Formatted date string, or Unix timestamp.
     1878 * @return string|int Formatted date string, Unix timestamp or empty string if post
     1879 *                               could not be determined.
    18701880 */
    18711881function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
    18721882        $post = get_post($post);
    18731883
     1884        if ( ! $post ) {
     1885                return '';
     1886        }
     1887
    18741888        if ( $gmt )
    18751889                $time = $post->post_date_gmt;
    18761890        else
    function get_the_modified_time($d = '') { 
    19481962 * @param bool $gmt Optional, default is false. Whether to return the gmt time.
    19491963 * @param int|object $post Optional, default is global post object. A post_id or post object
    19501964 * @param bool $translate Optional, default is false. Whether to translate the result
    1951  * @return string Returns timestamp
     1965 * @return string Returns timestamp or empty string if post could not be determined.
    19521966 */
    19531967function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
    19541968        $post = get_post($post);
    19551969
     1970        if ( ! $post ) {
     1971                return '';
     1972        }
     1973
    19561974        if ( $gmt )
    19571975                $time = $post->post_modified_gmt;
    19581976        else