diff --git a/wp-admin/export.php b/wp-admin/export.php
index 27fbe523b7..c8090e4dde 100644
--- a/wp-admin/export.php
+++ b/wp-admin/export.php
@@ -141,6 +141,27 @@ function wxr_tag_description($t) {
echo '' . wxr_cdata($t->description) . '';
}
+function wxr_post_taxonomy() {
+ $categories = get_the_category();
+ $tags = get_the_tags();
+ $cat_names = array();
+ $tag_names = array();
+ $the_list = '';
+ $filter = 'rss';
+
+ if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
+ $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
+ $the_list .= "\n\t\t\n";
+ }
+
+ if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
+ $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
+ $the_list .= "\n\t\t\n";
+ }
+
+ echo $the_list;
+}
+
print '\n";
?>
@@ -201,7 +222,7 @@ print '\n";
-
+
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
index df1b67bd06..d15f3a43be 100644
--- a/wp-admin/import/wordpress.php
+++ b/wp-admin/import/wordpress.php
@@ -316,6 +316,15 @@ class WP_Import {
$post_content = str_replace('
', '
', $post_content);
$post_content = str_replace('
', '
', $post_content);
+ preg_match_all('|(.*?)|is', $post, $tags);
+ $tags = $tags[1];
+
+ $tag_index = 0;
+ foreach ($tags as $tag) {
+ $tags[$tag_index] = $wpdb->escape($this->unhtmlentities(str_replace(array (''), '', $tag)));
+ $tag_index++;
+ }
+
preg_match_all('|(.*?)|is', $post, $categories);
$categories = $categories[1];
@@ -372,6 +381,25 @@ class WP_Import {
}
wp_set_post_categories($post_id, $post_cats);
}
+
+ // Add tags.
+ if (count($tags) > 0) {
+ $post_tags = array();
+ foreach ($tags as $tag) {
+ $slug = sanitize_term_field('slug', $tag, 0, 'post_tag', 'db');
+ $tag_obj = get_term_by('slug', $slug, 'post_tag');
+ $tag_id = 0;
+ if ( ! empty($tag_obj) )
+ $tag_id = $tag_obj->term_id;
+ if ( $tag_id == 0 ) {
+ $tag = $wpdb->escape($tag);
+ $tag_id = wp_insert_term($tag, 'post_tag');
+ $tag_id = $tag_id['term_id'];
+ }
+ $post_tags[] = $tag_id;
+ }
+ wp_set_post_tags($post_id, $post_tags);
+ }
}
// Now for comments