Ticket #12871: 12871.importer.diff
File 12871.importer.diff, 4.0 KB (added by , 14 years ago) |
---|
-
trunk/parsers.php
173 173 foreach ( $wp->postmeta as $meta ) { 174 174 $post['postmeta'][] = array( 175 175 'key' => (string) $meta->meta_key, 176 'value' => (string) $meta->meta_value ,176 'value' => (string) $meta->meta_value 177 177 ); 178 178 } 179 179 180 180 foreach ( $wp->comment as $comment ) { 181 $meta = array(); 182 if ( isset( $comment->commentmeta ) ) { 183 foreach ( $comment->commentmeta as $m ) { 184 $meta[] = array( 185 'key' => (string) $m->meta_key, 186 'value' => (string) $m->meta_value 187 ); 188 } 189 } 190 181 191 $post['comments'][] = array( 182 192 'comment_id' => (int) $comment->comment_id, 183 193 'comment_author' => (string) $comment->comment_author, … … 191 201 'comment_type' => (string) $comment->comment_type, 192 202 'comment_parent' => (string) $comment->comment_parent, 193 203 'comment_user_id' => (int) $comment->comment_user_id, 204 'commentmeta' => $meta, 194 205 ); 195 206 } 196 207 … … 302 313 function tag_close( $parser, $tag ) { 303 314 switch ( $tag ) { 304 315 case 'wp:comment': 316 unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data 305 317 if ( ! empty( $this->sub_data ) ) 306 318 $this->data['comments'][] = $this->sub_data; 307 319 $this->sub_data = false; 308 320 break; 321 case 'wp:commentmeta': 322 $this->sub_data['commentmeta'][] = array( 323 'key' => $this->sub_data['key'], 324 'value' => $this->sub_data['value'] 325 ); 326 break; 309 327 case 'category': 310 328 if ( ! empty( $this->sub_data ) ) { 311 329 $this->sub_data['name'] = $this->cdata; … … 546 564 $comments = $comments[1]; 547 565 if ( $comments ) { 548 566 foreach ( $comments as $comment ) { 567 preg_match_all( '|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta ); 568 $commentmeta = $commentmeta[1]; 569 $c_meta = array(); 570 foreach ( $commentmeta as $m ) { 571 $c_meta[] = array( 572 'key' => $this->get_tag( $m, 'wp:meta_key' ), 573 'value' => $this->get_tag( $m, 'wp:meta_value' ), 574 ); 575 } 576 549 577 $post_comments[] = array( 550 578 'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ), 551 579 'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ), … … 559 587 'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ), 560 588 'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ), 561 589 'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ), 590 'commentmeta' => $c_meta, 562 591 ); 563 592 } 564 593 } -
trunk/wordpress-importer.php
523 523 continue; 524 524 } 525 525 526 if ( isset( $this->processed_posts[$post['post_id']] ) )526 if ( isset( $this->processed_posts[$post['post_id']] ) && ! empty( $post['post_id'] ) ) 527 527 continue; 528 528 529 529 if ( $post['status'] == 'auto-draft' ) … … 654 654 $newcomments[$comment_id]['comment_approved'] = $comment['comment_approved']; 655 655 $newcomments[$comment_id]['comment_type'] = $comment['comment_type']; 656 656 $newcomments[$comment_id]['comment_parent'] = $comment['comment_parent']; 657 $newcomments[$comment_id]['commentmeta'] = $comment['commentmeta']; 657 658 if ( isset( $this->processed_authors[$comment['comment_user_id']] ) ) 658 659 $newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']]; 659 660 } … … 666 667 $comment['comment_parent'] = $inserted_comments[$comment['comment_parent']]; 667 668 $comment = wp_filter_comment( $comment ); 668 669 $inserted_comments[$key] = wp_insert_comment( $comment ); 670 671 foreach( $comment['commentmeta'] as $meta ) { 672 $value = maybe_unserialize( $meta['value'] ); 673 add_comment_meta( $inserted_comments[$key], $meta['key'], $value ); 674 } 675 669 676 $num_comments++; 670 677 } 671 678 }