Changeset 13653
- Timestamp:
- 03/10/2010 09:32:03 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/post.php
r13576 r13653 3719 3719 3720 3720 /** 3721 * Retrieve the date th ethe last post was published.3721 * Retrieve the date that the last post was published. 3722 3722 * 3723 3723 * The server timezone is the default and is the difference between GMT and … … 3771 3771 * @uses apply_filters() Calls 'get_lastpostmodified' filter 3772 3772 * 3773 * @global mixed $cache_lastpostmodified Stores the date the last post was modified3774 *3775 3773 * @param string $timezone The location to get the time. Can be 'gmt', 'blog', or 'server'. 3776 3774 * @return string The date the post was last modified. 3777 3775 */ 3778 3776 function get_lastpostmodified($timezone = 'server') { 3779 global $cache_lastpostmodified, $wpdb, $blog_id; 3777 global $wpdb; 3778 3780 3779 $add_seconds_server = date('Z'); 3781 if ( !isset($cache_lastpostmodified[$blog_id][$timezone]) ) { 3782 switch(strtolower($timezone)) { 3783 case 'gmt': 3784 $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); 3785 break; 3786 case 'blog': 3787 $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); 3788 break; 3789 case 'server': 3790 $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); 3791 break; 3792 } 3793 $lastpostdate = get_lastpostdate($timezone); 3794 if ( $lastpostdate > $lastpostmodified ) { 3795 $lastpostmodified = $lastpostdate; 3796 } 3797 $cache_lastpostmodified[$blog_id][$timezone] = $lastpostmodified; 3798 } else { 3799 $lastpostmodified = $cache_lastpostmodified[$blog_id][$timezone]; 3800 } 3780 $timezone = strtolower( $timezone ); 3781 3782 $lastpostmodified = wp_cache_get( "lastpostmodified:$timezone", 'timeinfo' ); 3783 if ( $lastpostmodified ) 3784 return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone ); 3785 3786 switch ( strtolower($timezone) ) { 3787 case 'gmt': 3788 $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); 3789 break; 3790 case 'blog': 3791 $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); 3792 break; 3793 case 'server': 3794 $lastpostmodified = $wpdb->get_var("SELECT DATE_ADD(post_modified_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY post_modified_gmt DESC LIMIT 1"); 3795 break; 3796 } 3797 3798 $lastpostdate = get_lastpostdate($timezone); 3799 if ( $lastpostdate > $lastpostmodified ) 3800 $lastpostmodified = $lastpostdate; 3801 3802 if ( $lastpostmodified ) 3803 wp_cache_set( "lastpostmodified:$timezone", $lastpostmodified, 'timeinfo' ); 3804 3801 3805 return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone ); 3802 3806 } … … 4015 4019 $wpdb->update( $wpdb->posts, array( 'guid' => get_permalink( $post->ID ) ), array( 'ID' => $post->ID ) ); 4016 4020 do_action('private_to_published', $post->ID); // Deprecated, use private_to_publish 4021 } 4022 4023 // If published posts changed clear the lastpostmodified cache 4024 if ( 'publish' == $new_status || 'publish' == $old_status) { 4025 wp_cache_delete( 'lastpostmodified:server', 'timeinfo' ); 4026 wp_cache_delete( 'lastpostmodified:gmt', 'timeinfo' ); 4027 wp_cache_delete( 'lastpostmodified:blog', 'timeinfo' ); 4017 4028 } 4018 4029
Note: See TracChangeset
for help on using the changeset viewer.