Make WordPress Core

Changeset 48314


Ignore:
Timestamp:
07/05/2020 11:11:46 AM (4 years ago)
Author:
SergeyBiryukov
Message:

Taxonomy: Introduce saved_term and saved_{$taxonomy} actions to complement created_term and created_{$taxonomy}.

This allows for hooking into both the create and update events with a single callback, in the same way that is already possible for posts via the save_post and save_post_{$post->post_type} actions.

Props dlh.
Fixes #48416.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

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

    r48310 r48314  
    42084208     * @param int     $post_ID Post ID.
    42094209     * @param WP_Post $post    Post object.
    4210      * @param bool    $update  Whether this is an existing post being updated or not.
     4210     * @param bool    $update  Whether this is an existing post being updated.
    42114211     */
    42124212    do_action( "save_post_{$post->post_type}", $post_ID, $post, $update );
     
    42194219     * @param int     $post_ID Post ID.
    42204220     * @param WP_Post $post    Post object.
    4221      * @param bool    $update  Whether this is an existing post being updated or not.
     4221     * @param bool    $update  Whether this is an existing post being updated.
    42224222     */
    42234223    do_action( 'save_post', $post_ID, $post, $update );
     
    42304230     * @param int     $post_ID Post ID.
    42314231     * @param WP_Post $post    Post object.
    4232      * @param bool    $update  Whether this is an existing post being updated or not.
     4232     * @param bool    $update  Whether this is an existing post being updated.
    42334233     */
    42344234    do_action( 'wp_insert_post', $post_ID, $post, $update );
  • trunk/src/wp-includes/taxonomy.php

    r48214 r48314  
    24152415    do_action( "created_{$taxonomy}", $term_id, $tt_id );
    24162416
     2417    /**
     2418     * Fires after a term has been saved, and the term cache has been cleared.
     2419     *
     2420     * @since 5.5.0
     2421     *
     2422     * @param int    $term_id  Term ID.
     2423     * @param int    $tt_id    Term taxonomy ID.
     2424     * @param string $taxonomy Taxonomy slug.
     2425     * @param bool   $update   Whether this is an existing term being updated.
     2426     */
     2427    do_action( 'saved_term', $term_id, $tt_id, $taxonomy, false );
     2428
     2429    /**
     2430     * Fires after a term in a specific taxonomy has been saved, and the term
     2431     * cache has been cleared.
     2432     *
     2433     * The dynamic portion of the hook name, `$taxonomy`, refers to the taxonomy slug.
     2434     *
     2435     * @since 5.5.0
     2436     *
     2437     * @param int  $term_id Term ID.
     2438     * @param int  $tt_id   Term taxonomy ID.
     2439     * @param bool $update  Whether this is an existing term being updated.
     2440     */
     2441    do_action( "saved_{$taxonomy}", $term_id, $tt_id, false );
     2442
    24172443    return array(
    24182444        'term_id'          => $term_id,
     
    30783104     */
    30793105    do_action( "edited_{$taxonomy}", $term_id, $tt_id );
     3106
     3107    /** This action is documented in wp-includes/taxonomy.php */
     3108    do_action( 'saved_term', $term_id, $tt_id, $taxonomy, true );
     3109
     3110    /** This action is documented in wp-includes/taxonomy.php */
     3111    do_action( "saved_{$taxonomy}", $term_id, $tt_id, true );
    30803112
    30813113    return array(
Note: See TracChangeset for help on using the changeset viewer.