Make WordPress Core


Ignore:
Timestamp:
11/29/2021 11:41:50 AM (5 years ago)
Author:
spacedmonkey
Message:

REST API: Ensure that the rest_after_insert_ action is executed in the templates controller.

Fire the that dynamic action rest_after_insert_{$this->post_type} in templates controller, as this action is fired in other post based REST API controllers.

Props spacedmonkey, peterwilsoncc, zieladam.
Fixes #54520.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-templates-controller.php

    r52186 r52268  
    268268                $request->set_param( 'context', 'edit' );
    269269
     270                $post = get_post( $template->wp_id );
     271                /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
     272                do_action( "rest_after_insert_{$this->post_type}", $post, $request, false );
     273
    270274                $response = $this->prepare_item_for_response( $template, $request );
    271275
     
    311315                }
    312316                $id            = $posts[0]->id;
     317                $post          = get_post( $post_id );
    313318                $template      = get_block_template( $id, $this->post_type );
    314319                $fields_update = $this->update_additional_fields_for_object( $template, $request );
     
    316321                        return $fields_update;
    317322                }
     323
     324                /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
     325                do_action( "rest_after_insert_{$this->post_type}", $post, $request, true );
    318326
    319327                $response = $this->prepare_item_for_response( $template, $request );
Note: See TracChangeset for help on using the changeset viewer.