Ticket #1368: template_functions_general_1.5.1.2_mp001_hookup.patch

File template_functions_general_1.5.1.2_mp001_hookup.patch, 3.4 KB (added by pejve, 7 years ago)
  • template-functions-general.php

    old new  
    297297    $now = current_time('mysql'); 
    298298 
    299299    if ('monthly' == $type) { 
    300         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 
     300        $join = apply_filters('posts_join', ''); 
     301        $where = apply_filters('posts_where', "WHERE post_date < '$now' AND post_status = 'publish'"); 
     302        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit); 
    301303        if ($arcresults) { 
    302304            $afterafter = $after; 
    303305            foreach ($arcresults as $arcresult) { 
     
    312314            } 
    313315        } 
    314316    } elseif ('daily' == $type) { 
    315         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     317        $join = apply_filters('posts_join', ''); 
     318        $where = apply_filters('posts_where', "WHERE post_date < '$now' AND post_status = 'publish'"); 
     319        $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth` FROM $wpdb->posts $join $where ORDER BY post_date DESC" . $limit); 
    316320        if ($arcresults) { 
    317321            foreach ($arcresults as $arcresult) { 
    318322                $url  = get_day_link($arcresult->year, $arcresult->month, $arcresult->dayofmonth); 
     
    323327        } 
    324328    } elseif ('weekly' == $type) { 
    325329        $start_of_week = get_settings('start_of_week'); 
    326         $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     330        $join = apply_filters('posts_join', ''); 
     331        $where = apply_filters('posts_where', "WHERE post_date < '$now' AND post_status = 'publish'"); 
     332        $arcresults = $wpdb->get_results("SELECT DISTINCT WEEK(post_date, $start_of_week) AS `week`, YEAR(post_date) AS yr, DATE_FORMAT(post_date, '%Y-%m-%d') AS yyyymmdd FROM $wpdb->posts $join $where ORDER BY post_date DESC" . $limit); 
    327333        $arc_w_last = ''; 
    328334        if ($arcresults) { 
    329335            foreach ($arcresults as $arcresult) { 
     
    342348            } 
    343349        } 
    344350    } elseif ('postbypost' == $type) { 
    345         $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_date < '$now' AND post_status = 'publish' ORDER BY post_date DESC" . $limit); 
     351        $join = apply_filters('posts_join', ''); 
     352        $where = apply_filters('posts_where', "WHERE post_date < '$now' AND post_status = 'publish'"); 
     353        $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts $join $where ORDER BY post_date DESC" . $limit); 
    346354        if ($arcresults) { 
    347355            foreach ($arcresults as $arcresult) { 
    348356                if ($arcresult->post_date != '0000-00-00 00:00:00') {