WordPress.org

Make WordPress Core

Changeset 6375


Ignore:
Timestamp:
12/12/2007 05:11:24 AM (11 years ago)
Author:
ryan
Message:

Additional metadata for wxr export from tellyworth. fixes #5454

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/export.php

    r6354 r6375  
    11<?php
     2
     3// version number for the export format.  bump this when something changes that might affect compatibility.
     4define('WXR_VERSION', '1.0');
    25
    36function export_wp($author='') {
     
    7073}
    7174
     75function wxr_site_url() {
     76    global $current_site;
     77   
     78    // mu: the base url
     79    if ( isset($current_site->domain) ) {
     80        return 'http://'.$current_site->domain.$current_site->path;
     81    }
     82    // wp: the blog url
     83    else {
     84        return get_bloginfo_rss('url');
     85    }
     86}
     87
    7288function wxr_cat_name($c) {
    7389    if ( empty($c->name) )
     
    106122    if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
    107123        $cat_name = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
     124        // for backwards compatibility
    108125        $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
     126        // forwards compatibility: use a unique identifier for each cat to avoid clashes
     127        // http://trac.wordpress.org/ticket/5447
     128        $the_list .= "\n\t\t<category domain=\"category\" nicename=\"{$category->slug}\"><![CDATA[$cat_name]]></category>\n";
    109129    }
    110130
     
    112132        $tag_name = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
    113133        $the_list .= "\n\t\t<category domain=\"tag\"><![CDATA[$tag_name]]></category>\n";
     134        // forwards compatibility as above
     135        $the_list .= "\n\t\t<category domain=\"tag\" nicename=\"{$tag->slug}\"><![CDATA[$tag_name]]></category>\n";
    114136    }
    115137
     
    141163    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    142164    xmlns:dc="http://purl.org/dc/elements/1.1/"
    143     xmlns:wp="http://wordpress.org/export/1.0/"
     165    xmlns:wp="http://wordpress.org/export/<?php echo WXR_VERSION; ?>/"
    144166>
    145167
     
    151173    <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
    152174    <language><?php echo get_option('rss_language'); ?></language>
     175    <wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
     176    <wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
     177    <wp:base_blog_url><?php bloginfo_rss('url'); ?></wp:base_blog_url>
    153178<?php if ( $cats ) : foreach ( $cats as $c ) : ?>
    154179    <wp:category><wp:category_nicename><?php echo $c->slug; ?></wp:category_nicename><wp:category_parent><?php echo $c->parent ? $cats[$c->parent]->name : ''; ?></wp:category_parent><?php wxr_cat_name($c); ?><?php wxr_category_description($c); ?></wp:category>
     
    188213<wp:post_type><?php echo $post->post_type; ?></wp:post_type>
    189214<?php
     215if ($post->post_type == 'attachment') { ?>
     216<wp:attachment_url><?php echo wp_get_attachment_url($post->ID); ?></wp:attachment_url>
     217<?php } ?>
     218<?php
    190219$postmeta = $wpdb->get_results("SELECT * FROM $wpdb->postmeta WHERE post_id = $post->ID");
    191220if ( $postmeta ) {
     
    213242<wp:comment_type><?php echo $c->comment_type; ?></wp:comment_type>
    214243<wp:comment_parent><?php echo $c->comment_parent; ?></wp:comment_parent>
     244<wp:comment_user_id><?php echo $c->user_id; ?></wp:comment_user_id>
    215245</wp:comment>
    216246<?php } } ?>
Note: See TracChangeset for help on using the changeset viewer.