Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: rest_after_insert_{$this->post_type}

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
669            *
670            * The dynamic portion of the hook name, `$this->post_type`, refers to the post type slug.
671            *
672            * @since 5.0.0
673            *
674            * @param WP_Post         $post     Inserted or updated post object.
675            * @param WP_REST_Request $request  Request object.
676            * @param bool            $creating True when creating a post, false when updating.
677            */
678           do_action( "rest_after_insert_{$this->post_type}", $post, $request, true );
679
680           wp_after_insert_post( $post, false, null );
681
682           $response = $this->prepare_item_for_response( $post, $request );
683           $response = rest_ensure_response( $response );
684
685           $response->set_status( 201 );
686           $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $post_id ) ) );
687
 
Line Code
823           $request->set_param( 'context', 'edit' );
824
825           // Filter is fired in WP_REST_Attachments_Controller subclass.
826           if ( 'attachment' === $this->post_type ) {
827                $response = $this->prepare_item_for_response( $post, $request );
828                return rest_ensure_response( $response );
829           }
830
831           /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */
832           do_action( "rest_after_insert_{$this->post_type}", $post, $request, false );
833
834           wp_after_insert_post( $post, true, $post_before );
835
836           $response = $this->prepare_item_for_response( $post, $request );
837
838           return rest_ensure_response( $response );
839      }
840
841      /**