Prefix transient.

This commit is contained in:
Konstantin Kovshenin 2014-03-18 18:43:00 +04:00
parent 43241a811d
commit 87ca7b66ad
1 changed files with 6 additions and 6 deletions

View File

@ -99,19 +99,19 @@ endif;
* Returns true if a blog has more than 1 category. * Returns true if a blog has more than 1 category.
*/ */
function _s_categorized_blog() { function _s_categorized_blog() {
if ( false === ( $all_the_cool_cats = get_transient( 'all_the_cool_cats' ) ) ) { if ( false === ( $categories = get_transient( '_s_categories' ) ) ) {
// Create an array of all the categories that are attached to posts. // Create an array of all the categories that are attached to posts.
$all_the_cool_cats = get_categories( array( $categories = get_categories( array(
'hide_empty' => 1, 'hide_empty' => 1,
) ); ) );
// Count the number of categories that are attached to the posts. // Count the number of categories that are attached to the posts.
$all_the_cool_cats = count( $all_the_cool_cats ); $categories = count( $categories );
set_transient( 'all_the_cool_cats', $all_the_cool_cats ); set_transient( '_s_categories', $categories );
} }
if ( '1' != $all_the_cool_cats ) { if ( '1' != $categories ) {
// This blog has more than 1 category so _s_categorized_blog should return true. // This blog has more than 1 category so _s_categorized_blog should return true.
return true; return true;
} else { } else {
@ -125,7 +125,7 @@ function _s_categorized_blog() {
*/ */
function _s_category_transient_flusher() { function _s_category_transient_flusher() {
// Like, beat it. Dig? // Like, beat it. Dig?
delete_transient( 'all_the_cool_cats' ); delete_transient( '_s_categories' );
} }
add_action( 'edit_category', '_s_category_transient_flusher' ); add_action( 'edit_category', '_s_category_transient_flusher' );
add_action( 'save_post', '_s_category_transient_flusher' ); add_action( 'save_post', '_s_category_transient_flusher' );