From b3a5117b6dead166a1d5b28cbc4eb1ca4d4f4c01 Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 27 May 2005 06:10:41 +0000 Subject: [PATCH] Bad cat ID cleanup git-svn-id: http://svn.automattic.com/wordpress/trunk@2616 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 2 ++ wp-includes/template-functions-category.php | 1 + wp-includes/template-functions-general.php | 20 ++++++++++---------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 722f23e1d..c35a2795b 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -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(); diff --git a/wp-includes/template-functions-category.php b/wp-includes/template-functions-category.php index 50e256604..c28f61196 100644 --- a/wp-includes/template-functions-category.php +++ b/wp-includes/template-functions-category.php @@ -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; } diff --git a/wp-includes/template-functions-general.php b/wp-includes/template-functions-general.php index 9aa7bb27e..340dc577c 100644 --- a/wp-includes/template-functions-general.php +++ b/wp-includes/template-functions-general.php @@ -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 ) {