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 |
|---|---|
| 191 | /** |
| 192 | * Fires after a single attachment is completely created or updated via the REST API. |
| 193 | * |
| 194 | * @since 5.0.0 |
| 195 | * |
| 196 | * @param WP_Post $attachment Inserted or updated attachment object. |
| 197 | * @param WP_REST_Request $request Request object. |
| 198 | * @param bool $creating True when creating an attachment, false when updating. |
| 199 | */ |
| 200 | do_action( 'rest_after_insert_attachment', $attachment, $request, true ); |
| 201 | |
| 202 | wp_after_insert_post( $attachment, false, null ); |
| 203 | |
| 204 | if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { |
| 205 | // Set a custom header with the attachment_id. |
| 206 | // Used by the browser/client to resume creating image sub-sizes after a PHP fatal error. |
| 207 | header( 'X-WP-Upload-Attachment-ID: ' . $attachment_id ); |
| 208 | } |
| 209 | |
| Line | Code |
| 348 | $fields_update = $this->update_additional_fields_for_object( $attachment, $request ); |
| 349 | |
| 350 | if ( is_wp_error( $fields_update ) ) { |
| 351 | return $fields_update; |
| 352 | } |
| 353 | |
| 354 | $request->set_param( 'context', 'edit' ); |
| 355 | |
| 356 | /** This action is documented in wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php */ |
| 357 | do_action( 'rest_after_insert_attachment', $attachment, $request, false ); |
| 358 | |
| 359 | wp_after_insert_post( $attachment, true, $attachment_before ); |
| 360 | |
| 361 | $response = $this->prepare_item_for_response( $attachment, $request ); |
| 362 | $response = rest_ensure_response( $response ); |
| 363 | |
| 364 | return $response; |
| 365 | } |
| 366 | |