Commit 9069ba41 authored by shammash's avatar shammash Committed by lechuck
Browse files

updated wordpress-importer to 0.5

parent a01d8818
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
# This file is distributed under the same license as the WordPress Importer package. # This file is distributed under the same license as the WordPress Importer package.
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: WordPress Importer 0.3\n" "Project-Id-Version: WordPress Importer 0.5\n"
"Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-importer\n" "Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-importer\n"
"POT-Creation-Date: 2011-02-21 21:07:12+00:00\n" "POT-Creation-Date: 2011-07-16 15:45:12+00:00\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
...@@ -22,49 +22,49 @@ msgid "" ...@@ -22,49 +22,49 @@ msgid ""
"parser..." "parser..."
msgstr "" msgstr ""
#: parsers.php:67 parsers.php:72 parsers.php:248 parsers.php:430 #: parsers.php:67 parsers.php:72 parsers.php:262 parsers.php:451
msgid "" msgid ""
"This does not appear to be a WXR file, missing/invalid WXR version number" "This does not appear to be a WXR file, missing/invalid WXR version number"
msgstr "" msgstr ""
#: wordpress-importer.php:133 wordpress-importer.php:142 #: wordpress-importer.php:134 wordpress-importer.php:143
#: wordpress-importer.php:193 wordpress-importer.php:201 #: wordpress-importer.php:194 wordpress-importer.php:202
msgid "Sorry, there has been an error." msgid "Sorry, there has been an error."
msgstr "" msgstr ""
#: wordpress-importer.php:134 #: wordpress-importer.php:135
msgid "The file does not exist, please try again." msgid "The file does not exist, please try again."
msgstr "" msgstr ""
#: wordpress-importer.php:177 #: wordpress-importer.php:178
msgid "All done." msgid "All done."
msgstr "" msgstr ""
#: wordpress-importer.php:177 #: wordpress-importer.php:178
msgid "Have fun!" msgid "Have fun!"
msgstr "" msgstr ""
#: wordpress-importer.php:178 #: wordpress-importer.php:179
msgid "Remember to update the passwords and roles of imported users." msgid "Remember to update the passwords and roles of imported users."
msgstr "" msgstr ""
#: wordpress-importer.php:209 #: wordpress-importer.php:210
msgid "" msgid ""
"This WXR file (version %s) may not be supported by this version of the " "This WXR file (version %s) may not be supported by this version of the "
"importer. Please consider updating." "importer. Please consider updating."
msgstr "" msgstr ""
#: wordpress-importer.php:234 #: wordpress-importer.php:235
msgid "" msgid ""
"Failed to import author %s. Their posts will be attributed to the current " "Failed to import author %s. Their posts will be attributed to the current "
"user." "user."
msgstr "" msgstr ""
#: wordpress-importer.php:260 #: wordpress-importer.php:261
msgid "Assign Authors" msgid "Assign Authors"
msgstr "" msgstr ""
#: wordpress-importer.php:261 #: wordpress-importer.php:262
msgid "" msgid ""
"To make it easier for you to edit and save the imported content, you may " "To make it easier for you to edit and save the imported content, you may "
"want to reassign the author of the imported item to an existing user of this " "want to reassign the author of the imported item to an existing user of this "
...@@ -72,137 +72,137 @@ msgid "" ...@@ -72,137 +72,137 @@ msgid ""
"code>s entries." "code>s entries."
msgstr "" msgstr ""
#: wordpress-importer.php:263 #: wordpress-importer.php:264
msgid "" msgid ""
"If a new user is created by WordPress, a new password will be randomly " "If a new user is created by WordPress, a new password will be randomly "
"generated and the new user’s role will be set as %s. Manually changing " "generated and the new user’s role will be set as %s. Manually changing "
"the new user’s details will be necessary." "the new user’s details will be necessary."
msgstr "" msgstr ""
#: wordpress-importer.php:273 #: wordpress-importer.php:274
msgid "Import Attachments" msgid "Import Attachments"
msgstr "" msgstr ""
#: wordpress-importer.php:276 #: wordpress-importer.php:277
msgid "Download and import file attachments" msgid "Download and import file attachments"
msgstr "" msgstr ""
#: wordpress-importer.php:280 #: wordpress-importer.php:281
msgid "Submit" msgid "Submit"
msgstr "" msgstr ""
#: wordpress-importer.php:293 #: wordpress-importer.php:294
msgid "Import author:" msgid "Import author:"
msgstr "" msgstr ""
#: wordpress-importer.php:304 #: wordpress-importer.php:305
msgid "or create new user with login name:" msgid "or create new user with login name:"
msgstr "" msgstr ""
#: wordpress-importer.php:307 #: wordpress-importer.php:308
msgid "as a new user:" msgid "as a new user:"
msgstr "" msgstr ""
#: wordpress-importer.php:315 #: wordpress-importer.php:316
msgid "assign posts to an existing user:" msgid "assign posts to an existing user:"
msgstr "" msgstr ""
#: wordpress-importer.php:317 #: wordpress-importer.php:318
msgid "or assign posts to an existing user:" msgid "or assign posts to an existing user:"
msgstr "" msgstr ""
#: wordpress-importer.php:318 #: wordpress-importer.php:319
msgid "- Select -" msgid "- Select -"
msgstr "" msgstr ""
#: wordpress-importer.php:366 #: wordpress-importer.php:369
msgid "" msgid ""
"Failed to create new user for %s. Their posts will be attributed to the " "Failed to create new user for %s. Their posts will be attributed to the "
"current user." "current user."
msgstr "" msgstr ""
#: wordpress-importer.php:413 #: wordpress-importer.php:418
msgid "Failed to import category %s" msgid "Failed to import category %s"
msgstr "" msgstr ""
#: wordpress-importer.php:449 #: wordpress-importer.php:456
msgid "Failed to import post tag %s" msgid "Failed to import post tag %s"
msgstr "" msgstr ""
#: wordpress-importer.php:491 wordpress-importer.php:603 #: wordpress-importer.php:500 wordpress-importer.php:626
msgid "Failed to import %s %s" msgid "Failed to import %s %s"
msgstr "" msgstr ""
#: wordpress-importer.php:513 #: wordpress-importer.php:522
msgid "Failed to import “%s”: Invalid post type %s" msgid "Failed to import “%s”: Invalid post type %s"
msgstr "" msgstr ""
#: wordpress-importer.php:534 #: wordpress-importer.php:543
msgid "%s “%s” already exists." msgid "%s “%s” already exists."
msgstr "" msgstr ""
#: wordpress-importer.php:575 #: wordpress-importer.php:598
msgid "Failed to import %s “%s”" msgid "Failed to import %s “%s”"
msgstr "" msgstr ""
#: wordpress-importer.php:712 #: wordpress-importer.php:744
msgid "Menu item skipped due to missing menu slug" msgid "Menu item skipped due to missing menu slug"
msgstr "" msgstr ""
#: wordpress-importer.php:719 #: wordpress-importer.php:751
msgid "Menu item skipped due to invalid menu slug: %s" msgid "Menu item skipped due to invalid menu slug: %s"
msgstr "" msgstr ""
#: wordpress-importer.php:782 #: wordpress-importer.php:814
msgid "Fetching attachments is not enabled" msgid "Fetching attachments is not enabled"
msgstr "" msgstr ""
#: wordpress-importer.php:795 #: wordpress-importer.php:827
msgid "Invalid file type" msgid "Invalid file type"
msgstr "" msgstr ""
#: wordpress-importer.php:838 #: wordpress-importer.php:871
msgid "Remote server did not respond" msgid "Remote server did not respond"
msgstr "" msgstr ""
#: wordpress-importer.php:844 #: wordpress-importer.php:877
msgid "Remote server returned error response %1$d %2$s" msgid "Remote server returned error response %1$d %2$s"
msgstr "" msgstr ""
#: wordpress-importer.php:851 #: wordpress-importer.php:884
msgid "Remote file is incorrect size" msgid "Remote file is incorrect size"
msgstr "" msgstr ""
#: wordpress-importer.php:856 #: wordpress-importer.php:889
msgid "Zero size file downloaded" msgid "Zero size file downloaded"
msgstr "" msgstr ""
#: wordpress-importer.php:862 #: wordpress-importer.php:895
msgid "Remote file is too large, limit is %s" msgid "Remote file is too large, limit is %s"
msgstr "" msgstr ""
#: wordpress-importer.php:961 #: wordpress-importer.php:994
msgid "Import WordPress" msgid "Import WordPress"
msgstr "" msgstr ""
#: wordpress-importer.php:968 #: wordpress-importer.php:1001
msgid "" msgid ""
"A new version of this importer is available. Please update to version %s to " "A new version of this importer is available. Please update to version %s to "
"ensure compatibility with newer export files." "ensure compatibility with newer export files."
msgstr "" msgstr ""
#: wordpress-importer.php:983 #: wordpress-importer.php:1016
msgid "" msgid ""
"Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import " "Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import "
"the posts, pages, comments, custom fields, categories, and tags into this " "the posts, pages, comments, custom fields, categories, and tags into this "
"site." "site."
msgstr "" msgstr ""
#: wordpress-importer.php:984 #: wordpress-importer.php:1017
msgid "Choose a WXR file to upload, then click Upload file and import." msgid "Choose a WXR (.xml) file to upload, then click Upload file and import."
msgstr "" msgstr ""
#: wordpress-importer.php:1058 #: wordpress-importer.php:1091
msgid "" msgid ""
"Import <strong>posts, pages, comments, custom fields, categories, and tags</" "Import <strong>posts, pages, comments, custom fields, categories, and tags</"
"strong> from a WordPress export file." "strong> from a WordPress export file."
......
...@@ -157,6 +157,9 @@ class WXR_Parser_SimpleXML { ...@@ -157,6 +157,9 @@ class WXR_Parser_SimpleXML {
$post['post_password'] = (string) $wp->post_password; $post['post_password'] = (string) $wp->post_password;
$post['is_sticky'] = (int) $wp->is_sticky; $post['is_sticky'] = (int) $wp->is_sticky;
if ( isset($wp->attachment_url) )
$post['attachment_url'] = (string) $wp->attachment_url;
foreach ( $item->category as $c ) { foreach ( $item->category as $c ) {
$att = $c->attributes(); $att = $c->attributes();
if ( isset( $att['nicename'] ) ) if ( isset( $att['nicename'] ) )
...@@ -170,11 +173,21 @@ class WXR_Parser_SimpleXML { ...@@ -170,11 +173,21 @@ class WXR_Parser_SimpleXML {
foreach ( $wp->postmeta as $meta ) { foreach ( $wp->postmeta as $meta ) {
$post['postmeta'][] = array( $post['postmeta'][] = array(
'key' => (string) $meta->meta_key, 'key' => (string) $meta->meta_key,
'value' => (string) $meta->meta_value, 'value' => (string) $meta->meta_value
); );
} }
foreach ( $wp->comment as $comment ) { foreach ( $wp->comment as $comment ) {
$meta = array();
if ( isset( $comment->commentmeta ) ) {
foreach ( $comment->commentmeta as $m ) {
$meta[] = array(
'key' => (string) $m->meta_key,
'value' => (string) $m->meta_value
);
}
}
$post['comments'][] = array( $post['comments'][] = array(
'comment_id' => (int) $comment->comment_id, 'comment_id' => (int) $comment->comment_id,
'comment_author' => (string) $comment->comment_author, 'comment_author' => (string) $comment->comment_author,
...@@ -188,6 +201,7 @@ class WXR_Parser_SimpleXML { ...@@ -188,6 +201,7 @@ class WXR_Parser_SimpleXML {
'comment_type' => (string) $comment->comment_type, 'comment_type' => (string) $comment->comment_type,
'comment_parent' => (string) $comment->comment_parent, 'comment_parent' => (string) $comment->comment_parent,
'comment_user_id' => (int) $comment->comment_user_id, 'comment_user_id' => (int) $comment->comment_user_id,
'commentmeta' => $meta,
); );
} }
...@@ -211,7 +225,7 @@ class WXR_Parser_SimpleXML { ...@@ -211,7 +225,7 @@ class WXR_Parser_SimpleXML {
*/ */
class WXR_Parser_XML { class WXR_Parser_XML {
var $wp_tags = array( var $wp_tags = array(
'wp:post_id', 'wp:post_date', 'wp:post_date_gmt', 'wp:comment_status', 'wp:ping_status', 'wp:post_id', 'wp:post_date', 'wp:post_date_gmt', 'wp:comment_status', 'wp:ping_status', 'wp:attachment_url',
'wp:status', 'wp:post_name', 'wp:post_parent', 'wp:menu_order', 'wp:post_type', 'wp:post_password', 'wp:status', 'wp:post_name', 'wp:post_parent', 'wp:menu_order', 'wp:post_type', 'wp:post_password',
'wp:is_sticky', 'wp:term_id', 'wp:category_nicename', 'wp:category_parent', 'wp:cat_name', 'wp:category_description', 'wp:is_sticky', 'wp:term_id', 'wp:category_nicename', 'wp:category_parent', 'wp:cat_name', 'wp:category_description',
'wp:tag_slug', 'wp:tag_name', 'wp:tag_description', 'wp:term_taxonomy', 'wp:term_parent', 'wp:tag_slug', 'wp:tag_name', 'wp:tag_description', 'wp:term_taxonomy', 'wp:term_parent',
...@@ -299,10 +313,17 @@ class WXR_Parser_XML { ...@@ -299,10 +313,17 @@ class WXR_Parser_XML {
function tag_close( $parser, $tag ) { function tag_close( $parser, $tag ) {
switch ( $tag ) { switch ( $tag ) {
case 'wp:comment': case 'wp:comment':
unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data
if ( ! empty( $this->sub_data ) ) if ( ! empty( $this->sub_data ) )
$this->data['comments'][] = $this->sub_data; $this->data['comments'][] = $this->sub_data;
$this->sub_data = false; $this->sub_data = false;
break; break;
case 'wp:commentmeta':
$this->sub_data['commentmeta'][] = array(
'key' => $this->sub_data['key'],
'value' => $this->sub_data['value']
);
break;
case 'category': case 'category':
if ( ! empty( $this->sub_data ) ) { if ( ! empty( $this->sub_data ) ) {
$this->sub_data['name'] = $this->cdata; $this->sub_data['name'] = $this->cdata;
...@@ -525,6 +546,10 @@ class WXR_Parser_Regex { ...@@ -525,6 +546,10 @@ class WXR_Parser_Regex {
'menu_order', 'post_type', 'post_password', 'is_sticky' 'menu_order', 'post_type', 'post_password', 'is_sticky'
); );
$attachment_url = $this->get_tag( $post, 'wp:attachment_url' );
if ( $attachment_url )
$postdata['attachment_url'] = $attachment_url;
preg_match_all( '|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER ); preg_match_all( '|<category domain="([^"]+?)" nicename="([^"]+?)">(.+?)</category>|is', $post, $terms, PREG_SET_ORDER );
foreach ( $terms as $t ) { foreach ( $terms as $t ) {
$post_terms[] = array( $post_terms[] = array(
...@@ -539,6 +564,16 @@ class WXR_Parser_Regex { ...@@ -539,6 +564,16 @@ class WXR_Parser_Regex {
$comments = $comments[1]; $comments = $comments[1];
if ( $comments ) { if ( $comments ) {
foreach ( $comments as $comment ) { foreach ( $comments as $comment ) {
preg_match_all( '|<wp:commentmeta>(.+?)</wp:commentmeta>|is', $comment, $commentmeta );
$commentmeta = $commentmeta[1];
$c_meta = array();
foreach ( $commentmeta as $m ) {
$c_meta[] = array(
'key' => $this->get_tag( $m, 'wp:meta_key' ),
'value' => $this->get_tag( $m, 'wp:meta_value' ),
);
}
$post_comments[] = array( $post_comments[] = array(
'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ), 'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ),
'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ), 'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ),
...@@ -551,6 +586,8 @@ class WXR_Parser_Regex { ...@@ -551,6 +586,8 @@ class WXR_Parser_Regex {
'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ), 'comment_approved' => $this->get_tag( $comment, 'wp:comment_approved' ),
'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ), 'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ),
'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ), 'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ),
'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ),
'commentmeta' => $c_meta,
); );
} }
} }
......
...@@ -3,39 +3,89 @@ Contributors: wordpressdotorg ...@@ -3,39 +3,89 @@ Contributors: wordpressdotorg
Donate link: Donate link:
Tags: importer, wordpress Tags: importer, wordpress
Requires at least: 3.0 Requires at least: 3.0
Tested up to: 3.1 Tested up to: 3.2.1
Stable tag: 0.2 Stable tag: 0.5
Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
== Description == == Description ==
Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. The WordPress Importer will import the following content from a WordPress export file:
* Posts, pages and other custom post types
* Comments
* Custom fields and post meta
* Categories, tags and terms from custom taxonomies
* Authors
For further information and instructions please see the [Codex page on Importing Content](http://codex.wordpress.org/Importing_Content#WordPress)
== Installation == == Installation ==
The quickest method for installing the importer is:
1. Visit Tools -> Import in the WordPress dashboard
1. Click on the WordPress link in the list of importers
1. Click "Install Now"
1. Finally click "Activate Plugin & Run Importer"
If you would prefer to do things manually then follow these instructions:
1. Upload the `wordpress-importer` folder to the `/wp-content/plugins/` directory 1. Upload the `wordpress-importer` folder to the `/wp-content/plugins/` directory
1. Activate the plugin through the 'Plugins' menu in WordPress 1. Activate the plugin through the 'Plugins' menu in WordPress
1. Go to the Tools -> Import screen, click on WordPress 1. Go to the Tools -> Import screen, click on WordPress
== Changelog == == Changelog ==
= 0.5 =
* Import comment meta (requires export from WordPress 3.2)
* Minor bugfixes and enhancements
= 0.4 =
* Map comment user_id where possible
* Import attachments from `wp:attachment_url`
* Upload attachments to correct directory
* Remap resized image URLs correctly
= 0.3 = = 0.3 =
* Use an XML Parser if possible * Use an XML Parser if possible
* Proper import support for nav menus * Proper import support for nav menus
* ... and more, see [Trac ticket #15197](http://core.trac.wordpress.org/ticket/15197) * ... and much more, see [Trac ticket #15197](http://core.trac.wordpress.org/ticket/15197)
= 0.1 = = 0.1 =
* Initial release * Initial release
== Upgrade Notice == == Upgrade Notice ==
= 0.5 =
Import comment meta and other minor bugfixes and enhancements.
= 0.4 =
Bug fixes for attachment importing and other small enhancements.
= 0.3 = = 0.3 =
Upgrade for a more robust and reliable experience when importing WordPress export files, and for compatibility with WordPress 3.1. Upgrade for a more robust and reliable experience when importing WordPress export files, and for compatibility with WordPress 3.1.
== Frequently Asked Questions ==
= Help! I'm getting out of memory errors or a blank screen. =
If your exported file is very large, the import script may run into your host's configured memory limit for PHP.
A message like "Fatal error: Allowed memory size of 8388608 bytes exhausted" indicates that the script can't successfully import your XML file under the current PHP memory limit. If you have access to the php.ini file, you can manually increase the limit; if you do not (your WordPress installation is hosted on a shared server, for instance), you might have to break your exported XML file into several smaller pieces and run the import script one at a time.
For those with shared hosting, the best alternative may be to consult hosting support to determine the safest approach for running the import. A host may be willing to temporarily lift the memory limit and/or run the process directly from their end.
-- [WordPress Codex: Importing Content](http://codex.wordpress.org/Importing_Content#Before_Importing)
== Filters == == Filters ==
The importer has a couple of filters to allow you to completely enable/block certain features: The importer has a couple of filters to allow you to completely enable/block certain features:
* `import_allow_create_users`: return false if you only want to allow mapping to existing users