rest_insert_(post_type)
Fires after a single post is created or updated via the REST API.
The dynamic portion of the hook name, $this->post_type, refers to the post type slug.
Possible hook names include:
Использование
add_action( 'rest_insert_(post_type)', 'wp_kama_rest_insert_post_type_action', 10, 3 );
/**
* Function for `rest_insert_(post_type)` action-hook.
*
* @param WP_Post $post Inserted or updated post object.
* @param WP_REST_Request $request Request object.
* @param bool $creating True when creating a post, false when updating.
*
* @return void
*/
function wp_kama_rest_insert_post_type_action( $post, $request, $creating ){
// action...
}
- $post(WP_Post)
- Inserted or updated post object.
- $request(WP_REST_Request)
- Request object.
- $creating(true|false)
- True when creating a post, false when updating.
Список изменений
| С версии 4.7.0 | Введена. |
Где вызывается хук
rest_insert_(post_type)
rest_insert_(post_type)
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 805
do_action( "rest_insert_{$this->post_type}", $post, $request, true );
wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php 991
do_action( "rest_insert_{$this->post_type}", $post, $request, false );
Где используется хук в WordPress
wp-includes/default-filters.php 525
add_action( 'rest_insert_comment', 'wp_new_comment_via_rest_notify_postauthor' );