Parse default args and return WP_Error for emprt cat name in wp_insert_category.

git-svn-id: https://develop.svn.wordpress.org/trunk@7423 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-03-20 20:19:25 +00:00
parent fe0bbb63e2
commit 27f4dc5ba4
1 changed files with 7 additions and 2 deletions

View File

@ -52,10 +52,15 @@ function wp_delete_category($cat_ID) {
function wp_insert_category($catarr, $wp_error = false) {
$cat_defaults = array('cat_ID' => 0, 'cat_name' => '', 'category_description' => '', 'category_nicename' => '', 'category_parent' => '');
$cat_arr = wp_parse_args($cat_arr, $cat_defaults);
extract($catarr, EXTR_SKIP);
if ( trim( $cat_name ) == '' )
return 0;
if ( trim( $cat_name ) == '' ) {
if ( ! $wp_error )
return 0;
else
return new WP_Error( 'cat_name', __('You did not enter a category name.') );
}
$cat_ID = (int) $cat_ID;