Ticket #7155: calendar-sql-hook.patch
File calendar-sql-hook.patch, 2.6 KB (added by , 17 years ago) |
---|
-
general-template.php
old new function get_calendar($initial = true) { 489 489 } 490 490 } 491 491 492 //filters 493 $where = apply_filters('getcalendar_where', "WHERE post_type = 'post' AND post_status = 'publish'"); 494 492 495 ob_start(); 493 496 // Quick check. If we have no posts at all, abort! 494 497 if ( !$posts ) { 495 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'ORDER BY post_date DESC LIMIT 1");498 $gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts $where ORDER BY post_date DESC LIMIT 1"); 496 499 if ( !$gotsome ) 497 500 return; 498 501 } … … function get_calendar($initial = true) { 530 533 531 534 // Get the next and previous month and year with at least one post 532 535 $previous = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 533 FROM $wpdb->posts 534 WHERE post_date < '$thisyear-$thismonth-01' 535 AND post_type = 'post' AND post_status = 'publish' 536 FROM $wpdb->posts $where 537 AND post_date < '$thisyear-$thismonth-01' 536 538 ORDER BY post_date DESC 537 539 LIMIT 1"); 538 540 $next = $wpdb->get_row("SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year 539 FROM $wpdb->posts 540 WHEREpost_date > '$thisyear-$thismonth-01'541 FROM $wpdb->posts $where 542 AND post_date > '$thisyear-$thismonth-01' 541 543 AND MONTH( post_date ) != MONTH( '$thisyear-$thismonth-01' ) 542 AND post_type = 'post' AND post_status = 'publish'543 544 ORDER BY post_date ASC 544 545 LIMIT 1"); 545 546 … … function get_calendar($initial = true) { 593 594 594 595 // Get days with posts 595 596 $dayswithposts = $wpdb->get_results("SELECT DISTINCT DAYOFMONTH(post_date) 596 FROM $wpdb->posts WHERE MONTH(post_date) = '$thismonth'597 FROM $wpdb->posts $where 597 598 AND YEAR(post_date) = '$thisyear' 598 AND post_type = 'post' AND post_status = 'publish'599 AND MONTH(post_date) = '$thismonth' 599 600 AND post_date < '" . current_time('mysql') . '\'', ARRAY_N); 600 601 if ( $dayswithposts ) { 601 602 foreach ( $dayswithposts as $daywith ) { … … function get_calendar($initial = true) { 612 613 613 614 $ak_titles_for_day = array(); 614 615 $ak_post_titles = $wpdb->get_results("SELECT post_title, DAYOFMONTH(post_date) as dom " 615 ."FROM $wpdb->posts "616 ." WHEREYEAR(post_date) = '$thisyear' "616 ."FROM $wpdb->posts $where" 617 ."AND YEAR(post_date) = '$thisyear' " 617 618 ."AND MONTH(post_date) = '$thismonth' " 618 619 ."AND post_date < '".current_time('mysql')."' " 619 ."AND post_type = 'post' AND post_status = 'publish'"620 620 ); 621 621 if ( $ak_post_titles ) { 622 622 foreach ( $ak_post_titles as $ak_post_title ) {