WordPress.org

Make WordPress Core

Changeset 47909


Ignore:
Timestamp:
06/04/2020 02:58:58 PM (17 months ago)
Author:
whyisjake
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/media.php

    r47808 r47909  
    37253725            $result = $wpdb->query( "UPDATE $wpdb->posts SET post_parent = 0 WHERE post_type = 'attachment' AND ID IN ( $ids_string )" );
    37263726        }
    3727 
     3727    }
     3728
     3729    if ( isset( $result ) ) {
    37283730        foreach ( $ids as $att_id ) {
     3731            /**
     3732             * Fires when media is attached/detached from a post.
     3733             *
     3734             * @since 5.5
     3735             *
     3736             * @param string $action    Attach/detach action.
     3737             * @param int    $att_id    The attachment ID.
     3738             * @param int    $parent_id Attachment parent ID.
     3739             */
     3740            do_action( 'wp_media_attach_action', $action, $att_id, $parent_id );
     3741
    37293742            clean_attachment_cache( $att_id );
    37303743        }
    3731     }
    3732 
    3733     if ( isset( $result ) ) {
     3744
    37343745        $location = 'upload.php';
    37353746        $referer  = wp_get_referer();
Note: See TracChangeset for help on using the changeset viewer.