diff --git a/src/wp-includes/taxonomy.php b/src/wp-includes/taxonomy.php
index 778a6a3947..ac855d7e79 100644
|
a
|
b
|
function wp_insert_term( $term, $taxonomy, $args = array() ) { |
| 2464 | 2464 | return new WP_Error( 'invalid_term_name', __( 'Invalid term name.' ) ); |
| 2465 | 2465 | } |
| 2466 | 2466 | |
| 2467 | | $slug_provided = ! empty( $args['slug'] ); |
| 2468 | | if ( ! $slug_provided ) { |
| | 2467 | $slug = $args['slug']; |
| | 2468 | |
| | 2469 | // If no slug was provided, create one from the term name. |
| | 2470 | if ( empty( $args['slug'] ) ) { |
| 2469 | 2471 | $slug = sanitize_title( $name ); |
| 2470 | | } else { |
| 2471 | | $slug = $args['slug']; |
| 2472 | 2472 | } |
| 2473 | 2473 | |
| 2474 | 2474 | $term_group = 0; |
| … |
… |
function wp_insert_term( $term, $taxonomy, $args = array() ) { |
| 2524 | 2524 | |
| 2525 | 2525 | if ( $name_match ) { |
| 2526 | 2526 | $slug_match = get_term_by( 'slug', $slug, $taxonomy ); |
| 2527 | | if ( ! $slug_provided || $name_match->slug === $slug || $slug_match ) { |
| | 2527 | if ( $name_match->slug === $slug || $slug_match ) { |
| 2528 | 2528 | if ( is_taxonomy_hierarchical( $taxonomy ) ) { |
| 2529 | 2529 | $siblings = get_terms( |
| 2530 | 2530 | array( |
| … |
… |
function wp_insert_term( $term, $taxonomy, $args = array() ) { |
| 2539 | 2539 | $sibling_names = wp_list_pluck( $siblings, 'name' ); |
| 2540 | 2540 | $sibling_slugs = wp_list_pluck( $siblings, 'slug' ); |
| 2541 | 2541 | |
| 2542 | | if ( ( ! $slug_provided || $name_match->slug === $slug ) && in_array( $name, $sibling_names, true ) ) { |
| | 2542 | if ( ( $name_match->slug === $slug ) && in_array( $name, $sibling_names, true ) ) { |
| 2543 | 2543 | $existing_term = $name_match; |
| 2544 | 2544 | } elseif ( $slug_match && in_array( $slug, $sibling_slugs, true ) ) { |
| 2545 | 2545 | $existing_term = $slug_match; |