mirror of
https://github.com/WordPress/WordPress.git
synced 2024-09-28 23:27:39 +02:00
Taxonomy: Pass the $args
parameter to all actions and filters in wp_insert_term()
and wp_update_term()
.
This allows actions and filters to access potentially useful contextual information when terms are inserted and updated. Props mboynes Fixes #55441 Built from https://develop.svn.wordpress.org/trunk@53627 git-svn-id: http://core.svn.wordpress.org/trunk@53186 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
3e622b1d75
commit
d50fbb4469
@ -2346,11 +2346,13 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
* Filters a term before it is sanitized and inserted into the database.
|
* Filters a term before it is sanitized and inserted into the database.
|
||||||
*
|
*
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param string|WP_Error $term The term name to add, or a WP_Error object if there's an error.
|
* @param string|WP_Error $term The term name to add, or a WP_Error object if there's an error.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array|string $args Array or query string of arguments for inserting a term.
|
||||||
*/
|
*/
|
||||||
$term = apply_filters( 'pre_insert_term', $term, $taxonomy );
|
$term = apply_filters( 'pre_insert_term', $term, $taxonomy, $args );
|
||||||
|
|
||||||
if ( is_wp_error( $term ) ) {
|
if ( is_wp_error( $term ) ) {
|
||||||
return $term;
|
return $term;
|
||||||
@ -2574,12 +2576,14 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
* taxonomy.
|
* taxonomy.
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array $args Term arguments passed to the function.
|
||||||
*/
|
*/
|
||||||
do_action( 'create_term', $term_id, $tt_id, $taxonomy );
|
do_action( 'create_term', $term_id, $tt_id, $taxonomy, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires after a new term is created for a specific taxonomy.
|
* Fires after a new term is created for a specific taxonomy.
|
||||||
@ -2593,21 +2597,25 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
* - `create_post_tag`
|
* - `create_post_tag`
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
|
* @param array $args Term arguments passed to the function.
|
||||||
*/
|
*/
|
||||||
do_action( "create_{$taxonomy}", $term_id, $tt_id );
|
do_action( "create_{$taxonomy}", $term_id, $tt_id, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the term ID after a new term is created.
|
* Filters the term ID after a new term is created.
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
|
* @param array $args Term arguments passed to the function.
|
||||||
*/
|
*/
|
||||||
$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
|
$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id, $args );
|
||||||
|
|
||||||
clean_term_cache( $term_id, $taxonomy );
|
clean_term_cache( $term_id, $taxonomy );
|
||||||
|
|
||||||
@ -2618,12 +2626,14 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
* taxonomy.
|
* taxonomy.
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array $args Term arguments passed to the function.
|
||||||
*/
|
*/
|
||||||
do_action( 'created_term', $term_id, $tt_id, $taxonomy );
|
do_action( 'created_term', $term_id, $tt_id, $taxonomy, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires after a new term in a specific taxonomy is created, and after the term
|
* Fires after a new term in a specific taxonomy is created, and after the term
|
||||||
@ -2637,11 +2647,13 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
* - `created_post_tag`
|
* - `created_post_tag`
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
|
* @param array $args Term arguments passed to the function.
|
||||||
*/
|
*/
|
||||||
do_action( "created_{$taxonomy}", $term_id, $tt_id );
|
do_action( "created_{$taxonomy}", $term_id, $tt_id, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires after a term has been saved, and the term cache has been cleared.
|
* Fires after a term has been saved, and the term cache has been cleared.
|
||||||
@ -2650,13 +2662,15 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
* taxonomy.
|
* taxonomy.
|
||||||
*
|
*
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
* @param bool $update Whether this is an existing term being updated.
|
* @param bool $update Whether this is an existing term being updated.
|
||||||
|
* @param array $args Term arguments passed to the function.
|
||||||
*/
|
*/
|
||||||
do_action( 'saved_term', $term_id, $tt_id, $taxonomy, false );
|
do_action( 'saved_term', $term_id, $tt_id, $taxonomy, false, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires after a term in a specific taxonomy has been saved, and the term
|
* Fires after a term in a specific taxonomy has been saved, and the term
|
||||||
@ -2670,12 +2684,14 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
|
|||||||
* - `saved_post_tag`
|
* - `saved_post_tag`
|
||||||
*
|
*
|
||||||
* @since 5.5.0
|
* @since 5.5.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
* @param bool $update Whether this is an existing term being updated.
|
* @param bool $update Whether this is an existing term being updated.
|
||||||
|
* @param array $args Term arguments passed to the function.
|
||||||
*/
|
*/
|
||||||
do_action( "saved_{$taxonomy}", $term_id, $tt_id, false );
|
do_action( "saved_{$taxonomy}", $term_id, $tt_id, false, $args );
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'term_id' => $term_id,
|
'term_id' => $term_id,
|
||||||
@ -3234,11 +3250,13 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||||||
* Fires immediately before the given terms are edited.
|
* Fires immediately before the given terms are edited.
|
||||||
*
|
*
|
||||||
* @since 2.9.0
|
* @since 2.9.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array $args Arguments passed to wp_update_term().
|
||||||
*/
|
*/
|
||||||
do_action( 'edit_terms', $term_id, $taxonomy );
|
do_action( 'edit_terms', $term_id, $taxonomy, $args );
|
||||||
|
|
||||||
$data = compact( 'name', 'slug', 'term_group' );
|
$data = compact( 'name', 'slug', 'term_group' );
|
||||||
|
|
||||||
@ -3266,21 +3284,25 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||||||
* term-taxonomy relationship is updated.
|
* term-taxonomy relationship is updated.
|
||||||
*
|
*
|
||||||
* @since 2.9.0
|
* @since 2.9.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array $args Arguments passed to wp_update_term().
|
||||||
*/
|
*/
|
||||||
do_action( 'edited_terms', $term_id, $taxonomy );
|
do_action( 'edited_terms', $term_id, $taxonomy, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires immediate before a term-taxonomy relationship is updated.
|
* Fires immediate before a term-taxonomy relationship is updated.
|
||||||
*
|
*
|
||||||
* @since 2.9.0
|
* @since 2.9.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array $args Arguments passed to wp_update_term().
|
||||||
*/
|
*/
|
||||||
do_action( 'edit_term_taxonomy', $tt_id, $taxonomy );
|
do_action( 'edit_term_taxonomy', $tt_id, $taxonomy, $args );
|
||||||
|
|
||||||
$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
|
$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
|
||||||
|
|
||||||
@ -3288,11 +3310,13 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||||||
* Fires immediately after a term-taxonomy relationship is updated.
|
* Fires immediately after a term-taxonomy relationship is updated.
|
||||||
*
|
*
|
||||||
* @since 2.9.0
|
* @since 2.9.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array $args Arguments passed to wp_update_term().
|
||||||
*/
|
*/
|
||||||
do_action( 'edited_term_taxonomy', $tt_id, $taxonomy );
|
do_action( 'edited_term_taxonomy', $tt_id, $taxonomy, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires after a term has been updated, but before the term cache has been cleaned.
|
* Fires after a term has been updated, but before the term cache has been cleaned.
|
||||||
@ -3301,12 +3325,14 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||||||
* taxonomy.
|
* taxonomy.
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array $args Arguments passed to wp_update_term().
|
||||||
*/
|
*/
|
||||||
do_action( 'edit_term', $term_id, $tt_id, $taxonomy );
|
do_action( 'edit_term', $term_id, $tt_id, $taxonomy, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires after a term in a specific taxonomy has been updated, but before the term
|
* Fires after a term in a specific taxonomy has been updated, but before the term
|
||||||
@ -3320,11 +3346,13 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||||||
* - `edit_post_tag`
|
* - `edit_post_tag`
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
|
* @param array $args Arguments passed to wp_update_term().
|
||||||
*/
|
*/
|
||||||
do_action( "edit_{$taxonomy}", $term_id, $tt_id );
|
do_action( "edit_{$taxonomy}", $term_id, $tt_id, $args );
|
||||||
|
|
||||||
/** This filter is documented in wp-includes/taxonomy.php */
|
/** This filter is documented in wp-includes/taxonomy.php */
|
||||||
$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
|
$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
|
||||||
@ -3338,12 +3366,14 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||||||
* taxonomy.
|
* taxonomy.
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
* @param string $taxonomy Taxonomy slug.
|
* @param string $taxonomy Taxonomy slug.
|
||||||
|
* @param array $args Arguments passed to wp_update_term().
|
||||||
*/
|
*/
|
||||||
do_action( 'edited_term', $term_id, $tt_id, $taxonomy );
|
do_action( 'edited_term', $term_id, $tt_id, $taxonomy, $args );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fires after a term for a specific taxonomy has been updated, and the term
|
* Fires after a term for a specific taxonomy has been updated, and the term
|
||||||
@ -3357,17 +3387,19 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
|
|||||||
* - `edited_post_tag`
|
* - `edited_post_tag`
|
||||||
*
|
*
|
||||||
* @since 2.3.0
|
* @since 2.3.0
|
||||||
|
* @since 6.1.0 The `$args` parameter was added.
|
||||||
*
|
*
|
||||||
* @param int $term_id Term ID.
|
* @param int $term_id Term ID.
|
||||||
* @param int $tt_id Term taxonomy ID.
|
* @param int $tt_id Term taxonomy ID.
|
||||||
|
* @param array $args Arguments passed to wp_update_term().
|
||||||
*/
|
*/
|
||||||
do_action( "edited_{$taxonomy}", $term_id, $tt_id );
|
do_action( "edited_{$taxonomy}", $term_id, $tt_id, $args );
|
||||||
|
|
||||||
/** This action is documented in wp-includes/taxonomy.php */
|
/** This action is documented in wp-includes/taxonomy.php */
|
||||||
do_action( 'saved_term', $term_id, $tt_id, $taxonomy, true );
|
do_action( 'saved_term', $term_id, $tt_id, $taxonomy, true, $args );
|
||||||
|
|
||||||
/** This action is documented in wp-includes/taxonomy.php */
|
/** This action is documented in wp-includes/taxonomy.php */
|
||||||
do_action( "saved_{$taxonomy}", $term_id, $tt_id, true );
|
do_action( "saved_{$taxonomy}", $term_id, $tt_id, true, $args );
|
||||||
|
|
||||||
return array(
|
return array(
|
||||||
'term_id' => $term_id,
|
'term_id' => $term_id,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '6.1-alpha-53626';
|
$wp_version = '6.1-alpha-53627';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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