WordPress.org

Make WordPress Core

Ticket #28310: 28310.3.diff

File 28310.3.diff, 3.9 KB (added by SergeyBiryukov, 5 years ago)
  • src/wp-includes/functions.php

     
    2121 * @param string $format Format of the date to return.
    2222 * @param string $date Date string to convert.
    2323 * @param bool $translate Whether the return date should be translated. Default is true.
    24  * @return string|int Formatted date string, or Unix timestamp.
     24 * @return string|int|bool Formatted date string or Unix timestamp. False if $date is empty.
    2525 */
    2626function mysql2date( $format, $date, $translate = true ) {
    2727        if ( empty( $date ) )
  • src/wp-includes/general-template.php

     
    17221722 *
    17231723 * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
    17241724 * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
    1725  * @return string Date the current post was written.
     1725 * @return string|bool Date the current post was written. False on failure.
    17261726 */
    17271727function get_the_date( $d = '', $post = null ) {
    17281728        $post = get_post( $post );
    17291729
     1730        if ( ! $post ) {
     1731                return false;
     1732        }
     1733
    17301734        if ( '' == $d ) {
    17311735                $the_date = mysql2date( get_option( 'date_format' ), $post->post_date );
    17321736        } else {
     
    18361840 *                          was written. Either 'G', 'U', or php date format defaults
    18371841 *                          to the value specified in the time_format option. Default empty.
    18381842 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
    1839  * @return string|int Formatted date string, or Unix timestamp.
     1843 * @return string|int|bool Formatted date string or Unix timestamp. False on failure.
    18401844 */
    18411845function get_the_time( $d = '', $post = null ) {
    18421846        $post = get_post($post);
    18431847
     1848        if ( ! $post ) {
     1849                return false;
     1850        }
     1851
    18441852        if ( '' == $d )
    18451853                $the_time = get_post_time(get_option('time_format'), false, $post, true);
    18461854        else
     
    18701878 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
    18711879 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
    18721880 * @param bool        $translate Whether to translate the time string. Default false.
    1873  * @return string|int Formatted date string, or Unix timestamp.
     1881 * @return string|int|bool Formatted date string or Unix timestamp. False on failure.
    18741882 */
    18751883function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
    18761884        $post = get_post($post);
    18771885
     1886        if ( ! $post ) {
     1887                return false;
     1888        }
     1889
    18781890        if ( $gmt )
    18791891                $time = $post->post_date_gmt;
    18801892        else
     
    19481960 *
    19491961 * @since 2.0.0
    19501962 *
    1951  * @param string $d Optional, default is 'U'. Either 'G', 'U', or php date format.
    1952  * @param bool $gmt Optional, default is false. Whether to return the gmt time.
    1953  * @param int|object $post Optional, default is global post object. A post_id or post object
    1954  * @param bool $translate Optional, default is false. Whether to translate the result
    1955  * @return string Returns timestamp
     1963 * @param string      $d         Optional. Format to use for retrieving the time the post
     1964 *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
     1965 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
     1966 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
     1967 * @param bool        $translate Whether to translate the time string. Default false.
     1968 * @return string|int|bool Formatted date string or Unix timestamp. False on failure.
    19561969 */
    19571970function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
    19581971        $post = get_post($post);
    19591972
     1973        if ( ! $post ) {
     1974                return false;
     1975        }
     1976
    19601977        if ( $gmt )
    19611978                $time = $post->post_modified_gmt;
    19621979        else