Ticket #8351: general-template.php.2.diff

File general-template.php.2.diff, 2.4 KB (added by vladimir_kolesnikov, 3 years ago)
  • general-template.php

     
    10051005        } 
    10061006 
    10071007        $unixmonth = mktime(0, 0 , 0, $thismonth, 1, $thisyear); 
     1008        $last_day = date('t', $unixmonth); 
    10081009 
    10091010        // Get the next and previous month and year with at least one post 
    1010         $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 
     1011        $previous = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 
    10111012                FROM $wpdb->posts 
    10121013                WHERE post_date < '$thisyear-$thismonth-01' 
    10131014                AND post_type = 'post' AND post_status = 'publish' 
    10141015                        ORDER BY post_date DESC 
    10151016                        LIMIT 1"); 
    1016         $next = $wpdb->get_row("SELECT  DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 
     1017        $next = $wpdb->get_row("SELECT MONTH(post_date) AS month, YEAR(post_date) AS year 
    10171018                FROM $wpdb->posts 
    1018                 WHERE post_date >       '$thisyear-$thismonth-01' 
    1019                 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 
     1019                WHERE post_date > '$thisyear-$thismonth-{$last_day} 23:59:59' 
    10201020                AND post_type = 'post' AND post_status = 'publish' 
    1021                         ORDER   BY post_date ASC 
     1021                        ORDER BY post_date ASC 
    10221022                        LIMIT 1"); 
    10231023 
    10241024        /* translators: Calendar caption: 1: month name, 2: 4-digit year */ 
     
    10741074 
    10751075        // Get days with posts 
    10761076        $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 
    1077                 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth' 
    1078                 AND YEAR(post_date) = '$thisyear' 
     1077                FROM $wpdb->posts WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' 
    10791078                AND post_type = 'post' AND post_status = 'publish' 
    1080                 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); 
     1079                AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59'", ARRAY_N); 
    10811080        if ( $dayswithposts ) { 
    10821081                foreach ( (array) $dayswithposts as $daywith ) { 
    10831082                        $daywithpost[] = $daywith[0]; 
     
    10941093        $ak_titles_for_day = array(); 
    10951094        $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " 
    10961095                ."FROM $wpdb->posts " 
    1097                 ."WHERE YEAR(post_date) = '$thisyear' " 
    1098                 ."AND MONTH(post_date) = '$thismonth' " 
    1099                 ."AND post_date < '".current_time('mysql')."' " 
     1096                ."WHERE post_date >= '{$thisyear}-{$thismonth}-01 00:00:00' " 
     1097                ."AND post_date <= '{$thisyear}-{$thismonth}-{$last_day} 23:59:59' " 
    11001098                ."AND post_type = 'post' AND post_status = 'publish'" 
    11011099        ); 
    11021100        if ( $ak_post_titles ) {