WordPress.org

Make WordPress Core

Ticket #11118: export.patch

File export.patch, 2.0 KB (added by briancolinger, 12 years ago)

re-structuring the xml tags for users

  • export.

    old new  
    1414 * @since unknown
    1515 * @var string
    1616 */
    17 define('WXR_VERSION', '1.0');
     17define('WXR_VERSION', '1.1');
    1818
    1919/**
    2020 * {@internal Missing Short Description}}
     
    212212        echo $the_list;
    213213}
    214214
     215/**
     216 * Get list of blog authors
     217 *
     218 * @param mixed UserID or all
     219 * @return array of user objects
     220 */
     221
     222function wxr_get_authors( $author ) {
     223        global $wpdb;
     224        $users = array();
     225
     226        if ( 'all' == $author) {
     227                $user_ids = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" );
     228                foreach ( $user_ids as $id )
     229                        $users[] = get_userdata( $id );
     230        } else {
     231                $users[] = get_userdata( $author );
     232        }
     233
     234        return $users;
     235}
     236
    215237echo '<?xml version="1.0" encoding="' . get_bloginfo('charset') . '"?' . ">\n";
    216238
    217239?>
     
    250272        <wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
    251273        <wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
    252274        <wp:base_blog_url><?php bloginfo_rss('url'); ?></wp:base_blog_url>
     275
     276<?php
     277$wp_users = wxr_get_authors( $author );
     278?>
     279<wp:users>
     280<?php foreach( $wp_users as $wp_user ) : ?>
     281        <wp:user>
     282                <wp:user_nicename><?php echo $wp_user->user_nicename; ?></wp:user_nicename>
     283                <wp:user_email><?php echo $wp_user->user_email; ?></wp:user_email>
     284                <wp:user_display_name><?php echo wxr_cdata( $wp_user->display_name ); ?></wp:user_display_name>
     285                <wp:user_first_name><?php echo wxr_cdata( $wp_user->user_firstname ); ?></wp:user_first_name>
     286                <wp:user_last_name><?php echo wxr_cdata( $wp_user->user_lastname ); ?></wp:user_last_name>
     287        </wp:user>
     288<?php endforeach; ?>
     289</wp:users>
     290
    253291<?php if ( $cats ) : foreach ( $cats as $c ) : ?>
    254292        <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>
    255293<?php endforeach; endif; ?>