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

git-svn-id: http://svn.automattic.com/wordpress/trunk@7423 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-20 20:19:25 +00:00
parent 1b4a86c41e
commit c81a649596

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 ) == '' )
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;