Make WordPress Core


Ignore:
Timestamp:
12/05/2008 06:21:42 AM (17 years ago)
Author:
azaozz
Message:

Attach orphan attachments when inserting into a post, fixes #8490

File:
1 edited

Legend:

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

    r9981 r10062  
    373373        if ( isset($attachment['menu_order']) )
    374374            $post['menu_order'] = $attachment['menu_order'];
     375        if ( isset($attachment['post_parent']) )
     376            $post['post_parent'] = $attachment['post_parent'];
    375377
    376378        $post = apply_filters('attachment_fields_to_save', $post, $attachment);
     
    11851187    foreach ( $hidden_fields as $name => $value )
    11861188        $item .= "\t<input type='hidden' name='$name' id='$name' value='" . attribute_escape( $value ) . "' />\n";
     1189
     1190    if ( $post->post_parent < 1 && (int) $_REQUEST['post_id'] ) {
     1191        $parent = (int) $_REQUEST['post_id'];
     1192        $parent_name = "attachments[$attachment_id][post_parent]";
     1193
     1194        $item .= "\t<input type='hidden' name='$parent_name' id='$parent_name' value='" . $parent . "' />\n";
     1195    }
    11871196
    11881197    return $item;
Note: See TracChangeset for help on using the changeset viewer.