Don't allow empty term names. Props scohoust. fixes #7336 for trunk
git-svn-id: http://svn.automattic.com/wordpress/trunk@8393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0ef06f9569
commit
364d78f689
|
@ -1199,6 +1199,9 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
||||||
if ( is_int($term) && 0 == $term )
|
if ( is_int($term) && 0 == $term )
|
||||||
return new WP_Error('invalid_term_id', __('Invalid term ID'));
|
return new WP_Error('invalid_term_id', __('Invalid term ID'));
|
||||||
|
|
||||||
|
if ( '' == trim($term) )
|
||||||
|
return new WP_Error('empty_term_name', __('A name is required for this term'));
|
||||||
|
|
||||||
$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
|
$defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
|
||||||
$args = wp_parse_args($args, $defaults);
|
$args = wp_parse_args($args, $defaults);
|
||||||
$args['name'] = $term;
|
$args['name'] = $term;
|
||||||
|
@ -1469,6 +1472,9 @@ function wp_update_term( $term, $taxonomy, $args = array() ) {
|
||||||
$name = stripslashes($name);
|
$name = stripslashes($name);
|
||||||
$description = stripslashes($description);
|
$description = stripslashes($description);
|
||||||
|
|
||||||
|
if ( '' == trim($name) )
|
||||||
|
return new WP_Error('empty_term_name', __('A name is required for this term'));
|
||||||
|
|
||||||
$empty_slug = false;
|
$empty_slug = false;
|
||||||
if ( empty($slug) ) {
|
if ( empty($slug) ) {
|
||||||
$empty_slug = true;
|
$empty_slug = true;
|
||||||
|
|
Loading…
Reference in New Issue