summaryrefslogtreecommitdiffstats
path: root/wp-admin/import/wordpress.php
diff options
context:
space:
mode:
authordonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-11-30 18:54:22 +0000
committerdonncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36>2006-11-30 18:54:22 +0000
commit9415bbca12c01c39da58e0ed2c4e6b44ff833e5d (patch)
tree72e6c3da0cf5b18f808b7b5002ffd41f3edc0904 /wp-admin/import/wordpress.php
parent475ef251608d4d8a4d44a86d99693c416a1159fd (diff)
downloadwordpress-mu-9415bbca12c01c39da58e0ed2c4e6b44ff833e5d.tar.gz
wordpress-mu-9415bbca12c01c39da58e0ed2c4e6b44ff833e5d.tar.xz
wordpress-mu-9415bbca12c01c39da58e0ed2c4e6b44ff833e5d.zip
WP Merge to 4559
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@816 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-admin/import/wordpress.php')
-rw-r--r--wp-admin/import/wordpress.php34
1 files changed, 33 insertions, 1 deletions
diff --git a/wp-admin/import/wordpress.php b/wp-admin/import/wordpress.php
index ac965b8..109d0a7 100644
--- a/wp-admin/import/wordpress.php
+++ b/wp-admin/import/wordpress.php
@@ -69,6 +69,8 @@ class WP_Import {
$importdata = preg_replace("/(\r\n|\n|\r)/", "\n", $importdata);
preg_match_all('|<item>(.*?)</item>|is', $importdata, $this->posts);
$this->posts = $this->posts[1];
+ preg_match_all('|<wp:category>(.*?)</wp:category>|is', $importdata, $this->categories);
+ $this->categories = $this->categories[1];
}
function get_wp_authors() {
@@ -160,6 +162,35 @@ class WP_Import {
$this->wp_authors_form();
}
+ function process_categories() {
+ global $wpdb;
+
+ $cat_names = (array) $wpdb->get_col("SELECT cat_name FROM $wpdb->categories");
+
+ while ( $c = array_shift($this->categories) ) {
+ $cat_name = trim(str_replace(array ('<![CDATA[', ']]>'), '', $this->get_tag( $c, 'wp:cat_name' )));
+
+ // If the category exists we leave it alone
+ if ( in_array($cat_name, $cat_names) )
+ continue;
+
+ $category_nicename = $this->get_tag( $c, 'wp:category_nicename' );
+ $posts_private = (int) $this->get_tag( $c, 'wp:posts_private' );
+ $links_private = (int) $this->get_tag( $c, 'wp:links_private' );
+
+ $parent = $this->get_tag( $c, 'wp:category_parent' );
+
+ if ( empty($parent) )
+ $category_parent = '0';
+ else
+ $category_parent = (int) category_exists($parent);
+
+ $catarr = compact('category_nicename', 'category_parent', 'posts_private', 'links_private', 'posts_private', 'cat_name');
+
+ $cat_ID = wp_insert_category($catarr);
+ }
+ }
+
function process_posts() {
global $wpdb;
$i = -1;
@@ -189,7 +220,7 @@ class WP_Import {
$cat_index = 0;
foreach ($categories as $category) {
- $categories[$cat_index] = $wpdb->escape($this->unhtmlentities($category));
+ $categories[$cat_index] = $wpdb->escape($this->unhtmlentities(str_replace(array ('<![CDATA[', ']]>'), '', $category)));
$cat_index++;
}
@@ -260,6 +291,7 @@ class WP_Import {
$this->file = get_attached_file($this->id);
$this->get_authors_from_post();
$this->get_entries();
+ $this->process_categories();
$this->process_posts();
}