Make WordPress Core

Ticket #15202: 15202.patch

File 15202.patch, 2.5 KB (added by ximm, 10 years ago)

updated patch

  • src/wp-includes/general-template.php

     
    11481148        if ( !is_array($cache) )
    11491149                $cache = array();
    11501150
     1151        $join = apply_filters( 'getcalendar_join', '' );
     1152        $where = apply_filters( 'getcalendar_where', "post_type = 'post' AND post_status = 'publish'" );
     1153
    11511154        // Quick check. If we have no posts at all, abort!
    11521155        if ( !$posts ) {
    1153                 $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
     1156                $gotsome = $wpdb->get_var("SELECT 1 as test FROM $wpdb->posts $join WHERE $where LIMIT 1");
    11541157                if ( !$gotsome ) {
    11551158                        $cache[ $key ] = '';
    11561159                        wp_cache_set( 'get_calendar', $cache, 'calendar' );
     
    11891192
    11901193        // Get the next and previous month and year with at least one post
    11911194        $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
    1192                 FROM $wpdb->posts
     1195                FROM $wpdb->posts $join
    11931196                WHERE post_date < '$thisyear-$thismonth-01'
    1194                 AND post_type = 'post' AND post_status = 'publish'
     1197                AND $where
    11951198                        ORDER BY post_date DESC
    11961199                        LIMIT 1");
    11971200        $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year
    1198                 FROM $wpdb->posts
     1201                FROM $wpdb->posts $join
    11991202                WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59'
    1200                 AND post_type = 'post' AND post_status = 'publish'
     1203                AND $where
    12011204                        ORDER BY post_date ASC
    12021205                        LIMIT 1");
    12031206
     
    12501253
    12511254        // Get days with posts
    12521255        $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date)
    1253                 FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
    1254                 AND post_type = 'post' AND post_status = 'publish'
     1256                FROM $wpdb->posts $join
     1257                WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00'
     1258                AND $where
    12551259                AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N);
    12561260        if ( $dayswithposts ) {
    12571261                foreach ( (array) $dayswithposts as $daywith ) {
     
    12681272
    12691273        $ak_titles_for_day = array();
    12701274        $ak_post_titles = $wpdb->get_results("SELECT ID, post_title, DAYOFMONTH(post_date) as dom "
    1271                 ."FROM $wpdb->posts "
     1275                ."FROM $wpdb->posts $join "
    12721276                ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' "
    12731277                ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' "
    1274                 ."AND post_type = 'post' AND post_status = 'publish'"
     1278                ."AND $where"
    12751279        );
    12761280        if ( $ak_post_titles ) {
    12771281                foreach ( (array) $ak_post_titles as $ak_post_title ) {