Code Duplication    Length = 17-19 lines in 2 locations

src/wp-includes/taxonomy.php 2 locations

@@ 2018-2034 (lines=17) @@
2015
	}
2016
2017
	$term_group = 0;
2018
	if ( $args['alias_of'] ) {
2019
		$alias = get_term_by( 'slug', $args['alias_of'], $taxonomy );
2020
		if ( ! empty( $alias->term_group ) ) {
2021
			// The alias we want is already in a group, so let's use that one.
2022
			$term_group = $alias->term_group;
2023
		} elseif ( ! empty( $alias->term_id ) ) {
2024
			/*
2025
			 * The alias is not in a group, so we create a new one
2026
			 * and add the alias to it.
2027
			 */
2028
			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
2029
2030
			wp_update_term( $alias->term_id, $taxonomy, array(
2031
				'term_group' => $term_group,
2032
			) );
2033
		}
2034
	}
2035
2036
	/*
2037
	 * Prevent the creation of terms with duplicate names at the same level of a taxonomy hierarchy,
@@ 2632-2650 (lines=19) @@
2629
	$parsed_args['slug'] = $slug;
2630
2631
	$term_group = isset( $parsed_args['term_group'] ) ? $parsed_args['term_group'] : 0;
2632
	if ( $args['alias_of'] ) {
2633
		$alias = get_term_by( 'slug', $args['alias_of'], $taxonomy );
2634
		if ( ! empty( $alias->term_group ) ) {
2635
			// The alias we want is already in a group, so let's use that one.
2636
			$term_group = $alias->term_group;
2637
		} elseif ( ! empty( $alias->term_id ) ) {
2638
			/*
2639
			 * The alias is not in a group, so we create a new one
2640
			 * and add the alias to it.
2641
			 */
2642
			$term_group = $wpdb->get_var("SELECT MAX(term_group) FROM $wpdb->terms") + 1;
2643
2644
			wp_update_term( $alias->term_id, $taxonomy, array(
2645
				'term_group' => $term_group,
2646
			) );
2647
		}
2648
2649
		$parsed_args['term_group'] = $term_group;
2650
	}
2651
2652
	/**
2653
	 * Filters the term parent.