Commit 5489cb4b authored by lucha's avatar lucha
Browse files

[auto] plugin: wordpress-importer 0.6.4

parent b9de8022
......@@ -437,7 +437,16 @@ class WXR_Parser_Regex {
}
function parse( $file ) {
$wxr_version = $in_post = false;
$wxr_version = $in_multiline = false;
$multiline_content = '';
$multiline_tags = array(
'item' => array( 'posts', array( $this, 'process_post' ) ),
'wp:category' => array( 'categories', array( $this, 'process_category' ) ),
'wp:tag' => array( 'tags', array( $this, 'process_tag' ) ),
'wp:term' => array( 'terms', array( $this, 'process_term' ) ),
);
$fp = $this->fopen( $file, 'r' );
if ( $fp ) {
......@@ -452,39 +461,37 @@ class WXR_Parser_Regex {
$this->base_url = $url[1];
continue;
}
if ( false !== strpos( $importline, '<wp:category>' ) ) {
preg_match( '|<wp:category>(.*?)</wp:category>|is', $importline, $category );
$this->categories[] = $this->process_category( $category[1] );
continue;
}
if ( false !== strpos( $importline, '<wp:tag>' ) ) {
preg_match( '|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag );
$this->tags[] = $this->process_tag( $tag[1] );
continue;
}
if ( false !== strpos( $importline, '<wp:term>' ) ) {
preg_match( '|<wp:term>(.*?)</wp:term>|is', $importline, $term );
$this->terms[] = $this->process_term( $term[1] );
continue;
}
if ( false !== strpos( $importline, '<wp:author>' ) ) {
preg_match( '|<wp:author>(.*?)</wp:author>|is', $importline, $author );
$a = $this->process_author( $author[1] );
$this->authors[$a['author_login']] = $a;
continue;
}
if ( false !== strpos( $importline, '<item>' ) ) {
$post = '';
$in_post = true;
continue;
}
if ( false !== strpos( $importline, '</item>' ) ) {
$in_post = false;
$this->posts[] = $this->process_post( $post );
continue;
foreach ( $multiline_tags as $tag => $handler ) {
// Handle multi-line tags on a singular line
if ( preg_match( '|<' . $tag . '>(.*?)</' . $tag . '>|is', $importline, $matches ) ) {
$this->{$handler[0]}[] = call_user_func( $handler[1], $matches[1] );
} elseif ( false !== ( $pos = strpos( $importline, "<$tag>" ) ) ) {
// Take note of any content after the opening tag
$multiline_content = trim( substr( $importline, $pos + strlen( $tag ) + 2 ) );
// We don't want to have this line added to `$is_multiline` below.
$importline = '';
$in_multiline = $tag;
} elseif ( false !== ( $pos = strpos( $importline, "</$tag>" ) ) ) {
$in_multiline = false;
$multiline_content .= trim( substr( $importline, 0, $pos ) );
$this->{$handler[0]}[] = call_user_func( $handler[1], $multiline_content );
}
}
if ( $in_post ) {
$post .= $importline . "\n";
if ( $in_multiline && $importline ) {
$multiline_content .= $importline . "\n";
}
}
......
=== WordPress Importer ===
Contributors: wordpressdotorg
Donate link: https://wordpressfoundation.org/donate/
Tags: importer, wordpress
Requires at least: 3.0
Tested up to: 4.6
Stable tag: 0.6.3
Requires at least: 3.6
Tested up to: 4.9
Stable tag: 0.6.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Import posts, pages, comments, custom fields, categories, tags and more from a WordPress export file.
......@@ -19,7 +20,7 @@ The WordPress Importer will import the following content from a WordPress export
* 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)
For further information and instructions please see the [Codex page on Importing Content](https://codex.wordpress.org/Importing_Content#WordPress)
== Installation ==
......@@ -38,6 +39,12 @@ If you would prefer to do things manually then follow these instructions:
== Changelog ==
= 0.6.4 =
* Improve PHP7 compatibility.
* Fix bug that caused slashes to be stripped from imported comments.
* Fix for various deprecation notices including `wp_get_http()` and `screen_icon()`.
* Fix for importing export files with multiline term meta data.
= 0.6.3 =
* Add support for import term metadata.
* Fix bug that caused slashes to be stripped from imported content.
......@@ -45,7 +52,7 @@ If you would prefer to do things manually then follow these instructions:
* Fix PHP notices.
= 0.6.2 =
* Add wp_import_existing_post filter. See: https://core.trac.wordpress.org/ticket/33721
* Add `wp_import_existing_post` filter, see [Trac ticket #33721](https://core.trac.wordpress.org/ticket/33721).
= 0.6 =
* Support for WXR 1.2 and multiple CDATA sections
......@@ -68,7 +75,7 @@ an export file is uploaded to a server with bad permissions and WordPress 3.3 or
= 0.3 =
* Use an XML Parser if possible
* Proper import support for nav menus
* ... and much more, see [Trac ticket #15197](http://core.trac.wordpress.org/ticket/15197)
* ... and much more, see [Trac ticket #15197](https://core.trac.wordpress.org/ticket/15197)
= 0.1 =
* Initial release
......@@ -99,7 +106,7 @@ A message like "Fatal error: Allowed memory size of 8388608 bytes exhausted" ind
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)
-- [WordPress Codex: Importing Content](https://codex.wordpress.org/Importing_Content#Before_Importing)
== Filters ==
......
<?php
/*
Plugin Name: WordPress Importer
Plugin URI: http://wordpress.org/extend/plugins/wordpress-importer/
Plugin URI: https://wordpress.org/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.6.3
Author URI: https://wordpress.org/
Version: 0.6.4
Text Domain: wordpress-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
......@@ -786,6 +786,7 @@ class WP_Import extends WP_Importer {
if ( ! $post_exists || ! comment_exists( $comment['comment_author'], $comment['comment_date'] ) ) {
if ( isset( $inserted_comments[$comment['comment_parent']] ) )
$comment['comment_parent'] = $inserted_comments[$comment['comment_parent']];
$comment = wp_slash( $comment );
$comment = wp_filter_comment( $comment );
$inserted_comments[$key] = wp_insert_comment( $comment );
do_action( 'wp_import_insert_comment', $inserted_comments[$key], $comment, $comment_post_ID, $post );
......@@ -881,7 +882,7 @@ class WP_Import extends WP_Importer {
}
foreach ( $item['postmeta'] as $meta )
$$meta['key'] = $meta['value'];
${$meta['key']} = $meta['value'];
if ( 'taxonomy' == $_menu_item_type && isset( $this->processed_terms[intval($_menu_item_object_id)] ) ) {
$_menu_item_object_id = $this->processed_terms[intval($_menu_item_object_id)];
......@@ -988,7 +989,13 @@ class WP_Import extends WP_Importer {
return new WP_Error( 'upload_dir_error', $upload['error'] );
// fetch the remote url and write it to the placeholder file
$headers = wp_get_http( $url, $upload['file'] );
$remote_response = wp_safe_remote_get( $url, array(
'timeout' => 300,
'stream' => true,
'filename' => $upload['file'],
) );
$headers = wp_remote_retrieve_headers( $remote_response );
// request failed
if ( ! $headers ) {
......@@ -996,10 +1003,12 @@ class WP_Import extends WP_Importer {
return new WP_Error( 'import_file_error', __('Remote server did not respond', 'wordpress-importer') );
}
$remote_response_code = wp_remote_retrieve_response_code( $remote_response );
// make sure the fetch was successful
if ( $headers['response'] != '200' ) {
if ( $remote_response_code != '200' ) {
@unlink( $upload['file'] );
return new WP_Error( 'import_file_error', sprintf( __('Remote server returned error response %1$d %2$s', 'wordpress-importer'), esc_html($headers['response']), get_status_header_desc($headers['response']) ) );
return new WP_Error( 'import_file_error', sprintf( __('Remote server returned error response %1$d %2$s', 'wordpress-importer'), esc_html($remote_response_code), get_status_header_desc($remote_response_code) ) );
}
$filesize = filesize( $upload['file'] );
......@@ -1048,8 +1057,10 @@ class WP_Import extends WP_Importer {
if ( isset( $this->processed_posts[$parent_id] ) )
$local_parent_id = $this->processed_posts[$parent_id];
if ( $local_child_id && $local_parent_id )
if ( $local_child_id && $local_parent_id ) {
$wpdb->update( $wpdb->posts, array( 'post_parent' => $local_parent_id ), array( 'ID' => $local_child_id ), '%d', '%d' );
clean_post_cache( $local_child_id );
}
}
// all other posts/terms are imported, retry menu items with missing associated object
......@@ -1115,7 +1126,6 @@ class WP_Import extends WP_Importer {
// Display import page title
function header() {
echo '<div class="wrap">';
screen_icon();
echo '<h2>' . __( 'Import WordPress', 'wordpress-importer' ) . '</h2>';
$updates = get_plugin_updates();
......@@ -1206,7 +1216,7 @@ class WP_Import extends WP_Importer {
} // class_exists( 'WP_Importer' )
function wordpress_importer_init() {
load_plugin_textdomain( 'wordpress-importer', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
load_plugin_textdomain( 'wordpress-importer' );
/**
* WordPress Importer object for registering the import callback
......
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