Commit a7cfa472 authored by lucha's avatar lucha Committed by lechuck

Wordpress-Importer plugin 0.6

parent 45233ec7
......@@ -462,11 +462,20 @@ class WXR_Parser_Regex {
}
function get_tag( $string, $tag ) {
global $wpdb;
preg_match( "|<$tag.*?>(.*?)</$tag>|is", $string, $return );
if ( isset( $return[1] ) ) {
$return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] );
$return = $wpdb->escape( trim( $return ) );
if ( substr( $return[1], 0, 9 ) == '<![CDATA[' ) {
if ( strpos( $return[1], ']]]]><![CDATA[>' ) !== false ) {
preg_match_all( '|<!\[CDATA\[(.*?)\]\]>|s', $return[1], $matches );
$return = '';
foreach( $matches[1] as $match )
$return .= $match;
} else {
$return = preg_replace( '|^<!\[CDATA\[(.*)\]\]>$|s', '$1', $return[1] );
}
} else {
$return = $return[1];
}
} else {
$return = '';
}
......@@ -527,7 +536,7 @@ class WXR_Parser_Regex {
$menu_order = $this->get_tag( $post, 'wp:menu_order' );
$post_type = $this->get_tag( $post, 'wp:post_type' );
$post_password = $this->get_tag( $post, 'wp:post_password' );
$is_sticky = $this->get_tag( $post, 'wp:is_sticky' );
$is_sticky = $this->get_tag( $post, 'wp:is_sticky' );
$guid = $this->get_tag( $post, 'guid' );
$post_author = $this->get_tag( $post, 'dc:creator' );
......
......@@ -3,8 +3,8 @@ Contributors: wordpressdotorg
Donate link:
Tags: importer, wordpress
Requires at least: 3.0
Tested up to: 3.2.1
Stable tag: 0.5
Tested up to: 3.4
Stable tag: 0.6
Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
......@@ -37,6 +37,14 @@ If you would prefer to do things manually then follow these instructions:
== Changelog ==
= 0.6 =
* Support for WXR 1.2 and multiple CDATA sections
* Post aren't duplicates if their post_type's are different
= 0.5.2 =
* Double check that the uploaded export file exists before processing it. This prevents incorrect error messages when
an export file is uploaded to a server with bad permissions and WordPress 3.3 or 3.3.1 is being used.
= 0.5 =
* Import comment meta (requires export from WordPress 3.2)
* Minor bugfixes and enhancements
......@@ -57,6 +65,12 @@ If you would prefer to do things manually then follow these instructions:
== Upgrade Notice ==
= 0.6 =
Support for exports from WordPress 3.4.
= 0.5.2 =
Fix incorrect error message when the export file could not be uploaded.
= 0.5 =
Import comment meta and other minor bugfixes and enhancements.
......
......@@ -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.5
Version: 0.6
Text Domain: wordpress-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
......@@ -36,7 +36,7 @@ require dirname( __FILE__ ) . '/parsers.php';
*/
if ( class_exists( 'WP_Importer' ) ) {
class WP_Import extends WP_Importer {
var $max_wxr_version = 1.1; // max. supported WXR version
var $max_wxr_version = 1.2; // max. supported WXR version
var $id; // WXR attachment ID
......@@ -194,6 +194,11 @@ class WP_Import extends WP_Importer {
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '</strong><br />';
echo esc_html( $file['error'] ) . '</p>';
return false;
} else if ( ! file_exists( $file['file'] ) ) {
echo '<p><strong>' . __( 'Sorry, there has been an error.', 'wordpress-importer' ) . '</strong><br />';
printf( __( 'The export file could not be found at <code>%s</code>. It is likely that this was caused by a permissions problem.', 'wordpress-importer' ), esc_html( $file['file'] ) );
echo '</p>';
return false;
}
$this->id = (int) $file['id'];
......@@ -335,7 +340,7 @@ 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.
// Multisite 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;
......@@ -539,7 +544,7 @@ class WP_Import extends WP_Importer {
$post_type_object = get_post_type_object( $post['post_type'] );
$post_exists = post_exists( $post['post_title'], '', $post['post_date'] );
if ( $post_exists ) {
if ( $post_exists && get_post_type( $post_exists ) == $post['post_type'] ) {
printf( __('%s &#8220;%s&#8221; already exists.', 'wordpress-importer'), $post_type_object->labels->singular_name, esc_html($post['post_title']) );
echo '<br />';
$comment_post_ID = $post_id = $post_exists;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment