| 1 | Index: wp-includes/post.php |
|---|
| 2 | =================================================================== |
|---|
| 3 | --- wp-includes/post.php (revision 17936) |
|---|
| 4 | +++ wp-includes/post.php (working copy) |
|---|
| 5 | @@ -4138,10 +4138,11 @@ |
|---|
| 6 | * @uses apply_filters() Calls 'get_lastpostdate' filter |
|---|
| 7 | * |
|---|
| 8 | * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. |
|---|
| 9 | + * @param string $post_type The post type to check. Default is 'any' for any publicly queryable post type. |
|---|
| 10 | * @return string The date of the last post. |
|---|
| 11 | */ |
|---|
| 12 | -function get_lastpostdate($timezone = 'server') { |
|---|
| 13 | - return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date' ), $timezone ); |
|---|
| 14 | +function get_lastpostdate( $timezone = 'server', $post_type = 'any' ) { |
|---|
| 15 | + return apply_filters( 'get_lastpostdate', _get_last_post_time( $timezone, 'date', $post_type ), $timezone ); |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | /** |
|---|
| 19 | @@ -4155,10 +4156,11 @@ |
|---|
| 20 | * @uses apply_filters() Calls 'get_lastpostmodified' filter |
|---|
| 21 | * |
|---|
| 22 | * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. |
|---|
| 23 | + * @param string $post_type The post type to check. Default is 'any' for any publicly queryable post type. |
|---|
| 24 | * @return string The date the post was last modified. |
|---|
| 25 | */ |
|---|
| 26 | -function get_lastpostmodified($timezone = 'server') { |
|---|
| 27 | - $lastpostmodified = _get_last_post_time( $timezone, 'modified' ); |
|---|
| 28 | +function get_lastpostmodified( $timezone = 'server', $post_type = 'any' ) { |
|---|
| 29 | + $lastpostmodified = _get_last_post_time( $timezone, 'modified', $post_type ); |
|---|
| 30 | |
|---|
| 31 | $lastpostdate = get_lastpostdate($timezone); |
|---|
| 32 | if ( $lastpostdate > $lastpostmodified ) |
|---|
| 33 | @@ -4175,9 +4177,10 @@ |
|---|
| 34 | * |
|---|
| 35 | * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. |
|---|
| 36 | * @param string $field Field to check. Can be 'date' or 'modified'. |
|---|
| 37 | + * @param string $post_type The post type to check. Can be 'any' for any publicly queryable post type. |
|---|
| 38 | * @return string The date. |
|---|
| 39 | */ |
|---|
| 40 | -function _get_last_post_time( $timezone, $field ) { |
|---|
| 41 | +function _get_last_post_time( $timezone, $field, $post_type ) { |
|---|
| 42 | global $wpdb; |
|---|
| 43 | |
|---|
| 44 | if ( !in_array( $field, array( 'date', 'modified' ) ) ) |
|---|
| 45 | @@ -4186,15 +4189,21 @@ |
|---|
| 46 | $timezone = strtolower( $timezone ); |
|---|
| 47 | |
|---|
| 48 | $key = "lastpost{$field}:$timezone"; |
|---|
| 49 | + if ( 'any' != $post_type ) |
|---|
| 50 | + $key .= ':' . sanitize_key( $post_type ); |
|---|
| 51 | |
|---|
| 52 | $date = wp_cache_get( $key, 'timeinfo' ); |
|---|
| 53 | |
|---|
| 54 | if ( !$date ) { |
|---|
| 55 | $add_seconds_server = date('Z'); |
|---|
| 56 | |
|---|
| 57 | - $post_types = get_post_types( array( 'publicly_queryable' => true ) ); |
|---|
| 58 | - array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) ); |
|---|
| 59 | - $post_types = "'" . implode( "', '", $post_types ) . "'"; |
|---|
| 60 | + if ( 'any' == $post_type ) { |
|---|
| 61 | + $post_types = get_post_types( array( 'publicly_queryable' => true ) ); |
|---|
| 62 | + array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) ); |
|---|
| 63 | + $post_types = "'" . implode( "', '", $post_types ) . "'"; |
|---|
| 64 | + } else { |
|---|
| 65 | + $post_types = "'" . sanitize_key( $post_type ) . "'"; |
|---|
| 66 | + } |
|---|
| 67 | |
|---|
| 68 | switch ( $timezone ) { |
|---|
| 69 | case 'gmt': |
|---|