WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/18/2019 05:07:07 PM (2 years ago)
Author:
adamsilverstein
Message:

Feeds: improve structure and naming of feed build date helper function.

Simplify overall code structure by passing the required format to the helper function.
Clarify functionality by renaming get_last_build_date to get_feed_build_date.

Props pento, spacedmonkey.
Fixes #4575.

File:
1 edited

Legend:

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

    r44948 r45247  
    639639
    640640/*
    641 * Get the timestamp of the most recently modified post from WP_Query.
    642 *
    643 * If viewing a comment feed, the date of the most recently modified
    644 * comment will be returned.
    645 *
    646 * @global WP_Query  $wp_query The global WP_Query object.
    647 *
    648 * @since 5.2.0
    649 *
    650 * @return string The timestamp.
    651 */
    652 function get_last_build_date() {
     641 * Get the timestamp of the most recently modified post from WP_Query.
     642 *
     643 * If viewing a comment feed, the timestamp of the most recently modified
     644 * comment will be returned.
     645 *
     646 * @global WP_Query  $wp_query The global WP_Query object.
     647 *
     648 * @since 5.2.0
     649 *
     650 * @param string $format Format of the timestamp to return, passed to mysql2date.
     651 *
     652 * @return string The timestamp.
     653 */
     654function get_feed_build_date( $format ) {
    653655    global $wp_query;
    654656
     
    671673
    672674    // Determine the maximum modified time.
    673     $max_modified_time = max( $modified_times );
     675    $max_modified_time = max(
     676        array_map(
     677            function ( $time ) use ( $format ) {
     678                return mysql2date( $format, $time, false );
     679            },
     680            $modified_times
     681        )
     682    );
    674683
    675684    /**
     
    678687     * @since 5.2.0
    679688     *
    680      * @param string $max_modified_times Date the last post or comment was modified in the query.
    681      */
    682     return apply_filters( 'get_last_build_date', $max_modified_time );
     689     * @param string $max_modified_time Date the last post or comment was modified in the query.
     690     * @param string $format            The date format requested in get_feed_build_date.
     691     */
     692    return apply_filters( 'get_feed_build_date', $max_modified_time, $format );
    683693}
    684694
Note: See TracChangeset for help on using the changeset viewer.