wp/wp-admin/export.php
changeset 21 48c4eec2b7e6
parent 19 3d72ae0968f4
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    54 	)
    54 	)
    55 );
    55 );
    56 
    56 
    57 get_current_screen()->set_help_sidebar(
    57 get_current_screen()->set_help_sidebar(
    58 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    58 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    59 	'<p>' . __( '<a href="https://wordpress.org/support/article/tools-export-screen/">Documentation on Export</a>' ) . '</p>' .
    59 	'<p>' . __( '<a href="https://wordpress.org/documentation/article/tools-export-screen/">Documentation on Export</a>' ) . '</p>' .
    60 	'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
    60 	'<p>' . __( '<a href="https://wordpress.org/support/forums/">Support forums</a>' ) . '</p>'
    61 );
    61 );
    62 
    62 
    63 // If the 'download' URL parameter is set, a WXR export file is baked and returned.
    63 // If the 'download' URL parameter is set, a WXR export file is baked and returned.
    64 if ( isset( $_GET['download'] ) ) {
    64 if ( isset( $_GET['download'] ) ) {
    65 	$args = array();
    65 	$args = array();
   125 }
   125 }
   126 
   126 
   127 require_once ABSPATH . 'wp-admin/admin-header.php';
   127 require_once ABSPATH . 'wp-admin/admin-header.php';
   128 
   128 
   129 /**
   129 /**
   130  * Create the date options fields for exporting a given post type.
   130  * Creates the date options fields for exporting a given post type.
       
   131  *
       
   132  * @since 3.1.0
   131  *
   133  *
   132  * @global wpdb      $wpdb      WordPress database abstraction object.
   134  * @global wpdb      $wpdb      WordPress database abstraction object.
   133  * @global WP_Locale $wp_locale WordPress date and time locale object.
   135  * @global WP_Locale $wp_locale WordPress date and time locale object.
   134  *
       
   135  * @since 3.1.0
       
   136  *
   136  *
   137  * @param string $post_type The post type. Default 'post'.
   137  * @param string $post_type The post type. Default 'post'.
   138  */
   138  */
   139 function export_date_options( $post_type = 'post' ) {
   139 function export_date_options( $post_type = 'post' ) {
   140 	global $wpdb, $wp_locale;
   140 	global $wpdb, $wp_locale;
   141 
   141 
   142 	$months = $wpdb->get_results(
   142 	$months = $wpdb->get_results(
   143 		$wpdb->prepare(
   143 		$wpdb->prepare(
   144 			"
   144 			"SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
   145 		SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
   145 			FROM $wpdb->posts
   146 		FROM $wpdb->posts
   146 			WHERE post_type = %s AND post_status != 'auto-draft'
   147 		WHERE post_type = %s AND post_status != 'auto-draft'
   147 			ORDER BY post_date DESC",
   148 		ORDER BY post_date DESC
       
   149 			",
       
   150 			$post_type
   148 			$post_type
   151 		)
   149 		)
   152 	);
   150 	);
   153 
   151 
   154 	$month_count = count( $months );
   152 	$month_count = count( $months );
   160 		if ( 0 === (int) $date->year ) {
   158 		if ( 0 === (int) $date->year ) {
   161 			continue;
   159 			continue;
   162 		}
   160 		}
   163 
   161 
   164 		$month = zeroise( $date->month, 2 );
   162 		$month = zeroise( $date->month, 2 );
   165 		echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>';
   163 
       
   164 		printf(
       
   165 			'<option value="%1$s">%2$s</option>',
       
   166 			esc_attr( $date->year . '-' . $month ),
       
   167 			$wp_locale->get_month( $month ) . ' ' . $date->year
       
   168 		);
   166 	}
   169 	}
   167 }
   170 }
   168 ?>
   171 ?>
   169 
   172 
   170 <div class="wrap">
   173 <div class="wrap">
   175 <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>
   178 <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>
   176 
   179 
   177 <h2><?php _e( 'Choose what to export' ); ?></h2>
   180 <h2><?php _e( 'Choose what to export' ); ?></h2>
   178 <form method="get" id="export-filters">
   181 <form method="get" id="export-filters">
   179 <fieldset>
   182 <fieldset>
   180 <legend class="screen-reader-text"><?php _e( 'Content to export' ); ?></legend>
   183 <legend class="screen-reader-text">
       
   184 	<?php
       
   185 	/* translators: Hidden accessibility text. */
       
   186 	_e( 'Content to export' );
       
   187 	?>
       
   188 </legend>
   181 <input type="hidden" name="download" value="true" />
   189 <input type="hidden" name="download" value="true" />
   182 <p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e( 'All content' ); ?></label></p>
   190 <p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e( 'All content' ); ?></label></p>
   183 <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>
   191 <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>
   184 
   192 
   185 <p><label><input type="radio" name="content" value="posts" /> <?php _ex( 'Posts', 'post type general name' ); ?></label></p>
   193 <p><label><input type="radio" name="content" value="posts" /> <?php _ex( 'Posts', 'post type general name' ); ?></label></p>
   205 		?>
   213 		?>
   206 		</label>
   214 		</label>
   207 	</li>
   215 	</li>
   208 	<li>
   216 	<li>
   209 		<fieldset>
   217 		<fieldset>
   210 		<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
   218 		<legend class="screen-reader-text">
       
   219 			<?php
       
   220 			/* translators: Hidden accessibility text. */
       
   221 			_e( 'Date range:' )
       
   222 			?>
       
   223 		</legend>
   211 		<label for="post-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
   224 		<label for="post-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
   212 		<select name="post_start_date" id="post-start-date">
   225 		<select name="post_start_date" id="post-start-date">
   213 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   226 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   214 			<?php export_date_options(); ?>
   227 			<?php export_date_options(); ?>
   215 		</select>
   228 		</select>
   223 	<li>
   236 	<li>
   224 		<label for="post-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
   237 		<label for="post-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
   225 		<select name="post_status" id="post-status">
   238 		<select name="post_status" id="post-status">
   226 			<option value="0"><?php _e( 'All' ); ?></option>
   239 			<option value="0"><?php _e( 'All' ); ?></option>
   227 			<?php
   240 			<?php
   228 			$post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
   241 			$post_statuses = get_post_stati( array( 'internal' => false ), 'objects' );
   229 			foreach ( $post_stati as $status ) :
   242 			foreach ( $post_statuses as $status ) :
   230 				?>
   243 				?>
   231 			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
   244 			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
   232 			<?php endforeach; ?>
   245 			<?php endforeach; ?>
   233 		</select>
   246 		</select>
   234 	</li>
   247 	</li>
   252 		?>
   265 		?>
   253 		</label>
   266 		</label>
   254 	</li>
   267 	</li>
   255 	<li>
   268 	<li>
   256 		<fieldset>
   269 		<fieldset>
   257 		<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
   270 		<legend class="screen-reader-text">
       
   271 			<?php
       
   272 			/* translators: Hidden accessibility text. */
       
   273 			_e( 'Date range:' );
       
   274 			?>
       
   275 		</legend>
   258 		<label for="page-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
   276 		<label for="page-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
   259 		<select name="page_start_date" id="page-start-date">
   277 		<select name="page_start_date" id="page-start-date">
   260 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   278 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   261 			<?php export_date_options( 'page' ); ?>
   279 			<?php export_date_options( 'page' ); ?>
   262 		</select>
   280 		</select>
   269 	</li>
   287 	</li>
   270 	<li>
   288 	<li>
   271 		<label for="page-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
   289 		<label for="page-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
   272 		<select name="page_status" id="page-status">
   290 		<select name="page_status" id="page-status">
   273 			<option value="0"><?php _e( 'All' ); ?></option>
   291 			<option value="0"><?php _e( 'All' ); ?></option>
   274 			<?php foreach ( $post_stati as $status ) : ?>
   292 			<?php foreach ( $post_statuses as $status ) : ?>
   275 			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
   293 			<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
   276 			<?php endforeach; ?>
   294 			<?php endforeach; ?>
   277 		</select>
   295 		</select>
   278 	</li>
   296 	</li>
   279 </ul>
   297 </ul>
   292 
   310 
   293 <p><label><input type="radio" name="content" value="attachment" /> <?php _e( 'Media' ); ?></label></p>
   311 <p><label><input type="radio" name="content" value="attachment" /> <?php _e( 'Media' ); ?></label></p>
   294 <ul id="attachment-filters" class="export-filters">
   312 <ul id="attachment-filters" class="export-filters">
   295 	<li>
   313 	<li>
   296 		<fieldset>
   314 		<fieldset>
   297 		<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
   315 		<legend class="screen-reader-text">
       
   316 			<?php
       
   317 			/* translators: Hidden accessibility text. */
       
   318 			_e( 'Date range:' );
       
   319 			?>
       
   320 		</legend>
   298 		<label for="attachment-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
   321 		<label for="attachment-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
   299 		<select name="attachment_start_date" id="attachment-start-date">
   322 		<select name="attachment_start_date" id="attachment-start-date">
   300 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   323 			<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
   301 			<?php export_date_options( 'attachment' ); ?>
   324 			<?php export_date_options( 'attachment' ); ?>
   302 		</select>
   325 		</select>