Ticket #14922: 14922.002.diff
File 14922.002.diff, 4.1 KB (added by , 15 years ago) |
---|
-
wp-includes/post.php
2074 2074 2075 2075 $post = get_post($postid, $mode); 2076 2076 2077 if ( 2077 if ( 2078 2078 ( OBJECT == $mode && empty( $post->ID ) ) || 2079 2079 ( OBJECT != $mode && empty( $post['ID'] ) ) 2080 2080 ) … … 3892 3892 * @return string The date of the last post. 3893 3893 */ 3894 3894 function get_lastpostdate($timezone = 'server') { 3895 global $cache_lastpostdate, $wpdb, $blog_id ;3895 global $cache_lastpostdate, $wpdb, $blog_id, $wp_query; 3896 3896 $add_seconds_server = date('Z'); 3897 3897 if ( !isset($cache_lastpostdate[$blog_id][$timezone]) ) { 3898 $post_types = apply_filters( 'get_lastpostdate_post_types', $wp_query->query_vars['post_type'] ); 3899 array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) ); 3900 $post_types = "'" . implode( "', '", $post_types ) . "'"; 3898 3901 switch(strtolower($timezone)) { 3899 3902 case 'gmt': 3900 $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post'ORDER BY post_date_gmt DESC LIMIT 1");3903 $lastpostdate = $wpdb->get_var("SELECT post_date_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_date_gmt DESC LIMIT 1"); 3901 3904 break; 3902 3905 case 'blog': 3903 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post'ORDER BY post_date_gmt DESC LIMIT 1");3906 $lastpostdate = $wpdb->get_var("SELECT post_date FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_date_gmt DESC LIMIT 1"); 3904 3907 break; 3905 3908 case 'server': 3906 $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post'ORDER BY post_date_gmt DESC LIMIT 1");3909 $lastpostdate = $wpdb->get_var("SELECT DATE_ADD(post_date_gmt, INTERVAL '$add_seconds_server' SECOND) FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_date_gmt DESC LIMIT 1"); 3907 3910 break; 3908 3911 } 3909 3912 $cache_lastpostdate[$blog_id][$timezone] = $lastpostdate; … … 3929 3932 * @return string The date the post was last modified. 3930 3933 */ 3931 3934 function get_lastpostmodified($timezone = 'server') { 3932 global $wpdb ;3935 global $wpdb, $wp_query; 3933 3936 3934 3937 $add_seconds_server = date('Z'); 3935 3938 $timezone = strtolower( $timezone ); … … 3938 3941 if ( $lastpostmodified ) 3939 3942 return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone ); 3940 3943 3944 $post_types = apply_filters( 'get_lastpostmodified_post_types', $wp_query->query_vars['post_type'] ); 3945 array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) ); 3946 $post_types = "'" . implode( "', '", $post_types ) . "'"; 3941 3947 switch ( strtolower($timezone) ) { 3942 3948 case 'gmt': 3943 $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");3949 $lastpostmodified = $wpdb->get_var("SELECT post_modified_gmt FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_modified_gmt DESC LIMIT 1"); 3944 3950 break; 3945 3951 case 'blog': 3946 $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");3952 $lastpostmodified = $wpdb->get_var("SELECT post_modified FROM $wpdb->posts WHERE post_status = 'publish' AND post_type IN ({$post_types}) ORDER BY post_modified_gmt DESC LIMIT 1"); 3947 3953 break; 3948 3954 case 'server': 3949 $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");3955 $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 IN ({$post_types}) ORDER BY post_modified_gmt DESC LIMIT 1"); 3950 3956 break; 3951 3957 } 3952 3958