Make WordPress Core

Ticket #12180: 12180.diff

File 12180.diff, 2.0 KB (added by ryan, 12 years ago)
  • wp-admin/includes/export.php

     
    223223 * @since unknown
    224224 */
    225225function wxr_post_taxonomy() {
    226         $categories = get_the_category();
    227         $tags = get_the_tags();
     226        global $post;
     227
    228228        $the_list = '';
    229229        $filter = 'rss';
    230230
    231         if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
    232                 $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
    233                 // for backwards compatibility
    234                 $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
    235                 // forwards compatibility: use a unique identifier for each cat to avoid clashes
    236                 // http://trac.wordpress.org/ticket/5447
    237                 $the_list .= "\n\t\t<category domain=\"category\" nicename=\"{$category->slug}\"><![CDATA[$cat_name]]></category>\n";
    238         }
    239 
    240         if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
    241                 $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
    242                 $the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[$tag_name]]></category>\n";
     231        $taxonomies = get_object_taxonomies('post');
     232        $terms = wp_get_post_terms($post->ID, $taxonomies);
     233        foreach ( (array) $terms as $term ) {
     234                $domain = ( 'post_tag' == $term->taxonomy ) ? 'tag' : $term->taxonomy;
     235                $term_name = sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, $filter);
     236                // Back compat.
     237                if ( 'category' == $term->taxonomy )
     238                        $the_list .= "\n\t\t<category><![CDATA[$term_name]]></category>\n";
     239                elseif ( 'post_tag' == $term->taxonomy )
     240                        $the_list .= "\n\t\t<category domain=\"$domain\"><![CDATA[$term_name]]></category>\n";
    243241                // forwards compatibility as above
    244                 $the_list .= "\n\t\t<category domain=\"tag\" nicename=\"{$tag->slug}\"><![CDATA[$tag_name]]></category>\n";
     242                $the_list .= "\n\t\t<category domain=\"$domain\" nicename=\"{$term->slug}\"><![CDATA[$term_name]]></category>\n";
    245243        }
    246 
    247244        echo $the_list;
    248245}
    249246