mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-29 07:37:44 +02:00
Fix calendar widget when there are no posts. Optimize query. Props Denis-de-Bernardy. fixes #6442
git-svn-id: http://svn.automattic.com/wordpress/trunk@10708 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
ead9ed7938
commit
0b1292e1d2
@ -930,14 +930,17 @@ function get_calendar($initial = true) {
|
|||||||
if ( !is_array($cache) )
|
if ( !is_array($cache) )
|
||||||
$cache = array();
|
$cache = array();
|
||||||
|
|
||||||
ob_start();
|
|
||||||
// Quick check. If we have no posts at all, abort!
|
// Quick check. If we have no posts at all, abort!
|
||||||
if ( !$posts ) {
|
if ( !$posts ) {
|
||||||
$gotsome = $wpdb->get_var("SELECT ID from $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY post_date DESC LIMIT 1");
|
$gotsome = $wpdb->get_var("SELECT 1 FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' LIMIT 1");
|
||||||
if ( !$gotsome )
|
if ( !$gotsome ) {
|
||||||
|
$cache[ $key ] = '';
|
||||||
|
wp_cache_set( 'get_calendar', $cache, 'calendar' );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ob_start();
|
||||||
if ( isset($_GET['w']) )
|
if ( isset($_GET['w']) )
|
||||||
$w = ''.intval($_GET['w']);
|
$w = ''.intval($_GET['w']);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user