WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/14/2020 12:05:43 AM (11 months ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename $d parameter in various date/time functions to $format for clarity.

See #49222.

File:
1 edited

Legend:

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

    r47230 r47287  
    23452345 * @global string $previousday The day of the previous post in the loop.
    23462346 *
    2347  * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
     2347 * @param string $format Optional. PHP date format defaults to the date_format option if not specified.
    23482348 * @param string $before Optional. Output before the date.
    23492349 * @param string $after  Optional. Output after the date.
     
    23512351 * @return string|void String if retrieving.
    23522352 */
    2353 function the_date( $d = '', $before = '', $after = '', $echo = true ) {
     2353function the_date( $format = '', $before = '', $after = '', $echo = true ) {
    23542354    global $currentday, $previousday;
    23552355
     
    23572357
    23582358    if ( is_new_day() ) {
    2359         $the_date    = $before . get_the_date( $d ) . $after;
     2359        $the_date    = $before . get_the_date( $format ) . $after;
    23602360        $previousday = $currentday;
    23612361    }
     
    23672367     *
    23682368     * @param string $the_date The formatted date string.
    2369      * @param string $d        PHP date format. Defaults to 'date_format' option
     2369     * @param string $format   PHP date format. Defaults to 'date_format' option
    23702370     *                         if not specified.
    23712371     * @param string $before   HTML output before the date.
    23722372     * @param string $after    HTML output after the date.
    23732373     */
    2374     $the_date = apply_filters( 'the_date', $the_date, $d, $before, $after );
     2374    $the_date = apply_filters( 'the_date', $the_date, $format, $before, $after );
    23752375
    23762376    if ( $echo ) {
     
    23892389 * @since 3.0.0
    23902390 *
    2391  * @param  string      $d    Optional. PHP date format defaults to the date_format option if not specified.
    2392  * @param  int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
     2391 * @param  string      $format Optional. PHP date format defaults to the date_format option if not specified.
     2392 * @param  int|WP_Post $post   Optional. Post ID or WP_Post object. Default current post.
    23932393 * @return string|false Date the current post was written. False on failure.
    23942394 */
    2395 function get_the_date( $d = '', $post = null ) {
     2395function get_the_date( $format = '', $post = null ) {
    23962396    $post = get_post( $post );
    23972397
     
    24002400    }
    24012401
    2402     if ( '' == $d ) {
     2402    if ( '' == $format ) {
    24032403        $the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
    24042404    } else {
    2405         $the_date = get_post_time( $d, false, $post, true );
     2405        $the_date = get_post_time( $format, false, $post, true );
    24062406    }
    24072407
     
    24122412     *
    24132413     * @param string      $the_date The formatted date.
    2414      * @param string      $d        PHP date format. Defaults to 'date_format' option
     2414     * @param string      $format   PHP date format. Defaults to 'date_format' option
    24152415     *                              if not specified.
    24162416     * @param int|WP_Post $post     The post object or ID.
    24172417     */
    2418     return apply_filters( 'get_the_date', $the_date, $d, $post );
     2418    return apply_filters( 'get_the_date', $the_date, $format, $post );
    24192419}
    24202420
     
    24242424 * @since 2.1.0
    24252425 *
    2426  * @param string $d      Optional. PHP date format defaults to the date_format option if not specified.
     2426 * @param string $format Optional. PHP date format defaults to the date_format option if not specified.
    24272427 * @param string $before Optional. Output before the date.
    24282428 * @param string $after  Optional. Output after the date.
     
    24302430 * @return string|void String if retrieving.
    24312431 */
    2432 function the_modified_date( $d = '', $before = '', $after = '', $echo = true ) {
    2433     $the_modified_date = $before . get_the_modified_date( $d ) . $after;
     2432function the_modified_date( $format = '', $before = '', $after = '', $echo = true ) {
     2433    $the_modified_date = $before . get_the_modified_date( $format ) . $after;
    24342434
    24352435    /**
     
    24392439     *
    24402440     * @param string $the_modified_date The last modified date.
    2441      * @param string $d                 PHP date format. Defaults to 'date_format' option
     2441     * @param string $format            PHP date format. Defaults to 'date_format' option
    24422442     *                                  if not specified.
    24432443     * @param string $before            HTML output before the date.
    24442444     * @param string $after             HTML output after the date.
    24452445     */
    2446     $the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $d, $before, $after );
     2446    $the_modified_date = apply_filters( 'the_modified_date', $the_modified_date, $format, $before, $after );
    24472447
    24482448    if ( $echo ) {
     
    24602460 * @since 4.6.0 Added the `$post` parameter.
    24612461 *
    2462  * @param string      $d    Optional. PHP date format defaults to the date_format option if not specified.
    2463  * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default current post.
     2462 * @param string      $format Optional. PHP date format defaults to the date_format option if not specified.
     2463 * @param int|WP_Post $post   Optional. Post ID or WP_Post object. Default current post.
    24642464 * @return string|false Date the current post was modified. False on failure.
    24652465 */
    2466 function get_the_modified_date( $d = '', $post = null ) {
     2466function get_the_modified_date( $format = '', $post = null ) {
    24672467    $post = get_post( $post );
    24682468
     
    24702470        // For backward compatibility, failures go through the filter below.
    24712471        $the_time = false;
    2472     } elseif ( empty( $d ) ) {
     2472    } elseif ( empty( $format ) ) {
    24732473        $the_time = get_post_modified_time( get_option( 'date_format' ), false, $post, true );
    24742474    } else {
    2475         $the_time = get_post_modified_time( $d, false, $post, true );
     2475        $the_time = get_post_modified_time( $format, false, $post, true );
    24762476    }
    24772477
     
    24832483     *
    24842484     * @param string|bool  $the_time The formatted date or false if no post is found.
    2485      * @param string       $d        PHP date format. Defaults to value specified in
     2485     * @param string       $format   PHP date format. Defaults to value specified in
    24862486     *                               'date_format' option.
    24872487     * @param WP_Post|null $post     WP_Post object or null if no post is found.
    24882488     */
    2489     return apply_filters( 'get_the_modified_date', $the_time, $d, $post );
     2489    return apply_filters( 'get_the_modified_date', $the_time, $format, $post );
    24902490}
    24912491
     
    24952495 * @since 0.71
    24962496 *
    2497  * @param string $d Either 'G', 'U', or php date format.
    2498  */
    2499 function the_time( $d = '' ) {
     2497 * @param string $format Either 'G', 'U', or PHP date format.
     2498 */
     2499function the_time( $format = '' ) {
    25002500    /**
    25012501     * Filters the time a post was written for display.
     
    25042504     *
    25052505     * @param string $get_the_time The formatted time.
    2506      * @param string $d            The time format. Accepts 'G', 'U',
    2507      *                             or php date format.
    2508      */
    2509     echo apply_filters( 'the_time', get_the_time( $d ), $d );
     2506     * @param string $format       The time format. Accepts 'G', 'U',
     2507     *                             or PHP date format.
     2508     */
     2509    echo apply_filters( 'the_time', get_the_time( $format ), $format );
    25102510}
    25112511
     
    25152515 * @since 1.5.0
    25162516 *
    2517  * @param string      $d    Optional. Format to use for retrieving the time the post
    2518  *                          was written. Either 'G', 'U', or php date format defaults
    2519  *                          to the value specified in the time_format option. Default empty.
    2520  * @param int|WP_Post $post WP_Post object or ID. Default is global `$post` object.
    2521  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
    2522  */
    2523 function get_the_time( $d = '', $post = null ) {
     2517 * @param string      $format Optional. Format to use for retrieving the time the post
     2518 *                            was written. Either 'G', 'U', or PHP date format defaults
     2519 *                            to the value specified in the time_format option. Default empty.
     2520 * @param int|WP_Post $post   WP_Post object or ID. Default is global `$post` object.
     2521 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
     2522 *                          False on failure.
     2523 */
     2524function get_the_time( $format = '', $post = null ) {
    25242525    $post = get_post( $post );
    25252526
     
    25282529    }
    25292530
    2530     if ( '' == $d ) {
     2531    if ( '' == $format ) {
    25312532        $the_time = get_post_time( get_option( 'time_format' ), false, $post, true );
    25322533    } else {
    2533         $the_time = get_post_time( $d, false, $post, true );
     2534        $the_time = get_post_time( $format, false, $post, true );
    25342535    }
    25352536
     
    25402541     *
    25412542     * @param string      $the_time The formatted time.
    2542      * @param string      $d        Format to use for retrieving the time the post was written.
    2543      *                              Accepts 'G', 'U', or php date format value specified
     2543     * @param string      $format   Format to use for retrieving the time the post was written.
     2544     *                              Accepts 'G', 'U', or PHP date format value specified
    25442545     *                              in 'time_format' option. Default empty.
    25452546     * @param int|WP_Post $post     WP_Post object or ID.
    25462547     */
    2547     return apply_filters( 'get_the_time', $the_time, $d, $post );
     2548    return apply_filters( 'get_the_time', $the_time, $format, $post );
    25482549}
    25492550
     
    25532554 * @since 2.0.0
    25542555 *
    2555  * @param string      $d         Optional. Format to use for retrieving the time the post
    2556  *                               was written. Either 'G', 'U', or php date format. Default 'U'.
     2556 * @param string      $format    Optional. Format to use for retrieving the time the post
     2557 *                               was written. Either 'G', 'U', or PHP date format. Default 'U'.
    25572558 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
    25582559 * @param int|WP_Post $post      WP_Post object or ID. Default is global `$post` object.
    25592560 * @param bool        $translate Whether to translate the time string. Default false.
    2560  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
    2561  */
    2562 function get_post_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
     2561 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
     2562 *                          False on failure.
     2563 */
     2564function get_post_time( $format = 'U', $gmt = false, $post = null, $translate = false ) {
    25632565    $post = get_post( $post );
    25642566
     
    25742576    }
    25752577
    2576     if ( 'U' === $d || 'G' === $d ) {
     2578    if ( 'U' === $format || 'G' === $format ) {
    25772579        $time = $datetime->getTimestamp();
    25782580
     
    25822584        }
    25832585    } elseif ( $translate ) {
    2584         $time = wp_date( $d, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null );
     2586        $time = wp_date( $format, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null );
    25852587    } else {
    25862588        if ( $gmt ) {
     
    25882590        }
    25892591
    2590         $time = $datetime->format( $d );
     2592        $time = $datetime->format( $format );
    25912593    }
    25922594
     
    25962598     * @since 2.6.0
    25972599     *
    2598      * @param string $time The formatted time.
    2599      * @param string $d    Format to use for retrieving the time the post was written.
    2600      *                     Accepts 'G', 'U', or php date format. Default 'U'.
    2601      * @param bool   $gmt  Whether to retrieve the GMT time. Default false.
    2602      */
    2603     return apply_filters( 'get_post_time', $time, $d, $gmt );
     2600     * @param string $time   The formatted time.
     2601     * @param string $format Format to use for retrieving the time the post was written.
     2602     *                       Accepts 'G', 'U', or PHP date format. Default 'U'.
     2603     * @param bool   $gmt    Whether to retrieve the GMT time. Default false.
     2604     */
     2605    return apply_filters( 'get_post_time', $time, $format, $gmt );
    26042606}
    26052607
     
    26812683 * @since 2.0.0
    26822684 *
    2683  * @param string $d Optional Either 'G', 'U', or php date format defaults to the value specified in the time_format option.
    2684  */
    2685 function the_modified_time( $d = '' ) {
     2685 * @param string $format Optional. Either 'G', 'U', or PHP date format defaults
     2686 *                       to the value specified in the time_format option.
     2687 */
     2688function the_modified_time( $format = '' ) {
    26862689    /**
    26872690     * Filters the localized time a post was last modified, for display.
     
    26902693     *
    26912694     * @param string $get_the_modified_time The formatted time.
    2692      * @param string $d                     The time format. Accepts 'G', 'U',
    2693      *                                      or php date format. Defaults to value
     2695     * @param string $format                The time format. Accepts 'G', 'U',
     2696     *                                      or PHP date format. Defaults to value
    26942697     *                                      specified in 'time_format' option.
    26952698     */
    2696     echo apply_filters( 'the_modified_time', get_the_modified_time( $d ), $d );
     2699    echo apply_filters( 'the_modified_time', get_the_modified_time( $format ), $format );
    26972700}
    26982701
     
    27032706 * @since 4.6.0 Added the `$post` parameter.
    27042707 *
    2705  * @param string      $d    Optional. Format to use for retrieving the time the post
    2706  *                           was modified. Either 'G', 'U', or php date format defaults
    2707  *                           to the value specified in the time_format option. Default empty.
    2708  * @param int|WP_Post $post  Optional. Post ID or WP_Post object. Default current post.
     2708 * @param string      $format Optional. Format to use for retrieving the time the post
     2709 *                            was modified. Either 'G', 'U', or PHP date format defaults
     2710 *                            to the value specified in the time_format option. Default empty.
     2711 * @param int|WP_Post $post   Optional. Post ID or WP_Post object. Default current post.
    27092712 * @return string|false Formatted date string or Unix timestamp. False on failure.
    27102713 */
    2711 function get_the_modified_time( $d = '', $post = null ) {
     2714function get_the_modified_time( $format = '', $post = null ) {
    27122715    $post = get_post( $post );
    27132716
     
    27152718        // For backward compatibility, failures go through the filter below.
    27162719        $the_time = false;
    2717     } elseif ( empty( $d ) ) {
     2720    } elseif ( empty( $format ) ) {
    27182721        $the_time = get_post_modified_time( get_option( 'time_format' ), false, $post, true );
    27192722    } else {
    2720         $the_time = get_post_modified_time( $d, false, $post, true );
     2723        $the_time = get_post_modified_time( $format, false, $post, true );
    27212724    }
    27222725
     
    27282731     *
    27292732     * @param string|bool  $the_time The formatted time or false if no post is found.
    2730      * @param string       $d        Format to use for retrieving the time the post was
    2731      *                               written. Accepts 'G', 'U', or php date format. Defaults
     2733     * @param string       $format   Format to use for retrieving the time the post was
     2734     *                               written. Accepts 'G', 'U', or PHP date format. Defaults
    27322735     *                               to value specified in 'time_format' option.
    27332736     * @param WP_Post|null $post     WP_Post object or null if no post is found.
    27342737     */
    2735     return apply_filters( 'get_the_modified_time', $the_time, $d, $post );
     2738    return apply_filters( 'get_the_modified_time', $the_time, $format, $post );
    27362739}
    27372740
     
    27412744 * @since 2.0.0
    27422745 *
    2743  * @param string      $d         Optional. Format to use for retrieving the time the post
    2744  *                               was modified. Either 'G', 'U', or php date format. Default 'U'.
     2746 * @param string      $format    Optional. Format to use for retrieving the time the post
     2747 *                               was modified. Either 'G', 'U', or PHP date format. Default 'U'.
    27452748 * @param bool        $gmt       Optional. Whether to retrieve the GMT time. Default false.
    27462749 * @param int|WP_Post $post      WP_Post object or ID. Default is global `$post` object.
    27472750 * @param bool        $translate Whether to translate the time string. Default false.
    2748  * @return string|int|false Formatted date string or Unix timestamp if `$d` is 'U' or 'G'. False on failure.
    2749  */
    2750 function get_post_modified_time( $d = 'U', $gmt = false, $post = null, $translate = false ) {
     2751 * @return string|int|false Formatted date string or Unix timestamp if `$format` is 'U' or 'G'.
     2752 *                          False on failure.
     2753 */
     2754function get_post_modified_time( $format = 'U', $gmt = false, $post = null, $translate = false ) {
    27512755    $post = get_post( $post );
    27522756
     
    27622766    }
    27632767
    2764     if ( 'U' === $d || 'G' === $d ) {
     2768    if ( 'U' === $format || 'G' === $format ) {
    27652769        $time = $datetime->getTimestamp();
    27662770
     
    27702774        }
    27712775    } elseif ( $translate ) {
    2772         $time = wp_date( $d, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null );
     2776        $time = wp_date( $format, $datetime->getTimestamp(), $gmt ? new DateTimeZone( 'UTC' ) : null );
    27732777    } else {
    27742778        if ( $gmt ) {
     
    27762780        }
    27772781
    2778         $time = $datetime->format( $d );
     2782        $time = $datetime->format( $format );
    27792783    }
    27802784
     
    27842788     * @since 2.8.0
    27852789     *
    2786      * @param string $time The formatted time.
    2787      * @param string $d    Format to use for retrieving the time the post was modified.
    2788      *                     Accepts 'G', 'U', or php date format. Default 'U'.
    2789      * @param bool   $gmt  Whether to retrieve the GMT time. Default false.
    2790      */
    2791     return apply_filters( 'get_post_modified_time', $time, $d, $gmt );
     2790     * @param string $time   The formatted time.
     2791     * @param string $format Format to use for retrieving the time the post was modified.
     2792     *                       Accepts 'G', 'U', or PHP date format. Default 'U'.
     2793     * @param bool   $gmt    Whether to retrieve the GMT time. Default false.
     2794     */
     2795    return apply_filters( 'get_post_modified_time', $time, $format, $gmt );
    27922796}
    27932797
Note: See TracChangeset for help on using the changeset viewer.