337
343
$tag_ID = wp_insert_term($tag_name, 'post_tag', $tagarr);
347
function process_terms() {
348
global $wpdb, $wp_taxonomies;
350
$custom_taxonomies = $wp_taxonomies;
351
// get rid of the standard taxonomies
352
unset( $custom_taxonomies['category'] );
353
unset( $custom_taxonomies['post_tag'] );
354
unset( $custom_taxonomies['link_category'] );
356
$custom_taxonomies = array_keys( $custom_taxonomies );
357
$current_terms = (array) get_terms( $custom_taxonomies, 'get=all' );
358
$taxonomies = array();
359
foreach ( $current_terms as $term ) {
360
if ( isset( $_terms[$term->taxonomy] ) ) {
361
$taxonomies[$term->taxonomy] = array_merge( $taxonomies[$term->taxonomy], array($term->name) );
363
$taxonomies[$term->taxonomy] = array($term->name);
367
while ( $c = array_shift($this->terms) ) {
368
$term_name = trim($this->get_tag( $c, 'wp:term_name' ));
369
$term_taxonomy = trim($this->get_tag( $c, 'wp:term_taxonomy' ));
371
// If the term exists in the taxonomy we leave it alone
372
if ( isset($taxonomies[$term_taxonomy] ) && in_array( $term_name, $taxonomies[$term_taxonomy] ) )
375
$slug = $this->get_tag( $c, 'wp:term_slug' );
376
$description = $this->get_tag( $c, 'wp:term_description' );
378
$termarr = compact('slug', 'description');
380
$term_ID = wp_insert_term($term_name, $this->get_tag( $c, 'wp:term_taxonomy' ), $termarr);
341
384
function process_author($post) {
342
385
$author = $this->get_tag( $post, 'dc:creator' );
378
425
$menu_order = $this->get_tag( $post, 'wp:menu_order' );
379
426
$post_type = $this->get_tag( $post, 'wp:post_type' );
380
427
$post_password = $this->get_tag( $post, 'wp:post_password' );
428
$is_sticky = $this->get_tag( $post, 'wp:is_sticky' );
381
429
$guid = $this->get_tag( $post, 'guid' );
382
430
$post_author = $this->get_tag( $post, 'dc:creator' );
384
432
$post_excerpt = $this->get_tag( $post, 'excerpt:encoded' );
385
$post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_excerpt);
433
$post_excerpt = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_excerpt);
386
434
$post_excerpt = str_replace('<br>', '<br />', $post_excerpt);
387
435
$post_excerpt = str_replace('<hr>', '<hr />', $post_excerpt);
389
437
$post_content = $this->get_tag( $post, 'content:encoded' );
390
$post_content = preg_replace_callback('|<(/?[A-Z]+)|', create_function('$match', 'return "<" . strtolower($match[1]);'), $post_content);
438
$post_content = preg_replace_callback('|<(/?[A-Z]+)|', array( &$this, '_normalize_tag' ), $post_content);
391
439
$post_content = str_replace('<br>', '<br />', $post_content);
392
440
$post_content = str_replace('<hr>', '<hr />', $post_content);
508
559
preg_match_all('|<wp:comment>(.*?)</wp:comment>|is', $post, $comments);
509
560
$comments = $comments[1];
510
561
$num_comments = 0;
511
if ( $comments) { foreach ($comments as $comment) {
512
$comment_author = $this->get_tag( $comment, 'wp:comment_author');
513
$comment_author_email = $this->get_tag( $comment, 'wp:comment_author_email');
514
$comment_author_IP = $this->get_tag( $comment, 'wp:comment_author_IP');
515
$comment_author_url = $this->get_tag( $comment, 'wp:comment_author_url');
516
$comment_date = $this->get_tag( $comment, 'wp:comment_date');
517
$comment_date_gmt = $this->get_tag( $comment, 'wp:comment_date_gmt');
518
$comment_content = $this->get_tag( $comment, 'wp:comment_content');
519
$comment_approved = $this->get_tag( $comment, 'wp:comment_approved');
520
$comment_type = $this->get_tag( $comment, 'wp:comment_type');
521
$comment_parent = $this->get_tag( $comment, 'wp:comment_parent');
523
// if this is a new post we can skip the comment_exists() check
524
if ( !$post_exists || !comment_exists($comment_author, $comment_date) ) {
525
$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');
526
wp_insert_comment($commentdata);
562
$inserted_comments = array();
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');
578
// Sort by comment ID, to make sure comment parents exist (if there at all)
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);
531
592
if ( $num_comments )
532
593
printf(' '._n('(%s comment)', '(%s comments)', $num_comments), $num_comments);