Bad cat ID cleanup
git-svn-id: https://develop.svn.wordpress.org/trunk@2616 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f7f2958c1d
commit
64e674dad8
@ -543,6 +543,8 @@ function &get_category(&$category, $output = OBJECT) {
|
||||
if ( empty($category) )
|
||||
return null;
|
||||
|
||||
$category = (int) $category;
|
||||
|
||||
if ( ! isset($cache_categories))
|
||||
update_category_cache();
|
||||
|
||||
|
@ -101,6 +101,7 @@ function the_category($separator = '', $parents='') {
|
||||
}
|
||||
|
||||
function get_the_category_by_ID($cat_ID) {
|
||||
$cat_ID = (int) $cat_ID;
|
||||
$category = &get_category($cat_ID);
|
||||
return $category->cat_name;
|
||||
}
|
||||
|
@ -205,16 +205,16 @@ function single_post_title($prefix = '', $display = true) {
|
||||
}
|
||||
|
||||
function single_cat_title($prefix = '', $display = true ) {
|
||||
$cat = get_query_var('cat');
|
||||
if(!empty($cat) && !(strtoupper($cat) == 'ALL')) {
|
||||
$my_cat_name = get_the_category_by_ID($cat);
|
||||
if(!empty($my_cat_name)) {
|
||||
if ($display)
|
||||
echo $prefix.strip_tags($my_cat_name);
|
||||
else
|
||||
return strip_tags($my_cat_name);
|
||||
}
|
||||
}
|
||||
$cat = intval( get_query_var('cat') );
|
||||
if( !empty($cat) && !(strtoupper($cat) == 'ALL') ) {
|
||||
$my_cat_name = get_the_category_by_ID($cat);
|
||||
if( !empty($my_cat_name) ) {
|
||||
if ($display)
|
||||
echo $prefix.strip_tags($my_cat_name);
|
||||
else
|
||||
return strip_tags($my_cat_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function single_month_title($prefix = '', $display = true ) {
|
||||
|
Loading…
Reference in New Issue
Block a user