Ticket #17455: 17455.diff
File 17455.diff, 2.9 KB (added by , 14 years ago) |
---|
-
wp-includes/post.php
4138 4138 * @uses apply_filters() Calls 'get_lastpostdate' filter 4139 4139 * 4140 4140 * @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. 4141 4142 * @return string The date of the last post. 4142 4143 */ 4143 function get_lastpostdate( $timezone = 'server') {4144 return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date' ), $timezone );4144 function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) { 4145 return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone ); 4145 4146 } 4146 4147 4147 4148 /** … … 4155 4156 * @uses apply_filters() Calls 'get_lastpostmodified' filter 4156 4157 * 4157 4158 * @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. 4158 4160 * @return string The date the post was last modified. 4159 4161 */ 4160 function get_lastpostmodified( $timezone = 'server') {4161 $lastpostmodified = _get_last_post_time( $timezone, 'modified' );4162 function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) { 4163 $lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type ); 4162 4164 4163 4165 $lastpostdate = get_lastpostdate($timezone); 4164 4166 if ( $lastpostdate > $lastpostmodified ) … … 4175 4177 * 4176 4178 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. 4177 4179 * @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. 4178 4181 * @return string The date. 4179 4182 */ 4180 function _get_last_post_time( $timezone, $field ) {4183 function _get_last_post_time( $timezone, $field, $post_type ) { 4181 4184 global $wpdb; 4182 4185 4183 4186 if ( !in_array( $field, array( 'date', 'modified' ) ) ) … … 4186 4189 $timezone = strtolower( $timezone ); 4187 4190 4188 4191 $key = "lastpost{$field}:$timezone"; 4192 if ( 'any' != $post_type ) 4193 $key .= ':' . sanitize_key( $post_type ); 4189 4194 4190 4195 $date = wp_cache_get( $key, 'timeinfo' ); 4191 4196 4192 4197 if ( !$date ) { 4193 4198 $add_seconds_server = date('Z'); 4194 4199 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 } 4198 4207 4199 4208 switch ( $timezone ) { 4200 4209 case 'gmt':