WP hooks navigation: Home/browse • Actions index • Filters index
To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).
The best way to understand what a hook does is to look at where it occurs in the source code.
do_action( "hook_name" )
apply_filters( "hook_name", "what_to_filter" )
.Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.
This hook occurs 2 times in this file.
Line | Code |
---|---|
612 | * |
613 | * The dynamic portion of the hook name, `$this->post_type`, refers to the post type slug. |
614 | * |
615 | * @since 5.0.0 |
616 | * |
617 | * @param WP_Post $post Inserted or updated post object. |
618 | * @param WP_REST_Request $request Request object. |
619 | * @param bool $creating True when creating a post, false when updating. |
620 | */ |
621 | do_action( "rest_after_insert_{$this->post_type}", $post, $request, true ); |
622 |
|
623 | $response = $this->prepare_item_for_response( $post, $request ); |
624 | $response = rest_ensure_response( $response ); |
625 |
|
626 | $response->set_status( 201 ); |
627 | $response->header( 'Location', rest_url( sprintf( '%s/%s/%d', $this->namespace, $this->rest_base, $post_id ) ) ); |
628 |
|
629 | return $response; |
630 | } |
Line | Code |
747 | $request->set_param( 'context', 'edit' ); |
748 |
|
749 | // Filter is fired in WP_REST_Attachments_Controller subclass. |
750 | if ( 'attachment' === $this->post_type ) { |
751 | $response = $this->prepare_item_for_response( $post, $request ); |
752 | return rest_ensure_response( $response ); |
753 | } |
754 |
|
755 | /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php */ |
756 | do_action( "rest_after_insert_{$this->post_type}", $post, $request, false ); |
757 |
|
758 | $response = $this->prepare_item_for_response( $post, $request ); |
759 |
|
760 | return rest_ensure_response( $response ); |
761 | } |
762 |
|
763 | /** |
764 | * Checks if a given request has access to delete a post. |
765 | * |