| @@ 49-55 (lines=7) @@ | ||
| 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 | // get_term_by is not case-sensitive, but a name with different casing is allowed |
|
| 51 | // also, the exact same name is allowed as long as the parents are different |
|
| 52 | if ( $input['name'] === $term->name && $input['parent'] === $term->parent ) { |
|
| 53 | return new WP_Error( 'duplicate', 'A taxonomy with that name already exists', 400 ); |
|
| 54 | } |
|
| 55 | } |
|
| 56 | ||
| 57 | $data = wp_insert_term( addslashes( $input['name'] ), $taxonomy_type, |
|
| 58 | array( |
|
| @@ 63-69 (lines=7) @@ | ||
| 60 | $input['parent'] = 0; |
|
| 61 | } |
|
| 62 | ||
| 63 | if ( $term = get_term_by( 'name', $input['name'], $taxonomy ) ) { |
|
| 64 | // get_term_by is not case-sensitive, but a name with different casing is allowed |
|
| 65 | // also, the exact same name is allowed as long as the parents are different |
|
| 66 | if ( $input['name'] === $term->name && $input['parent'] === $term->parent ) { |
|
| 67 | return new WP_Error( 'duplicate', 'A taxonomy with that name already exists', 409 ); |
|
| 68 | } |
|
| 69 | } |
|
| 70 | ||
| 71 | $data = wp_insert_term( addslashes( $input['name'] ), $taxonomy, array( |
|
| 72 | 'description' => addslashes( $input['description'] ), |
|