WordPress.org

Make WordPress Core

Ticket #5454: export-minor-additions-r6367.patch

File export-minor-additions-r6367.patch, 3.6 KB (added by tellyworth, 6 years ago)
  • wordpress/wp-admin/includes/export.php

     
    11<?php 
    22 
     3// version number for the export format.  bump this when something changes that might affect compatibility. 
     4define('WXR_VERSION', '1.0'); 
     5 
    36function export_wp($author='') { 
    47global $wpdb, $post_ids, $post; 
    58 
     
    6972        return $str; 
    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) ) 
    7490                return; 
     
    105121 
    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 
    111131        if ( !empty($tags) ) foreach ( (array) $tags as $tag ) { 
    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 
    116138        echo $the_list; 
     
    140162        xmlns:content="http://purl.org/rss/1.0/modules/content/" 
    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 
    146168<channel> 
     
    150172        <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), false); ?></pubDate> 
    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> 
    155180<?php endforeach; endif; ?> 
     
    187212<wp:menu_order><?php echo $post->menu_order; ?></wp:menu_order> 
    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 ) { 
    192221?> 
     
    212241<wp:comment_approved><?php echo $c->comment_approved; ?></wp:comment_approved> 
    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 } } ?> 
    217247        </item>