Make WordPress Core

Changeset 22843


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.

Location:
trunk
Files:
2 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'] ) ) {
  • trunk/wp-includes/js/media-editor.js

    r22835 r22843  
    451451                    nonce:      wp.media.view.settings.nonce.sendToEditor,
    452452                    attachment: options,
    453                     html:       html
     453                    html:       html,
     454                    post_id:    wp.media.view.settings.postId
    454455                }).done( function( resp ) {
    455456                    wp.media.editor.insert( resp );
Note: See TracChangeset for help on using the changeset viewer.