WordPress Importer - Version 0.6

Version Description

  • Support for WXR 1.2 and multiple CDATA sections
  • Post aren't duplicates if their post_type's are different
Download this release

Release Info

Developer duck_
Plugin Icon 128x128 WordPress Importer
Version 0.6
Comparing to
See all releases

Code changes from version 0.5.2 to 0.6

Files changed (3) hide show
  1. parsers.php +13 -4
  2. readme.txt +9 -2
  3. wordpress-importer.php +4 -4
parsers.php CHANGED
@@ -462,11 +462,20 @@ class WXR_Parser_Regex {
462
  }
463
 
464
  function get_tag( $string, $tag ) {
465
- global $wpdb;
466
  preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return );
467
  if ( isset( $return[1] ) ) {
468
- $return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] );
469
- $return = $wpdb->escape( trim( $return ) );
 
 
 
 
 
 
 
 
 
 
470
  } else {
471
  $return = '';
472
  }
@@ -527,7 +536,7 @@ class WXR_Parser_Regex {
527
  $menu_order = $this->get_tag( $post, 'wp:menu_order' );
528
  $post_type = $this->get_tag( $post, 'wp:post_type' );
529
  $post_password = $this->get_tag( $post, 'wp:post_password' );
530
- $is_sticky = $this->get_tag( $post, 'wp:is_sticky' );
531
  $guid = $this->get_tag( $post, 'guid' );
532
  $post_author = $this->get_tag( $post, 'dc:creator' );
533
 
462
  }
463
 
464
  function get_tag( $string, $tag ) {
 
465
  preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return );
466
  if ( isset( $return[1] ) ) {
467
+ if ( substr( $return[1], 0, 9 ) == '<![CDATA[' ) {
468
+ if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) {
469
+ preg_match_all( '|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches );
470
+ $return = '';
471
+ foreach( $matches[1] as $match )
472
+ $return .= $match;
473
+ } else {
474
+ $return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] );
475
+ }
476
+ } else {
477
+ $return = $return[1];
478
+ }
479
  } else {
480
  $return = '';
481
  }
536
  $menu_order = $this->get_tag( $post, 'wp:menu_order' );
537
  $post_type = $this->get_tag( $post, 'wp:post_type' );
538
  $post_password = $this->get_tag( $post, 'wp:post_password' );
539
+ $is_sticky = $this->get_tag( $post, 'wp:is_sticky' );
540
  $guid = $this->get_tag( $post, 'guid' );
541
  $post_author = $this->get_tag( $post, 'dc:creator' );
542
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: wordpressdotorg
3
  Donate link:
4
  Tags: importer, wordpress
5
  Requires at least: 3.0
6
- Tested up to: 3.3.1
7
- Stable tag: 0.5.2
8
 
9
  Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
10
 
@@ -37,6 +37,10 @@ If you would prefer to do things manually then follow these instructions:
37
 
38
  == Changelog ==
39
 
 
 
 
 
40
  = 0.5.2 =
41
  * Double check that the uploaded export file exists before processing it. This prevents incorrect error messages when
42
  an export file is uploaded to a server with bad permissions and WordPress 3.3 or 3.3.1 is being used.
@@ -61,6 +65,9 @@ an export file is uploaded to a server with bad permissions and WordPress 3.3 or
61
 
62
  == Upgrade Notice ==
63
 
 
 
 
64
  = 0.5.2 =
65
  Fix incorrect error message when the export file could not be uploaded.
66
 
3
  Donate link:
4
  Tags: importer, wordpress
5
  Requires at least: 3.0
6
+ Tested up to: 3.4
7
+ Stable tag: 0.6
8
 
9
  Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
10
 
37
 
38
  == Changelog ==
39
 
40
+ = 0.6 =
41
+ * Support for WXR 1.2 and multiple CDATA sections
42
+ * Post aren't duplicates if their post_type's are different
43
+
44
  = 0.5.2 =
45
  * Double check that the uploaded export file exists before processing it. This prevents incorrect error messages when
46
  an export file is uploaded to a server with bad permissions and WordPress 3.3 or 3.3.1 is being used.
65
 
66
  == Upgrade Notice ==
67
 
68
+ = 0.6 =
69
+ Support for exports from WordPress 3.4.
70
+
71
  = 0.5.2 =
72
  Fix incorrect error message when the export file could not be uploaded.
73
 
wordpress-importer.php CHANGED
@@ -5,7 +5,7 @@ Plugin URI: http://wordpress.org/extend/plugins/wordpress-importer/
5
  Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
6
  Author: wordpressdotorg
7
  Author URI: http://wordpress.org/
8
- Version: 0.5.2
9
  Text Domain: wordpress-importer
10
  License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11
  */
@@ -36,7 +36,7 @@ require dirname( __FILE__ ) . '/parsers.php';
36
  */
37
  if ( class_exists( 'WP_Importer' ) ) {
38
  class WP_Import extends WP_Importer {
39
- var $max_wxr_version = 1.1; // max. supported WXR version
40
 
41
  var $id; // WXR attachment ID
42
 
@@ -340,7 +340,7 @@ class WP_Import extends WP_Importer {
340
  $create_users = $this->allow_create_users();
341
 
342
  foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) {
343
- // Multsite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts.
344
  $santized_old_login = sanitize_user( $old_login, true );
345
  $old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval($this->authors[$old_login]['author_id']) : false;
346
 
@@ -544,7 +544,7 @@ class WP_Import extends WP_Importer {
544
  $post_type_object = get_post_type_object( $post['post_type'] );
545
 
546
  $post_exists = post_exists( $post['post_title'], '', $post['post_date'] );
547
- if ( $post_exists ) {
548
  printf( __('%s &#8220;%s&#8221; already exists.', 'wordpress-importer'), $post_type_object->labels->singular_name, esc_html($post['post_title']) );
549
  echo '<br />';
550
  $comment_post_ID = $post_id = $post_exists;
5
  Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
6
  Author: wordpressdotorg
7
  Author URI: http://wordpress.org/
8
+ Version: 0.6
9
  Text Domain: wordpress-importer
10
  License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11
  */
36
  */
37
  if ( class_exists( 'WP_Importer' ) ) {
38
  class WP_Import extends WP_Importer {
39
+ var $max_wxr_version = 1.2; // max. supported WXR version
40
 
41
  var $id; // WXR attachment ID
42
 
340
  $create_users = $this->allow_create_users();
341
 
342
  foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) {
343
+ // Multisite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts.
344
  $santized_old_login = sanitize_user( $old_login, true );
345
  $old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval($this->authors[$old_login]['author_id']) : false;
346
 
544
  $post_type_object = get_post_type_object( $post['post_type'] );
545
 
546
  $post_exists = post_exists( $post['post_title'], '', $post['post_date'] );
547
+ if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) {
548
  printf( __('%s &#8220;%s&#8221; already exists.', 'wordpress-importer'), $post_type_object->labels->singular_name, esc_html($post['post_title']) );
549
  echo '<br />';
550
  $comment_post_ID = $post_id = $post_exists;