When inserting orphaned attachment in a post, set post_parent only for this attachment, see #8721
git-svn-id: http://svn.automattic.com/wordpress/trunk@10390 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
37abfcb33f
commit
e9636d400c
|
@ -370,6 +370,11 @@ add_action('media_upload_media', 'media_upload_handler');
|
|||
function media_upload_form_handler() {
|
||||
check_admin_referer('media-form');
|
||||
|
||||
if ( isset($_POST['send']) ) {
|
||||
$keys = array_keys($_POST['send']);
|
||||
$send_id = (int) array_shift($keys);
|
||||
}
|
||||
|
||||
if ( !empty($_POST['attachments']) ) foreach ( $_POST['attachments'] as $attachment_id => $attachment ) {
|
||||
$post = $_post = get_post($attachment_id, ARRAY_A);
|
||||
if ( isset($attachment['post_content']) )
|
||||
|
@ -380,8 +385,11 @@ function media_upload_form_handler() {
|
|||
$post['post_excerpt'] = $attachment['post_excerpt'];
|
||||
if ( isset($attachment['menu_order']) )
|
||||
$post['menu_order'] = $attachment['menu_order'];
|
||||
if ( isset($attachment['post_parent']) )
|
||||
$post['post_parent'] = $attachment['post_parent'];
|
||||
|
||||
if ( isset($send_id) && $attachment_id == $send_id ) {
|
||||
if ( isset($attachment['post_parent']) )
|
||||
$post['post_parent'] = $attachment['post_parent'];
|
||||
}
|
||||
|
||||
$post = apply_filters('attachment_fields_to_save', $post, $attachment);
|
||||
|
||||
|
@ -409,9 +417,7 @@ function media_upload_form_handler() {
|
|||
exit;
|
||||
}
|
||||
|
||||
if ( isset($_POST['send']) ) {
|
||||
$keys = array_keys($_POST['send']);
|
||||
$send_id = (int) array_shift($keys);
|
||||
if ( isset($send_id) ) {
|
||||
$attachment = stripslashes_deep( $_POST['attachments'][$send_id] );
|
||||
$html = $attachment['post_title'];
|
||||
if ( !empty($attachment['url']) ) {
|
||||
|
|
Loading…
Reference in New Issue