WordPress.org

Make WordPress Core

Ticket #14922: 14922.001.diff

File 14922.001.diff, 3.6 KB (added by aaroncampbell, 5 years ago)
  • wp-includes/post.php

     
    20742074 
    20752075        $post = get_post($postid, $mode); 
    20762076 
    2077         if (  
     2077        if ( 
    20782078                ( OBJECT == $mode && empty( $post->ID ) ) || 
    20792079                ( OBJECT != $mode && empty( $post['ID'] ) ) 
    20802080        ) 
     
    38953895        global $cache_lastpostdate, $wpdb, $blog_id; 
    38963896        $add_seconds_server = date('Z'); 
    38973897        if ( !isset($cache_lastpostdate[$blog_id][$timezone]) ) { 
     3898                $post_types = apply_filters( 'get_lastpostdate_post_types', array('post') ); 
     3899                array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) ); 
     3900                $post_types = "'" . implode( "', '", $post_types ) . "'"; 
    38983901                switch(strtolower($timezone)) { 
    38993902                        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"); 
    39013904                                break; 
    39023905                        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"); 
    39043907                                break; 
    39053908                        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"); 
    39073910                                break; 
    39083911                } 
    39093912                $cache_lastpostdate[$blog_id][$timezone] = $lastpostdate; 
     
    39383941        if ( $lastpostmodified ) 
    39393942                return apply_filters( 'get_lastpostmodified', $lastpostmodified, $timezone ); 
    39403943 
     3944        $post_types = apply_filters( 'get_lastpostmodified_post_types', array('post') ); 
     3945        array_walk( $post_types, array( &$wpdb, 'escape_by_ref' ) ); 
     3946        $post_types = "'" . implode( "', '", $post_types ) . "'"; 
    39413947        switch ( strtolower($timezone) ) { 
    39423948                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"); 
    39443950                        break; 
    39453951                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"); 
    39473953                        break; 
    39483954                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"); 
    39503956                        break; 
    39513957        } 
    39523958