mirror of
https://github.com/WordPress/WordPress.git
synced 2024-10-02 00:57:40 +02:00
Import tags. see #4682
git-svn-id: http://svn.automattic.com/wordpress/trunk@6129 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
1d146b6153
commit
8eceaca349
@ -88,6 +88,7 @@ class WP_Import {
|
|||||||
|
|
||||||
$this->posts = array();
|
$this->posts = array();
|
||||||
$this->categories = array();
|
$this->categories = array();
|
||||||
|
$this->tags = array();
|
||||||
$num = 0;
|
$num = 0;
|
||||||
$doing_entry = false;
|
$doing_entry = false;
|
||||||
|
|
||||||
@ -101,6 +102,11 @@ class WP_Import {
|
|||||||
$this->categories[] = $category[1];
|
$this->categories[] = $category[1];
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if ( false !== strpos($importline, '<wp:tag>') ) {
|
||||||
|
preg_match('|<wp:tag>(.*?)</wp:tag>|is', $importline, $tag);
|
||||||
|
$this->tags[] = $tag[1];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if ( false !== strpos($importline, '<item>') ) {
|
if ( false !== strpos($importline, '<item>') ) {
|
||||||
$this->posts[$num] = '';
|
$this->posts[$num] = '';
|
||||||
$doing_entry = true;
|
$doing_entry = true;
|
||||||
@ -246,6 +252,27 @@ class WP_Import {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function process_tags() {
|
||||||
|
global $wpdb;
|
||||||
|
|
||||||
|
$tag_names = (array) get_terms('post_tag', 'fields=names');
|
||||||
|
|
||||||
|
while ( $c = array_shift($this->tags) ) {
|
||||||
|
$tag_name = trim($this->get_tag( $c, 'wp:tag_name' ));
|
||||||
|
|
||||||
|
// If the category exists we leave it alone
|
||||||
|
if ( in_array($tag_name, $tag_names) )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$slug = $this->get_tag( $c, 'wp:tag_slug' );
|
||||||
|
$description = $this->get_tag( $c, 'wp:tag_description' );
|
||||||
|
|
||||||
|
$tagarr = compact('slug', 'description');
|
||||||
|
|
||||||
|
$tag_ID = wp_insert_term($tag_name, 'post_tag', $tagarr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function process_posts() {
|
function process_posts() {
|
||||||
$i = -1;
|
$i = -1;
|
||||||
echo '<ol>';
|
echo '<ol>';
|
||||||
@ -391,6 +418,7 @@ class WP_Import {
|
|||||||
$this->get_authors_from_post();
|
$this->get_authors_from_post();
|
||||||
$this->get_entries();
|
$this->get_entries();
|
||||||
$this->process_categories();
|
$this->process_categories();
|
||||||
|
$this->process_tags();
|
||||||
$result = $this->process_posts();
|
$result = $this->process_posts();
|
||||||
if ( is_wp_error( $result ) )
|
if ( is_wp_error( $result ) )
|
||||||
return $result;
|
return $result;
|
||||||
|
Loading…
Reference in New Issue
Block a user