Changeset 42343 for trunk/src/wp-admin/export.php
- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/export.php
r38725 r42343 10 10 require_once( dirname( __FILE__ ) . '/admin.php' ); 11 11 12 if ( !current_user_can('export') ) 13 wp_die(__('Sorry, you are not allowed to export the content of this site.')); 12 if ( ! current_user_can( 'export' ) ) { 13 wp_die( __( 'Sorry, you are not allowed to export the content of this site.' ) ); 14 } 14 15 15 16 /** Load WordPress export API */ 16 17 require_once( ABSPATH . 'wp-admin/includes/export.php' ); 17 $title = __( 'Export');18 $title = __( 'Export' ); 18 19 19 20 /** … … 26 27 <script type="text/javascript"> 27 28 jQuery(document).ready(function($){ 28 29 30 31 29 var form = $('#export-filters'), 30 filters = form.find('.export-filters'); 31 filters.hide(); 32 form.find('input:radio').change(function() { 32 33 filters.slideUp('fast'); 33 34 switch ( $(this).val() ) { … … 36 37 case 'pages': $('#page-filters').slideDown(); break; 37 38 } 38 39 }); 39 40 }); 40 41 </script> … … 43 44 add_action( 'admin_head', 'export_add_js' ); 44 45 45 get_current_screen()->add_help_tab( array( 46 'id' => 'overview', 47 'title' => __('Overview'), 48 'content' => '<p>' . __('You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.') . '</p>' . 49 '<p>' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '</p>', 50 ) ); 46 get_current_screen()->add_help_tab( 47 array( 48 'id' => 'overview', 49 'title' => __( 'Overview' ), 50 'content' => '<p>' . __( 'You can export a file of your site’s content in order to import it into another installation or platform. The export file will be an XML file format called WXR. Posts, pages, comments, custom fields, categories, and tags can be included. You can choose for the WXR file to include only certain posts or pages by setting the dropdown filters to limit the export by category, author, date range by month, or publishing status.' ) . '</p>' . 51 '<p>' . __( 'Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.' ) . '</p>', 52 ) 53 ); 51 54 52 55 get_current_screen()->set_help_sidebar( 53 '<p><strong>' . __( 'For more information:') . '</strong></p>' .54 '<p>' . __( '<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>') . '</p>' .55 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'56 '<p><strong>' . __( 'For more information:' ) . '</strong></p>' . 57 '<p>' . __( '<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>' ) . '</p>' . 58 '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>' 56 59 ); 57 60 … … 65 68 $args['content'] = 'post'; 66 69 67 if ( $_GET['cat'] ) 70 if ( $_GET['cat'] ) { 68 71 $args['category'] = (int) $_GET['cat']; 69 70 if ( $_GET['post_author'] ) 72 } 73 74 if ( $_GET['post_author'] ) { 71 75 $args['author'] = (int) $_GET['post_author']; 76 } 72 77 73 78 if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) { 74 79 $args['start_date'] = $_GET['post_start_date']; 75 $args['end_date'] = $_GET['post_end_date'];76 } 77 78 if ( $_GET['post_status'] ) 80 $args['end_date'] = $_GET['post_end_date']; 81 } 82 83 if ( $_GET['post_status'] ) { 79 84 $args['status'] = $_GET['post_status']; 85 } 80 86 } elseif ( 'pages' == $_GET['content'] ) { 81 87 $args['content'] = 'page'; 82 88 83 if ( $_GET['page_author'] ) 89 if ( $_GET['page_author'] ) { 84 90 $args['author'] = (int) $_GET['page_author']; 91 } 85 92 86 93 if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) { 87 94 $args['start_date'] = $_GET['page_start_date']; 88 $args['end_date'] = $_GET['page_end_date'];89 } 90 91 if ( $_GET['page_status'] ) 95 $args['end_date'] = $_GET['page_end_date']; 96 } 97 98 if ( $_GET['page_status'] ) { 92 99 $args['status'] = $_GET['page_status']; 100 } 93 101 } elseif ( 'attachment' == $_GET['content'] ) { 94 102 $args['content'] = 'attachment'; … … 96 104 if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) { 97 105 $args['start_date'] = $_GET['attachment_start_date']; 98 $args['end_date'] = $_GET['attachment_end_date']; 99 } 100 } 101 else { 106 $args['end_date'] = $_GET['attachment_end_date']; 107 } 108 } else { 102 109 $args['content'] = $_GET['content']; 103 110 } … … 131 138 global $wpdb, $wp_locale; 132 139 133 $months = $wpdb->get_results( $wpdb->prepare( " 140 $months = $wpdb->get_results( 141 $wpdb->prepare( 142 " 134 143 SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month 135 144 FROM $wpdb->posts 136 145 WHERE post_type = %s AND post_status != 'auto-draft' 137 146 ORDER BY post_date DESC 138 ", $post_type ) ); 147 ", $post_type 148 ) 149 ); 139 150 140 151 $month_count = count( $months ); 141 if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) )152 if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { 142 153 return; 154 } 143 155 144 156 foreach ( $months as $date ) { 145 if ( 0 == $date->year ) 157 if ( 0 == $date->year ) { 146 158 continue; 159 } 147 160 148 161 $month = zeroise( $date->month, 2 ); … … 155 168 <h1><?php echo esc_html( $title ); ?></h1> 156 169 157 <p><?php _e( 'When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>158 <p><?php _e( 'This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.'); ?></p>159 <p><?php _e( 'Once you’ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.'); ?></p>170 <p><?php _e( 'When you click the button below WordPress will create an XML file for you to save to your computer.' ); ?></p> 171 <p><?php _e( 'This format, which we call WordPress eXtended RSS or WXR, will contain your posts, pages, comments, custom fields, categories, and tags.' ); ?></p> 172 <p><?php _e( 'Once you’ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.' ); ?></p> 160 173 161 174 <h2><?php _e( 'Choose what to export' ); ?></h2> … … 171 184 <li> 172 185 <label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span> 173 <?php wp_dropdown_categories( array( 'show_option_all' => __( 'All') ) ); ?>186 <?php wp_dropdown_categories( array( 'show_option_all' => __( 'All' ) ) ); ?> 174 187 </label> 175 188 </li> … … 178 191 <?php 179 192 $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" ); 180 wp_dropdown_users( array( 181 'include' => $authors, 182 'name' => 'post_author', 183 'multi' => true, 184 'show_option_all' => __( 'All' ), 185 'show' => 'display_name_with_login', 186 ) ); ?> 193 wp_dropdown_users( 194 array( 195 'include' => $authors, 196 'name' => 'post_author', 197 'multi' => true, 198 'show_option_all' => __( 'All' ), 199 'show' => 'display_name_with_login', 200 ) 201 ); 202 ?> 187 203 </label> 188 204 </li> … … 206 222 <select name="post_status" id="post-status"> 207 223 <option value="0"><?php _e( 'All' ); ?></option> 208 <?php $post_stati = get_post_stati( array( 'internal' => false ), 'objects' ); 209 foreach ( $post_stati as $status ) : ?> 224 <?php 225 $post_stati = get_post_stati( array( 'internal' => false ), 'objects' ); 226 foreach ( $post_stati as $status ) : 227 ?> 210 228 <option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option> 211 229 <?php endforeach; ?> … … 220 238 <?php 221 239 $authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" ); 222 wp_dropdown_users( array( 223 'include' => $authors, 224 'name' => 'page_author', 225 'multi' => true, 226 'show_option_all' => __( 'All' ), 227 'show' => 'display_name_with_login', 228 ) ); ?> 240 wp_dropdown_users( 241 array( 242 'include' => $authors, 243 'name' => 'page_author', 244 'multi' => true, 245 'show_option_all' => __( 'All' ), 246 'show' => 'display_name_with_login', 247 ) 248 ); 249 ?> 229 250 </label> 230 251 </li> … … 255 276 </ul> 256 277 257 <?php foreach ( get_post_types( array( '_builtin' => false, 'can_export' => true ), 'objects' ) as $post_type ) : ?> 278 <?php 279 foreach ( get_post_types( 280 array( 281 '_builtin' => false, 282 'can_export' => true, 283 ), 'objects' 284 ) as $post_type ) : 285 ?> 258 286 <p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p> 259 287 <?php endforeach; ?> … … 288 316 ?> 289 317 290 <?php submit_button( __( 'Download Export File') ); ?>318 <?php submit_button( __( 'Download Export File' ) ); ?> 291 319 </form> 292 320 </div>
Note: See TracChangeset
for help on using the changeset viewer.