WordPress.org

Make WordPress Core

Ticket #28310: 28310.2.diff

File 28310.2.diff, 3.3 KB (added by SergeyBiryukov, 5 years ago)
  • src/wp-includes/general-template.php

     
    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. Empty string on failure.
    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 {
     
    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 or Unix timestamp. Empty string on failure.
    18361840 */
    18371841function get_the_time( $d = '', $post = null ) {
    18381842        $post = get_post($post);
    18391843
     1844        if ( ! $post ) {
     1845                return '';
     1846        }
     1847
    18401848        if ( '' == $d )
    18411849                $the_time = get_post_time(get_option('time_format'), false, $post, true);
    18421850        else
     
    18661874 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
    18671875 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
    18681876 * @param bool        $translate Whether to translate the time string. Default false.
    1869  * @return string|int Formatted date string, or Unix timestamp.
     1877 * @return string|int Formatted date string or Unix timestamp. Empty string on failure.
    18701878 */
    18711879function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
    18721880        $post = get_post($post);
    18731881
     1882        if ( ! $post ) {
     1883                return '';
     1884        }
     1885
    18741886        if ( $gmt )
    18751887                $time = $post->post_date_gmt;
    18761888        else
     
    19441956 *
    19451957 * @since 2.0.0
    19461958 *
    1947  * @param string $d Optional, default is 'U'. Either 'G', 'U', or php date format.
    1948  * @param bool $gmt Optional, default is false. Whether to return the gmt time.
    1949  * @param int|object $post Optional, default is global post object. A post_id or post object
    1950  * @param bool $translate Optional, default is false. Whether to translate the result
    1951  * @return string Returns timestamp
     1959 * @param string      $d         Optional. Format to use for retrieving the time the post
     1960 *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
     1961 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
     1962 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
     1963 * @param bool        $translate Whether to translate the time string. Default false.
     1964 * @return string|int Formatted date string or Unix timestamp. Empty string on failure.
    19521965 */
    19531966function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
    19541967        $post = get_post($post);
    19551968
     1969        if ( ! $post ) {
     1970                return '';
     1971        }
     1972
    19561973        if ( $gmt )
    19571974                $time = $post->post_modified_gmt;
    19581975        else