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:
parent
c644b16083
commit
09820497cb
|
@ -180,11 +180,13 @@ function get_cat_ID( $cat_name='General' ) {
|
|||
* @since 1.0.0
|
||||
*
|
||||
* @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 ) {
|
||||
$cat_id = (int) $cat_id;
|
||||
$category = &get_category( $cat_id );
|
||||
if ( ! $category || is_wp_error( $category ) )
|
||||
return '';
|
||||
return $category->name;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue