WordPress.org

Make WordPress Core

Changeset 10435


Ignore:
Timestamp:
01/24/2009 02:44:15 PM (9 years ago)
Author:
azaozz
Message:

When inserting orphaned attachment in a post, set post_parent only for this attachment, fixes #8721

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.7/wp-admin/includes/media.php

    r10150 r10435  
    370370    check_admin_referer('media-form');
    371371
     372    if ( isset($_POST['send']) ) {
     373        $keys = array_keys($_POST['send']);
     374        $send_id = (int) array_shift($keys);
     375    }
     376   
    372377    if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
    373378        $post = $_post = get_post($attachment_id, ARRAY_A);
     
    380385        if ( isset($attachment['menu_order']) )
    381386            $post['menu_order'] = $attachment['menu_order'];
    382         if ( isset($attachment['post_parent']) )
    383             $post['post_parent'] = $attachment['post_parent'];
     387        if ( isset($send_id) && $attachment_id == $send_id ) {
     388            if ( isset($attachment['post_parent']) )
     389                $post['post_parent'] = $attachment['post_parent'];
     390        }
    384391
    385392        $post = apply_filters('attachment_fields_to_save', $post, $attachment);
     
    409416    }
    410417
    411     if ( isset($_POST['send']) ) {
    412         $keys = array_keys($_POST['send']);
    413         $send_id = (int) array_shift($keys);
     418    if ( isset($send_id) ) {
    414419        $attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
    415420        $html = $attachment['post_title'];
Note: See TracChangeset for help on using the changeset viewer.