Make WordPress Core

Changeset 29344

Timestamp:
08/01/2014 06:39:22 PM (10 years ago)
Author:
wonderboymusic
Message:

Clarify that get_the_date(), get_the_time(), get_post_time() and get_post_modified_time() should return false when get_post() is null.

Adds unit tests.

Props GaryJ, SergeyBiryukov, tollmanz.
Fixes #28310.

Location:
trunk
Files:
3 edited

Legend:

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

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

    r29244 r29344  
    17261726 * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
    17271727 * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
    1728  * @return string Date the current post was written.
     1728 * @return string.
    17291729 */
    17301730function get_the_date( $d = '', $post = null ) {
    17311731    $post = get_post( $post );
     1732
     1733
     1734
     1735
    17321736
    17331737    if ( '' == $d ) {
     
    18401844 *                          to the value specified in the time_format option. Default empty.
    18411845 * @param int|WP_Post $post WP_Post object or ID. Default is global $post object.
    1842  * @return string|int Formatted date string, or Unix timestamp.
     1846 * @return string|int.
    18431847 */
    18441848function get_the_time( $d = '', $post = null ) {
    18451849    $post = get_post($post);
     1850
     1851
     1852
     1853
    18461854
    18471855    if ( '' == $d )
     
    18741882 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
    18751883 * @param bool        $translate Whether to translate the time string. Default false.
    1876  * @return string|int Formatted date string, or Unix timestamp.
     1884 * @return string|int.
    18771885 */
    18781886function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
    18791887    $post = get_post($post);
     1888
     1889
     1890
     1891
    18801892
    18811893    if ( $gmt )
     
    19521964 * @since 2.0.0
    19531965 *
    1954  * @param string $d Optional, default is 'U'. Either 'G', 'U', or php date format.
    1955  * @param bool $gmt Optional, default is false. Whether to return the gmt time.
    1956  * @param int|object $post Optional, default is global post object. A post_id or post object
    1957  * @param bool $translate Optional, default is false. Whether to translate the result
    1958  * @return string Returns timestamp
     1966 * @param string      $d         Optional. Format to use for retrieving the time the post
     1967 *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
     1968 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
     1969 * @param int|WP_Post $post      WP_Post object or ID. Default is global $post object.
     1970 * @param bool        $translate Whether to translate the time string. Default false.
     1971 * @return string|int|bool Formatted date string or Unix timestamp. False on failure.
    19591972 */
    19601973function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
    19611974    $post = get_post($post);
     1975
     1976
     1977
     1978
    19621979
    19631980    if ( $gmt )
  • trunk/tests/phpunit/tests/post.php

    r27720 r29344  
    876876
    877877    /**
     878
     879
     880
     881
     882
     883
     884
     885
     886
     887
     888
     889
     890
     891
     892
     893
     894
     895
     896
     897
     898
     899
     900
     901
     902
     903
     904
     905
     906
     907
     908
     909
     910
     911
     912
     913
     914
     915
     916
     917
     918
     919
     920
     921
     922
     923
     924
     925
     926
     927
     928
     929
     930
     931
     932
     933
     934
     935
     936
     937
     938
     939
     940
     941
     942
     943
     944
     945
     946
     947
     948
     949
     950
     951
     952
     953
     954
     955
     956
     957
     958
     959
     960
     961
     962
     963
     964
     965
     966
     967
     968
     969
     970
     971
     972
     973
     974
     975
     976
     977
     978
     979
     980
     981
     982
     983
     984
     985
     986
     987
     988
     989
     990
     991
     992
     993
     994
     995
     996
     997
     998
     999
     1000
     1001
     1002
     1003
     1004
     1005
     1006
     1007
     1008
     1009
     1010
     1011
     1012
     1013
     1014
     1015
     1016
     1017
     1018
     1019
     1020
     1021
     1022
     1023
     1024
     1025
     1026
     1027
     1028
     1029
     1030
     1031
     1032
     1033
     1034
    8781035     * @ticket 25566
    8791036     */
Note: See TracChangeset for help on using the changeset viewer.