Changeset 12301
- Timestamp:
- 12/01/2009 02:12:42 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/import/wordpress.php
r12269 r12301 560 560 $comments = $comments[1]; 561 561 $num_comments = 0; 562 if ( $comments) { foreach ($comments as $comment) { 563 $comment_author = $this->get_tag( $comment, 'wp:comment_author'); 564 $comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email'); 565 $comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP'); 566 $comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url'); 567 $comment_date = $this->get_tag( $comment, 'wp:comment_date'); 568 $comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt'); 569 $comment_content = $this->get_tag( $comment, 'wp:comment_content'); 570 $comment_approved = $this->get_tag( $comment, 'wp:comment_approved'); 571 $comment_type = $this->get_tag( $comment, 'wp:comment_type'); 572 $comment_parent = $this->get_tag( $comment, 'wp:comment_parent'); 573 574 // if this is a new post we can skip the comment_exists() check 575 if ( !$post_exists || !comment_exists($comment_author, $comment_date) ) { 576 $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_author_email', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_approved', 'comment_type', 'comment_parent'); 577 $commentdata = wp_filter_comment($commentdata); 578 wp_insert_comment($commentdata); 579 $num_comments++; 580 } 581 } } 562 $inserted_comments = array(); 563 if ( $comments) { 564 foreach ($comments as $comment) { 565 $comment_id = $this->get_tag( $comment, 'wp:comment_id'); 566 $newcomments[$comment_id]['comment_post_ID'] = $comment_post_ID; 567 $newcomments[$comment_id]['comment_author'] = $this->get_tag( $comment, 'wp:comment_author'); 568 $newcomments[$comment_id]['comment_author_email'] = $this->get_tag( $comment, 'wp:comment_author_email'); 569 $newcomments[$comment_id]['comment_author_IP'] = $this->get_tag( $comment, 'wp:comment_author_IP'); 570 $newcomments[$comment_id]['comment_author_url'] = $this->get_tag( $comment, 'wp:comment_author_url'); 571 $newcomments[$comment_id]['comment_date'] = $this->get_tag( $comment, 'wp:comment_date'); 572 $newcomments[$comment_id]['comment_date_gmt'] = $this->get_tag( $comment, 'wp:comment_date_gmt'); 573 $newcomments[$comment_id]['comment_content'] = $this->get_tag( $comment, 'wp:comment_content'); 574 $newcomments[$comment_id]['comment_approved'] = $this->get_tag( $comment, 'wp:comment_approved'); 575 $newcomments[$comment_id]['comment_type'] = $this->get_tag( $comment, 'wp:comment_type'); 576 $newcomments[$comment_id]['comment_parent'] = $this->get_tag( $comment, 'wp:comment_parent'); 577 } 578 // Sort by comment ID, to make sure comment parents exist (if there at all) 579 ksort($newcomments); 580 foreach ($newcomments as $key => $comment) { 581 // if this is a new post we can skip the comment_exists() check 582 if ( !$post_exists || !comment_exists($comment['comment_author'], $comment['comment_date']) ) { 583 if (isset($inserted_comments[$comment['comment_parent']])) 584 $comment['comment_parent'] = $inserted_comments[$comment['comment_parent']]; 585 $comment = wp_filter_comment($comment); 586 $inserted_comments[$key] = wp_insert_comment($comment); 587 $num_comments++; 588 } 589 } 590 } 582 591 583 592 if ( $num_comments )
Note: See TracChangeset
for help on using the changeset viewer.