mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 17:48:01 +01:00
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:
parent
1b4a86c41e
commit
c81a649596
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user