Make WordPress Core


Ignore:
Timestamp:
10/17/2018 11:19:02 AM (7 years ago)
Author:
danielbachhuber
Message:

REST API: Fire actions after items are completely updated/inserted.

The existing rest_insert_* actions are fired before meta and additional fields are updated. These new rest_after_* actions fire after all write operations have completed.

Props timothyblynjacobs.
Fixes #42864.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php

    r43714 r43737  
    457457        $request->set_param( 'context', 'view' );
    458458
     459        /**
     460         * Fires after a single term is completely created or updated via the REST API.
     461         *
     462         * The dynamic portion of the hook name, `$this->taxonomy`, refers to the taxonomy slug.
     463         *
     464         * @since 5.0.0
     465         *
     466         * @param WP_Term         $term     Inserted or updated term object.
     467         * @param WP_REST_Request $request  Request object.
     468         * @param bool            $creating True when creating a term, false when updating.
     469         */
     470        do_action( "rest_after_insert_{$this->taxonomy}", $term, $request, true );
     471
    459472        $response = $this->prepare_item_for_response( $term, $request );
    460473        $response = rest_ensure_response( $response );
     
    545558
    546559        $request->set_param( 'context', 'view' );
     560
     561        /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-terms-controller.php */
     562        do_action( "rest_after_insert_{$this->taxonomy}", $term, $request, false );
    547563
    548564        $response = $this->prepare_item_for_response( $term, $request );
Note: See TracChangeset for help on using the changeset viewer.