Make WordPress Core


Ignore:
Timestamp:
05/04/2010 05:31:36 PM (14 years ago)
Author:
wpmuguru
Message:

export improvements, props blepoxp, see #10317

File:
1 edited

Legend:

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

    r14313 r14444  
    1919if ( isset( $_GET['download'] ) ) {
    2020        $author = isset($_GET['author']) ? $_GET['author'] : 'all';
    21         $category = isset($_GET['category']) ? $_GET['category'] : 'all';
     21        $taxonomy = array();
     22        foreach ( get_taxonomies( array( 'show_ui' => true ) ) as $tax )
     23            $taxonomy[ $tax ] = ! empty( $_GET['taxonomy'][ $tax ] ) ? $_GET['taxonomy'][ $tax ] : 'all';
    2224        $post_type = isset($_GET['post_type']) ? stripslashes_deep($_GET['post_type']) : 'all';
    2325        $status = isset($_GET['status']) ? stripslashes_deep($_GET['status']) : 'all';
    2426        $mm_start = isset($_GET['mm_start']) ? $_GET['mm_start'] : 'all';
    2527        $mm_end = isset($_GET['mm_end']) ? $_GET['mm_end'] : 'all';
    26         $aa_start = isset($_GET['aa_start']) ? intval($_GET['aa_start']) : 0;
    27         $aa_end = isset($_GET['aa_end']) ? intval($_GET['aa_end']) : 0;
    28         if($mm_start != 'all' && $aa_start > 0) {
    29             $start_date = sprintf( "%04d-%02d-%02d", $aa_start, $mm_start, 1 );
     28        if( $mm_start != 'all' ) {
     29            $start_date = sprintf( "%04d-%02d-%02d", substr( $mm_start, 0, 4 ), substr( $mm_start, 5, 2 ), 1 );
    3030        } else {
    3131            $start_date = 'all';
    3232        }
    33         if($mm_end != 'all' && $aa_end > 0) {
    34             if($mm_end == 12) {
    35                 $mm_end = 1;
    36                 $aa_end++;
    37             } else {
    38                 $mm_end++;
    39             }
    40             $end_date = sprintf( "%04d-%02d-%02d", $aa_end, $mm_end, 1 );
     33        if( $mm_end != 'all' ) {
     34            $end_date = sprintf( "%04d-%02d-%02d", substr( $mm_end, 0, 4 ), substr( $mm_end, 5, 2 ), 1 );
    4135        } else {
    4236            $end_date = 'all';
    4337        }
    44     export_wp( $author, $category, $post_type, $status, $start_date, $end_date );
     38
     39    export_wp( array( 'author' => $author, 'taxonomy' => $taxonomy, 'post_type' => $post_type, 'post_status' => $status, 'start_date' => $start_date, 'end_date' => $end_date ) );
    4540    die();
    4641}
     
    4843require_once ('admin-header.php');
    4944
    50 $months = "";
    51 for ( $i = 1; $i < 13; $i++ ) {
    52     $months .= "\t\t\t<option value=\"" . zeroise($i, 2) . '">' .
    53         $wp_locale->get_month_abbrev( $wp_locale->get_month( $i ) ) . "</option>\n";
    54 } ?>
     45$dateoptions = '';
     46if ( $monthyears = $wpdb->get_results( "SELECT YEAR(post_date) AS `year`, MONTH(post_date) AS `month`, count(ID) as posts FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date DESC " ) ) {
     47    foreach ( $monthyears as $monthyear ) {
     48        $dateoptions .= "\t<option value=\"" . $monthyear->year . '-' . zeroise( $monthyear->month, 2 ) . '">' . $wp_locale->get_month( $monthyear->month ) . ' ' . $monthyear->year . "</option>\n";
     49    }
     50}
     51
     52?>
    5553
    5654<div class="wrap">
     
    6765<tr>
    6866<th><label for="mm_start"><?php _e('Restrict Date'); ?></label></th>
    69 <td><strong><?php _e('Start:'); ?></strong> <?php _e('Month'); ?>&nbsp;
     67<td><strong><?php _e('Start:'); ?></strong>
    7068<select name="mm_start" id="mm_start">
    71 <option value="all" selected="selected"><?php _e('All Dates'); ?></option>
    72 <?php echo $months; ?>
    73 </select>&nbsp;<?php _e('Year'); ?>&nbsp;
    74 <input type="text" id="aa_start" name="aa_start" value="" size="4" maxlength="5" />
    75 </td>
    76 <td><strong><?php _e('End:'); ?></strong> <?php _e('Month'); ?>&nbsp;
     69    <option value="all" selected="selected"><?php _e('All Dates'); ?></option>
     70<?php echo ($dateoptions); ?>
     71</select> <br/>
     72<strong><?php _e('End:'); ?></strong>
    7773<select name="mm_end" id="mm_end">
    78 <option value="all" selected="selected"><?php _e('All Dates'); ?></option>
    79 <?php echo $months; ?>
    80 </select>&nbsp;<?php _e('Year'); ?>&nbsp;
    81 <input type="text" id="aa_end" name="aa_end" value="" size="4" maxlength="5" />
     74    <option value="all" selected="selected"><?php _e('All Dates'); ?></option>
     75<?php echo $dateoptions; ?>
     76</select>
    8277</td>
    8378</tr>
     
    8883<option value="all" selected="selected"><?php _e('All Authors'); ?></option>
    8984<?php
    90 $authors = $wpdb->get_results( "SELECT DISTINCT u.id, u.display_name FROM $wpdb->users u INNER JOIN $wpdb->posts p ON u.id = p.post_author ORDER BY u.display_name" );
    91 foreach ( (array) $authors as $author )
    92        echo "<option value='{$author->id}'>{$author->display_name}</option>\n";
    93 ?>
    94 </select>
    95 </td>
    96 </tr>
    97 <tr>
    98 <th><label for="category"><?php _e('Restrict Category'); ?></label></th>
    99 <td>
    100 <select name="category" id="category">
    101 <option value="all" selected="selected"><?php _e('All Categories'); ?></option>
    102 <?php
    103 $categories = (array) get_categories('get=all');
    104 if($categories) {
    105     foreach ( $categories as $cat ) {
    106         echo "<option value='{$cat->term_taxonomy_id}'>{$cat->name}</option>\n";
    107     }
     85$authors = $wpdb->get_results( "SELECT DISTINCT u.id, u.display_name FROM $wpdb->users u INNER JOIN $wpdb->posts p WHERE u.id = p.post_author ORDER BY u.display_name" );
     86foreach ( (array) $authors as $author ) {
     87    echo "<option value='{$author->id}'>{$author->display_name}</option>\n";
    10888}
    10989?>
     
    11292</tr>
    11393<tr>
     94<th><?php _e('Restrict Taxonomies'); ?></th>
     95<td>
     96<?php foreach ( get_taxonomies( array( 'show_ui' => true ), 'objects' ) as $tax_obj ) {
     97    $term_dropdown = wp_dropdown_categories( array( 'taxonomy' => $tax_obj->name, 'hide_if_empty' => true, 'show_option_all' => __( 'All Terms' ), 'name' => 'taxonomy[' . $tax_obj->name . ']', 'id' => 'taxonomy-' . $tax_obj->name, 'class' => '', 'echo' => false ) );
     98    if ( $term_dropdown )
     99        echo '<label for="taxonomy-' . $tax_obj->name . '">' . $tax_obj->label . '</label>: ' . $term_dropdown . '<br/>';
     100}
     101?>
     102</td>
     103</tr>
     104<tr>
    114105<th><label for="post_type"><?php _e('Restrict Content'); ?></label></th>
    115106<td>
    116107<select name="post_type" id="post_type">
    117 <option value="all" selected="selected"><?php _e('All Content'); ?></option>
    118 <option value="page"><?php _e('Pages'); ?></option>
    119 <option value="post"><?php _e('Posts'); ?></option>
     108    <option value="all" selected="selected"><?php _e('All Content'); ?></option>
     109    <?php foreach ( get_post_types( array( 'public' => true, 'can_export' => true ), 'objects' ) as $post_type_obj ) { ?>
     110        <option value="<?php echo $post_type_obj->name; ?>"><?php echo $post_type_obj->label; ?></option>
     111    <?php } ?>
    120112</select>
    121113</td>
     
    125117<td>
    126118<select name="status" id="status">
    127 <option value="all" selected="selected"><?php _e('All Statuses'); ?></option>
    128 <option value="draft"><?php _e('Draft'); ?></option>
    129 <option value="private"><?php _e('Privately published'); ?></option>
    130 <option value="publish"><?php _e('Published'); ?></option>
    131 <option value="future"><?php _e('Scheduled'); ?></option>
     119    <option value="all" selected="selected"><?php _e('All Statuses'); ?></option>
     120<?php foreach ( get_post_stati( array( 'internal' => false ), 'objects' ) as $post_status_obj ) { ?>
     121    <option value="<?php echo $post_status_obj->name; ?>"><?php echo $post_status_obj->label; ?></option>
     122<?php } ?>
    132123</select>
    133124</td>
Note: See TracChangeset for help on using the changeset viewer.