mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-05-29 15:44:27 +00:00
REST API: Pass the previous state of the post as a parameter to the wp_after_insert_post hook.
This enables, for example, the previous post status to be used by this hook without the need to first capture it on an earlier hook. This also fixes the value of the `$fire_after_hooks` parameter in `get_default_post_to_edit()` so the `wp_after_insert_post` action correctly fires just once on the new post screen. Props Collizo4sky, peterwilsoncc, hellofromTonya, TimothyBlynJacobs, SergeyBiryukov Fixes #45114 git-svn-id: https://develop.svn.wordpress.org/trunk@49731 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -191,7 +191,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
*/
|
||||
do_action( 'rest_after_insert_attachment', $attachment, $request, true );
|
||||
|
||||
wp_after_insert_post( $attachment, false );
|
||||
wp_after_insert_post( $attachment, false, null );
|
||||
|
||||
if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) {
|
||||
// Set a custom header with the attachment_id.
|
||||
@@ -321,7 +321,8 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
);
|
||||
}
|
||||
|
||||
$response = parent::update_item( $request );
|
||||
$attachment_before = get_post( $request['id'] );
|
||||
$response = parent::update_item( $request );
|
||||
|
||||
if ( is_wp_error( $response ) ) {
|
||||
return $response;
|
||||
@@ -347,7 +348,7 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
|
||||
/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php */
|
||||
do_action( 'rest_after_insert_attachment', $attachment, $request, false );
|
||||
|
||||
wp_after_insert_post( $attachment, true );
|
||||
wp_after_insert_post( $attachment, true, $attachment_before );
|
||||
|
||||
$response = $this->prepare_item_for_response( $attachment, $request );
|
||||
$response = rest_ensure_response( $response );
|
||||
|
||||
Reference in New Issue
Block a user