Skip to content

Add wp_after_insert_post call in global styles controller.#1953

Closed
spacedmonkey wants to merge 3 commits intoWordPress:trunkfrom
spacedmonkey:fix/global-styles-fire-event
Closed

Add wp_after_insert_post call in global styles controller.#1953
spacedmonkey wants to merge 3 commits intoWordPress:trunkfrom
spacedmonkey:fix/global-styles-fire-event

Conversation

@spacedmonkey
Copy link
Copy Markdown
Member

Trac ticket: https://core.trac.wordpress.org/ticket/54498


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

);
wp_after_insert_post( $post, true, $post_before );

$response = $this->prepare_item_for_response( $post, $request );
Copy link
Copy Markdown
Contributor

@adamziel adamziel Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, $post was re-retrieved with get_post( $request['id'] ), presumably to account for anything changed as a result of update_additional_fields_for_object. After this PR, it is not re-retrieved anymore. Is this intentional?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how it works on the post controller. Just copying that format over.

$fields_update = $this->update_additional_fields_for_object( $post, $request );
if ( is_wp_error( $fields_update ) ) {
return $fields_update;
}
$request->set_param( 'context', 'edit' );
// Filter is fired in WP_REST_Attachments_Controller subclass.
if ( 'attachment' === $this->post_type ) {
$response = $this->prepare_item_for_response( $post, $request );
return rest_ensure_response( $response );
}
/** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
do_action( "rest_after_insert_{$this->post_type}", $post, $request, false );
wp_after_insert_post( $post, true, $post_before );
$response = $this->prepare_item_for_response( $post, $request );
return rest_ensure_response( $response );

Copy link
Copy Markdown
Contributor

@peterwilsoncc peterwilsoncc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks boss. I'll test in the next few hours and either commit or mark as ready for it to be done.

@peterwilsoncc
Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants