WordPress.org

Make WordPress Core

Ticket #22047: 22407.patch

File 22407.patch, 1.5 KB (added by c3mdigital, 9 years ago)

adds save_post and edit_post actions to wp_insert_attachment

  • wp-includes/post.php

     
    37403740 * @uses $user_ID
    37413741 * @uses do_action() Calls 'edit_attachment' on $post_ID if this is an update.
    37423742 * @uses do_action() Calls 'add_attachment' on $post_ID if this is not an update.
     3743 * @uses do_action() Calls 'update_post' on $post_ID if this is an update
     3744 * @uses do_action() Calls 'save_post' on $post_ID if this is not an update
    37433745 *
    37443746 * @param string|array $object Arguments to override defaults.
    3745  * @param string $file Optional filename.
     3747 * @param bool|string $file Optional filename.
    37463748 * @param int $parent Parent post ID.
    37473749 * @return int Attachment ID.
    37483750 */
     
    37853787        if ( !empty($ID) ) {
    37863788                $update = true;
    37873789                $post_ID = (int) $ID;
     3790                $post_before = get_post( $post_ID );
    37883791        } else {
    37893792                $update = false;
    37903793                $post_ID = 0;
     
    38843887                update_attached_file( $post_ID, $file );
    38853888
    38863889        clean_post_cache( $post_ID );
     3890        $post = get_post( $post_ID );
    38873891
    38883892        if ( ! empty( $context ) )
    38893893                add_post_meta( $post_ID, '_wp_attachment_context', $context, true );
    38903894
    3891         if ( $update) {
     3895        if ( $update ) {
    38923896                do_action('edit_attachment', $post_ID);
     3897                do_action('edit_post', $post_ID, $post);
     3898                $post_after = get_post( $post_ID );
     3899                do_action('post_updated', $post_ID, $post_after, $post_before);
    38933900        } else {
     3901                do_action('save_post', $post_ID, $post);
    38943902                do_action('add_attachment', $post_ID);
    38953903        }
    38963904