Commit 1b2ee53e authored by root's avatar root Committed by lechuck
Browse files

Import wordpress-importer 0.3

parent 3e32bd9d
# Translation of the WordPress plugin WordPress Importer 0.2 by wordpressdotorg.
# Copyright (C) 2010 wordpressdotorg
# Copyright (C) 2011 WordPress Importer
# This file is distributed under the same license as the WordPress Importer package.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: WordPress Importer 0.2\n"
"Project-Id-Version: WordPress Importer 0.3\n"
"Report-Msgid-Bugs-To: http://wordpress.org/tag/wordpress-importer\n"
"POT-Creation-Date: 2010-06-01 13:26+0300\n"
"POT-Creation-Date: 2011-02-21 21:07:12+00:00\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
#: wordpress-importer.php:55
msgid "Import WordPress"
#: parsers.php:42 parsers.php:63
msgid "There was an error when reading this WXR file"
msgstr ""
#: wordpress-importer.php:64
#: parsers.php:43
msgid ""
"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."
"Details are shown above. The importer will now try again with a different "
"parser..."
msgstr ""
#: wordpress-importer.php:65
#: parsers.php:67 parsers.php:72 parsers.php:248 parsers.php:430
msgid ""
"Choose a WordPress WXR file to upload, then click Upload file and import."
"This does not appear to be a WXR file, missing/invalid WXR version number"
msgstr ""
#: wordpress-importer.php:228
msgid "Assign Authors"
#: wordpress-importer.php:133 wordpress-importer.php:142
#: wordpress-importer.php:193 wordpress-importer.php:201
msgid "Sorry, there has been an error."
msgstr ""
#: wordpress-importer.php:229
#: wordpress-importer.php:134
msgid "The file does not exist, please try again."
msgstr ""
#: wordpress-importer.php:177
msgid "All done."
msgstr ""
#: wordpress-importer.php:177
msgid "Have fun!"
msgstr ""
#: wordpress-importer.php:178
msgid "Remember to update the passwords and roles of imported users."
msgstr ""
#: wordpress-importer.php:209
msgid ""
"To make it easier for you to edit and save the imported posts and drafts, "
"you may want to change the name of the author of the posts. For example, you "
"may want to import all the entries as <code>admin</code>s entries."
"This WXR file (version %s) may not be supported by this version of the "
"importer. Please consider updating."
msgstr ""
#: wordpress-importer.php:232
#: wordpress-importer.php:234
msgid ""
"If a new user is created by WordPress, a password will be randomly "
"generated. Manually change the user&#8217;s details if necessary."
"Failed to import author %s. Their posts will be attributed to the current "
"user."
msgstr ""
#: wordpress-importer.php:245
msgid "Import author:"
#: wordpress-importer.php:260
msgid "Assign Authors"
msgstr ""
#: wordpress-importer.php:261
msgid ""
"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 "
"site. For example, you may want to import all the entries as <code>admin</"
"code>s entries."
msgstr ""
#: wordpress-importer.php:263
msgid ""
"If a new user is created by WordPress, a new password will be randomly "
"generated and the new user&#8217;s role will be set as %s. Manually changing "
"the new user&#8217;s details will be necessary."
msgstr ""
#: wordpress-importer.php:253
#: wordpress-importer.php:273
msgid "Import Attachments"
msgstr ""
#: wordpress-importer.php:256
#: wordpress-importer.php:276
msgid "Download and import file attachments"
msgstr ""
#: wordpress-importer.php:263
#: wordpress-importer.php:280
msgid "Submit"
msgstr ""
#: wordpress-importer.php:272
#, php-format
msgid "Create user %1$s or map to existing"
#: wordpress-importer.php:293
msgid "Import author:"
msgstr ""
#: wordpress-importer.php:275
msgid "Map to existing"
#: wordpress-importer.php:304
msgid "or create new user with login name:"
msgstr ""
#: wordpress-importer.php:283
msgid "- Select -"
#: wordpress-importer.php:307
msgid "as a new user:"
msgstr ""
#: wordpress-importer.php:299
msgid "Invalid file"
#: wordpress-importer.php:315
msgid "assign posts to an existing user:"
msgstr ""
#: wordpress-importer.php:300
msgid "Please upload a valid WXR (WordPress eXtended RSS) export file."
#: wordpress-importer.php:317
msgid "or assign posts to an existing user:"
msgstr ""
#: wordpress-importer.php:343
#, php-format
msgid "Importing category <em>%s</em>&#8230;"
#: wordpress-importer.php:318
msgid "- Select -"
msgstr ""
#: wordpress-importer.php:365
#, php-format
msgid "Importing tag <em>%s</em>&#8230;"
#: wordpress-importer.php:366
msgid ""
"Failed to create new user for %s. Their posts will be attributed to the "
"current user."
msgstr ""
#: wordpress-importer.php:403
#, php-format
msgid "Importing <em>%s</em>&#8230;"
#: wordpress-importer.php:413
msgid "Failed to import category %s"
msgstr ""
#: wordpress-importer.php:424
msgid "All done."
#: wordpress-importer.php:449
msgid "Failed to import post tag %s"
msgstr ""
#: wordpress-importer.php:424
msgid "Have fun!"
#: wordpress-importer.php:491 wordpress-importer.php:603
msgid "Failed to import %s %s"
msgstr ""
#: wordpress-importer.php:488
#, php-format
msgid "Post <em>%s</em> already exists."
#: wordpress-importer.php:513
msgid "Failed to import &#8220;%s&#8221;: Invalid post type %s"
msgstr ""
#: wordpress-importer.php:521
#, php-format
msgid "Importing post <em>%s</em>..."
#: wordpress-importer.php:534
msgid "%s &#8220;%s&#8221; already exists."
msgstr ""
#: wordpress-importer.php:617
#, php-format
msgid "(%s comment)"
msgid_plural "(%s comments)"
msgstr[0] ""
msgstr[1] ""
#: wordpress-importer.php:645
#, php-format
msgid "Importing attachment <em>%s</em>... "
#: wordpress-importer.php:575
msgid "Failed to import %s &#8220;%s&#8221;"
msgstr ""
#: wordpress-importer.php:653
#, php-format
msgid "Remote file error: %s"
#: wordpress-importer.php:712
msgid "Menu item skipped due to missing menu slug"
msgstr ""
#: wordpress-importer.php:661
msgid "Zero length file, deleting"
#: wordpress-importer.php:719
msgid "Menu item skipped due to invalid menu slug: %s"
msgstr ""
#: wordpress-importer.php:670
msgid "Invalid file type"
#: wordpress-importer.php:782
msgid "Fetching attachments is not enabled"
msgstr ""
#: wordpress-importer.php:691
#, php-format
msgid "Skipping attachment <em>%s</em>"
#: wordpress-importer.php:795
msgid "Invalid file type"
msgstr ""
#: wordpress-importer.php:716
#: wordpress-importer.php:838
msgid "Remote server did not respond"
msgstr ""
#: wordpress-importer.php:722
#, php-format
msgid "Remote file returned error response %1$d %2$s"
#: wordpress-importer.php:844
msgid "Remote server returned error response %1$d %2$s"
msgstr ""
#: wordpress-importer.php:726
#: wordpress-importer.php:851
msgid "Remote file is incorrect size"
msgstr ""
#: wordpress-importer.php:732
#, php-format
#: wordpress-importer.php:856
msgid "Zero size file downloaded"
msgstr ""
#: wordpress-importer.php:862
msgid "Remote file is too large, limit is %s"
msgstr ""
#: wordpress-importer.php:864
msgid "Sorry, there has been an error."
#: wordpress-importer.php:961
msgid "Import WordPress"
msgstr ""
#: wordpress-importer.php:968
msgid ""
"A new version of this importer is available. Please update to version %s to "
"ensure compatibility with newer export files."
msgstr ""
#: wordpress-importer.php:983
msgid ""
"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."
msgstr ""
#: wordpress-importer.php:984
msgid "Choose a WXR file to upload, then click Upload file and import."
msgstr ""
#: wordpress-importer.php:914
#: wordpress-importer.php:1058
msgid ""
"Import <strong>posts, pages, comments, custom fields, categories, and tags</"
"strong> from a WordPress export file."
......@@ -188,8 +218,8 @@ msgstr ""
#. Description of the plugin/theme
msgid ""
"Import posts, pages, comments, custom fields, categories, and tags from a "
"WordPress export file."
"Import posts, pages, comments, custom fields, categories, tags and more from "
"a WordPress export file."
msgstr ""
#. Author of the plugin/theme
......
......@@ -68,7 +68,7 @@ class WXR_Parser_SimpleXML {
$wxr_version = (string) trim( $wxr_version[0] );
// confirm that we are dealing with the correct file format
if ( ! preg_match( '/^\d\.\d$/', $wxr_version ) )
if ( ! preg_match( '/^\d+\.\d+$/', $wxr_version ) )
return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
$base_url = $xml->xpath('/rss/channel/wp:base_site_url');
......@@ -85,6 +85,7 @@ class WXR_Parser_SimpleXML {
$a = $author_arr->children( $namespaces['wp'] );
$login = (string) $a->author_login;
$authors[$login] = array(
'author_id' => (int) $a->author_id,
'author_login' => $login,
'author_email' => (string) $a->author_email,
'author_display_name' => (string) $a->author_display_name,
......@@ -199,7 +200,8 @@ class WXR_Parser_SimpleXML {
'categories' => $categories,
'tags' => $tags,
'terms' => $terms,
'base_url' => $base_url
'base_url' => $base_url,
'version' => $wxr_version
);
}
}
......@@ -213,7 +215,7 @@ class WXR_Parser_XML {
'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:tag_slug', 'wp:tag_name', 'wp:tag_description', 'wp:term_taxonomy', 'wp:term_parent',
'wp:term_name', 'wp:term_description', 'wp:author_login', 'wp:author_email', 'wp:author_display_name',
'wp:term_name', 'wp:term_description', 'wp:author_id', 'wp:author_login', 'wp:author_email', 'wp:author_display_name',
'wp:author_first_name', 'wp:author_last_name',
);
var $wp_sub_tags = array(
......@@ -223,7 +225,7 @@ class WXR_Parser_XML {
);
function parse( $file ) {
$this->is_wxr_file = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false;
$this->wxr_version = $this->in_post = $this->cdata = $this->data = $this->sub_data = $this->in_tag = $this->in_sub_tag = false;
$this->authors = $this->posts = $this->term = $this->category = $this->tag = array();
$xml = xml_parser_create( 'UTF-8' );
......@@ -242,7 +244,7 @@ class WXR_Parser_XML {
}
xml_parser_free( $xml );
if ( ! $this->is_wxr_file )
if ( ! preg_match( '/^\d+\.\d+$/', $this->wxr_version ) )
return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
return array(
......@@ -251,7 +253,8 @@ class WXR_Parser_XML {
'categories' => $this->category,
'tags' => $this->tag,
'terms' => $this->term,
'base_url' => $this->base_url
'base_url' => $this->base_url,
'version' => $this->wxr_version
);
}
......@@ -332,7 +335,7 @@ class WXR_Parser_XML {
$this->base_url = $this->cdata;
break;
case 'wp:wxr_version':
$this->is_wxr_file = preg_match( '/\d+\.\d+/', $this->cdata );
$this->wxr_version = $this->cdata;
break;
default:
......@@ -369,15 +372,15 @@ class WXR_Parser_Regex {
}
function parse( $file ) {
$is_wxr = $in_post = false;
$wxr_version = $in_post = false;
$fp = $this->fopen( $file, 'r' );
if ( $fp ) {
while ( ! $this->feof( $fp ) ) {
$importline = rtrim( $this->fgets( $fp ) );
if ( ! $is_wxr && preg_match( '|<wp:wxr_version>\d+\.\d+</wp:wxr_version>|', $importline ) )
$is_wxr = true;
if ( ! $wxr_version && preg_match( '|<wp:wxr_version>(\d+\.\d+)</wp:wxr_version>|', $importline, $version ) )
$wxr_version = $version[1];
if ( false !== strpos( $importline, '<wp:base_site_url>' ) ) {
preg_match( '|<wp:base_site_url>(.*?)</wp:base_site_url>|is', $importline, $url );
......@@ -423,7 +426,7 @@ class WXR_Parser_Regex {
$this->fclose($fp);
}
if ( ! $is_wxr )
if ( ! $wxr_version )
return new WP_Error( 'WXR_parse_error', __( 'This does not appear to be a WXR file, missing/invalid WXR version number', 'wordpress-importer' ) );
return array(
......@@ -432,7 +435,8 @@ class WXR_Parser_Regex {
'categories' => $this->categories,
'tags' => $this->tags,
'terms' => $this->terms,
'base_url' => $this->base_url
'base_url' => $this->base_url,
'version' => $wxr_version
);
}
......@@ -480,6 +484,7 @@ class WXR_Parser_Regex {
function process_author( $a ) {
return array(
'author_id' => $this->get_tag( $a, 'wp:author_id' ),
'author_login' => $this->get_tag( $a, 'wp:author_login' ),
'author_email' => $this->get_tag( $a, 'wp:author_email' ),
'author_display_name' => $this->get_tag( $a, 'wp:author_display_name' ),
......
......@@ -3,7 +3,7 @@ Contributors: wordpressdotorg
Donate link:
Tags: importer, wordpress
Requires at least: 3.0
Tested up to: 3.1-alpha
Tested up to: 3.1
Stable tag: 0.2
Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
......@@ -23,7 +23,7 @@ Import posts, pages, comments, custom fields, categories, tags and more from a W
= 0.3 =
* Use an XML Parser if possible
* Proper import support for nav menus
* ... and more
* ... and more, see [Trac ticket #15197](http://core.trac.wordpress.org/ticket/15197)
= 0.1 =
* Initial release
......@@ -31,7 +31,7 @@ Import posts, pages, comments, custom fields, categories, tags and more from a W
== Upgrade Notice ==
= 0.3 =
Upgrade for a more robust and reliable experience when importing WordPress export file.
Upgrade for a more robust and reliable experience when importing WordPress export files, and for compatibility with WordPress 3.1.
== Filters ==
......
......@@ -5,15 +5,16 @@ Plugin URI: http://wordpress.org/extend/plugins/wordpress-importer/
Description: Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
Author: wordpressdotorg
Author URI: http://wordpress.org/
Version: 0.3-beta2
License: GPL v2 - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
Version: 0.3
Text Domain: wordpress-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
if ( ! defined( 'WP_LOAD_IMPORTERS' ) )
return;
/** Display verbose errors */
define( 'IMPORT_DEBUG', true );
define( 'IMPORT_DEBUG', false );
// Load Importer API
require_once ABSPATH . 'wp-admin/includes/import.php';
......@@ -35,8 +36,12 @@ require dirname( __FILE__ ) . '/parsers.php';
*/
if ( class_exists( 'WP_Importer' ) ) {
class WP_Import extends WP_Importer {
var $id;
var $max_wxr_version = 1.1; // max. supported WXR version
var $id; // WXR attachment ID
// information to import from WXR file
var $version;
var $authors = array();
var $posts = array();
var $terms = array();
......@@ -44,7 +49,9 @@ class WP_Import extends WP_Importer {
var $tags = array();
var $base_url = '';
// mappings from old information to new
var $processed_authors = array();
var $author_mapping = array();
var $processed_terms = array();
var $processed_posts = array();
var $post_orphans = array();
......@@ -54,6 +61,7 @@ class WP_Import extends WP_Importer {
var $fetch_attachments = false;
var $url_remap = array();
var $featured_images = array();
function WP_Import() { /* nothing */ }
......@@ -80,6 +88,7 @@ class WP_Import extends WP_Importer {
$this->fetch_attachments = ( ! empty( $_POST['fetch_attachments'] ) && $this->allow_fetch_attachments() );
$this->id = (int) $_POST['import_id'];
$file = get_attached_file( $this->id );
set_time_limit(0);
$this->import( $file );
break;
}
......@@ -106,10 +115,10 @@ class WP_Import extends WP_Importer {
$this->process_posts();
wp_suspend_cache_invalidation( false );
// update items with missing/incorrect parent IDs
// update incorrect/missing information in the DB
$this->backfill_parents();
// update attachment references within posts and postmeta
$this->backfill_attachment_urls();
$this->remap_featured_images();
$this->import_end();
}
......@@ -136,6 +145,7 @@ class WP_Import extends WP_Importer {
die();
}
$this->version = $import_data['version'];
$this->get_authors_from_import( $import_data );
$this->posts = $import_data['posts'];
$this->terms = $import_data['terms'];
......@@ -164,7 +174,8 @@ class WP_Import extends WP_Importer {
wp_defer_term_counting( false );
wp_defer_comment_counting( false );
echo '<p>' . __( 'All done.' ) . ' <a href="' . admin_url() . '">' . __( 'Have fun!' ) . '</a>' . '</p>';
echo '<p>' . __( 'All done.', 'wordpress-importer' ) . ' <a href="' . admin_url() . '">' . __( 'Have fun!', 'wordpress-importer' ) . '</a>' . '</p>';
echo '<p>' . __( 'Remember to update the passwords and roles of imported users.', 'wordpress-importer' ) . '</p>';
do_action( 'import_end' );
}
......@@ -192,6 +203,13 @@ class WP_Import extends WP_Importer {
return false;
}
$this->version = $import_data['version'];
if ( $this->version > $this->max_wxr_version ) {
echo '<div class="error"><p><strong>';
printf( __( 'This WXR file (version %s) may not be supported by this version of the importer. Please consider updating.', 'wordpress-importer' ), esc_html($import_data['version']) );
echo '</strong></p></div>';
}
$this->get_authors_from_import( $import_data );
return true;
......@@ -213,7 +231,7 @@ class WP_Import extends WP_Importer {
foreach ( $import_data['posts'] as $post ) {
$login = sanitize_user( $post['post_author'], true );
if ( empty( $login ) ) {
_e( sprintf( 'Failed to import author %s. Their posts will be attributed to the current user.', esc_html( $post['post_author'] ) ) );
printf( __( 'Failed to import author %s. Their posts will be attributed to the current user.', 'wordpress-importer' ), esc_html( $post['post_author'] ) );
echo '<br />';
continue;
}
......@@ -239,7 +257,7 @@ class WP_Import extends WP_Importer {
<input type="hidden" name="import_id" value="<?php echo $this->id; ?>" />
<?php if ( ! empty( $this->authors ) ) : ?>
<h3><?php _e('Assign Authors', 'wordpress-importer'); ?></h3>
<h3><?php _e( 'Assign Authors', 'wordpress-importer' ); ?></h3>
<p><?php _e( '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 site. For example, you may want to import all the entries as <code>admin</code>s entries.', 'wordpress-importer' ); ?></p>
<?php if ( $this->allow_create_users() ) : ?>
<p><?php printf( __( 'If a new user is created by WordPress, a new password will be randomly generated and the new user&#8217;s role will be set as %s. Manually changing the new user&#8217;s details will be necessary.', 'wordpress-importer' ), esc_html( get_option('default_role') ) ); ?></p>
......@@ -252,7 +270,7 @@ class WP_Import extends WP_Importer {
<?php endif; ?>
<?php if ( $this->allow_fetch_attachments() ) : ?>
<h3><?php _e('Import Attachments', 'wordpress-importer'); ?></h3>
<h3><?php _e( 'Import Attachments', 'wordpress-importer' ); ?></h3>
<p>
<input type="checkbox" value="1" name="fetch_attachments" id="import-attachments" />
<label for="import-attachments"><?php _e( 'Download and import file attachments', 'wordpress-importer' ); ?></label>
......@@ -273,16 +291,35 @@ class WP_Import extends WP_Importer {
*/
function author_select( $n, $author ) {
_e( 'Import author:', 'wordpress-importer' );
echo ' <strong>' . esc_html( $author['author_display_name'] . ' (' . esc_html( $author['author_login'] ) . ')' ) . '</strong><br />';
echo ' <strong>' . esc_html( $author['author_display_name'] );
if ( $this->version != '1.0' ) echo ' (' . esc_html( $author['author_login'] ) . ')';
echo '</strong><br />';
if ( $this->version != '1.0' )
echo '<div style="margin-left:18px">';
$create_users = $this->allow_create_users();
if ( $create_users ) {
if ( $this->version != '1.0' ) {
_e( 'or create new user with login name:', 'wordpress-importer' );
$value = '';
} else {
_e( 'as a new user:', 'wordpress-importer' );
$value = esc_attr( sanitize_user( $author['author_login'], true ) );
}
if ( $this->allow_create_users() ) {
_e( 'Create new user with login name', 'wordpress-importer' );
echo ' <input type="text" name="user_new['.$n.']" value="'. esc_attr( sanitize_user( $author['author_login'], true ) ) .'" /><br />';
echo ' <input type="text" name="user_new['.$n.']" value="'. $value .'" /><br />';
}
_e( 'Map to existing user', 'wordpress-importer' );
if ( ! $create_users && $this->version == '1.0' )
_e( 'assign posts to an existing user:', 'wordpress-importer' );
else
_e( 'or assign posts to an existing user:', 'wordpress-importer' );