forked from mirror/_s
Prefix transient.
This commit is contained in:
parent
43241a811d
commit
87ca7b66ad
|
@ -99,19 +99,19 @@ endif;
|
|||
* Returns true if a blog has more than 1 category.
|
||||
*/
|
||||
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.
|
||||
$all_the_cool_cats = get_categories( array(
|
||||
$categories = get_categories( array(
|
||||
'hide_empty' => 1,
|
||||
) );
|
||||
|
||||
// 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.
|
||||
return true;
|
||||
} else {
|
||||
|
@ -125,7 +125,7 @@ function _s_categorized_blog() {
|
|||
*/
|
||||
function _s_category_transient_flusher() {
|
||||
// Like, beat it. Dig?
|
||||
delete_transient( 'all_the_cool_cats' );
|
||||
delete_transient( '_s_categories' );
|
||||
}
|
||||
add_action( 'edit_category', '_s_category_transient_flusher' );
|
||||
add_action( 'save_post', '_s_category_transient_flusher' );
|
||||
|
|
Reference in New Issue