Ticket #7972: preserve-attachment-ids.diff
| File preserve-attachment-ids.diff, 1.1 KB (added by , 17 years ago) |
|---|
-
post.php
2245 2245 $defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID, 2246 2246 'ping_status' => get_option('default_ping_status'), 'post_parent' => 0, 2247 2247 'menu_order' => 0, 'to_ping' => '', 'pinged' => '', 'post_password' => '', 2248 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '' );2248 'guid' => '', 'post_content_filtered' => '', 'post_excerpt' => '', 'import_id' => 0); 2249 2249 2250 2250 $object = wp_parse_args($object, $defaults); 2251 2251 if ( !empty($parent) ) … … 2341 2341 if ( $update ) { 2342 2342 $wpdb->update( $wpdb->posts, $data, array( 'ID' => $post_ID ) ); 2343 2343 } else { 2344 // If there is a suggested ID, use it if not already present 2345 if ( !empty($import_id) ) { 2346 $import_id = (int) $import_id; 2347 if ( ! $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE ID = %d", $import_id) ) ) { 2348 $data['ID'] = $import_id; 2349 } 2350 } 2351 2344 2352 $wpdb->insert( $wpdb->posts, $data ); 2345 2353 $post_ID = (int) $wpdb->insert_id; 2346 2354 }