Skip to content

Commit c12992d

Browse files
committed
Media: Add an action hook on wp_ajax_save_attachment().
This changeset introduces the `wp_ajax_save_attachment` action hook, triggered after an attachment has been updated and before the JSON response is sent. For example, it allows developers to update any additional attachment fields that have been rendered by extending the `media.view.Attachment.Details` subview. Props griffinjt, bradyvercher, pputzer, antpb, sc0ttkclark, audrasjb, costdev, hellofromTonya. Fixes #23148. git-svn-id: https://develop.svn.wordpress.org/trunk@55106 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 675fe39 commit c12992d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/wp-admin/includes/ajax-actions.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,6 +3144,17 @@ function wp_ajax_save_attachment() {
31443144
wp_delete_post( $id );
31453145
} else {
31463146
wp_update_post( $post );
3147+
3148+
/**
3149+
* Fires after an attachment has been updated and before
3150+
* the JSON response is sent.
3151+
*
3152+
* @since 6.2.0
3153+
*
3154+
* @param array $post The attachment.
3155+
* @param array $changes An array of changes.
3156+
*/
3157+
do_action( 'wp_ajax_save_attachment', $post, $changes );
31473158
}
31483159

31493160
wp_send_json_success();

0 commit comments

Comments
 (0)