Make WordPress Core

Ticket #17455: 17455.diff

File 17455.diff, 2.9 KB (added by duck_, 14 years ago)
  • wp-includes/post.php

     
    41384138 * @uses apply_filters() Calls 'get_lastpostdate' filter
    41394139 *
    41404140 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
     4141 * @param string $post_type The post type to check. Default is 'any' for any publicly queryable post type.
    41414142 * @return string The date of the last post.
    41424143 */
    4143 function get_lastpostdate($timezone = 'server') {
    4144         return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date' ), $timezone );
     4144function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) {
     4145        return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone );
    41454146}
    41464147
    41474148/**
     
    41554156 * @uses apply_filters() Calls 'get_lastpostmodified' filter
    41564157 *
    41574158 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
     4159 * @param string $post_type The post type to check. Default is 'any' for any publicly queryable post type.
    41584160 * @return string The date the post was last modified.
    41594161 */
    4160 function get_lastpostmodified($timezone = 'server') {
    4161         $lastpostmodified = _get_last_post_time( $timezone, 'modified' );
     4162function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) {
     4163        $lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type );
    41624164
    41634165        $lastpostdate = get_lastpostdate($timezone);
    41644166        if ( $lastpostdate > $lastpostmodified )
     
    41754177 *
    41764178 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'.
    41774179 * @param string $field Field to check. Can be 'date' or 'modified'.
     4180 * @param string $post_type The post type to check. Can be 'any' for any publicly queryable post type.
    41784181 * @return string The date.
    41794182 */
    4180 function _get_last_post_time( $timezone, $field ) {
     4183function _get_last_post_time( $timezone, $field, $post_type ) {
    41814184        global $wpdb;
    41824185
    41834186        if ( !in_array( $field, array( 'date', 'modified' ) ) )
     
    41864189        $timezone = strtolower( $timezone );
    41874190
    41884191        $key = "lastpost{$field}:$timezone";
     4192        if ( 'any' != $post_type )
     4193                $key .= ':' . sanitize_key( $post_type );
    41894194
    41904195        $date = wp_cache_get( $key, 'timeinfo' );
    41914196
    41924197        if ( !$date ) {
    41934198                $add_seconds_server = date('Z');
    41944199
    4195                 $post_types = get_post_types( array( 'publicly_queryable' => true ) );
    4196                 array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) );
    4197                 $post_types = "'" . implode( "', '", $post_types ) . "'";
     4200                if ( 'any' == $post_type ) {
     4201                        $post_types = get_post_types( array( 'publicly_queryable' => true ) );
     4202                        array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) );
     4203                        $post_types = "'" . implode( "', '", $post_types ) . "'";
     4204                } else {
     4205                        $post_types = "'" . sanitize_key( $post_type ) . "'";
     4206                }
    41984207
    41994208                switch ( $timezone ) {
    42004209                        case 'gmt':