wp/wp-admin/export.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     8 
     8 
     9 /** Load WordPress Bootstrap */
     9 /** Load WordPress Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    11 
    11 
    12 if ( !current_user_can('export') )
    12 if ( !current_user_can('export') )
    13 	wp_die(__('You do not have sufficient permissions 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 /** Load WordPress export API */
    15 /** Load WordPress export API */
    16 require_once( ABSPATH . 'wp-admin/includes/export.php' );
    16 require_once( ABSPATH . 'wp-admin/includes/export.php' );
    17 $title = __('Export');
    17 $title = __('Export');
    18 
    18 
    29  			filters = form.find('.export-filters');
    29  			filters = form.find('.export-filters');
    30  		filters.hide();
    30  		filters.hide();
    31  		form.find('input:radio').change(function() {
    31  		form.find('input:radio').change(function() {
    32 			filters.slideUp('fast');
    32 			filters.slideUp('fast');
    33 			switch ( $(this).val() ) {
    33 			switch ( $(this).val() ) {
       
    34 				case 'attachment': $('#attachment-filters').slideDown(); break;
    34 				case 'posts': $('#post-filters').slideDown(); break;
    35 				case 'posts': $('#post-filters').slideDown(); break;
    35 				case 'pages': $('#page-filters').slideDown(); break;
    36 				case 'pages': $('#page-filters').slideDown(); break;
    36 			}
    37 			}
    37  		});
    38  		});
    38 	});
    39 	});
    48 		'<p>' . __('Once generated, your WXR file can be imported by another WordPress site or by another blogging platform able to access this format.') . '</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>',
    49 ) );
    50 ) );
    50 
    51 
    51 get_current_screen()->set_help_sidebar(
    52 get_current_screen()->set_help_sidebar(
    52 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    53 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    53 	'<p>' . __('<a href="https://codex.wordpress.org/Tools_Export_Screen" target="_blank">Documentation on Export</a>') . '</p>' .
    54 	'<p>' . __('<a href="https://codex.wordpress.org/Tools_Export_Screen">Documentation on Export</a>') . '</p>' .
    54 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    55 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
    55 );
    56 );
    56 
    57 
    57 // If the 'download' URL parameter is set, a WXR export file is baked and returned.
    58 // If the 'download' URL parameter is set, a WXR export file is baked and returned.
    58 if ( isset( $_GET['download'] ) ) {
    59 if ( isset( $_GET['download'] ) ) {
    59 	$args = array();
    60 	$args = array();
    87 			$args['end_date'] = $_GET['page_end_date'];
    88 			$args['end_date'] = $_GET['page_end_date'];
    88 		}
    89 		}
    89 
    90 
    90 		if ( $_GET['page_status'] )
    91 		if ( $_GET['page_status'] )
    91 			$args['status'] = $_GET['page_status'];
    92 			$args['status'] = $_GET['page_status'];
    92 	} else {
    93 	} elseif ( 'attachment' == $_GET['content'] ) {
       
    94 		$args['content'] = 'attachment';
       
    95 
       
    96 		if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) {
       
    97 			$args['start_date'] = $_GET['attachment_start_date'];
       
    98 			$args['end_date'] = $_GET['attachment_end_date'];
       
    99 		}
       
   100 	}
       
   101 	else {
    93 		$args['content'] = $_GET['content'];
   102 		$args['content'] = $_GET['content'];
    94 	}
   103 	}
    95 
   104 
    96 	/**
   105 	/**
    97 	 * Filter the export args.
   106 	 * Filters the export args.
    98 	 *
   107 	 *
    99 	 * @since 3.5.0
   108 	 * @since 3.5.0
   100 	 *
   109 	 *
   101 	 * @param array $args The arguments to send to the exporter.
   110 	 * @param array $args The arguments to send to the exporter.
   102 	 */
   111 	 */
   141 	}
   150 	}
   142 }
   151 }
   143 ?>
   152 ?>
   144 
   153 
   145 <div class="wrap">
   154 <div class="wrap">
   146 <h2><?php echo esc_html( $title ); ?></h2>
   155 <h1><?php echo esc_html( $title ); ?></h1>
   147 
   156 
   148 <p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
   157 <p><?php _e('When you click the button below WordPress will create an XML file for you to save to your computer.'); ?></p>
   149 <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>
   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>
   150 <p><?php _e('Once you&#8217;ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.'); ?></p>
   159 <p><?php _e('Once you&#8217;ve saved the download file, you can use the Import function in another WordPress installation to import the content from this site.'); ?></p>
   151 
   160 
   152 <h3><?php _e( 'Choose what to export' ); ?></h3>
   161 <h2><?php _e( 'Choose what to export' ); ?></h2>
   153 <form method="get" id="export-filters">
   162 <form method="get" id="export-filters">
       
   163 <fieldset>
       
   164 <legend class="screen-reader-text"><?php _e( 'Content to export' ); ?></legend>
   154 <input type="hidden" name="download" value="true" />
   165 <input type="hidden" name="download" value="true" />
   155 <p><label><input type="radio" name="content" value="all" checked="checked" /> <?php _e( 'All content' ); ?></label></p>
   166 <p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e( 'All content' ); ?></label></p>
   156 <p class="description"><?php _e( 'This will contain all of your posts, pages, comments, custom fields, terms, navigation menus and custom posts.' ); ?></p>
   167 <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>
   157 
   168 
   158 <p><label><input type="radio" name="content" value="posts" /> <?php _e( 'Posts' ); ?></label></p>
   169 <p><label><input type="radio" name="content" value="posts" /> <?php _e( 'Posts' ); ?></label></p>
   159 <ul id="post-filters" class="export-filters">
   170 <ul id="post-filters" class="export-filters">
   160 	<li>
   171 	<li>
   161 		<label><?php _e( 'Categories:' ); ?></label>
   172 		<label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span>
   162 		<?php wp_dropdown_categories( array( 'show_option_all' => __('All') ) ); ?>
   173 		<?php wp_dropdown_categories( array( 'show_option_all' => __('All') ) ); ?>
   163 	</li>
   174 		</label>
   164 	<li>
   175 	</li>
   165 		<label><?php _e( 'Authors:' ); ?></label>
   176 	<li>
   166 <?php
   177 		<label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span>
       
   178 		<?php
   167 		$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" );
   179 		$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" );
   168 		wp_dropdown_users( array( 'include' => $authors, 'name' => 'post_author', 'multi' => true, 'show_option_all' => __('All') ) );
   180 		wp_dropdown_users( array(
   169 ?>
   181 			'include' => $authors,
   170 	</li>
   182 			'name' => 'post_author',
   171 	<li>
   183 			'multi' => true,
   172 		<label><?php _e( 'Date range:' ); ?></label>
   184 			'show_option_all' => __( 'All' ),
   173 		<select name="post_start_date">
   185 			'show' => 'display_name_with_login',
   174 			<option value="0"><?php _e( 'Start Date' ); ?></option>
   186 		) ); ?>
       
   187 		</label>
       
   188 	</li>
       
   189 	<li>
       
   190 		<fieldset>
       
   191 		<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
       
   192 		<label for="post-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
       
   193 		<select name="post_start_date" id="post-start-date">
       
   194 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   175 			<?php export_date_options(); ?>
   195 			<?php export_date_options(); ?>
   176 		</select>
   196 		</select>
   177 		<select name="post_end_date">
   197 		<label for="post-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label>
   178 			<option value="0"><?php _e( 'End Date' ); ?></option>
   198 		<select name="post_end_date" id="post-end-date">
       
   199 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   179 			<?php export_date_options(); ?>
   200 			<?php export_date_options(); ?>
   180 		</select>
   201 		</select>
   181 	</li>
   202 		</fieldset>
   182 	<li>
   203 	</li>
   183 		<label><?php _e( 'Status:' ); ?></label>
   204 	<li>
   184 		<select name="post_status">
   205 		<label for="post-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
       
   206 		<select name="post_status" id="post-status">
   185 			<option value="0"><?php _e( 'All' ); ?></option>
   207 			<option value="0"><?php _e( 'All' ); ?></option>
   186 			<?php $post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
   208 			<?php $post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
   187 			foreach ( $post_stati as $status ) : ?>
   209 			foreach ( $post_stati as $status ) : ?>
   188 			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
   210 			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
   189 			<?php endforeach; ?>
   211 			<?php endforeach; ?>
   192 </ul>
   214 </ul>
   193 
   215 
   194 <p><label><input type="radio" name="content" value="pages" /> <?php _e( 'Pages' ); ?></label></p>
   216 <p><label><input type="radio" name="content" value="pages" /> <?php _e( 'Pages' ); ?></label></p>
   195 <ul id="page-filters" class="export-filters">
   217 <ul id="page-filters" class="export-filters">
   196 	<li>
   218 	<li>
   197 		<label><?php _e( 'Authors:' ); ?></label>
   219 		<label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span>
   198 <?php
   220 		<?php
   199 		$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" );
   221 		$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" );
   200 		wp_dropdown_users( array( 'include' => $authors, 'name' => 'page_author', 'multi' => true, 'show_option_all' => __('All') ) );
   222 		wp_dropdown_users( array(
   201 ?>
   223 			'include' => $authors,
   202 	</li>
   224 			'name' => 'page_author',
   203 	<li>
   225 			'multi' => true,
   204 		<label><?php _e( 'Date range:' ); ?></label>
   226 			'show_option_all' => __( 'All' ),
   205 		<select name="page_start_date">
   227 			'show' => 'display_name_with_login',
   206 			<option value="0"><?php _e( 'Start Date' ); ?></option>
   228 		) ); ?>
       
   229 		</label>
       
   230 	</li>
       
   231 	<li>
       
   232 		<fieldset>
       
   233 		<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
       
   234 		<label for="page-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
       
   235 		<select name="page_start_date" id="page-start-date">
       
   236 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   207 			<?php export_date_options( 'page' ); ?>
   237 			<?php export_date_options( 'page' ); ?>
   208 		</select>
   238 		</select>
   209 		<select name="page_end_date">
   239 		<label for="page-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label>
   210 			<option value="0"><?php _e( 'End Date' ); ?></option>
   240 		<select name="page_end_date" id="page-end-date">
       
   241 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   211 			<?php export_date_options( 'page' ); ?>
   242 			<?php export_date_options( 'page' ); ?>
   212 		</select>
   243 		</select>
   213 	</li>
   244 		</fieldset>
   214 	<li>
   245 	</li>
   215 		<label><?php _e( 'Status:' ); ?></label>
   246 	<li>
   216 		<select name="page_status">
   247 		<label for="page-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
       
   248 		<select name="page_status" id="page-status">
   217 			<option value="0"><?php _e( 'All' ); ?></option>
   249 			<option value="0"><?php _e( 'All' ); ?></option>
   218 			<?php foreach ( $post_stati as $status ) : ?>
   250 			<?php foreach ( $post_stati as $status ) : ?>
   219 			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
   251 			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
   220 			<?php endforeach; ?>
   252 			<?php endforeach; ?>
   221 		</select>
   253 		</select>
   224 
   256 
   225 <?php foreach ( get_post_types( array( '_builtin' => false, 'can_export' => true ), 'objects' ) as $post_type ) : ?>
   257 <?php foreach ( get_post_types( array( '_builtin' => false, 'can_export' => true ), 'objects' ) as $post_type ) : ?>
   226 <p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p>
   258 <p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p>
   227 <?php endforeach; ?>
   259 <?php endforeach; ?>
   228 
   260 
       
   261 <p><label><input type="radio" name="content" value="attachment" /> <?php _e( 'Media' ); ?></label></p>
       
   262 <ul id="attachment-filters" class="export-filters">
       
   263 	<li>
       
   264 		<fieldset>
       
   265 		<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
       
   266 		<label for="attachment-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
       
   267 		<select name="attachment_start_date" id="attachment-start-date">
       
   268 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
       
   269 			<?php export_date_options( 'attachment' ); ?>
       
   270 		</select>
       
   271 		<label for="attachment-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label>
       
   272 		<select name="attachment_end_date" id="attachment-end-date">
       
   273 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
       
   274 			<?php export_date_options( 'attachment' ); ?>
       
   275 		</select>
       
   276 		</fieldset>
       
   277 	</li>
       
   278 </ul>
       
   279 
       
   280 </fieldset>
   229 <?php
   281 <?php
   230 /**
   282 /**
   231  * Fires after the export filters form.
   283  * Fires at the end of the export filters form.
   232  *
   284  *
   233  * @since 3.5.0
   285  * @since 3.5.0
   234  */
   286  */
   235 do_action( 'export_filters' );
   287 do_action( 'export_filters' );
   236 ?>
   288 ?>