Export post <-> term relationships for all taxonomies. fixes #12180
git-svn-id: https://develop.svn.wordpress.org/trunk@13055 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
10221b01f2
commit
d440214a7b
@ -223,27 +223,24 @@ function wxr_term_description($t) {
|
|||||||
* @since unknown
|
* @since unknown
|
||||||
*/
|
*/
|
||||||
function wxr_post_taxonomy() {
|
function wxr_post_taxonomy() {
|
||||||
$categories = get_the_category();
|
global $post;
|
||||||
$tags = get_the_tags();
|
|
||||||
$the_list = '';
|
$the_list = '';
|
||||||
$filter = 'rss';
|
$filter = 'rss';
|
||||||
|
|
||||||
if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
|
$taxonomies = get_object_taxonomies('post');
|
||||||
$cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
|
$terms = wp_get_post_terms($post->ID, $taxonomies);
|
||||||
// for backwards compatibility
|
foreach ( (array) $terms as $term ) {
|
||||||
$the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
|
$domain = ( 'post_tag' == $term->taxonomy ) ? 'tag' : $term->taxonomy;
|
||||||
// forwards compatibility: use a unique identifier for each cat to avoid clashes
|
$term_name = sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, $filter);
|
||||||
// http://trac.wordpress.org/ticket/5447
|
// Back compat.
|
||||||
$the_list .= "\n\t\t<category domain=\"category\" nicename=\"{$category->slug}\"><![CDATA[$cat_name]]></category>\n";
|
if ( 'category' == $term->taxonomy )
|
||||||
}
|
$the_list .= "\n\t\t<category><![CDATA[$term_name]]></category>\n";
|
||||||
|
elseif ( 'post_tag' == $term->taxonomy )
|
||||||
if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
|
$the_list .= "\n\t\t<category domain=\"$domain\"><![CDATA[$term_name]]></category>\n";
|
||||||
$tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
|
|
||||||
$the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[$tag_name]]></category>\n";
|
|
||||||
// forwards compatibility as above
|
// forwards compatibility as above
|
||||||
$the_list .= "\n\t\t<category domain=\"tag\" nicename=\"{$tag->slug}\"><![CDATA[$tag_name]]></category>\n";
|
$the_list .= "\n\t\t<category domain=\"$domain\" nicename=\"{$term->slug}\"><![CDATA[$term_name]]></category>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo $the_list;
|
echo $the_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user