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.

Built from https://develop.svn.wordpress.org/trunk@55106


git-svn-id: http://core.svn.wordpress.org/trunk@54639 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
audrasjb 2023-01-20 14:17:16 +00:00
parent 28562c4306
commit fe3e932421
2 changed files with 12 additions and 1 deletions

View File

@ -3144,6 +3144,17 @@ function wp_ajax_save_attachment() {
wp_delete_post( $id );
} else {
wp_update_post( $post );
/**
* Fires after an attachment has been updated and before
* the JSON response is sent.
*
* @since 6.2.0
*
* @param array $post The attachment.
* @param array $changes An array of changes.
*/
do_action( 'wp_ajax_save_attachment', $post, $changes );
}
wp_send_json_success();

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.2-alpha-55105';
$wp_version = '6.2-alpha-55106';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.