equal
deleted
inserted
replaced
5 * @package WordPress |
5 * @package WordPress |
6 * @subpackage Administration |
6 * @subpackage Administration |
7 */ |
7 */ |
8 |
8 |
9 /** Load WordPress Bootstrap */ |
9 /** Load WordPress Bootstrap */ |
10 require_once( dirname( __FILE__ ) . '/admin.php' ); |
10 require_once __DIR__ . '/admin.php'; |
11 |
11 |
12 if ( ! current_user_can( 'export' ) ) { |
12 if ( ! current_user_can( 'export' ) ) { |
13 wp_die( __( 'Sorry, you are not allowed to export the content of this site.' ) ); |
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 /** Load WordPress export API */ |
17 require_once( ABSPATH . 'wp-admin/includes/export.php' ); |
17 require_once ABSPATH . 'wp-admin/includes/export.php'; |
18 $title = __( 'Export' ); |
18 $title = __( 'Export' ); |
19 |
19 |
20 /** |
20 /** |
21 * Display JavaScript on the page. |
21 * Display JavaScript on the page. |
22 * |
22 * |
24 */ |
24 */ |
25 function export_add_js() { |
25 function export_add_js() { |
26 ?> |
26 ?> |
27 <script type="text/javascript"> |
27 <script type="text/javascript"> |
28 jQuery(document).ready(function($){ |
28 jQuery(document).ready(function($){ |
29 var form = $('#export-filters'), |
29 var form = $('#export-filters'), |
30 filters = form.find('.export-filters'); |
30 filters = form.find('.export-filters'); |
31 filters.hide(); |
31 filters.hide(); |
32 form.find('input:radio').change(function() { |
32 form.find('input:radio').change(function() { |
33 filters.slideUp('fast'); |
33 filters.slideUp('fast'); |
34 switch ( $(this).val() ) { |
34 switch ( $(this).val() ) { |
35 case 'attachment': $('#attachment-filters').slideDown(); break; |
35 case 'attachment': $('#attachment-filters').slideDown(); break; |
36 case 'posts': $('#post-filters').slideDown(); break; |
36 case 'posts': $('#post-filters').slideDown(); break; |
37 case 'pages': $('#page-filters').slideDown(); break; |
37 case 'pages': $('#page-filters').slideDown(); break; |
38 } |
38 } |
39 }); |
39 }); |
40 }); |
40 }); |
41 </script> |
41 </script> |
42 <?php |
42 <?php |
43 } |
43 } |
44 add_action( 'admin_head', 'export_add_js' ); |
44 add_action( 'admin_head', 'export_add_js' ); |
52 ) |
52 ) |
53 ); |
53 ); |
54 |
54 |
55 get_current_screen()->set_help_sidebar( |
55 get_current_screen()->set_help_sidebar( |
56 '<p><strong>' . __( 'For more information:' ) . '</strong></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>' . |
57 '<p>' . __( '<a href="https://wordpress.org/support/article/tools-export-screen/">Documentation on Export</a>' ) . '</p>' . |
58 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
58 '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>' |
59 ); |
59 ); |
60 |
60 |
61 // If the 'download' URL parameter is set, a WXR export file is baked and returned. |
61 // If the 'download' URL parameter is set, a WXR export file is baked and returned. |
62 if ( isset( $_GET['download'] ) ) { |
62 if ( isset( $_GET['download'] ) ) { |
63 $args = array(); |
63 $args = array(); |
64 |
64 |
65 if ( ! isset( $_GET['content'] ) || 'all' == $_GET['content'] ) { |
65 if ( ! isset( $_GET['content'] ) || 'all' === $_GET['content'] ) { |
66 $args['content'] = 'all'; |
66 $args['content'] = 'all'; |
67 } elseif ( 'posts' == $_GET['content'] ) { |
67 } elseif ( 'posts' === $_GET['content'] ) { |
68 $args['content'] = 'post'; |
68 $args['content'] = 'post'; |
69 |
69 |
70 if ( $_GET['cat'] ) { |
70 if ( $_GET['cat'] ) { |
71 $args['category'] = (int) $_GET['cat']; |
71 $args['category'] = (int) $_GET['cat']; |
72 } |
72 } |
81 } |
81 } |
82 |
82 |
83 if ( $_GET['post_status'] ) { |
83 if ( $_GET['post_status'] ) { |
84 $args['status'] = $_GET['post_status']; |
84 $args['status'] = $_GET['post_status']; |
85 } |
85 } |
86 } elseif ( 'pages' == $_GET['content'] ) { |
86 } elseif ( 'pages' === $_GET['content'] ) { |
87 $args['content'] = 'page'; |
87 $args['content'] = 'page'; |
88 |
88 |
89 if ( $_GET['page_author'] ) { |
89 if ( $_GET['page_author'] ) { |
90 $args['author'] = (int) $_GET['page_author']; |
90 $args['author'] = (int) $_GET['page_author']; |
91 } |
91 } |
96 } |
96 } |
97 |
97 |
98 if ( $_GET['page_status'] ) { |
98 if ( $_GET['page_status'] ) { |
99 $args['status'] = $_GET['page_status']; |
99 $args['status'] = $_GET['page_status']; |
100 } |
100 } |
101 } elseif ( 'attachment' == $_GET['content'] ) { |
101 } elseif ( 'attachment' === $_GET['content'] ) { |
102 $args['content'] = 'attachment'; |
102 $args['content'] = 'attachment'; |
103 |
103 |
104 if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) { |
104 if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) { |
105 $args['start_date'] = $_GET['attachment_start_date']; |
105 $args['start_date'] = $_GET['attachment_start_date']; |
106 $args['end_date'] = $_GET['attachment_end_date']; |
106 $args['end_date'] = $_GET['attachment_end_date']; |
120 |
120 |
121 export_wp( $args ); |
121 export_wp( $args ); |
122 die(); |
122 die(); |
123 } |
123 } |
124 |
124 |
125 require_once( ABSPATH . 'wp-admin/admin-header.php' ); |
125 require_once ABSPATH . 'wp-admin/admin-header.php'; |
126 |
126 |
127 /** |
127 /** |
128 * Create the date options fields for exporting a given post type. |
128 * Create the date options fields for exporting a given post type. |
129 * |
129 * |
130 * @global wpdb $wpdb WordPress database abstraction object. |
130 * @global wpdb $wpdb WordPress database abstraction object. |
131 * @global WP_Locale $wp_locale Date and Time Locale object. |
131 * @global WP_Locale $wp_locale WordPress date and time locale object. |
132 * |
132 * |
133 * @since 3.1.0 |
133 * @since 3.1.0 |
134 * |
134 * |
135 * @param string $post_type The post type. Default 'post'. |
135 * @param string $post_type The post type. Default 'post'. |
136 */ |
136 */ |
142 " |
142 " |
143 SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month |
143 SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month |
144 FROM $wpdb->posts |
144 FROM $wpdb->posts |
145 WHERE post_type = %s AND post_status != 'auto-draft' |
145 WHERE post_type = %s AND post_status != 'auto-draft' |
146 ORDER BY post_date DESC |
146 ORDER BY post_date DESC |
147 ", |
147 ", |
148 $post_type |
148 $post_type |
149 ) |
149 ) |
150 ); |
150 ); |
151 |
151 |
152 $month_count = count( $months ); |
152 $month_count = count( $months ); |
153 if ( ! $month_count || ( 1 == $month_count && 0 == $months[0]->month ) ) { |
153 if ( ! $month_count || ( 1 === $month_count && 0 === (int) $months[0]->month ) ) { |
154 return; |
154 return; |
155 } |
155 } |
156 |
156 |
157 foreach ( $months as $date ) { |
157 foreach ( $months as $date ) { |
158 if ( 0 == $date->year ) { |
158 if ( 0 === (int) $date->year ) { |
159 continue; |
159 continue; |
160 } |
160 } |
161 |
161 |
162 $month = zeroise( $date->month, 2 ); |
162 $month = zeroise( $date->month, 2 ); |
163 echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>'; |
163 echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>'; |
178 <legend class="screen-reader-text"><?php _e( 'Content to export' ); ?></legend> |
178 <legend class="screen-reader-text"><?php _e( 'Content to export' ); ?></legend> |
179 <input type="hidden" name="download" value="true" /> |
179 <input type="hidden" name="download" value="true" /> |
180 <p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e( 'All content' ); ?></label></p> |
180 <p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e( 'All content' ); ?></label></p> |
181 <p class="description" id="all-content-desc"><?php _e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus, and custom posts.' ); ?></p> |
181 <p class="description" id="all-content-desc"><?php _e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus, and custom posts.' ); ?></p> |
182 |
182 |
183 <p><label><input type="radio" name="content" value="posts" /> <?php _e( 'Posts' ); ?></label></p> |
183 <p><label><input type="radio" name="content" value="posts" /> <?php _ex( 'Posts', 'post type general name' ); ?></label></p> |
184 <ul id="post-filters" class="export-filters"> |
184 <ul id="post-filters" class="export-filters"> |
185 <li> |
185 <li> |
186 <label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span> |
186 <label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span> |
187 <?php wp_dropdown_categories( array( 'show_option_all' => __( 'All' ) ) ); ?> |
187 <?php wp_dropdown_categories( array( 'show_option_all' => __( 'All' ) ) ); ?> |
188 </label> |
188 </label> |
319 |
319 |
320 <?php submit_button( __( 'Download Export File' ) ); ?> |
320 <?php submit_button( __( 'Download Export File' ) ); ?> |
321 </form> |
321 </form> |
322 </div> |
322 </div> |
323 |
323 |
324 <?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?> |
324 <?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?> |