summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony G. Basile <blueness@gentoo.org>2016-08-23 20:04:47 -0400
committerAnthony G. Basile <blueness@gentoo.org>2016-08-23 20:05:07 -0400
commit15ad975d807a98ec34a4fa4f4d31b1eff01c4be0 (patch)
tree8ce6d6cc75c1923a4860ca7ea969d30798652817 /plugins/wordpress-importer/wordpress-importer.php
parentUpdate plugin jetpack to 4.2.2 (diff)
downloadblogs-gentoo-15ad975d807a98ec34a4fa4f4d31b1eff01c4be0.tar.gz
blogs-gentoo-15ad975d807a98ec34a4fa4f4d31b1eff01c4be0.tar.bz2
blogs-gentoo-15ad975d807a98ec34a4fa4f4d31b1eff01c4be0.zip
Update plugin wordpress-importer to 0.6.3
Diffstat (limited to 'plugins/wordpress-importer/wordpress-importer.php')
-rw-r--r--plugins/wordpress-importer/wordpress-importer.php94
1 files changed, 90 insertions, 4 deletions
diff --git a/plugins/wordpress-importer/wordpress-importer.php b/plugins/wordpress-importer/wordpress-importer.php
index ab6814c7..31b91b62 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.6.1
+Version: 0.6.3
Text Domain: wordpress-importer
License: GPL version 2 or later - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
@@ -63,8 +63,6 @@ class WP_Import extends WP_Importer {
var $url_remap = array();
var $featured_images = array();
- function WP_Import() { /* nothing */ }
-
/**
* Registered callback function for the WordPress Importer
*
@@ -416,6 +414,7 @@ class WP_Import extends WP_Importer {
'cat_name' => $cat['cat_name'],
'category_description' => $category_description
);
+ $catarr = wp_slash( $catarr );
$id = wp_insert_category( $catarr );
if ( ! is_wp_error( $id ) ) {
@@ -428,6 +427,8 @@ class WP_Import extends WP_Importer {
echo '<br />';
continue;
}
+
+ $this->process_termmeta( $cat, $id['term_id'] );
}
unset( $this->categories );
@@ -454,6 +455,7 @@ class WP_Import extends WP_Importer {
continue;
}
+ $tag = wp_slash( $tag );
$tag_desc = isset( $tag['tag_description'] ) ? $tag['tag_description'] : '';
$tagarr = array( 'slug' => $tag['tag_slug'], 'description' => $tag_desc );
@@ -468,6 +470,8 @@ class WP_Import extends WP_Importer {
echo '<br />';
continue;
}
+
+ $this->process_termmeta( $tag, $id['term_id'] );
}
unset( $this->tags );
@@ -500,6 +504,7 @@ class WP_Import extends WP_Importer {
$parent = term_exists( $term['term_parent'], $term['term_taxonomy'] );
if ( is_array( $parent ) ) $parent = $parent['term_id'];
}
+ $term = wp_slash( $term );
$description = isset( $term['term_description'] ) ? $term['term_description'] : '';
$termarr = array( 'slug' => $term['slug'], 'description' => $description, 'parent' => intval($parent) );
@@ -514,12 +519,75 @@ class WP_Import extends WP_Importer {
echo '<br />';
continue;
}
+
+ $this->process_termmeta( $term, $id['term_id'] );
}
unset( $this->terms );
}
/**
+ * Add metadata to imported term.
+ *
+ * @since 0.6.2
+ *
+ * @param array $term Term data from WXR import.
+ * @param int $term_id ID of the newly created term.
+ */
+ protected function process_termmeta( $term, $term_id ) {
+ if ( ! isset( $term['termmeta'] ) ) {
+ $term['termmeta'] = array();
+ }
+
+ /**
+ * Filters the metadata attached to an imported term.
+ *
+ * @since 0.6.2
+ *
+ * @param array $termmeta Array of term meta.
+ * @param int $term_id ID of the newly created term.
+ * @param array $term Term data from the WXR import.
+ */
+ $term['termmeta'] = apply_filters( 'wp_import_term_meta', $term['termmeta'], $term_id, $term );
+
+ if ( empty( $term['termmeta'] ) ) {
+ return;
+ }
+
+ foreach ( $term['termmeta'] as $meta ) {
+ /**
+ * Filters the meta key for an imported piece of term meta.
+ *
+ * @since 0.6.2
+ *
+ * @param string $meta_key Meta key.
+ * @param int $term_id ID of the newly created term.
+ * @param array $term Term data from the WXR import.
+ */
+ $key = apply_filters( 'import_term_meta_key', $meta['key'], $term_id, $term );
+ if ( ! $key ) {
+ continue;
+ }
+
+ // Export gets meta straight from the DB so could have a serialized string
+ $value = maybe_unserialize( $meta['value'] );
+
+ add_term_meta( $term_id, $key, $value );
+
+ /**
+ * Fires after term meta is imported.
+ *
+ * @since 0.6.2
+ *
+ * @param int $term_id ID of the newly created term.
+ * @param string $key Meta key.
+ * @param mixed $value Meta value.
+ */
+ do_action( 'import_term_meta', $term_id, $key, $value );
+ }
+ }
+
+ /**
* Create new posts based on import information
*
* Posts marked as having a parent which doesn't exist will become top level items.
@@ -555,10 +623,26 @@ 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'] );
+
+ /**
+ * Filter ID of the existing post corresponding to post currently importing.
+ *
+ * Return 0 to force the post to be imported. Filter the ID to be something else
+ * to override which existing post is mapped to the imported post.
+ *
+ * @see post_exists()
+ * @since 0.6.2
+ *
+ * @param int $post_exists Post ID, or 0 if post did not exist.
+ * @param array $post The post array to be inserted.
+ */
+ $post_exists = apply_filters( 'wp_import_existing_post', $post_exists, $post );
+
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;
+ $this->processed_posts[ intval( $post['post_id'] ) ] = intval( $post_exists );
} else {
$post_parent = (int) $post['post_parent'];
if ( $post_parent ) {
@@ -592,6 +676,8 @@ class WP_Import extends WP_Importer {
$original_post_ID = $post['post_id'];
$postdata = apply_filters( 'wp_import_post_data_processed', $postdata, $post );
+ $postdata = wp_slash( $postdata );
+
if ( 'attachment' == $postdata['post_type'] ) {
$remote_url = ! empty($post['attachment_url']) ? $post['attachment_url'] : $post['guid'];
@@ -1107,7 +1193,7 @@ class WP_Import extends WP_Importer {
* Added to http_request_timeout filter to force timeout at 60 seconds during import
* @return int 60
*/
- function bump_request_timeout() {
+ function bump_request_timeout( $val ) {
return 60;
}