Make WordPress Core


Ignore:
Timestamp:
11/26/2012 04:34:42 PM (12 years ago)
Author:
nacin
Message:

Media: When inserting an attachment, if the item is unattached (no post_parent), attach it to the post. fixes #22085.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ajax-actions.php

    r22834 r22843  
    19321932        wp_send_json_error();
    19331933
     1934    // If this attachment is unattached, attach it. Primarily a back compat thing.
     1935    if ( 0 == $post->post_parent && $insert_into_post_id = intval( $_POST['post_id'] ) ) {
     1936        wp_update_post( array( 'ID' => $id, 'post_parent' => $insert_into_post_id ) );
     1937    }
     1938
    19341939    $html = isset( $attachment['title'] ) ? $attachment['title'] : '';
    19351940    if ( ! empty( $attachment['url'] ) ) {
Note: See TracChangeset for help on using the changeset viewer.