Edit File by line
/home/barbar84/public_h.../wp-admin
File: export.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WordPress Export Administration Screen
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Administration
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/** Load WordPress Bootstrap */
[8] Fix | Delete
require_once __DIR__ . '/admin.php';
[9] Fix | Delete
[10] Fix | Delete
if ( ! current_user_can( 'export' ) ) {
[11] Fix | Delete
wp_die( __( 'Sorry, you are not allowed to export the content of this site.' ) );
[12] Fix | Delete
}
[13] Fix | Delete
[14] Fix | Delete
/** Load WordPress export API */
[15] Fix | Delete
require_once ABSPATH . 'wp-admin/includes/export.php';
[16] Fix | Delete
$title = __( 'Export' );
[17] Fix | Delete
[18] Fix | Delete
/**
[19] Fix | Delete
* Display JavaScript on the page.
[20] Fix | Delete
*
[21] Fix | Delete
* @since 3.5.0
[22] Fix | Delete
*/
[23] Fix | Delete
function export_add_js() {
[24] Fix | Delete
?>
[25] Fix | Delete
<script type="text/javascript">
[26] Fix | Delete
jQuery(document).ready(function($){
[27] Fix | Delete
var form = $('#export-filters'),
[28] Fix | Delete
filters = form.find('.export-filters');
[29] Fix | Delete
filters.hide();
[30] Fix | Delete
form.find('input:radio').on( 'change', function() {
[31] Fix | Delete
filters.slideUp('fast');
[32] Fix | Delete
switch ( $(this).val() ) {
[33] Fix | Delete
case 'attachment': $('#attachment-filters').slideDown(); break;
[34] Fix | Delete
case 'posts': $('#post-filters').slideDown(); break;
[35] Fix | Delete
case 'pages': $('#page-filters').slideDown(); break;
[36] Fix | Delete
}
[37] Fix | Delete
});
[38] Fix | Delete
});
[39] Fix | Delete
</script>
[40] Fix | Delete
<?php
[41] Fix | Delete
}
[42] Fix | Delete
add_action( 'admin_head', 'export_add_js' );
[43] Fix | Delete
[44] Fix | Delete
get_current_screen()->add_help_tab(
[45] Fix | Delete
array(
[46] Fix | Delete
'id' => 'overview',
[47] Fix | Delete
'title' => __( 'Overview' ),
[48] Fix | Delete
'content' => '<p>' . __( 'You can export a file of your site&#8217;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] Fix | Delete
'<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] Fix | Delete
)
[51] Fix | Delete
);
[52] Fix | Delete
[53] Fix | Delete
get_current_screen()->set_help_sidebar(
[54] Fix | Delete
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
[55] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/article/tools-export-screen/">Documentation on Export</a>' ) . '</p>' .
[56] Fix | Delete
'<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
[57] Fix | Delete
);
[58] Fix | Delete
[59] Fix | Delete
// If the 'download' URL parameter is set, a WXR export file is baked and returned.
[60] Fix | Delete
if ( isset( $_GET['download'] ) ) {
[61] Fix | Delete
$args = array();
[62] Fix | Delete
[63] Fix | Delete
if ( ! isset( $_GET['content'] ) || 'all' === $_GET['content'] ) {
[64] Fix | Delete
$args['content'] = 'all';
[65] Fix | Delete
} elseif ( 'posts' === $_GET['content'] ) {
[66] Fix | Delete
$args['content'] = 'post';
[67] Fix | Delete
[68] Fix | Delete
if ( $_GET['cat'] ) {
[69] Fix | Delete
$args['category'] = (int) $_GET['cat'];
[70] Fix | Delete
}
[71] Fix | Delete
[72] Fix | Delete
if ( $_GET['post_author'] ) {
[73] Fix | Delete
$args['author'] = (int) $_GET['post_author'];
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
if ( $_GET['post_start_date'] || $_GET['post_end_date'] ) {
[77] Fix | Delete
$args['start_date'] = $_GET['post_start_date'];
[78] Fix | Delete
$args['end_date'] = $_GET['post_end_date'];
[79] Fix | Delete
}
[80] Fix | Delete
[81] Fix | Delete
if ( $_GET['post_status'] ) {
[82] Fix | Delete
$args['status'] = $_GET['post_status'];
[83] Fix | Delete
}
[84] Fix | Delete
} elseif ( 'pages' === $_GET['content'] ) {
[85] Fix | Delete
$args['content'] = 'page';
[86] Fix | Delete
[87] Fix | Delete
if ( $_GET['page_author'] ) {
[88] Fix | Delete
$args['author'] = (int) $_GET['page_author'];
[89] Fix | Delete
}
[90] Fix | Delete
[91] Fix | Delete
if ( $_GET['page_start_date'] || $_GET['page_end_date'] ) {
[92] Fix | Delete
$args['start_date'] = $_GET['page_start_date'];
[93] Fix | Delete
$args['end_date'] = $_GET['page_end_date'];
[94] Fix | Delete
}
[95] Fix | Delete
[96] Fix | Delete
if ( $_GET['page_status'] ) {
[97] Fix | Delete
$args['status'] = $_GET['page_status'];
[98] Fix | Delete
}
[99] Fix | Delete
} elseif ( 'attachment' === $_GET['content'] ) {
[100] Fix | Delete
$args['content'] = 'attachment';
[101] Fix | Delete
[102] Fix | Delete
if ( $_GET['attachment_start_date'] || $_GET['attachment_end_date'] ) {
[103] Fix | Delete
$args['start_date'] = $_GET['attachment_start_date'];
[104] Fix | Delete
$args['end_date'] = $_GET['attachment_end_date'];
[105] Fix | Delete
}
[106] Fix | Delete
} else {
[107] Fix | Delete
$args['content'] = $_GET['content'];
[108] Fix | Delete
}
[109] Fix | Delete
[110] Fix | Delete
/**
[111] Fix | Delete
* Filters the export args.
[112] Fix | Delete
*
[113] Fix | Delete
* @since 3.5.0
[114] Fix | Delete
*
[115] Fix | Delete
* @param array $args The arguments to send to the exporter.
[116] Fix | Delete
*/
[117] Fix | Delete
$args = apply_filters( 'export_args', $args );
[118] Fix | Delete
[119] Fix | Delete
export_wp( $args );
[120] Fix | Delete
die();
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
require_once ABSPATH . 'wp-admin/admin-header.php';
[124] Fix | Delete
[125] Fix | Delete
/**
[126] Fix | Delete
* Create the date options fields for exporting a given post type.
[127] Fix | Delete
*
[128] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[129] Fix | Delete
* @global WP_Locale $wp_locale WordPress date and time locale object.
[130] Fix | Delete
*
[131] Fix | Delete
* @since 3.1.0
[132] Fix | Delete
*
[133] Fix | Delete
* @param string $post_type The post type. Default 'post'.
[134] Fix | Delete
*/
[135] Fix | Delete
function export_date_options( $post_type = 'post' ) {
[136] Fix | Delete
global $wpdb, $wp_locale;
[137] Fix | Delete
[138] Fix | Delete
$months = $wpdb->get_results(
[139] Fix | Delete
$wpdb->prepare(
[140] Fix | Delete
"
[141] Fix | Delete
SELECT DISTINCT YEAR( post_date ) AS year, MONTH( post_date ) AS month
[142] Fix | Delete
FROM $wpdb->posts
[143] Fix | Delete
WHERE post_type = %s AND post_status != 'auto-draft'
[144] Fix | Delete
ORDER BY post_date DESC
[145] Fix | Delete
",
[146] Fix | Delete
$post_type
[147] Fix | Delete
)
[148] Fix | Delete
);
[149] Fix | Delete
[150] Fix | Delete
$month_count = count( $months );
[151] Fix | Delete
if ( ! $month_count || ( 1 === $month_count && 0 === (int) $months[0]->month ) ) {
[152] Fix | Delete
return;
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
foreach ( $months as $date ) {
[156] Fix | Delete
if ( 0 === (int) $date->year ) {
[157] Fix | Delete
continue;
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
$month = zeroise( $date->month, 2 );
[161] Fix | Delete
echo '<option value="' . $date->year . '-' . $month . '">' . $wp_locale->get_month( $month ) . ' ' . $date->year . '</option>';
[162] Fix | Delete
}
[163] Fix | Delete
}
[164] Fix | Delete
?>
[165] Fix | Delete
[166] Fix | Delete
<div class="wrap">
[167] Fix | Delete
<h1><?php echo esc_html( $title ); ?></h1>
[168] Fix | Delete
[169] Fix | Delete
<p><?php _e( 'When you click the button below WordPress will create an XML file for you to save to your computer.' ); ?></p>
[170] Fix | Delete
<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>
[171] Fix | Delete
<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>
[172] Fix | Delete
[173] Fix | Delete
<h2><?php _e( 'Choose what to export' ); ?></h2>
[174] Fix | Delete
<form method="get" id="export-filters">
[175] Fix | Delete
<fieldset>
[176] Fix | Delete
<legend class="screen-reader-text"><?php _e( 'Content to export' ); ?></legend>
[177] Fix | Delete
<input type="hidden" name="download" value="true" />
[178] Fix | Delete
<p><label><input type="radio" name="content" value="all" checked="checked" aria-describedby="all-content-desc" /> <?php _e( 'All content' ); ?></label></p>
[179] Fix | Delete
<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>
[180] Fix | Delete
[181] Fix | Delete
<p><label><input type="radio" name="content" value="posts" /> <?php _ex( 'Posts', 'post type general name' ); ?></label></p>
[182] Fix | Delete
<ul id="post-filters" class="export-filters">
[183] Fix | Delete
<li>
[184] Fix | Delete
<label><span class="label-responsive"><?php _e( 'Categories:' ); ?></span>
[185] Fix | Delete
<?php wp_dropdown_categories( array( 'show_option_all' => __( 'All' ) ) ); ?>
[186] Fix | Delete
</label>
[187] Fix | Delete
</li>
[188] Fix | Delete
<li>
[189] Fix | Delete
<label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span>
[190] Fix | Delete
<?php
[191] Fix | Delete
$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'post'" );
[192] Fix | Delete
wp_dropdown_users(
[193] Fix | Delete
array(
[194] Fix | Delete
'include' => $authors,
[195] Fix | Delete
'name' => 'post_author',
[196] Fix | Delete
'multi' => true,
[197] Fix | Delete
'show_option_all' => __( 'All' ),
[198] Fix | Delete
'show' => 'display_name_with_login',
[199] Fix | Delete
)
[200] Fix | Delete
);
[201] Fix | Delete
?>
[202] Fix | Delete
</label>
[203] Fix | Delete
</li>
[204] Fix | Delete
<li>
[205] Fix | Delete
<fieldset>
[206] Fix | Delete
<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
[207] Fix | Delete
<label for="post-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
[208] Fix | Delete
<select name="post_start_date" id="post-start-date">
[209] Fix | Delete
<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
[210] Fix | Delete
<?php export_date_options(); ?>
[211] Fix | Delete
</select>
[212] Fix | Delete
<label for="post-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label>
[213] Fix | Delete
<select name="post_end_date" id="post-end-date">
[214] Fix | Delete
<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
[215] Fix | Delete
<?php export_date_options(); ?>
[216] Fix | Delete
</select>
[217] Fix | Delete
</fieldset>
[218] Fix | Delete
</li>
[219] Fix | Delete
<li>
[220] Fix | Delete
<label for="post-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
[221] Fix | Delete
<select name="post_status" id="post-status">
[222] Fix | Delete
<option value="0"><?php _e( 'All' ); ?></option>
[223] Fix | Delete
<?php
[224] Fix | Delete
$post_stati = get_post_stati( array( 'internal' => false ), 'objects' );
[225] Fix | Delete
foreach ( $post_stati as $status ) :
[226] Fix | Delete
?>
[227] Fix | Delete
<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
[228] Fix | Delete
<?php endforeach; ?>
[229] Fix | Delete
</select>
[230] Fix | Delete
</li>
[231] Fix | Delete
</ul>
[232] Fix | Delete
[233] Fix | Delete
<p><label><input type="radio" name="content" value="pages" /> <?php _e( 'Pages' ); ?></label></p>
[234] Fix | Delete
<ul id="page-filters" class="export-filters">
[235] Fix | Delete
<li>
[236] Fix | Delete
<label><span class="label-responsive"><?php _e( 'Authors:' ); ?></span>
[237] Fix | Delete
<?php
[238] Fix | Delete
$authors = $wpdb->get_col( "SELECT DISTINCT post_author FROM {$wpdb->posts} WHERE post_type = 'page'" );
[239] Fix | Delete
wp_dropdown_users(
[240] Fix | Delete
array(
[241] Fix | Delete
'include' => $authors,
[242] Fix | Delete
'name' => 'page_author',
[243] Fix | Delete
'multi' => true,
[244] Fix | Delete
'show_option_all' => __( 'All' ),
[245] Fix | Delete
'show' => 'display_name_with_login',
[246] Fix | Delete
)
[247] Fix | Delete
);
[248] Fix | Delete
?>
[249] Fix | Delete
</label>
[250] Fix | Delete
</li>
[251] Fix | Delete
<li>
[252] Fix | Delete
<fieldset>
[253] Fix | Delete
<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
[254] Fix | Delete
<label for="page-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
[255] Fix | Delete
<select name="page_start_date" id="page-start-date">
[256] Fix | Delete
<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
[257] Fix | Delete
<?php export_date_options( 'page' ); ?>
[258] Fix | Delete
</select>
[259] Fix | Delete
<label for="page-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label>
[260] Fix | Delete
<select name="page_end_date" id="page-end-date">
[261] Fix | Delete
<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
[262] Fix | Delete
<?php export_date_options( 'page' ); ?>
[263] Fix | Delete
</select>
[264] Fix | Delete
</fieldset>
[265] Fix | Delete
</li>
[266] Fix | Delete
<li>
[267] Fix | Delete
<label for="page-status" class="label-responsive"><?php _e( 'Status:' ); ?></label>
[268] Fix | Delete
<select name="page_status" id="page-status">
[269] Fix | Delete
<option value="0"><?php _e( 'All' ); ?></option>
[270] Fix | Delete
<?php foreach ( $post_stati as $status ) : ?>
[271] Fix | Delete
<option value="<?php echo esc_attr( $status->name ); ?>"><?php echo esc_html( $status->label ); ?></option>
[272] Fix | Delete
<?php endforeach; ?>
[273] Fix | Delete
</select>
[274] Fix | Delete
</li>
[275] Fix | Delete
</ul>
[276] Fix | Delete
[277] Fix | Delete
<?php
[278] Fix | Delete
foreach ( get_post_types(
[279] Fix | Delete
array(
[280] Fix | Delete
'_builtin' => false,
[281] Fix | Delete
'can_export' => true,
[282] Fix | Delete
),
[283] Fix | Delete
'objects'
[284] Fix | Delete
) as $post_type ) :
[285] Fix | Delete
?>
[286] Fix | Delete
<p><label><input type="radio" name="content" value="<?php echo esc_attr( $post_type->name ); ?>" /> <?php echo esc_html( $post_type->label ); ?></label></p>
[287] Fix | Delete
<?php endforeach; ?>
[288] Fix | Delete
[289] Fix | Delete
<p><label><input type="radio" name="content" value="attachment" /> <?php _e( 'Media' ); ?></label></p>
[290] Fix | Delete
<ul id="attachment-filters" class="export-filters">
[291] Fix | Delete
<li>
[292] Fix | Delete
<fieldset>
[293] Fix | Delete
<legend class="screen-reader-text"><?php _e( 'Date range:' ); ?></legend>
[294] Fix | Delete
<label for="attachment-start-date" class="label-responsive"><?php _e( 'Start date:' ); ?></label>
[295] Fix | Delete
<select name="attachment_start_date" id="attachment-start-date">
[296] Fix | Delete
<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
[297] Fix | Delete
<?php export_date_options( 'attachment' ); ?>
[298] Fix | Delete
</select>
[299] Fix | Delete
<label for="attachment-end-date" class="label-responsive"><?php _e( 'End date:' ); ?></label>
[300] Fix | Delete
<select name="attachment_end_date" id="attachment-end-date">
[301] Fix | Delete
<option value="0"><?php _e( '&mdash; Select &mdash;' ); ?></option>
[302] Fix | Delete
<?php export_date_options( 'attachment' ); ?>
[303] Fix | Delete
</select>
[304] Fix | Delete
</fieldset>
[305] Fix | Delete
</li>
[306] Fix | Delete
</ul>
[307] Fix | Delete
[308] Fix | Delete
</fieldset>
[309] Fix | Delete
<?php
[310] Fix | Delete
/**
[311] Fix | Delete
* Fires at the end of the export filters form.
[312] Fix | Delete
*
[313] Fix | Delete
* @since 3.5.0
[314] Fix | Delete
*/
[315] Fix | Delete
do_action( 'export_filters' );
[316] Fix | Delete
?>
[317] Fix | Delete
[318] Fix | Delete
<?php submit_button( __( 'Download Export File' ) ); ?>
[319] Fix | Delete
</form>
[320] Fix | Delete
</div>
[321] Fix | Delete
[322] Fix | Delete
<?php require_once ABSPATH . 'wp-admin/admin-footer.php'; ?>
[323] Fix | Delete
[324] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function