| @@ 49-54 (lines=6) @@ | ||
| 46 | if ( 'category' !== $taxonomy_type || ! isset( $input['parent'] ) ) |
|
| 47 | $input['parent'] = 0; |
|
| 48 | ||
| 49 | if ( $term = get_term_by( 'name', $input['name'], $taxonomy_type ) ) { |
|
| 50 | // the same name is allowed as long as the parents are different |
|
| 51 | if ( $input['parent'] === $term->parent ) { |
|
| 52 | return new WP_Error( 'duplicate', 'A taxonomy with that name already exists', 400 ); |
|
| 53 | } |
|
| 54 | } |
|
| 55 | ||
| 56 | $data = wp_insert_term( addslashes( $input['name'] ), $taxonomy_type, |
|
| 57 | array( |
|
| @@ 57-63 (lines=7) @@ | ||
| 54 | $input['parent'] = 0; |
|
| 55 | } |
|
| 56 | ||
| 57 | if ( $term = get_term_by( 'name', $input['name'], $taxonomy ) ) { |
|
| 58 | // get_term_by is not case-sensitive, but a name with different casing is allowed |
|
| 59 | // also, the exact same name is allowed as long as the parents are different |
|
| 60 | if ( $input['name'] === $term->name && $input['parent'] === $term->parent ) { |
|
| 61 | return new WP_Error( 'duplicate', 'A taxonomy with that name already exists', 409 ); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| 65 | $data = wp_insert_term( addslashes( $input['name'] ), $taxonomy, array( |
|
| 66 | 'description' => isset( $input['description'] ) ? addslashes( $input['description'] ) : '', |
|