Media: Add an action for `wp_media_attach_action`.
This action fires when media is attached/detached from a post. Fixes: #49614. Props: jonoaldersonwp, antpb, rebasaurus, donmhico. Built from https://develop.svn.wordpress.org/trunk@47909 git-svn-id: http://core.svn.wordpress.org/trunk@47683 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0eaae8ebbf
commit
00d3696923
|
@ -3724,13 +3724,24 @@ function wp_media_attach_action( $parent_id, $action = 'attach' ) {
|
||||||
} else {
|
} else {
|
||||||
$result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" );
|
$result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" );
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ( $ids as $att_id ) {
|
|
||||||
clean_attachment_cache( $att_id );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isset( $result ) ) {
|
if ( isset( $result ) ) {
|
||||||
|
foreach ( $ids as $att_id ) {
|
||||||
|
/**
|
||||||
|
* Fires when media is attached/detached from a post.
|
||||||
|
*
|
||||||
|
* @since 5.5
|
||||||
|
*
|
||||||
|
* @param string $action Attach/detach action.
|
||||||
|
* @param int $att_id The attachment ID.
|
||||||
|
* @param int $parent_id Attachment parent ID.
|
||||||
|
*/
|
||||||
|
do_action( 'wp_media_attach_action', $action, $att_id, $parent_id );
|
||||||
|
|
||||||
|
clean_attachment_cache( $att_id );
|
||||||
|
}
|
||||||
|
|
||||||
$location = 'upload.php';
|
$location = 'upload.php';
|
||||||
$referer = wp_get_referer();
|
$referer = wp_get_referer();
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.5-alpha-47908';
|
$wp_version = '5.5-alpha-47909';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue