Make WordPress Core

Ticket #1368: 1368a.diff

File 1368a.diff, 3.9 KB (added by westi, 17 years ago)

Fixed patch

  • wp-includes/general-template.php

     
    342342        $add_hours = intval(get_option('gmt_offset'));
    343343        $add_minutes = intval(60 * (get_option('gmt_offset') - $add_hours));
    344344
     345        //filters
     346        $where = apply_filters('getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );
     347        $join = apply_filters('getarchives_join', "", $r);
     348
    345349        if ( 'monthly' == $type ) {
    346                 $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_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC" . $limit);
     350                $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);
    347351                if ( $arcresults ) {
    348352                        $afterafter = $after;
    349353                        foreach ( $arcresults as $arcresult ) {
     
    355359                        }
    356360                }
    357361        } elseif ('yearly' == $type) {
    358          $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts WHERE post_type ='post' AND post_status = 'publish' GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit);
     362         $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date) ORDER BY post_date DESC" . $limit);
    359363                if ($arcresults) {
    360364                        $afterafter = $after;
    361365                        foreach ($arcresults as $arcresult) {
     
    367371                        }
    368372                }
    369373        } elseif ( 'daily' == $type ) {
    370                 $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit);
     374                $arcresults = $wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, DAYOFMONTH(post_date) AS `dayofmonth`, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY YEAR(post_date), MONTH(post_date), DAYOFMONTH(post_date) ORDER BY post_date DESC" . $limit);
    371375                if ( $arcresults ) {
    372376                        $afterafter = $after;
    373377                        foreach ( $arcresults as $arcresult ) {
     
    381385                }
    382386        } elseif ( 'weekly' == $type ) {
    383387                $start_of_week = get_option('start_of_week');
    384                 $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, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit);
     388                $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, count(ID) as posts FROM $wpdb->posts $join $where GROUP BY WEEK(post_date, $start_of_week), YEAR(post_date) ORDER BY post_date DESC" . $limit);
    385389                $arc_w_last = '';
    386390                $afterafter = $after;
    387391                if ( $arcresults ) {
     
    402406                }
    403407        } elseif ( ( 'postbypost' == $type ) || ('alpha' == $type) ) {
    404408                ('alpha' == $type) ? $orderby = "post_title ASC " : $orderby = "post_date DESC ";
    405                 $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY $orderby $limit");
     409                $arcresults = $wpdb->get_results("SELECT * FROM $wpdb->posts $join $where $orderby $limit");
    406410                if ( $arcresults ) {
    407411                        foreach ( $arcresults as $arcresult ) {
    408412                                if ( $arcresult->post_date != '0000-00-00 00:00:00' ) {