mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
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. Built from https://develop.svn.wordpress.org/trunk@43570 git-svn-id: http://core.svn.wordpress.org/trunk@43399 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
8244397ffb
commit
8142df82bc
@ -2312,7 +2312,26 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
* and term_taxonomy_id of the older term instead. Then return out of the function so that the "create" hooks
|
* and term_taxonomy_id of the older term instead. Then return out of the function so that the "create" hooks
|
||||||
* are not fired.
|
* are not fired.
|
||||||
*/
|
*/
|
||||||
$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 ) );
|
$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 ) );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Filters the duplicate term check that takes place during term creation.
|
||||||
|
*
|
||||||
|
* Term parent+taxonomy+slug combinations are meant to be unique, and wp_insert_term()
|
||||||
|
* performs a last-minute confirmation of this uniqueness before allowing a new term
|
||||||
|
* to be created. Plugins with different uniqueness requirements may use this filter
|
||||||
|
* to bypass or modify the duplicate-term check.
|
||||||
|
*
|
||||||
|
* @since 5.0.0
|
||||||
|
*
|
||||||
|
* @param object $duplicate_term Duplicate term row from terms table, if found.
|
||||||
|
* @param string $term Term being inserted.
|
||||||
|
* @param string $taxonomy Taxonomy name.
|
||||||
|
* @param array $args Term arguments passed to the function.
|
||||||
|
* @param int $tt_id term_taxonomy_id for the newly created term.
|
||||||
|
*/
|
||||||
|
$duplicate_term = apply_filters( 'wp_insert_term_duplicate_term_check', $duplicate_term, $term, $taxonomy, $args, $tt_id );
|
||||||
|
|
||||||
if ( $duplicate_term ) {
|
if ( $duplicate_term ) {
|
||||||
$wpdb->delete( $wpdb->terms, array( 'term_id' => $term_id ) );
|
$wpdb->delete( $wpdb->terms, array( 'term_id' => $term_id ) );
|
||||||
$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
|
$wpdb->delete( $wpdb->term_taxonomy, array( 'term_taxonomy_id' => $tt_id ) );
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.0-alpha-43569';
|
$wp_version = '5.0-alpha-43570';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
Loading…
Reference in New Issue
Block a user