Twenty Fourteen: rename transient all_the_cool_cats and make sure count is an integer before checking it. Props SergeyBiryukov for initial patch, fixes #26319.

Built from https://develop.svn.wordpress.org/trunk@26572


git-svn-id: http://core.svn.wordpress.org/trunk@26463 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Lance Willett 2013-12-03 18:24:10 +00:00
parent 66425e1489
commit abfec528c3

View File

@ -129,7 +129,7 @@ endif;
* @return boolean true if blog has more than 1 category
*/
function twentyfourteen_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) {
if ( false === ( $all_the_cool_cats = get_transient( 'twentyfourteen_category_count' ) ) ) {
// Create an array of all the categories that are attached to posts
$all_the_cool_cats = get_categories( array(
'hide_empty' => 1,
@ -138,10 +138,10 @@ function twentyfourteen_categorized_blog() {
// Count the number of categories that are attached to the posts
$all_the_cool_cats = count( $all_the_cool_cats );
set_transient( 'all_the_cool_cats', $all_the_cool_cats );
set_transient( 'twentyfourteen_category_count', $all_the_cool_cats );
}
if ( '1' != $all_the_cool_cats ) {
if ( 1 !== (int) $all_the_cool_cats ) {
// This blog has more than 1 category so twentyfourteen_categorized_blog should return true
return true;
} else {
@ -159,7 +159,7 @@ function twentyfourteen_categorized_blog() {
*/
function twentyfourteen_category_transient_flusher() {
// Like, beat it. Dig?
delete_transient( 'all_the_cool_cats' );
delete_transient( 'twentyfourteen_category_count' );
}
add_action( 'edit_category', 'twentyfourteen_category_transient_flusher' );
add_action( 'save_post', 'twentyfourteen_category_transient_flusher' );