Export and import custom taxonomies. Props chrisscott. fixes #10012

git-svn-id: https://develop.svn.wordpress.org/trunk@12109 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2009-10-26 13:57:55 +00:00
parent 022ee3f66d
commit ba1f1d3780
2 changed files with 83 additions and 1 deletions
+39 -1
View File
@@ -24,7 +24,7 @@ define('WXR_VERSION', '1.0');
* @param unknown_type $author
*/
function export_wp($author='') {
global $wpdb, $post_ids, $post;
global $wpdb, $post_ids, $post, $wp_taxonomies;
do_action('export_wp');
@@ -46,6 +46,13 @@ $post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_dat
$categories = (array) get_categories('get=all');
$tags = (array) get_tags('get=all');
$custom_taxonomies = $wp_taxonomies;
unset($custom_taxonomies['category']);
unset($custom_taxonomies['post_tag']);
unset($custom_taxonomies['link_category']);
$custom_taxonomies = array_keys($custom_taxonomies);
$terms = (array) get_terms($custom_taxonomies, 'get=all');
/**
* {@internal Missing Short Description}}
*
@@ -182,6 +189,34 @@ function wxr_tag_description($t) {
echo '<wp:tag_description>' . wxr_cdata($t->description) . '</wp:tag_description>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Term Object
*/
function wxr_term_name($t) {
if ( empty($t->name) )
return;
echo '<wp:term_name>' . wxr_cdata($t->name) . '</wp:term_name>';
}
/**
* {@internal Missing Short Description}}
*
* @since unknown
*
* @param object $t Term Object
*/
function wxr_term_description($t) {
if ( empty($t->description) )
return;
echo '<wp:term_description>' . wxr_cdata($t->description) . '</wp:term_description>';
}
/**
* {@internal Missing Short Description}}
*
@@ -255,6 +290,9 @@ echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
<?php endforeach; endif; ?>
<?php if ( $tags ) : foreach ( $tags as $t ) : ?>
<wp:tag><wp:tag_slug><?php echo $t->slug; ?></wp:tag_slug><?php wxr_tag_name($t); ?><?php wxr_tag_description($t); ?></wp:tag>
<?php endforeach; endif; ?>
<?php if ( $terms ) : foreach ( $terms as $t ) : ?>
<wp:term><wp:term_taxonomy><?php echo $t->taxonomy; ?></wp:term_taxonomy><wp:term_slug><?php echo $t->slug; ?></wp:term_slug><wp:term_parent><?php echo $t->parent ? $custom_taxonomies[$t->parent]->name : ''; ?></wp:term_parent><?php wxr_term_name($t); ?><?php wxr_term_description($t); ?></wp:term>
<?php endforeach; endif; ?>
<?php do_action('rss2_head'); ?>
<?php if ($post_ids) {