Merge lp:~paulgear/wordpress/wp-plugin-wordpress-importer-0.6.3 into lp:~canonical-sysadmins/wordpress/wp-plugin-wordpress-importer

Proposed by Paul Gear
Status: Merged
Merged at revision: 2
Proposed branch: lp:~paulgear/wordpress/wp-plugin-wordpress-importer-0.6.3
Merge into: lp:~canonical-sysadmins/wordpress/wp-plugin-wordpress-importer
Diff against target: 586 lines (+193/-64)
4 files modified
languages/wordpress-importer.pot (+56/-48)
parsers.php (+36/-9)
readme.txt (+11/-3)
wordpress-importer.php (+90/-4)
To merge this branch: bzr merge lp:~paulgear/wordpress/wp-plugin-wordpress-importer-0.6.3
Reviewer Review Type Date Requested Status
The Canonical Sysadmins Pending
Review via email: mp+331035@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'languages/wordpress-importer.pot'
--- languages/wordpress-importer.pot 2015-05-07 02:17:14 +0000
+++ languages/wordpress-importer.pot 2017-09-20 05:06:40 +0000
@@ -1,18 +1,19 @@
1# Copyright (C) 2011 WordPress Importer1# Copyright (C) 2016 WordPress Importer
2# This file is distributed under the same license as the WordPress Importer package.2# This file is distributed under the same license as the WordPress Importer package.
3msgid ""3msgid ""
4msgstr ""4msgstr ""
5"Project-Id-Version: WordPress Importer 0.5\n"5"Project-Id-Version: WordPress Importer 0.6.3\n"
6"Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-importer\n"6"Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/wordpress-"
7"POT-Creation-Date: 2011-07-16 15:45:12+00:00\n"7"importer\n"
8"POT-Creation-Date: 2016-08-19 13:28:24+00:00\n"
8"MIME-Version: 1.0\n"9"MIME-Version: 1.0\n"
9"Content-Type: text/plain; charset=UTF-8\n"10"Content-Type: text/plain; charset=UTF-8\n"
10"Content-Transfer-Encoding: 8bit\n"11"Content-Transfer-Encoding: 8bit\n"
11"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"12"PO-Revision-Date: 2016-MO-DA HO:MI+ZONE\n"
12"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"13"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13"Language-Team: LANGUAGE <LL@li.org>\n"14"Language-Team: LANGUAGE <LL@li.org>\n"
1415
15#: parsers.php:42 parsers.php:6316#: parsers.php:42 parsers.php:72 parsers.php:80
16msgid "There was an error when reading this WXR file"17msgid "There was an error when reading this WXR file"
17msgstr ""18msgstr ""
1819
@@ -22,49 +23,56 @@
22"parser..."23"parser..."
23msgstr ""24msgstr ""
2425
25#: parsers.php:67 parsers.php:72 parsers.php:262 parsers.php:45126#: parsers.php:84 parsers.php:89 parsers.php:306 parsers.php:495
26msgid ""27msgid ""
27"This does not appear to be a WXR file, missing/invalid WXR version number"28"This does not appear to be a WXR file, missing/invalid WXR version number"
28msgstr ""29msgstr ""
2930
30#: wordpress-importer.php:134 wordpress-importer.php:14331#: wordpress-importer.php:132 wordpress-importer.php:141
31#: wordpress-importer.php:194 wordpress-importer.php:20232#: wordpress-importer.php:192 wordpress-importer.php:196
33#: wordpress-importer.php:205
32msgid "Sorry, there has been an error."34msgid "Sorry, there has been an error."
33msgstr ""35msgstr ""
3436
35#: wordpress-importer.php:13537#: wordpress-importer.php:133
36msgid "The file does not exist, please try again."38msgid "The file does not exist, please try again."
37msgstr ""39msgstr ""
3840
39#: wordpress-importer.php:17841#: wordpress-importer.php:176
40msgid "All done."42msgid "All done."
41msgstr ""43msgstr ""
4244
43#: wordpress-importer.php:17845#: wordpress-importer.php:176
44msgid "Have fun!"46msgid "Have fun!"
45msgstr ""47msgstr ""
4648
47#: wordpress-importer.php:17949#: wordpress-importer.php:177
48msgid "Remember to update the passwords and roles of imported users."50msgid "Remember to update the passwords and roles of imported users."
49msgstr ""51msgstr ""
5052
51#: wordpress-importer.php:21053#: wordpress-importer.php:197
54msgid ""
55"The export file could not be found at <code>%s</code>. It is likely that "
56"this was caused by a permissions problem."
57msgstr ""
58
59#: wordpress-importer.php:213
52msgid ""60msgid ""
53"This WXR file (version %s) may not be supported by this version of the "61"This WXR file (version %s) may not be supported by this version of the "
54"importer. Please consider updating."62"importer. Please consider updating."
55msgstr ""63msgstr ""
5664
57#: wordpress-importer.php:23565#: wordpress-importer.php:238
58msgid ""66msgid ""
59"Failed to import author %s. Their posts will be attributed to the current "67"Failed to import author %s. Their posts will be attributed to the current "
60"user."68"user."
61msgstr ""69msgstr ""
6270
63#: wordpress-importer.php:26171#: wordpress-importer.php:264
64msgid "Assign Authors"72msgid "Assign Authors"
65msgstr ""73msgstr ""
6674
67#: wordpress-importer.php:26275#: wordpress-importer.php:265
68msgid ""76msgid ""
69"To make it easier for you to edit and save the imported content, you may "77"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 "78"want to reassign the author of the imported item to an existing user of this "
@@ -72,137 +80,137 @@
72"code>s entries."80"code>s entries."
73msgstr ""81msgstr ""
7482
75#: wordpress-importer.php:26483#: wordpress-importer.php:267
76msgid ""84msgid ""
77"If a new user is created by WordPress, a new password will be randomly "85"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 "86"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."87"the new user&#8217;s details will be necessary."
80msgstr ""88msgstr ""
8189
82#: wordpress-importer.php:27490#: wordpress-importer.php:277
83msgid "Import Attachments"91msgid "Import Attachments"
84msgstr ""92msgstr ""
8593
86#: wordpress-importer.php:27794#: wordpress-importer.php:280
87msgid "Download and import file attachments"95msgid "Download and import file attachments"
88msgstr ""96msgstr ""
8997
90#: wordpress-importer.php:28198#: wordpress-importer.php:284
91msgid "Submit"99msgid "Submit"
92msgstr ""100msgstr ""
93101
94#: wordpress-importer.php:294102#: wordpress-importer.php:297
95msgid "Import author:"103msgid "Import author:"
96msgstr ""104msgstr ""
97105
98#: wordpress-importer.php:305106#: wordpress-importer.php:308
99msgid "or create new user with login name:"107msgid "or create new user with login name:"
100msgstr ""108msgstr ""
101109
102#: wordpress-importer.php:308110#: wordpress-importer.php:311
103msgid "as a new user:"111msgid "as a new user:"
104msgstr ""112msgstr ""
105113
106#: wordpress-importer.php:316114#: wordpress-importer.php:319
107msgid "assign posts to an existing user:"115msgid "assign posts to an existing user:"
108msgstr ""116msgstr ""
109117
110#: wordpress-importer.php:318118#: wordpress-importer.php:321
111msgid "or assign posts to an existing user:"119msgid "or assign posts to an existing user:"
112msgstr ""120msgstr ""
113121
114#: wordpress-importer.php:319122#: wordpress-importer.php:322
115msgid "- Select -"123msgid "- Select -"
116msgstr ""124msgstr ""
117125
118#: wordpress-importer.php:369126#: wordpress-importer.php:372
119msgid ""127msgid ""
120"Failed to create new user for %s. Their posts will be attributed to the "128"Failed to create new user for %s. Their posts will be attributed to the "
121"current user."129"current user."
122msgstr ""130msgstr ""
123131
124#: wordpress-importer.php:418132#: wordpress-importer.php:424
125msgid "Failed to import category %s"133msgid "Failed to import category %s"
126msgstr ""134msgstr ""
127135
128#: wordpress-importer.php:456136#: wordpress-importer.php:467
129msgid "Failed to import post tag %s"137msgid "Failed to import post tag %s"
130msgstr ""138msgstr ""
131139
132#: wordpress-importer.php:500 wordpress-importer.php:626140#: wordpress-importer.php:516 wordpress-importer.php:738
133msgid "Failed to import %s %s"141msgid "Failed to import %s %s"
134msgstr ""142msgstr ""
135143
136#: wordpress-importer.php:522144#: wordpress-importer.php:605
137msgid "Failed to import &#8220;%s&#8221;: Invalid post type %s"145msgid "Failed to import &#8220;%s&#8221;: Invalid post type %s"
138msgstr ""146msgstr ""
139147
140#: wordpress-importer.php:543148#: wordpress-importer.php:642
141msgid "%s &#8220;%s&#8221; already exists."149msgid "%s &#8220;%s&#8221; already exists."
142msgstr ""150msgstr ""
143151
144#: wordpress-importer.php:598152#: wordpress-importer.php:704
145msgid "Failed to import %s &#8220;%s&#8221;"153msgid "Failed to import %s &#8220;%s&#8221;"
146msgstr ""154msgstr ""
147155
148#: wordpress-importer.php:744156#: wordpress-importer.php:869
149msgid "Menu item skipped due to missing menu slug"157msgid "Menu item skipped due to missing menu slug"
150msgstr ""158msgstr ""
151159
152#: wordpress-importer.php:751160#: wordpress-importer.php:876
153msgid "Menu item skipped due to invalid menu slug: %s"161msgid "Menu item skipped due to invalid menu slug: %s"
154msgstr ""162msgstr ""
155163
156#: wordpress-importer.php:814164#: wordpress-importer.php:939
157msgid "Fetching attachments is not enabled"165msgid "Fetching attachments is not enabled"
158msgstr ""166msgstr ""
159167
160#: wordpress-importer.php:827168#: wordpress-importer.php:952
161msgid "Invalid file type"169msgid "Invalid file type"
162msgstr ""170msgstr ""
163171
164#: wordpress-importer.php:871172#: wordpress-importer.php:996
165msgid "Remote server did not respond"173msgid "Remote server did not respond"
166msgstr ""174msgstr ""
167175
168#: wordpress-importer.php:877176#: wordpress-importer.php:1002
169msgid "Remote server returned error response %1$d %2$s"177msgid "Remote server returned error response %1$d %2$s"
170msgstr ""178msgstr ""
171179
172#: wordpress-importer.php:884180#: wordpress-importer.php:1009
173msgid "Remote file is incorrect size"181msgid "Remote file is incorrect size"
174msgstr ""182msgstr ""
175183
176#: wordpress-importer.php:889184#: wordpress-importer.php:1014
177msgid "Zero size file downloaded"185msgid "Zero size file downloaded"
178msgstr ""186msgstr ""
179187
180#: wordpress-importer.php:895188#: wordpress-importer.php:1020
181msgid "Remote file is too large, limit is %s"189msgid "Remote file is too large, limit is %s"
182msgstr ""190msgstr ""
183191
184#: wordpress-importer.php:994192#: wordpress-importer.php:1119
185msgid "Import WordPress"193msgid "Import WordPress"
186msgstr ""194msgstr ""
187195
188#: wordpress-importer.php:1001196#: wordpress-importer.php:1126
189msgid ""197msgid ""
190"A new version of this importer is available. Please update to version %s to "198"A new version of this importer is available. Please update to version %s to "
191"ensure compatibility with newer export files."199"ensure compatibility with newer export files."
192msgstr ""200msgstr ""
193201
194#: wordpress-importer.php:1016202#: wordpress-importer.php:1141
195msgid ""203msgid ""
196"Howdy! Upload your WordPress eXtended RSS (WXR) file and we&#8217;ll import "204"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 "205"the posts, pages, comments, custom fields, categories, and tags into this "
198"site."206"site."
199msgstr ""207msgstr ""
200208
201#: wordpress-importer.php:1017209#: wordpress-importer.php:1142
202msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."210msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
203msgstr ""211msgstr ""
204212
205#: wordpress-importer.php:1091213#: wordpress-importer.php:1216
206msgid ""214msgid ""
207"Import <strong>posts, pages, comments, custom fields, categories, and tags</"215"Import <strong>posts, pages, comments, custom fields, categories, and tags</"
208"strong> from a WordPress export file."216"strong> from a WordPress export file."
209217
=== modified file 'parsers.php'
--- parsers.php 2015-05-07 02:17:14 +0000
+++ parsers.php 2017-09-20 05:06:40 +0000
@@ -114,28 +114,46 @@
114 // grab cats, tags and terms114 // grab cats, tags and terms
115 foreach ( $xml->xpath('/rss/channel/wp:category') as $term_arr ) {115 foreach ( $xml->xpath('/rss/channel/wp:category') as $term_arr ) {
116 $t = $term_arr->children( $namespaces['wp'] );116 $t = $term_arr->children( $namespaces['wp'] );
117 $categories[] = array(117 $category = array(
118 'term_id' => (int) $t->term_id,118 'term_id' => (int) $t->term_id,
119 'category_nicename' => (string) $t->category_nicename,119 'category_nicename' => (string) $t->category_nicename,
120 'category_parent' => (string) $t->category_parent,120 'category_parent' => (string) $t->category_parent,
121 'cat_name' => (string) $t->cat_name,121 'cat_name' => (string) $t->cat_name,
122 'category_description' => (string) $t->category_description122 'category_description' => (string) $t->category_description
123 );123 );
124
125 foreach ( $t->termmeta as $meta ) {
126 $category['termmeta'][] = array(
127 'key' => (string) $meta->meta_key,
128 'value' => (string) $meta->meta_value
129 );
130 }
131
132 $categories[] = $category;
124 }133 }
125134
126 foreach ( $xml->xpath('/rss/channel/wp:tag') as $term_arr ) {135 foreach ( $xml->xpath('/rss/channel/wp:tag') as $term_arr ) {
127 $t = $term_arr->children( $namespaces['wp'] );136 $t = $term_arr->children( $namespaces['wp'] );
128 $tags[] = array(137 $tag = array(
129 'term_id' => (int) $t->term_id,138 'term_id' => (int) $t->term_id,
130 'tag_slug' => (string) $t->tag_slug,139 'tag_slug' => (string) $t->tag_slug,
131 'tag_name' => (string) $t->tag_name,140 'tag_name' => (string) $t->tag_name,
132 'tag_description' => (string) $t->tag_description141 'tag_description' => (string) $t->tag_description
133 );142 );
143
144 foreach ( $t->termmeta as $meta ) {
145 $tag['termmeta'][] = array(
146 'key' => (string) $meta->meta_key,
147 'value' => (string) $meta->meta_value
148 );
149 }
150
151 $tags[] = $tag;
134 }152 }
135153
136 foreach ( $xml->xpath('/rss/channel/wp:term') as $term_arr ) {154 foreach ( $xml->xpath('/rss/channel/wp:term') as $term_arr ) {
137 $t = $term_arr->children( $namespaces['wp'] );155 $t = $term_arr->children( $namespaces['wp'] );
138 $terms[] = array(156 $term = array(
139 'term_id' => (int) $t->term_id,157 'term_id' => (int) $t->term_id,
140 'term_taxonomy' => (string) $t->term_taxonomy,158 'term_taxonomy' => (string) $t->term_taxonomy,
141 'slug' => (string) $t->term_slug,159 'slug' => (string) $t->term_slug,
@@ -143,6 +161,15 @@
143 'term_name' => (string) $t->term_name,161 'term_name' => (string) $t->term_name,
144 'term_description' => (string) $t->term_description162 'term_description' => (string) $t->term_description
145 );163 );
164
165 foreach ( $t->termmeta as $meta ) {
166 $term['termmeta'][] = array(
167 'key' => (string) $meta->meta_key,
168 'value' => (string) $meta->meta_value
169 );
170 }
171
172 $terms[] = $term;
146 }173 }
147174
148 // grab posts175 // grab posts
@@ -204,7 +231,7 @@
204 );231 );
205 }232 }
206 }233 }
207 234
208 $post['comments'][] = array(235 $post['comments'][] = array(
209 'comment_id' => (int) $comment->comment_id,236 'comment_id' => (int) $comment->comment_id,
210 'comment_author' => (string) $comment->comment_author,237 'comment_author' => (string) $comment->comment_author,
@@ -324,7 +351,11 @@
324 if ( ! trim( $cdata ) )351 if ( ! trim( $cdata ) )
325 return;352 return;
326353
327 $this->cdata .= trim( $cdata );354 if ( false !== $this->in_tag || false !== $this->in_sub_tag ) {
355 $this->cdata .= $cdata;
356 } else {
357 $this->cdata .= trim( $cdata );
358 }
328 }359 }
329360
330 function tag_close( $parser, $tag ) {361 function tag_close( $parser, $tag ) {
@@ -401,10 +432,6 @@
401 var $terms = array();432 var $terms = array();
402 var $base_url = '';433 var $base_url = '';
403434
404 function WXR_Parser_Regex() {
405 $this->__construct();
406 }
407
408 function __construct() {435 function __construct() {
409 $this->has_gzip = is_callable( 'gzopen' );436 $this->has_gzip = is_callable( 'gzopen' );
410 }437 }
411438
=== modified file 'readme.txt'
--- readme.txt 2015-05-07 02:17:14 +0000
+++ readme.txt 2017-09-20 05:06:40 +0000
@@ -1,10 +1,9 @@
1=== WordPress Importer ===1=== WordPress Importer ===
2Contributors: wordpressdotorg2Contributors: wordpressdotorg
3Donate link:
4Tags: importer, wordpress3Tags: importer, wordpress
5Requires at least: 3.04Requires at least: 3.0
6Tested up to: 4.15Tested up to: 4.6
7Stable tag: 0.6.16Stable tag: 0.6.3
8License: GPLv2 or later7License: GPLv2 or later
9License URI: http://www.gnu.org/licenses/gpl-2.0.html8License URI: http://www.gnu.org/licenses/gpl-2.0.html
109
@@ -39,6 +38,15 @@
3938
40== Changelog ==39== Changelog ==
4140
41= 0.6.3 =
42* Add support for import term metadata.
43* Fix bug that caused slashes to be stripped from imported content.
44* Fix bug that caused characters to be stripped inside of CDATA in some cases.
45* Fix PHP notices.
46
47= 0.6.2 =
48* Add wp_import_existing_post filter. See: https://core.trac.wordpress.org/ticket/33721
49
42= 0.6 =50= 0.6 =
43* Support for WXR 1.2 and multiple CDATA sections51* Support for WXR 1.2 and multiple CDATA sections
44* Post aren't duplicates if their post_type's are different52* Post aren't duplicates if their post_type's are different
4553
=== modified file 'wordpress-importer.php'
--- wordpress-importer.php 2015-05-07 02:17:14 +0000
+++ wordpress-importer.php 2017-09-20 05:06:40 +0000
@@ -5,7 +5,7 @@
5Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.5Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
6Author: wordpressdotorg6Author: wordpressdotorg
7Author URI: http://wordpress.org/7Author URI: http://wordpress.org/
8Version: 0.6.18Version: 0.6.3
9Text Domain: wordpress-importer9Text Domain: wordpress-importer
10License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html10License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
11*/11*/
@@ -63,8 +63,6 @@
63 var $url_remap = array();63 var $url_remap = array();
64 var $featured_images = array();64 var $featured_images = array();
6565
66 function WP_Import() { /* nothing */ }
67
68 /**66 /**
69 * Registered callback function for the WordPress Importer67 * Registered callback function for the WordPress Importer
70 *68 *
@@ -416,6 +414,7 @@
416 'cat_name' => $cat['cat_name'],414 'cat_name' => $cat['cat_name'],
417 'category_description' => $category_description415 'category_description' => $category_description
418 );416 );
417 $catarr = wp_slash( $catarr );
419418
420 $id = wp_insert_category( $catarr );419 $id = wp_insert_category( $catarr );
421 if ( ! is_wp_error( $id ) ) {420 if ( ! is_wp_error( $id ) ) {
@@ -428,6 +427,8 @@
428 echo '<br />';427 echo '<br />';
429 continue;428 continue;
430 }429 }
430
431 $this->process_termmeta( $cat, $id['term_id'] );
431 }432 }
432433
433 unset( $this->categories );434 unset( $this->categories );
@@ -454,6 +455,7 @@
454 continue;455 continue;
455 }456 }
456457
458 $tag = wp_slash( $tag );
457 $tag_desc = isset( $tag['tag_description'] ) ? $tag['tag_description'] : '';459 $tag_desc = isset( $tag['tag_description'] ) ? $tag['tag_description'] : '';
458 $tagarr = array( 'slug' => $tag['tag_slug'], 'description' => $tag_desc );460 $tagarr = array( 'slug' => $tag['tag_slug'], 'description' => $tag_desc );
459461
@@ -468,6 +470,8 @@
468 echo '<br />';470 echo '<br />';
469 continue;471 continue;
470 }472 }
473
474 $this->process_termmeta( $tag, $id['term_id'] );
471 }475 }
472476
473 unset( $this->tags );477 unset( $this->tags );
@@ -500,6 +504,7 @@
500 $parent = term_exists( $term['term_parent'], $term['term_taxonomy'] );504 $parent = term_exists( $term['term_parent'], $term['term_taxonomy'] );
501 if ( is_array( $parent ) ) $parent = $parent['term_id'];505 if ( is_array( $parent ) ) $parent = $parent['term_id'];
502 }506 }
507 $term = wp_slash( $term );
503 $description = isset( $term['term_description'] ) ? $term['term_description'] : '';508 $description = isset( $term['term_description'] ) ? $term['term_description'] : '';
504 $termarr = array( 'slug' => $term['slug'], 'description' => $description, 'parent' => intval($parent) );509 $termarr = array( 'slug' => $term['slug'], 'description' => $description, 'parent' => intval($parent) );
505510
@@ -514,12 +519,75 @@
514 echo '<br />';519 echo '<br />';
515 continue;520 continue;
516 }521 }
522
523 $this->process_termmeta( $term, $id['term_id'] );
517 }524 }
518525
519 unset( $this->terms );526 unset( $this->terms );
520 }527 }
521528
522 /**529 /**
530 * Add metadata to imported term.
531 *
532 * @since 0.6.2
533 *
534 * @param array $term Term data from WXR import.
535 * @param int $term_id ID of the newly created term.
536 */
537 protected function process_termmeta( $term, $term_id ) {
538 if ( ! isset( $term['termmeta'] ) ) {
539 $term['termmeta'] = array();
540 }
541
542 /**
543 * Filters the metadata attached to an imported term.
544 *
545 * @since 0.6.2
546 *
547 * @param array $termmeta Array of term meta.
548 * @param int $term_id ID of the newly created term.
549 * @param array $term Term data from the WXR import.
550 */
551 $term['termmeta'] = apply_filters( 'wp_import_term_meta', $term['termmeta'], $term_id, $term );
552
553 if ( empty( $term['termmeta'] ) ) {
554 return;
555 }
556
557 foreach ( $term['termmeta'] as $meta ) {
558 /**
559 * Filters the meta key for an imported piece of term meta.
560 *
561 * @since 0.6.2
562 *
563 * @param string $meta_key Meta key.
564 * @param int $term_id ID of the newly created term.
565 * @param array $term Term data from the WXR import.
566 */
567 $key = apply_filters( 'import_term_meta_key', $meta['key'], $term_id, $term );
568 if ( ! $key ) {
569 continue;
570 }
571
572 // Export gets meta straight from the DB so could have a serialized string
573 $value = maybe_unserialize( $meta['value'] );
574
575 add_term_meta( $term_id, $key, $value );
576
577 /**
578 * Fires after term meta is imported.
579 *
580 * @since 0.6.2
581 *
582 * @param int $term_id ID of the newly created term.
583 * @param string $key Meta key.
584 * @param mixed $value Meta value.
585 */
586 do_action( 'import_term_meta', $term_id, $key, $value );
587 }
588 }
589
590 /**
523 * Create new posts based on import information591 * Create new posts based on import information
524 *592 *
525 * Posts marked as having a parent which doesn't exist will become top level items.593 * Posts marked as having a parent which doesn't exist will become top level items.
@@ -555,10 +623,26 @@
555 $post_type_object = get_post_type_object( $post['post_type'] );623 $post_type_object = get_post_type_object( $post['post_type'] );
556624
557 $post_exists = post_exists( $post['post_title'], '', $post['post_date'] );625 $post_exists = post_exists( $post['post_title'], '', $post['post_date'] );
626
627 /**
628 * Filter ID of the existing post corresponding to post currently importing.
629 *
630 * Return 0 to force the post to be imported. Filter the ID to be something else
631 * to override which existing post is mapped to the imported post.
632 *
633 * @see post_exists()
634 * @since 0.6.2
635 *
636 * @param int $post_exists Post ID, or 0 if post did not exist.
637 * @param array $post The post array to be inserted.
638 */
639 $post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post );
640
558 if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) {641 if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) {
559 printf( __('%s &#8220;%s&#8221; already exists.', 'wordpress-importer'), $post_type_object->labels->singular_name, esc_html($post['post_title']) );642 printf( __('%s &#8220;%s&#8221; already exists.', 'wordpress-importer'), $post_type_object->labels->singular_name, esc_html($post['post_title']) );
560 echo '<br />';643 echo '<br />';
561 $comment_post_ID = $post_id = $post_exists;644 $comment_post_ID = $post_id = $post_exists;
645 $this->processed_posts[ intval( $post['post_id'] ) ] = intval( $post_exists );
562 } else {646 } else {
563 $post_parent = (int) $post['post_parent'];647 $post_parent = (int) $post['post_parent'];
564 if ( $post_parent ) {648 if ( $post_parent ) {
@@ -592,6 +676,8 @@
592 $original_post_ID = $post['post_id'];676 $original_post_ID = $post['post_id'];
593 $postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $post );677 $postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $post );
594678
679 $postdata = wp_slash( $postdata );
680
595 if ( 'attachment' == $postdata['post_type'] ) {681 if ( 'attachment' == $postdata['post_type'] ) {
596 $remote_url = ! empty($post['attachment_url']) ? $post['attachment_url'] : $post['guid'];682 $remote_url = ! empty($post['attachment_url']) ? $post['attachment_url'] : $post['guid'];
597683
@@ -1107,7 +1193,7 @@
1107 * Added to http_request_timeout filter to force timeout at 60 seconds during import1193 * Added to http_request_timeout filter to force timeout at 60 seconds during import
1108 * @return int 601194 * @return int 60
1109 */1195 */
1110 function bump_request_timeout() {1196 function bump_request_timeout( $val ) {
1111 return 60;1197 return 60;
1112 }1198 }
11131199

Subscribers

People subscribed via source and target branches