diff options
author | Theo Chatzimichos <tampakrap@gentoo.org> | 2011-08-01 14:17:42 +0300 |
---|---|---|
committer | Theo Chatzimichos <tampakrap@gentoo.org> | 2011-08-01 14:17:42 +0300 |
commit | 70011eb7f2f5c26a3b9bfee28863c3aa8dcdc2f7 (patch) | |
tree | 9f834d1696c4b647594ca3e19aef6dc50c0ebb0b /plugins/wordpress-importer | |
parent | Update smart-youtube and wp-syntax (diff) | |
download | blogs-gentoo-70011eb7f2f5c26a3b9bfee28863c3aa8dcdc2f7.tar.gz blogs-gentoo-70011eb7f2f5c26a3b9bfee28863c3aa8dcdc2f7.tar.bz2 blogs-gentoo-70011eb7f2f5c26a3b9bfee28863c3aa8dcdc2f7.zip |
Update wp-importer and wp-syntax
Diffstat (limited to 'plugins/wordpress-importer')
-rw-r--r-- | plugins/wordpress-importer/languages/wordpress-importer.pot | 90 | ||||
-rw-r--r-- | plugins/wordpress-importer/parsers.php | 31 | ||||
-rw-r--r-- | plugins/wordpress-importer/readme.txt | 11 | ||||
-rw-r--r-- | plugins/wordpress-importer/wordpress-importer.php | 23 |
4 files changed, 100 insertions, 55 deletions
diff --git a/plugins/wordpress-importer/languages/wordpress-importer.pot b/plugins/wordpress-importer/languages/wordpress-importer.pot index 8dae6cf0..0ca72e26 100644 --- a/plugins/wordpress-importer/languages/wordpress-importer.pot +++ b/plugins/wordpress-importer/languages/wordpress-importer.pot @@ -2,9 +2,9 @@ # This file is distributed under the same license as the WordPress Importer package. msgid "" 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" -"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" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" @@ -22,49 +22,49 @@ msgid "" "parser..." 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 "" "This does not appear to be a WXR file, missing/invalid WXR version number" msgstr "" -#: wordpress-importer.php:133 wordpress-importer.php:142 -#: wordpress-importer.php:193 wordpress-importer.php:201 +#: wordpress-importer.php:134 wordpress-importer.php:143 +#: wordpress-importer.php:194 wordpress-importer.php:202 msgid "Sorry, there has been an error." msgstr "" -#: wordpress-importer.php:134 +#: wordpress-importer.php:135 msgid "The file does not exist, please try again." msgstr "" -#: wordpress-importer.php:177 +#: wordpress-importer.php:178 msgid "All done." msgstr "" -#: wordpress-importer.php:177 +#: wordpress-importer.php:178 msgid "Have fun!" msgstr "" -#: wordpress-importer.php:178 +#: wordpress-importer.php:179 msgid "Remember to update the passwords and roles of imported users." msgstr "" -#: wordpress-importer.php:209 +#: wordpress-importer.php:210 msgid "" "This WXR file (version %s) may not be supported by this version of the " "importer. Please consider updating." msgstr "" -#: wordpress-importer.php:234 +#: wordpress-importer.php:235 msgid "" "Failed to import author %s. Their posts will be attributed to the current " "user." msgstr "" -#: wordpress-importer.php:260 +#: wordpress-importer.php:261 msgid "Assign Authors" msgstr "" -#: wordpress-importer.php:261 +#: wordpress-importer.php:262 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 " @@ -72,137 +72,137 @@ msgid "" "code>s entries." msgstr "" -#: wordpress-importer.php:263 +#: wordpress-importer.php:264 msgid "" "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 " "the new user’s details will be necessary." msgstr "" -#: wordpress-importer.php:273 +#: wordpress-importer.php:274 msgid "Import Attachments" msgstr "" -#: wordpress-importer.php:276 +#: wordpress-importer.php:277 msgid "Download and import file attachments" msgstr "" -#: wordpress-importer.php:280 +#: wordpress-importer.php:281 msgid "Submit" msgstr "" -#: wordpress-importer.php:293 +#: wordpress-importer.php:294 msgid "Import author:" msgstr "" -#: wordpress-importer.php:304 +#: wordpress-importer.php:305 msgid "or create new user with login name:" msgstr "" -#: wordpress-importer.php:307 +#: wordpress-importer.php:308 msgid "as a new user:" msgstr "" -#: wordpress-importer.php:315 +#: wordpress-importer.php:316 msgid "assign posts to an existing user:" msgstr "" -#: wordpress-importer.php:317 +#: wordpress-importer.php:318 msgid "or assign posts to an existing user:" msgstr "" -#: wordpress-importer.php:318 +#: wordpress-importer.php:319 msgid "- Select -" msgstr "" -#: wordpress-importer.php:366 +#: wordpress-importer.php:369 msgid "" "Failed to create new user for %s. Their posts will be attributed to the " "current user." msgstr "" -#: wordpress-importer.php:413 +#: wordpress-importer.php:418 msgid "Failed to import category %s" msgstr "" -#: wordpress-importer.php:449 +#: wordpress-importer.php:456 msgid "Failed to import post tag %s" msgstr "" -#: wordpress-importer.php:491 wordpress-importer.php:603 +#: wordpress-importer.php:500 wordpress-importer.php:626 msgid "Failed to import %s %s" msgstr "" -#: wordpress-importer.php:513 +#: wordpress-importer.php:522 msgid "Failed to import “%s”: Invalid post type %s" msgstr "" -#: wordpress-importer.php:534 +#: wordpress-importer.php:543 msgid "%s “%s” already exists." msgstr "" -#: wordpress-importer.php:575 +#: wordpress-importer.php:598 msgid "Failed to import %s “%s”" msgstr "" -#: wordpress-importer.php:712 +#: wordpress-importer.php:744 msgid "Menu item skipped due to missing menu slug" msgstr "" -#: wordpress-importer.php:719 +#: wordpress-importer.php:751 msgid "Menu item skipped due to invalid menu slug: %s" msgstr "" -#: wordpress-importer.php:782 +#: wordpress-importer.php:814 msgid "Fetching attachments is not enabled" msgstr "" -#: wordpress-importer.php:795 +#: wordpress-importer.php:827 msgid "Invalid file type" msgstr "" -#: wordpress-importer.php:838 +#: wordpress-importer.php:871 msgid "Remote server did not respond" msgstr "" -#: wordpress-importer.php:844 +#: wordpress-importer.php:877 msgid "Remote server returned error response %1$d %2$s" msgstr "" -#: wordpress-importer.php:851 +#: wordpress-importer.php:884 msgid "Remote file is incorrect size" msgstr "" -#: wordpress-importer.php:856 +#: wordpress-importer.php:889 msgid "Zero size file downloaded" msgstr "" -#: wordpress-importer.php:862 +#: wordpress-importer.php:895 msgid "Remote file is too large, limit is %s" msgstr "" -#: wordpress-importer.php:961 +#: wordpress-importer.php:994 msgid "Import WordPress" msgstr "" -#: wordpress-importer.php:968 +#: wordpress-importer.php:1001 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 +#: wordpress-importer.php:1016 msgid "" "Howdy! Upload your WordPress eXtended RSS (WXR) file and we’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." +#: wordpress-importer.php:1017 +msgid "Choose a WXR (.xml) file to upload, then click Upload file and import." msgstr "" -#: wordpress-importer.php:1058 +#: wordpress-importer.php:1091 msgid "" "Import <strong>posts, pages, comments, custom fields, categories, and tags</" "strong> from a WordPress export file." diff --git a/plugins/wordpress-importer/parsers.php b/plugins/wordpress-importer/parsers.php index 87c3b9d9..ab4be51a 100644 --- a/plugins/wordpress-importer/parsers.php +++ b/plugins/wordpress-importer/parsers.php @@ -173,11 +173,21 @@ class WXR_Parser_SimpleXML { foreach ( $wp->postmeta as $meta ) { $post['postmeta'][] = array( 'key' => (string) $meta->meta_key, - 'value' => (string) $meta->meta_value, + 'value' => (string) $meta->meta_value ); } 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( 'comment_id' => (int) $comment->comment_id, 'comment_author' => (string) $comment->comment_author, @@ -191,6 +201,7 @@ class WXR_Parser_SimpleXML { 'comment_type' => (string) $comment->comment_type, 'comment_parent' => (string) $comment->comment_parent, 'comment_user_id' => (int) $comment->comment_user_id, + 'commentmeta' => $meta, ); } @@ -302,10 +313,17 @@ class WXR_Parser_XML { function tag_close( $parser, $tag ) { switch ( $tag ) { case 'wp:comment': + unset( $this->sub_data['key'], $this->sub_data['value'] ); // remove meta sub_data if ( ! empty( $this->sub_data ) ) $this->data['comments'][] = $this->sub_data; $this->sub_data = false; break; + case 'wp:commentmeta': + $this->sub_data['commentmeta'][] = array( + 'key' => $this->sub_data['key'], + 'value' => $this->sub_data['value'] + ); + break; case 'category': if ( ! empty( $this->sub_data ) ) { $this->sub_data['name'] = $this->cdata; @@ -546,6 +564,16 @@ class WXR_Parser_Regex { $comments = $comments[1]; if ( $comments ) { 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( 'comment_id' => $this->get_tag( $comment, 'wp:comment_id' ), 'comment_author' => $this->get_tag( $comment, 'wp:comment_author' ), @@ -559,6 +587,7 @@ class WXR_Parser_Regex { 'comment_type' => $this->get_tag( $comment, 'wp:comment_type' ), 'comment_parent' => $this->get_tag( $comment, 'wp:comment_parent' ), 'comment_user_id' => $this->get_tag( $comment, 'wp:comment_user_id' ), + 'commentmeta' => $c_meta, ); } } diff --git a/plugins/wordpress-importer/readme.txt b/plugins/wordpress-importer/readme.txt index 554232f4..e2968149 100644 --- a/plugins/wordpress-importer/readme.txt +++ b/plugins/wordpress-importer/readme.txt @@ -3,8 +3,8 @@ Contributors: wordpressdotorg Donate link: Tags: importer, wordpress Requires at least: 3.0 -Tested up to: 3.1 -Stable tag: 0.4 +Tested up to: 3.2.1 +Stable tag: 0.5 Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file. @@ -37,6 +37,10 @@ If you would prefer to do things manually then follow these instructions: == 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` @@ -53,6 +57,9 @@ If you would prefer to do things manually then follow these instructions: == Upgrade Notice == += 0.5 = +Import comment meta and other minor bugfixes and enhancements. + = 0.4 = Bug fixes for attachment importing and other small enhancements. diff --git a/plugins/wordpress-importer/wordpress-importer.php b/plugins/wordpress-importer/wordpress-importer.php index 966182ac..5e384844 100644 --- a/plugins/wordpress-importer/wordpress-importer.php +++ b/plugins/wordpress-importer/wordpress-importer.php @@ -5,7 +5,7 @@ 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.4 +Version: 0.5 Text Domain: wordpress-importer License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html */ @@ -335,6 +335,8 @@ class WP_Import extends WP_Importer { $create_users = $this->allow_create_users(); foreach ( (array) $_POST['imported_authors'] as $i => $old_login ) { + // Multsite adds strtolower to sanitize_user. Need to sanitize here to stop breakage in process_posts. + $santized_old_login = sanitize_user( $old_login, true ); $old_id = isset( $this->authors[$old_login]['author_id'] ) ? intval($this->authors[$old_login]['author_id']) : false; if ( ! empty( $_POST['user_map'][$i] ) ) { @@ -342,7 +344,7 @@ class WP_Import extends WP_Importer { if ( isset( $user->ID ) ) { if ( $old_id ) $this->processed_authors[$old_id] = $user->ID; - $this->author_mapping[$old_login] = $user->ID; + $this->author_mapping[$santized_old_login] = $user->ID; } } else if ( $create_users ) { if ( ! empty($_POST['user_new'][$i]) ) { @@ -362,7 +364,7 @@ class WP_Import extends WP_Importer { if ( ! is_wp_error( $user_id ) ) { if ( $old_id ) $this->processed_authors[$old_id] = $user_id; - $this->author_mapping[$old_login] = $user_id; + $this->author_mapping[$santized_old_login] = $user_id; } else { 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']) ); if ( defined('IMPORT_DEBUG') && IMPORT_DEBUG ) @@ -372,10 +374,10 @@ class WP_Import extends WP_Importer { } // failsafe: if the user_id was invalid, default to the current user - if ( ! isset( $this->author_mapping[$old_login] ) ) { + if ( ! isset( $this->author_mapping[$santized_old_login] ) ) { if ( $old_id ) $this->processed_authors[$old_id] = (int) get_current_user_id(); - $this->author_mapping[$old_login] = (int) get_current_user_id(); + $this->author_mapping[$santized_old_login] = (int) get_current_user_id(); } } } @@ -523,7 +525,7 @@ class WP_Import extends WP_Importer { continue; } - if ( isset( $this->processed_posts[$post['post_id']] ) ) + if ( isset( $this->processed_posts[$post['post_id']] ) && ! empty( $post['post_id'] ) ) continue; if ( $post['status'] == 'auto-draft' ) @@ -654,6 +656,7 @@ class WP_Import extends WP_Importer { $newcomments[$comment_id]['comment_approved'] = $comment['comment_approved']; $newcomments[$comment_id]['comment_type'] = $comment['comment_type']; $newcomments[$comment_id]['comment_parent'] = $comment['comment_parent']; + $newcomments[$comment_id]['commentmeta'] = isset( $comment['commentmeta'] ) ? $comment['commentmeta'] : array(); if ( isset( $this->processed_authors[$comment['comment_user_id']] ) ) $newcomments[$comment_id]['user_id'] = $this->processed_authors[$comment['comment_user_id']]; } @@ -666,6 +669,12 @@ class WP_Import extends WP_Importer { $comment['comment_parent'] = $inserted_comments[$comment['comment_parent']]; $comment = wp_filter_comment( $comment ); $inserted_comments[$key] = wp_insert_comment( $comment ); + + foreach( $comment['commentmeta'] as $meta ) { + $value = maybe_unserialize( $meta['value'] ); + add_comment_meta( $inserted_comments[$key], $meta['key'], $value ); + } + $num_comments++; } } @@ -1005,7 +1014,7 @@ class WP_Import extends WP_Importer { function greet() { echo '<div class="narrow">'; echo '<p>'.__( 'Howdy! Upload your WordPress eXtended RSS (WXR) file and we’ll import the posts, pages, comments, custom fields, categories, and tags into this site.', 'wordpress-importer' ).'</p>'; - echo '<p>'.__( 'Choose a WXR file to upload, then click Upload file and import.', 'wordpress-importer' ).'</p>'; + echo '<p>'.__( 'Choose a WXR (.xml) file to upload, then click Upload file and import.', 'wordpress-importer' ).'</p>'; wp_import_upload_form( 'admin.php?import=wordpress&step=1' ); echo '</div>'; } |