Make WordPress Core

Changeset 10390


Ignore:
Timestamp:
01/21/2009 03:45:57 AM (16 years ago)
Author:
azaozz
Message:

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

File:
1 edited

Legend:

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

    r10348 r10390  
    371371    check_admin_referer('media-form');
    372372
     373    if ( isset($_POST['send']) ) {
     374        $keys = array_keys($_POST['send']);
     375        $send_id = (int) array_shift($keys);
     376    }
     377
    373378    if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
    374379        $post = $_post = get_post($attachment_id, ARRAY_A);
     
    381386        if ( isset($attachment['menu_order']) )
    382387            $post['menu_order'] = $attachment['menu_order'];
    383         if ( isset($attachment['post_parent']) )
    384             $post['post_parent'] = $attachment['post_parent'];
     388
     389        if ( isset($send_id) && $attachment_id == $send_id ) {
     390            if ( isset($attachment['post_parent']) )
     391                $post['post_parent'] = $attachment['post_parent'];
     392        }
    385393
    386394        $post = apply_filters('attachment_fields_to_save', $post, $attachment);
     
    410418    }
    411419
    412     if ( isset($_POST['send']) ) {
    413         $keys = array_keys($_POST['send']);
    414         $send_id = (int) array_shift($keys);
     420    if ( isset($send_id) ) {
    415421        $attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
    416422        $html = $attachment['post_title'];
Note: See TracChangeset for help on using the changeset viewer.