WordPress.org

Make WordPress Core


Ignore:
Timestamp:
03/03/2010 04:45:40 PM (11 years ago)
Author:
wpmuguru
Message:

add features to export, see #10317

File:
1 edited

Legend:

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

    r11764 r13573  
    1818
    1919if ( isset( $_GET['download'] ) ) {
    20     $author = isset($_GET['author']) ? $_GET['author'] : 'all';
    21     export_wp( $author );
     20        $author = isset($_GET['author']) ? $_GET['author'] : 'all';
     21        $category = isset($_GET['category']) ? $_GET['category'] : 'all';
     22        $post_type = isset($_GET['post_type']) ? stripslashes_deep($_GET['post_type']) : 'all';
     23        $status = isset($_GET['status']) ? stripslashes_deep($_GET['status']) : 'all';
     24        $mm_start = isset($_GET['mm_start']) ? $_GET['mm_start'] : 'all';
     25        $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 );
     30        } else {
     31            $start_date = 'all';
     32        }
     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 );
     41        } else {
     42            $end_date = 'all';
     43        }
     44    export_wp( $author, $category, $post_type, $status, $start_date, $end_date );
    2245    die();
    2346}
    2447
    2548require_once ('admin-header.php');
    26 ?>
     49
     50$months = "";
     51for ( $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} ?>
    2755
    2856<div class="wrap">
     
    3866<table class="form-table">
    3967<tr>
     68<th><label for="mm_start"><?php _e('Restrict Date'); ?></label></th>
     69<td><strong><?php _e('Start:'); ?></strong> <?php _e('Month'); ?>&nbsp;
     70<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;
     77<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" />
     82</td>
     83</tr>
     84<tr>
    4085<th><label for="author"><?php _e('Restrict Author'); ?></label></th>
    4186<td>
     
    4691foreach ( $authors as $id ) {
    4792    $o = get_userdata( $id );
    48     echo "<option value='" . esc_attr($o->ID) . "'>$o->display_name</option>";
     93    echo "<option value='{$o->ID}'>{$o->display_name}</option>\n";
    4994}
    5095?>
     96</select>
     97</td>
     98</tr>
     99<tr>
     100<th><label for="category"><?php _e('Restrict Category'); ?></label></th>
     101<td>
     102<select name="category" id="category">
     103<option value="all" selected="selected"><?php _e('All Categories'); ?></option>
     104<?php
     105$categories = (array) get_categories('get=all');
     106if($categories) {
     107    foreach ( $categories as $cat ) {
     108        echo "<option value='{$cat->term_taxonomy_id}'>{$cat->name}</option>\n";
     109    }
     110}
     111?>
     112</select>
     113</td>
     114</tr>
     115<tr>
     116<th><label for="post_type"><?php _e('Restrict Content'); ?></label></th>
     117<td>
     118<select name="post_type" id="post_type">
     119<option value="all" selected="selected"><?php _e('All Content'); ?></option>
     120<option value="page"><?php _e('Pages'); ?></option>
     121<option value="post"><?php _e('Posts'); ?></option>
     122</select>
     123</td>
     124</tr>
     125<tr>
     126<th><label for="status"><?php _e('Restrict Status'); ?></label></th>
     127<td>
     128<select name="status" id="status">
     129<option value="all" selected="selected"><?php _e('All Statuses'); ?></option>
     130<option value="draft"><?php _e('Draft'); ?></option>
     131<option value="private"><?php _e('Privately published'); ?></option>
     132<option value="publish"><?php _e('Published'); ?></option>
     133<option value="future"><?php _e('Scheduled'); ?></option>
    51134</select>
    52135</td>
Note: See TracChangeset for help on using the changeset viewer.