mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
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, danielbachhuber. Merges [43737] to trunk. Fixes #42864. git-svn-id: https://develop.svn.wordpress.org/trunk@43987 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -633,9 +633,20 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
}
|
||||
|
||||
$context = current_user_can( 'moderate_comments' ) ? 'edit' : 'view';
|
||||
|
||||
$request->set_param( 'context', $context );
|
||||
|
||||
/**
|
||||
* Fires completely after a comment is created or updated via the REST API.
|
||||
*
|
||||
* @since 5.0.0
|
||||
*
|
||||
* @param WP_Comment $comment Inserted or updated comment object.
|
||||
* @param WP_REST_Request $request Request object.
|
||||
* @param bool $creating True when creating a comment, false
|
||||
* when updating.
|
||||
*/
|
||||
do_action( 'rest_after_insert_comment', $comment, $request, true );
|
||||
|
||||
$response = $this->prepare_item_for_response( $comment, $request );
|
||||
$response = rest_ensure_response( $response );
|
||||
|
||||
@@ -757,6 +768,9 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
|
||||
$request->set_param( 'context', 'edit' );
|
||||
|
||||
/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php */
|
||||
do_action( 'rest_after_insert_comment', $comment, $request, false );
|
||||
|
||||
$response = $this->prepare_item_for_response( $comment, $request );
|
||||
|
||||
return rest_ensure_response( $response );
|
||||
|
||||
Reference in New Issue
Block a user