Changeset 13573
- Timestamp:
- 03/03/2010 04:45:40 PM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/export.php
r11764 r13573 18 18 19 19 if ( 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 ); 22 45 die(); 23 46 } 24 47 25 48 require_once ('admin-header.php'); 26 ?> 49 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 } ?> 27 55 28 56 <div class="wrap"> … … 38 66 <table class="form-table"> 39 67 <tr> 68 <th><label for="mm_start"><?php _e('Restrict Date'); ?></label></th> 69 <td><strong><?php _e('Start:'); ?></strong> <?php _e('Month'); ?> 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> <?php _e('Year'); ?> 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'); ?> 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> <?php _e('Year'); ?> 81 <input type="text" id="aa_end" name="aa_end" value="" size="4" maxlength="5" /> 82 </td> 83 </tr> 84 <tr> 40 85 <th><label for="author"><?php _e('Restrict Author'); ?></label></th> 41 86 <td> … … 46 91 foreach ( $authors as $id ) { 47 92 $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"; 49 94 } 50 95 ?> 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'); 106 if($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> 51 134 </select> 52 135 </td> -
trunk/wp-admin/includes/export.php
r13055 r13573 24 24 * @param unknown_type $author 25 25 */ 26 function export_wp($author='' ) {26 function export_wp($author='', $category='', $post_type='', $status='', $start_date='', $end_date='') { 27 27 global $wpdb, $post_ids, $post, $wp_taxonomies; 28 28 29 29 do_action('export_wp'); 30 30 31 $filename = 'wordpress.' . date('Y-m-d') . '.xml'; 31 if(strlen($start_date) > 4 && strlen($end_date) > 4) { 32 $filename = 'wordpress.' . $start_date . '.' . $end_date . '.xml'; 33 } else { 34 $filename = 'wordpress.' . date('Y-m-d') . '.xml'; 35 } 32 36 33 37 header('Content-Description: File Transfer'); … … 35 39 header('Content-Type: text/xml; charset=' . get_option('blog_charset'), true); 36 40 37 $where = ''; 38 if ( $author and $author != 'all' ) { 39 $author_id = (int) $author; 40 $where = $wpdb->prepare(" WHERE post_author = %d ", $author_id); 41 } 41 if ( $post_type and $post_type != 'all' ) { 42 $where = $wpdb->prepare("WHERE post_type = %s ", $post_type); 43 } else { 44 $where = "WHERE post_type != 'revision' "; 45 } 46 if ( $author and $author != 'all' ) { 47 $author_id = (int) $author; 48 $where .= $wpdb->prepare("AND post_author = %d ", $author_id); 49 } 50 if ( $start_date and $start_date != 'all' ) { 51 $where .= $wpdb->prepare("AND post_date >= %s ", $start_date); 52 } 53 if ( $end_date and $end_date != 'all' ) { 54 $where .= $wpdb->prepare("AND post_date < %s ", $end_date); 55 } 56 if ( $category and $category != 'all' ) { 57 $taxomony_id = (int) $category; 58 $where .= $wpdb->prepare("AND ID IN (SELECT object_id FROM {$wpdb->term_relationships} " . "WHERE term_taxonomy_id = %d) ", $taxomony_id); 59 } 60 if ( $status and $status != 'all' ) { 61 $where .= $wpdb->prepare("AND post_status = %s ", $status); 62 } 42 63 43 64 // grab a snapshot of post IDs, just in case it changes during the export … … 301 322 $posts = $wpdb->get_results("SELECT * FROM $wpdb->posts $where ORDER BY post_date_gmt ASC"); 302 323 foreach ($posts as $post) { 303 // Don't export revisions. They bloat the export.304 if ( 'revision' == $post->post_type )305 continue;306 324 setup_postdata($post); 307 325
Note: See TracChangeset
for help on using the changeset viewer.