WordPress.org

Make WordPress Core

Ticket #43271: 43271.2.diff

File 43271.2.diff, 2.1 KB (added by boonebgorges, 2 years ago)
  • src/wp-includes/taxonomy.php

    diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
    index 8ec3eaee3e..00c57947be 100644
    function wp_insert_term( $term, $taxonomy, $args = array() ) { 
    23122312         * and term_taxonomy_id of the older term instead. Then return out of the function so that the "create" hooks
    23132313         * are not fired.
    23142314         */
    2315         $duplicate_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id, tt.term_taxonomy_id FROM $wpdb->terms t INNER JOIN $wpdb->term_taxonomy tt ON ( tt.term_id = t.term_id ) WHERE t.slug = %s AND tt.parent = %d AND tt.taxonomy = %s AND t.term_id < %d AND tt.term_taxonomy_id != %d", $slug, $parent, $taxonomy, $term_id, $tt_id ) );
     2315        $duplicate_term = $wpdb->get_row( $wpdb->prepare( "SELECT t.term_id, t.slug, tt.term_taxonomy_id, tt.taxonomy FROM $wpdb->terms t INNER JOIN $wpdb->term_taxonomy tt ON ( tt.term_id = t.term_id ) WHERE t.slug = %s AND tt.parent = %d AND tt.taxonomy = %s AND t.term_id < %d AND tt.term_taxonomy_id != %d", $slug, $parent, $taxonomy, $term_id, $tt_id ) );
     2316
     2317        /**
     2318         * Filters the duplicate term check that takes place during term creation.
     2319         *
     2320         * Term parent+taxonomy+slug combinations are meant to be unique, and wp_insert_term()
     2321         * performs a last-minute confirmation of this uniqueness before allowing a new term
     2322         * to be created. Plugins with different uniqueness requirements may use this filter
     2323         * to bypass or modify the duplicate-term check.
     2324         *
     2325         * @since 5.0.0
     2326         *
     2327         * @param object $duplicate_term Duplicate term row from terms table, if found.
     2328         * @param string $term           Term being inserted.
     2329         * @param string $taxonomy       Taxonomy name.
     2330         * @param array  $args           Term arguments passed to the function.
     2331         * @param int    $tt_id          term_taxonomy_id for the newly created term.
     2332         */
     2333        $duplicate_term = apply_filters( 'wp_insert_term_duplicate_term_check', $duplicate_term, $term, $taxonomy, $args, $tt_id );
     2334
    23162335        if ( $duplicate_term ) {
    23172336                $wpdb->delete( $wpdb->terms, array( 'term_id' => $term_id ) );
    23182337                $wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );