Ticket #3840: import.php.diff
| File import.php.diff, 1.8 KB (added by technosailor, 5 years ago) |
|---|
-
Users/aaron/Sites/trunk/wp-admin/import/wordpress.php
212 212 function process_posts() { 213 213 global $wpdb; 214 214 $i = -1; 215 $id_lookup = array(); 215 216 echo '<ol>'; 216 217 foreach ($this->posts as $post) { 217 218 … … 258 259 wp_create_categories($categories, $post_id); 259 260 } 260 261 } 261 262 // Old Post IDs -> New Post IDs 263 $id_lookup[$this->get_tag($post, 'wp:post_id')] = $post_id; 264 262 265 // Now for comments 263 266 preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments); 264 267 $comments = $comments[1]; … … 297 300 } 298 301 299 302 echo '</ol>'; 303 304 // Run through and massage post_parents 305 foreach($this->posts as $old_post) //foreach($parent_lookup as $post_parent => $post_id) 306 { 307 $old_post_parent = $this->get_tag( $old_post, 'wp:post_parent' ); 308 $old_post_id = $this->get_tag( $old_post, 'wp:post_id' ); 309 310 if( 0 < $old_post_parent ) 311 { 312 // If we can find the original parent id and match it up, let's do it. Otherwise set to 0 so we don't lose the page on the manage screen 313 if ( in_array($old_post_parent, $id_lookup ) ) 314 wp_update_post( array('ID' => $id_lookup[$old_post_id], 'post_parent' => $id_lookup[$old_post_parent]) ); 315 else 316 wp_update_post( array('ID' => $id_lookup[$old_post_id], '0') ); 317 } 318 } 300 319 301 320 wp_import_cleanup($this->id); 302 321 … … 343 362 344 363 register_importer('wordpress', 'WordPress', __('Import <strong>posts, comments, custom fields, pages, and categories</strong> from a WordPress export file'), array ($wp_import, 'dispatch')); 345 364 346 ?> 365 ?> 366 No newline at end of file
