Skip to content

Commit 5d67fe7

Browse files
committed
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 git-svn-id: https://develop.svn.wordpress.org/trunk@53627 602fd350-edb4-49c9-b593-d223f7449a82
1 parent e2bf96e commit 5d67fe7

1 file changed

Lines changed: 63 additions & 31 deletions

File tree

src/wp-includes/taxonomy.php

Lines changed: 63 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2346,11 +2346,13 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
23462346
* Filters a term before it is sanitized and inserted into the database.
23472347
*
23482348
* @since 3.0.0
2349+
* @since 6.1.0 The `$args` parameter was added.
23492350
*
23502351
* @param string|WP_Error $term The term name to add, or a WP_Error object if there's an error.
23512352
* @param string $taxonomy Taxonomy slug.
2353+
* @param array|string $args Array or query string of arguments for inserting a term.
23522354
*/
2353-
$term = apply_filters( 'pre_insert_term', $term, $taxonomy );
2355+
$term = apply_filters( 'pre_insert_term', $term, $taxonomy, $args );
23542356

23552357
if ( is_wp_error( $term ) ) {
23562358
return $term;
@@ -2574,12 +2576,14 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
25742576
* taxonomy.
25752577
*
25762578
* @since 2.3.0
2579+
* @since 6.1.0 The `$args` parameter was added.
25772580
*
25782581
* @param int $term_id Term ID.
25792582
* @param int $tt_id Term taxonomy ID.
25802583
* @param string $taxonomy Taxonomy slug.
2584+
* @param array $args Term arguments passed to the function.
25812585
*/
2582-
do_action( 'create_term', $term_id, $tt_id, $taxonomy );
2586+
do_action( 'create_term', $term_id, $tt_id, $taxonomy, $args );
25832587

25842588
/**
25852589
* Fires after a new term is created for a specific taxonomy.
@@ -2593,21 +2597,25 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
25932597
* - `create_post_tag`
25942598
*
25952599
* @since 2.3.0
2600+
* @since 6.1.0 The `$args` parameter was added.
25962601
*
2597-
* @param int $term_id Term ID.
2598-
* @param int $tt_id Term taxonomy ID.
2602+
* @param int $term_id Term ID.
2603+
* @param int $tt_id Term taxonomy ID.
2604+
* @param array $args Term arguments passed to the function.
25992605
*/
2600-
do_action( "create_{$taxonomy}", $term_id, $tt_id );
2606+
do_action( "create_{$taxonomy}", $term_id, $tt_id, $args );
26012607

26022608
/**
26032609
* Filters the term ID after a new term is created.
26042610
*
26052611
* @since 2.3.0
2612+
* @since 6.1.0 The `$args` parameter was added.
26062613
*
2607-
* @param int $term_id Term ID.
2608-
* @param int $tt_id Term taxonomy ID.
2614+
* @param int $term_id Term ID.
2615+
* @param int $tt_id Term taxonomy ID.
2616+
* @param array $args Term arguments passed to the function.
26092617
*/
2610-
$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
2618+
$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id, $args );
26112619

26122620
clean_term_cache( $term_id, $taxonomy );
26132621

@@ -2618,12 +2626,14 @@ function wp_insert_term( $term, $taxonomy, $args = array() ) {
26182626
* taxonomy.
26192627
*
26202628
* @since 2.3.0
2629+
* @since 6.1.0 The `$args` parameter was added.
26212630
*
26222631
* @param int $term_id Term ID.
26232632
* @param int $tt_id Term taxonomy ID.
26242633
* @param string $taxonomy Taxonomy slug.
2634+
* @param array $args Term arguments passed to the function.
26252635
*/
2626-
do_action( 'created_term', $term_id, $tt_id, $taxonomy );
2636+
do_action( 'created_term', $term_id, $tt_id, $taxonomy, $args );
26272637

26282638
/**
26292639
* 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() ) {
26372647
* - `created_post_tag`
26382648
*
26392649
* @since 2.3.0
2650+
* @since 6.1.0 The `$args` parameter was added.
26402651
*
2641-
* @param int $term_id Term ID.
2642-
* @param int $tt_id Term taxonomy ID.
2652+
* @param int $term_id Term ID.
2653+
* @param int $tt_id Term taxonomy ID.
2654+
* @param array $args Term arguments passed to the function.
26432655
*/
2644-
do_action( "created_{$taxonomy}", $term_id, $tt_id );
2656+
do_action( "created_{$taxonomy}", $term_id, $tt_id, $args );
26452657

26462658
/**
26472659
* 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() ) {
26502662
* taxonomy.
26512663
*
26522664
* @since 5.5.0
2665+
* @since 6.1.0 The `$args` parameter was added.
26532666
*
26542667
* @param int $term_id Term ID.
26552668
* @param int $tt_id Term taxonomy ID.
26562669
* @param string $taxonomy Taxonomy slug.
26572670
* @param bool $update Whether this is an existing term being updated.
2671+
* @param array $args Term arguments passed to the function.
26582672
*/
2659-
do_action( 'saved_term', $term_id, $tt_id, $taxonomy, false );
2673+
do_action( 'saved_term', $term_id, $tt_id, $taxonomy, false, $args );
26602674

26612675
/**
26622676
* 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() ) {
26702684
* - `saved_post_tag`
26712685
*
26722686
* @since 5.5.0
2687+
* @since 6.1.0 The `$args` parameter was added.
26732688
*
2674-
* @param int $term_id Term ID.
2675-
* @param int $tt_id Term taxonomy ID.
2676-
* @param bool $update Whether this is an existing term being updated.
2689+
* @param int $term_id Term ID.
2690+
* @param int $tt_id Term taxonomy ID.
2691+
* @param bool $update Whether this is an existing term being updated.
2692+
* @param array $args Term arguments passed to the function.
26772693
*/
2678-
do_action( "saved_{$taxonomy}", $term_id, $tt_id, false );
2694+
do_action( "saved_{$taxonomy}", $term_id, $tt_id, false, $args );
26792695

26802696
return array(
26812697
'term_id' => $term_id,
@@ -3234,11 +3250,13 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
32343250
* Fires immediately before the given terms are edited.
32353251
*
32363252
* @since 2.9.0
3253+
* @since 6.1.0 The `$args` parameter was added.
32373254
*
32383255
* @param int $term_id Term ID.
32393256
* @param string $taxonomy Taxonomy slug.
3257+
* @param array $args Arguments passed to wp_update_term().
32403258
*/
3241-
do_action( 'edit_terms', $term_id, $taxonomy );
3259+
do_action( 'edit_terms', $term_id, $taxonomy, $args );
32423260

32433261
$data = compact( 'name', 'slug', 'term_group' );
32443262

@@ -3266,33 +3284,39 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
32663284
* term-taxonomy relationship is updated.
32673285
*
32683286
* @since 2.9.0
3287+
* @since 6.1.0 The `$args` parameter was added.
32693288
*
32703289
* @param int $term_id Term ID.
32713290
* @param string $taxonomy Taxonomy slug.
3291+
* @param array $args Arguments passed to wp_update_term().
32723292
*/
3273-
do_action( 'edited_terms', $term_id, $taxonomy );
3293+
do_action( 'edited_terms', $term_id, $taxonomy, $args );
32743294

32753295
/**
32763296
* Fires immediate before a term-taxonomy relationship is updated.
32773297
*
32783298
* @since 2.9.0
3299+
* @since 6.1.0 The `$args` parameter was added.
32793300
*
32803301
* @param int $tt_id Term taxonomy ID.
32813302
* @param string $taxonomy Taxonomy slug.
3303+
* @param array $args Arguments passed to wp_update_term().
32823304
*/
3283-
do_action( 'edit_term_taxonomy', $tt_id, $taxonomy );
3305+
do_action( 'edit_term_taxonomy', $tt_id, $taxonomy, $args );
32843306

32853307
$wpdb->update( $wpdb->term_taxonomy, compact( 'term_id', 'taxonomy', 'description', 'parent' ), array( 'term_taxonomy_id' => $tt_id ) );
32863308

32873309
/**
32883310
* Fires immediately after a term-taxonomy relationship is updated.
32893311
*
32903312
* @since 2.9.0
3313+
* @since 6.1.0 The `$args` parameter was added.
32913314
*
32923315
* @param int $tt_id Term taxonomy ID.
32933316
* @param string $taxonomy Taxonomy slug.
3317+
* @param array $args Arguments passed to wp_update_term().
32943318
*/
3295-
do_action( 'edited_term_taxonomy', $tt_id, $taxonomy );
3319+
do_action( 'edited_term_taxonomy', $tt_id, $taxonomy, $args );
32963320

32973321
/**
32983322
* 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() ) {
33013325
* taxonomy.
33023326
*
33033327
* @since 2.3.0
3328+
* @since 6.1.0 The `$args` parameter was added.
33043329
*
33053330
* @param int $term_id Term ID.
33063331
* @param int $tt_id Term taxonomy ID.
33073332
* @param string $taxonomy Taxonomy slug.
3333+
* @param array $args Arguments passed to wp_update_term().
33083334
*/
3309-
do_action( 'edit_term', $term_id, $tt_id, $taxonomy );
3335+
do_action( 'edit_term', $term_id, $tt_id, $taxonomy, $args );
33103336

33113337
/**
33123338
* 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() ) {
33203346
* - `edit_post_tag`
33213347
*
33223348
* @since 2.3.0
3349+
* @since 6.1.0 The `$args` parameter was added.
33233350
*
3324-
* @param int $term_id Term ID.
3325-
* @param int $tt_id Term taxonomy ID.
3351+
* @param int $term_id Term ID.
3352+
* @param int $tt_id Term taxonomy ID.
3353+
* @param array $args Arguments passed to wp_update_term().
33263354
*/
3327-
do_action( "edit_{$taxonomy}", $term_id, $tt_id );
3355+
do_action( "edit_{$taxonomy}", $term_id, $tt_id, $args );
33283356

33293357
/** This filter is documented in wp-includes/taxonomy.php */
33303358
$term_id = apply_filters( 'term_id_filter', $term_id, $tt_id );
@@ -3338,12 +3366,14 @@ function wp_update_term( $term_id, $taxonomy, $args = array() ) {
33383366
* taxonomy.
33393367
*
33403368
* @since 2.3.0
3369+
* @since 6.1.0 The `$args` parameter was added.
33413370
*
33423371
* @param int $term_id Term ID.
33433372
* @param int $tt_id Term taxonomy ID.
33443373
* @param string $taxonomy Taxonomy slug.
3374+
* @param array $args Arguments passed to wp_update_term().
33453375
*/
3346-
do_action( 'edited_term', $term_id, $tt_id, $taxonomy );
3376+
do_action( 'edited_term', $term_id, $tt_id, $taxonomy, $args );
33473377

33483378
/**
33493379
* 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() ) {
33573387
* - `edited_post_tag`
33583388
*
33593389
* @since 2.3.0
3390+
* @since 6.1.0 The `$args` parameter was added.
33603391
*
3361-
* @param int $term_id Term ID.
3362-
* @param int $tt_id Term taxonomy ID.
3392+
* @param int $term_id Term ID.
3393+
* @param int $tt_id Term taxonomy ID.
3394+
* @param array $args Arguments passed to wp_update_term().
33633395
*/
3364-
do_action( "edited_{$taxonomy}", $term_id, $tt_id );
3396+
do_action( "edited_{$taxonomy}", $term_id, $tt_id, $args );
33653397

33663398
/** This action is documented in wp-includes/taxonomy.php */
3367-
do_action( 'saved_term', $term_id, $tt_id, $taxonomy, true );
3399+
do_action( 'saved_term', $term_id, $tt_id, $taxonomy, true, $args );
33683400

33693401
/** This action is documented in wp-includes/taxonomy.php */
3370-
do_action( "saved_{$taxonomy}", $term_id, $tt_id, true );
3402+
do_action( "saved_{$taxonomy}", $term_id, $tt_id, true, $args );
33713403

33723404
return array(
33733405
'term_id' => $term_id,

0 commit comments

Comments
 (0)