Make WordPress Core


Ignore:
Timestamp:
11/18/2006 11:13:15 PM (18 years ago)
Author:
matt
Message:

Add IDs to export, and let it filter by authors.

File:
1 edited

Legend:

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

    r4480 r4485  
    1616<p><?php _e('This format, which we call WordPress eXtended RSS or WXR, will contain your posts, comments, custom fields, and categories.'); ?></p>
    1717<form action="" method="get">
     18<h3><?php _e('Optional options'); ?></h3>
     19
     20<table>
     21<tr>
     22<th><?php _e('Restrict Author:'); ?></th>
     23<td>
     24<select name="author">
     25<option value="all" selected="selected"><?php _e('All'); ?></option>
     26<?php
     27$authors = $wpdb->get_col( "SELECT post_author FROM $wpdb->posts GROUP BY post_author" ); 
     28foreach ( $authors as $id ) {
     29    $o = get_userdata( $id );
     30    echo "<option value='$o->ID'>$o->display_name</option>";
     31}
     32?>
     33</select>
     34</td>
     35</tr>
     36</table>
    1837<p class="submit"><input type="submit" name="submit" value="<?php _e('Download Export File'); ?> &raquo;" />
    1938<input type="hidden" name="download" value="true" />
     
    2645
    2746function export_wp() {
    28     global $wpdb, $posts, $post;
    29     $filename = 'wordpress.' . date('Y-m-d') . '.xml';
     47global $wpdb, $posts, $post;
     48
     49$filename = 'wordpress.' . date('Y-m-d') . '.xml';
     50
    3051header('Content-Description: File Transfer');
    3152header('Content-Type: application/octet-stream');
    3253header("Content-Disposition: attachment; filename=$filename");
    3354header('Content-type: text/wxr+xml; charset=' . get_option('blog_charset'), true);
    34 //$posts = query_posts('');
    35 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts ORDER BY post_date_gmt ASC");
     55
     56$where = '';
     57if ( isset( $_GET['author'] ) && $_GET['author'] != 'all' ) {
     58    $author_id = (int) $_GET['author'];
     59    $where = " WHERE post_author = '$author_id' ";
     60}
     61
     62$posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
    3663?>
    3764<!-- This is a WordPress eXtended RSS file generated by WordPress as an export of your blog. -->
     
    7299<description></description>
    73100<content:encoded><![CDATA[<?php echo $post->post_content ?>]]></content:encoded>
     101<wp:post_id><?php echo $post->ID; ?></wp:post_id>
    74102<wp:post_date><?php echo $post->post_date; ?></wp:post_date>
    75103<wp:post_date_gmt><?php echo $post->post_date_gmt; ?></wp:post_date_gmt>
     
    95123if ( $comments ) { foreach ( $comments as $c ) { ?>
    96124<wp:comment>
     125<wp:comment_id><?php echo $c->comment_ID; ?></wp:comment_id>
    97126<wp:comment_author><?php echo $c->comment_author; ?></wp:comment_author>
    98127<wp:comment_author_email><?php echo $c->comment_author_email; ?></wp:comment_author_email>
Note: See TracChangeset for help on using the changeset viewer.