WordPress.org

Make WordPress Core

Changeset 43570


Ignore:
Timestamp:
08/15/2018 07:49:50 PM (2 years ago)
Author:
boonebgorges
Message:

Introduce wp_insert_term_duplicate_term_check filter.

This filter allows plugins to intervene in the duplicate-term check
that takes place at the time of term creation. See [30238], #22023.

Props strategio.
Fixes #43271.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/taxonomy.php

    r43558 r43570  
    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 ) );
Note: See TracChangeset for help on using the changeset viewer.