Fix notice in get_cat_name(). Return empty string if category does not exist, fixes #11737.

git-svn-id: http://svn.automattic.com/wordpress/trunk@13074 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
nacin 2010-02-13 02:35:41 +00:00
parent c644b16083
commit 09820497cb
1 changed files with 3 additions and 1 deletions

View File

@ -180,11 +180,13 @@ function get_cat_ID( $cat_name='General' ) {
* @since 1.0.0 * @since 1.0.0
* *
* @param int $cat_id Category ID * @param int $cat_id Category ID
* @return string Category name * @return string Category name, or an empty string if category doesn't exist.
*/ */
function get_cat_name( $cat_id ) { function get_cat_name( $cat_id ) {
$cat_id = (int) $cat_id; $cat_id = (int) $cat_id;
$category = &get_category( $cat_id ); $category = &get_category( $cat_id );
if ( ! $category || is_wp_error( $category ) )
return '';
return $category->name; return $category->name;
} }