WordPress Importer - Version 0.5

Version Description

  • Import comment meta (requires export from WordPress 3.2)
  • Minor bugfixes and enhancements
Download this release

Release Info

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

Code changes from version 0.4 to 0.5

languages/wordpress-importer.pot CHANGED
@@ -2,9 +2,9 @@
2
  # This file is distributed under the same license as the WordPress Importer package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: WordPress Importer 0.3\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-importer\n"
7
- "POT-Creation-Date: 2011-02-21 21:07:12+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -22,49 +22,49 @@ msgid ""
22
  "parser..."
23
  msgstr ""
24
 
25
- #: parsers.php:67 parsers.php:72 parsers.php:248 parsers.php:430
26
  msgid ""
27
  "This does not appear to be a WXR file, missing/invalid WXR version number"
28
  msgstr ""
29
 
30
- #: wordpress-importer.php:133 wordpress-importer.php:142
31
- #: wordpress-importer.php:193 wordpress-importer.php:201
32
  msgid "Sorry, there has been an error."
33
  msgstr ""
34
 
35
- #: wordpress-importer.php:134
36
  msgid "The file does not exist, please try again."
37
  msgstr ""
38
 
39
- #: wordpress-importer.php:177
40
  msgid "All done."
41
  msgstr ""
42
 
43
- #: wordpress-importer.php:177
44
  msgid "Have fun!"
45
  msgstr ""
46
 
47
- #: wordpress-importer.php:178
48
  msgid "Remember to update the passwords and roles of imported users."
49
  msgstr ""
50
 
51
- #: wordpress-importer.php:209
52
  msgid ""
53
  "This WXR file (version %s) may not be supported by this version of the "
54
  "importer. Please consider updating."
55
  msgstr ""
56
 
57
- #: wordpress-importer.php:234
58
  msgid ""
59
  "Failed to import author %s. Their posts will be attributed to the current "
60
  "user."
61
  msgstr ""
62
 
63
- #: wordpress-importer.php:260
64
  msgid "Assign Authors"
65
  msgstr ""
66
 
67
- #: wordpress-importer.php:261
68
  msgid ""
69
  "To make it easier for you to edit and save the imported content, you may "
70
  "want to reassign the author of the imported item to an existing user of this "
@@ -72,137 +72,137 @@ msgid ""
72
  "code>s entries."
73
  msgstr ""
74
 
75
- #: wordpress-importer.php:263
76
  msgid ""
77
  "If a new user is created by WordPress, a new password will be randomly "
78
  "generated and the new user’s role will be set as %s. Manually changing "
79
  "the new user’s details will be necessary."
80
  msgstr ""
81
 
82
- #: wordpress-importer.php:273
83
  msgid "Import Attachments"
84
  msgstr ""
85
 
86
- #: wordpress-importer.php:276
87
  msgid "Download and import file attachments"
88
  msgstr ""
89
 
90
- #: wordpress-importer.php:280
91
  msgid "Submit"
92
  msgstr ""
93
 
94
- #: wordpress-importer.php:293
95
  msgid "Import author:"
96
  msgstr ""
97
 
98
- #: wordpress-importer.php:304
99
  msgid "or create new user with login name:"
100
  msgstr ""
101
 
102
- #: wordpress-importer.php:307
103
  msgid "as a new user:"
104
  msgstr ""
105
 
106
- #: wordpress-importer.php:315
107
  msgid "assign posts to an existing user:"
108
  msgstr ""
109
 
110
- #: wordpress-importer.php:317
111
  msgid "or assign posts to an existing user:"
112
  msgstr ""
113
 
114
- #: wordpress-importer.php:318
115
  msgid "- Select -"
116
  msgstr ""
117
 
118
- #: wordpress-importer.php:366
119
  msgid ""
120
  "Failed to create new user for %s. Their posts will be attributed to the "
121
  "current user."
122
  msgstr ""
123
 
124
- #: wordpress-importer.php:413
125
  msgid "Failed to import category %s"
126
  msgstr ""
127
 
128
- #: wordpress-importer.php:449
129
  msgid "Failed to import post tag %s"
130
  msgstr ""
131
 
132
- #: wordpress-importer.php:491 wordpress-importer.php:603
133
  msgid "Failed to import %s %s"
134
  msgstr ""
135
 
136
- #: wordpress-importer.php:513
137
  msgid "Failed to import “%s”: Invalid post type %s"
138
  msgstr ""
139
 
140
- #: wordpress-importer.php:534
141
  msgid "%s “%s” already exists."
142
  msgstr ""
143
 
144
- #: wordpress-importer.php:575
145
  msgid "Failed to import %s “%s”"
146
  msgstr ""
147
 
148
- #: wordpress-importer.php:712
149
  msgid "Menu item skipped due to missing menu slug"
150
  msgstr ""
151
 
152
- #: wordpress-importer.php:719
153
  msgid "Menu item skipped due to invalid menu slug: %s"
154
  msgstr ""
155
 
156
- #: wordpress-importer.php:782
157
  msgid "Fetching attachments is not enabled"
158
  msgstr ""
159
 
160
- #: wordpress-importer.php:795
161
  msgid "Invalid file type"
162
  msgstr ""
163
 
164
- #: wordpress-importer.php:838
165
  msgid "Remote server did not respond"
166
  msgstr ""
167
 
168
- #: wordpress-importer.php:844
169
  msgid "Remote server returned error response %1$d %2$s"
170
  msgstr ""
171
 
172
- #: wordpress-importer.php:851
173
  msgid "Remote file is incorrect size"
174
  msgstr ""
175
 
176
- #: wordpress-importer.php:856
177
  msgid "Zero size file downloaded"
178
  msgstr ""
179
 
180
- #: wordpress-importer.php:862
181
  msgid "Remote file is too large, limit is %s"
182
  msgstr ""
183
 
184
- #: wordpress-importer.php:961
185
  msgid "Import WordPress"
186
  msgstr ""
187
 
188
- #: wordpress-importer.php:968
189
  msgid ""
190
  "A new version of this importer is available. Please update to version %s to "
191
  "ensure compatibility with newer export files."
192
  msgstr ""
193
 
194
- #: wordpress-importer.php:983
195
  msgid ""
196
  "Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import "
197
  "the posts, pages, comments, custom fields, categories, and tags into this "
198
  "site."
199
  msgstr ""
200
 
201
- #: wordpress-importer.php:984
202
- msgid "Choose a WXR file to upload, then click Upload file and import."
203
  msgstr ""
204
 
205
- #: wordpress-importer.php:1058
206
  msgid ""
207
  "Import <strong>posts, pages, comments, custom fields, categories, and tags</"
208
  "strong> from a WordPress export file."
2
  # This file is distributed under the same license as the WordPress Importer package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: WordPress Importer 0.5\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-importer\n"
7
+ "POT-Creation-Date: 2011-07-16 15:45:12+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
22
  "parser..."
23
  msgstr ""
24
 
25
+ #: parsers.php:67 parsers.php:72 parsers.php:262 parsers.php:451
26
  msgid ""
27
  "This does not appear to be a WXR file, missing/invalid WXR version number"
28
  msgstr ""
29
 
30
+ #: wordpress-importer.php:134 wordpress-importer.php:143
31
+ #: wordpress-importer.php:194 wordpress-importer.php:202
32
  msgid "Sorry, there has been an error."
33
  msgstr ""
34
 
35
+ #: wordpress-importer.php:135
36
  msgid "The file does not exist, please try again."
37
  msgstr ""
38
 
39
+ #: wordpress-importer.php:178
40
  msgid "All done."
41
  msgstr ""
42
 
43
+ #: wordpress-importer.php:178
44
  msgid "Have fun!"
45
  msgstr ""
46
 
47
+ #: wordpress-importer.php:179
48
  msgid "Remember to update the passwords and roles of imported users."
49
  msgstr ""
50
 
51
+ #: wordpress-importer.php:210
52
  msgid ""
53
  "This WXR file (version %s) may not be supported by this version of the "
54
  "importer. Please consider updating."
55
  msgstr ""
56
 
57
+ #: wordpress-importer.php:235
58
  msgid ""
59
  "Failed to import author %s. Their posts will be attributed to the current "
60
  "user."
61
  msgstr ""
62
 
63
+ #: wordpress-importer.php:261
64
  msgid "Assign Authors"
65
  msgstr ""
66
 
67
+ #: wordpress-importer.php:262
68
  msgid ""
69
  "To make it easier for you to edit and save the imported content, you may "
70
  "want to reassign the author of the imported item to an existing user of this "
72
  "code>s entries."
73
  msgstr ""
74
 
75
+ #: wordpress-importer.php:264
76
  msgid ""
77
  "If a new user is created by WordPress, a new password will be randomly "
78
  "generated and the new user&#8217;s role will be set as %s. Manually changing "
79
  "the new user&#8217;s details will be necessary."
80
  msgstr ""
81
 
82
+ #: wordpress-importer.php:274
83
  msgid "Import Attachments"
84
  msgstr ""
85
 
86
+ #: wordpress-importer.php:277
87
  msgid "Download and import file attachments"
88
  msgstr ""
89
 
90
+ #: wordpress-importer.php:281
91
  msgid "Submit"
92
  msgstr ""
93
 
94
+ #: wordpress-importer.php:294
95
  msgid "Import author:"
96
  msgstr ""
97
 
98
+ #: wordpress-importer.php:305
99
  msgid "or create new user with login name:"
100
  msgstr ""
101
 
102
+ #: wordpress-importer.php:308
103
  msgid "as a new user:"
104
  msgstr ""
105
 
106
+ #: wordpress-importer.php:316
107
  msgid "assign posts to an existing user:"
108
  msgstr ""
109
 
110
+ #: wordpress-importer.php:318
111
  msgid "or assign posts to an existing user:"
112
  msgstr ""
113
 
114
+ #: wordpress-importer.php:319
115
  msgid "- Select -"
116
  msgstr ""
117
 
118
+ #: wordpress-importer.php:369
119
  msgid ""
120
  "Failed to create new user for %s. Their posts will be attributed to the "
121
  "current user."
122
  msgstr ""
123
 
124
+ #: wordpress-importer.php:418
125
  msgid "Failed to import category %s"
126
  msgstr ""
127
 
128
+ #: wordpress-importer.php:456
129
  msgid "Failed to import post tag %s"
130
  msgstr ""
131
 
132
+ #: wordpress-importer.php:500 wordpress-importer.php:626
133
  msgid "Failed to import %s %s"
134
  msgstr ""
135
 
136
+ #: wordpress-importer.php:522
137
  msgid "Failed to import &#8220;%s&#8221;: Invalid post type %s"
138
  msgstr ""
139
 
140
+ #: wordpress-importer.php:543
141
  msgid "%s &#8220;%s&#8221; already exists."
142
  msgstr ""
143
 
144
+ #: wordpress-importer.php:598
145
  msgid "Failed to import %s &#8220;%s&#8221;"
146
  msgstr ""
147
 
148
+ #: wordpress-importer.php:744
149
  msgid "Menu item skipped due to missing menu slug"
150
  msgstr ""
151
 
152
+ #: wordpress-importer.php:751
153
  msgid "Menu item skipped due to invalid menu slug: %s"
154
  msgstr ""
155
 
156
+ #: wordpress-importer.php:814
157
  msgid "Fetching attachments is not enabled"
158
  msgstr ""
159
 
160
+ #: wordpress-importer.php:827
161
  msgid "Invalid file type"
162
  msgstr ""
163
 
164
+ #: wordpress-importer.php:871
165
  msgid "Remote server did not respond"
166
  msgstr ""
167
 
168
+ #: wordpress-importer.php:877
169
  msgid "Remote server returned error response %1$d %2$s"
170
  msgstr ""
171
 
172
+ #: wordpress-importer.php:884
173
  msgid "Remote file is incorrect size"
174
  msgstr ""
175
 
176
+ #: wordpress-importer.php:889
177
  msgid "Zero size file downloaded"
178
  msgstr ""
179
 
180
+ #: wordpress-importer.php:895
181
  msgid "Remote file is too large, limit is %s"
182
  msgstr ""
183
 
184
+ #: wordpress-importer.php:994
185
  msgid "Import WordPress"
186
  msgstr ""
187
 
188
+ #: wordpress-importer.php:1001
189
  msgid ""
190
  "A new version of this importer is available. Please update to version %s to "
191
  "ensure compatibility with newer export files."
192
  msgstr ""
193
 
194
+ #: wordpress-importer.php:1016
195
  msgid ""
196
  "Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import "
197
  "the posts, pages, comments, custom fields, categories, and tags into this "
198
  "site."
199
  msgstr ""
200
 
201
+ #: wordpress-importer.php:1017
202
+ msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
203
  msgstr ""
204
 
205
+ #: wordpress-importer.php:1091
206
  msgid ""
207
  "Import <strong>posts, pages, comments, custom fields, categories, and tags</"
208
  "strong> from a WordPress export file."
parsers.php CHANGED
@@ -173,11 +173,21 @@ class WXR_Parser_SimpleXML {
173
  foreach ( $wp->postmeta as $meta ) {
174
  $post['postmeta'][] = array(
175
  'key' => (string) $meta->meta_key,
176
- 'value' => (string) $meta->meta_value,
177
  );
178
  }
179
 
180
  foreach ( $wp->comment as $comment ) {
 
 
 
 
 
 
 
 
 
 
181
  $post['comments'][] = array(
182
  'comment_id' => (int) $comment->comment_id,
183
  'comment_author' => (string) $comment->comment_author,
@@ -191,6 +201,7 @@ class WXR_Parser_SimpleXML {
191
  'comment_type' => (string) $comment->comment_type,
192
  'comment_parent' => (string) $comment->comment_parent,
193
  'comment_user_id' => (int) $comment->comment_user_id,
 
194
  );
195
  }
196
 
@@ -302,10 +313,17 @@ class WXR_Parser_XML {
302
  function tag_close( $parser, $tag ) {
303
  switch ( $tag ) {
304
  case 'wp:comment':
 
305
  if ( ! empty( $this->sub_data ) )
306
  $this->data['comments'][] = $this->sub_data;
307
  $this->sub_data = false;
308
  break;
 
 
 
 
 
 
309
  case 'category':
310
  if ( ! empty( $this->sub_data ) ) {
311
  $this->sub_data['name'] = $this->cdata;
@@ -546,6 +564,16 @@ class WXR_Parser_Regex {
546
  $comments = $comments[1];
547
  if ( $comments ) {
548
  foreach ( $comments as $comment ) {
 
 
 
 
 
 
 
 
 
 
549
  $post_comments[] = array(
550
  'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ),
551
  'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ),
@@ -559,6 +587,7 @@ class WXR_Parser_Regex {
559
  'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ),
560
  'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ),
561
  'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ),
 
562
  );
563
  }
564
  }
173
  foreach ( $wp->postmeta as $meta ) {
174
  $post['postmeta'][] = array(
175
  'key' => (string) $meta->meta_key,
176
+ 'value' => (string) $meta->meta_value
177
  );
178
  }
179
 
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
+
191
  $post['comments'][] = array(
192
  'comment_id' => (int) $comment->comment_id,
193
  'comment_author' => (string) $comment->comment_author,
201
  'comment_type' => (string) $comment->comment_type,
202
  'comment_parent' => (string) $comment->comment_parent,
203
  'comment_user_id' => (int) $comment->comment_user_id,
204
+ 'commentmeta' => $meta,
205
  );
206
  }
207
 
313
  function tag_close( $parser, $tag ) {
314
  switch ( $tag ) {
315
  case 'wp:comment':
316
+ unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data
317
  if ( ! empty( $this->sub_data ) )
318
  $this->data['comments'][] = $this->sub_data;
319
  $this->sub_data = false;
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;
327
  case 'category':
328
  if ( ! empty( $this->sub_data ) ) {
329
  $this->sub_data['name'] = $this->cdata;
564
  $comments = $comments[1];
565
  if ( $comments ) {
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
+
577
  $post_comments[] = array(
578
  'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ),
579
  'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ),
587
  'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ),
588
  'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ),
589
  'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ),
590
+ 'commentmeta' => $c_meta,
591
  );
592
  }
593
  }
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.1
7
- Stable tag: 0.4
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.4 =
41
  * Map comment user_id where possible
42
  * Import attachments from `wp:attachment_url`
@@ -53,6 +57,9 @@ If you would prefer to do things manually then follow these instructions:
53
 
54
  == Upgrade Notice ==
55
 
 
 
 
56
  = 0.4 =
57
  Bug fixes for attachment importing and other small enhancements.
58
 
3
  Donate link:
4
  Tags: importer, wordpress
5
  Requires at least: 3.0
6
+ Tested up to: 3.2.1
7
+ Stable tag: 0.5
8
 
9
  Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
10
 
37
 
38
  == Changelog ==
39
 
40
+ = 0.5 =
41
+ * Import comment meta (requires export from WordPress 3.2)
42
+ * Minor bugfixes and enhancements
43
+
44
  = 0.4 =
45
  * Map comment user_id where possible
46
  * Import attachments from `wp:attachment_url`
57
 
58
  == Upgrade Notice ==
59
 
60
+ = 0.5 =
61
+ Import comment meta and other minor bugfixes and enhancements.
62
+
63
  = 0.4 =
64
  Bug fixes for attachment importing and other small enhancements.
65
 
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.4
9
  Text Domain: wordpress-importer
10
  License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11
  */
@@ -335,6 +335,8 @@ class WP_Import extends WP_Importer {
335
  $create_users = $this->allow_create_users();
336
 
337
  foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) {
 
 
338
  $old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval($this->authors[$old_login]['author_id']) : false;
339
 
340
  if ( ! empty( $_POST['user_map'][$i] ) ) {
@@ -342,7 +344,7 @@ class WP_Import extends WP_Importer {
342
  if ( isset( $user->ID ) ) {
343
  if ( $old_id )
344
  $this->processed_authors[$old_id] = $user->ID;
345
- $this->author_mapping[$old_login] = $user->ID;
346
  }
347
  } else if ( $create_users ) {
348
  if ( ! empty($_POST['user_new'][$i]) ) {
@@ -362,7 +364,7 @@ class WP_Import extends WP_Importer {
362
  if ( ! is_wp_error( $user_id ) ) {
363
  if ( $old_id )
364
  $this->processed_authors[$old_id] = $user_id;
365
- $this->author_mapping[$old_login] = $user_id;
366
  } else {
367
  printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html($this->authors[$old_login]['author_display_name']) );
368
  if ( defined('IMPORT_DEBUG') && IMPORT_DEBUG )
@@ -372,10 +374,10 @@ class WP_Import extends WP_Importer {
372
  }
373
 
374
  // failsafe: if the user_id was invalid, default to the current user
375
- if ( ! isset( $this->author_mapping[$old_login] ) ) {
376
  if ( $old_id )
377
  $this->processed_authors[$old_id] = (int) get_current_user_id();
378
- $this->author_mapping[$old_login] = (int) get_current_user_id();
379
  }
380
  }
381
  }
@@ -523,7 +525,7 @@ class WP_Import extends WP_Importer {
523
  continue;
524
  }
525
 
526
- if ( isset( $this->processed_posts[$post['post_id']] ) )
527
  continue;
528
 
529
  if ( $post['status'] == 'auto-draft' )
@@ -654,6 +656,7 @@ class WP_Import extends WP_Importer {
654
  $newcomments[$comment_id]['comment_approved'] = $comment['comment_approved'];
655
  $newcomments[$comment_id]['comment_type'] = $comment['comment_type'];
656
  $newcomments[$comment_id]['comment_parent'] = $comment['comment_parent'];
 
657
  if ( isset( $this->processed_authors[$comment['comment_user_id']] ) )
658
  $newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']];
659
  }
@@ -666,6 +669,12 @@ class WP_Import extends WP_Importer {
666
  $comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
667
  $comment = wp_filter_comment( $comment );
668
  $inserted_comments[$key] = wp_insert_comment( $comment );
 
 
 
 
 
 
669
  $num_comments++;
670
  }
671
  }
@@ -1005,7 +1014,7 @@ class WP_Import extends WP_Importer {
1005
  function greet() {
1006
  echo '<div class="narrow">';
1007
  echo '<p>'.__( 'Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'wordpress-importer' ).'</p>';
1008
- echo '<p>'.__( 'Choose a WXR file to upload, then click Upload file and import.', 'wordpress-importer' ).'</p>';
1009
  wp_import_upload_form( 'admin.php?import=wordpress&amp;step=1' );
1010
  echo '</div>';
1011
  }
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
9
  Text Domain: wordpress-importer
10
  License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11
  */
335
  $create_users = $this->allow_create_users();
336
 
337
  foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) {
338
+ // Multsite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts.
339
+ $santized_old_login = sanitize_user( $old_login, true );
340
  $old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval($this->authors[$old_login]['author_id']) : false;
341
 
342
  if ( ! empty( $_POST['user_map'][$i] ) ) {
344
  if ( isset( $user->ID ) ) {
345
  if ( $old_id )
346
  $this->processed_authors[$old_id] = $user->ID;
347
+ $this->author_mapping[$santized_old_login] = $user->ID;
348
  }
349
  } else if ( $create_users ) {
350
  if ( ! empty($_POST['user_new'][$i]) ) {
364
  if ( ! is_wp_error( $user_id ) ) {
365
  if ( $old_id )
366
  $this->processed_authors[$old_id] = $user_id;
367
+ $this->author_mapping[$santized_old_login] = $user_id;
368
  } else {
369
  printf( __( 'Failed to create new user for %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html($this->authors[$old_login]['author_display_name']) );
370
  if ( defined('IMPORT_DEBUG') && IMPORT_DEBUG )
374
  }
375
 
376
  // failsafe: if the user_id was invalid, default to the current user
377
+ if ( ! isset( $this->author_mapping[$santized_old_login] ) ) {
378
  if ( $old_id )
379
  $this->processed_authors[$old_id] = (int) get_current_user_id();
380
+ $this->author_mapping[$santized_old_login] = (int) get_current_user_id();
381
  }
382
  }
383
  }
525
  continue;
526
  }
527
 
528
+ if ( isset( $this->processed_posts[$post['post_id']] ) && ! empty( $post['post_id'] ) )
529
  continue;
530
 
531
  if ( $post['status'] == 'auto-draft' )
656
  $newcomments[$comment_id]['comment_approved'] = $comment['comment_approved'];
657
  $newcomments[$comment_id]['comment_type'] = $comment['comment_type'];
658
  $newcomments[$comment_id]['comment_parent'] = $comment['comment_parent'];
659
+ $newcomments[$comment_id]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array();
660
  if ( isset( $this->processed_authors[$comment['comment_user_id']] ) )
661
  $newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']];
662
  }
669
  $comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
670
  $comment = wp_filter_comment( $comment );
671
  $inserted_comments[$key] = wp_insert_comment( $comment );
672
+
673
+ foreach( $comment['commentmeta'] as $meta ) {
674
+ $value = maybe_unserialize( $meta['value'] );
675
+ add_comment_meta( $inserted_comments[$key], $meta['key'], $value );
676
+ }
677
+
678
  $num_comments++;
679
  }
680
  }
1014
  function greet() {
1015
  echo '<div class="narrow">';
1016
  echo '<p>'.__( 'Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'wordpress-importer' ).'</p>';
1017
+ echo '<p>'.__( 'Choose a WXR (.xml) file to upload, then click Upload file and import.', 'wordpress-importer' ).'</p>';
1018
  wp_import_upload_form( 'admin.php?import=wordpress&amp;step=1' );
1019
  echo '</div>';
1020
  }