X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/53f4633144ed68c8b8fb5861f992b5489894a940..9441756a895fb4fdc4bcf20e0d228cef622663ca:/wp-admin/includes/export.php
diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php
index 98989324..4b18c9c0 100644
--- a/wp-admin/includes/export.php
+++ b/wp-admin/includes/export.php
@@ -43,8 +43,21 @@ function export_wp( $args = array() ) {
do_action( 'export_wp', $args );
$sitename = sanitize_key( get_bloginfo( 'name' ) );
- if ( ! empty($sitename) ) $sitename .= '.';
- $filename = $sitename . 'wordpress.' . date( 'Y-m-d' ) . '.xml';
+ if ( ! empty( $sitename ) ) {
+ $sitename .= '.';
+ }
+ $date = date( 'Y-m-d' );
+ $wp_filename = $sitename . 'wordpress.' . $date . '.xml';
+ /**
+ * Filter the export filename.
+ *
+ * @since 4.4.0
+ *
+ * @param string $wp_filename The name of the file for download.
+ * @param string $sitename The site name.
+ * @param string $date Today's date, formatted.
+ */
+ $filename = apply_filters( 'export_wp_filename', $wp_filename, $sitename, $date );
header( 'Content-Description: File Transfer' );
header( 'Content-Disposition: attachment; filename=' . $filename );
@@ -75,7 +88,7 @@ function export_wp( $args = array() ) {
}
}
- if ( 'post' == $args['content'] || 'page' == $args['content'] ) {
+ if ( 'post' == $args['content'] || 'page' == $args['content'] || 'attachment' == $args['content'] ) {
if ( $args['author'] )
$where .= $wpdb->prepare( " AND {$wpdb->posts}.post_author = %d", $args['author'] );
@@ -247,7 +260,7 @@ function export_wp( $args = array() ) {
*
* @since 3.1.0
*
- * @global wpdb $wpdb
+ * @global wpdb $wpdb WordPress database abstraction object.
*
* @param array $post_ids Array of post IDs to filter the query by. Optional.
*/
@@ -270,12 +283,12 @@ function export_wp( $args = array() ) {
foreach ( $authors as $author ) {
echo "\t";
- echo '' . $author->ID . '';
- echo '' . $author->user_login . '';
- echo '' . $author->user_email . '';
+ echo '' . intval( $author->ID ) . '';
+ echo '' . wxr_cdata( $author->user_login ) . '';
+ echo '' . wxr_cdata( $author->user_email ) . '';
echo '' . wxr_cdata( $author->display_name ) . '';
- echo '' . wxr_cdata( $author->user_firstname ) . '';
- echo '' . wxr_cdata( $author->user_lastname ) . '';
+ echo '' . wxr_cdata( $author->first_name ) . '';
+ echo '' . wxr_cdata( $author->last_name ) . '';
echo "\n";
}
}
@@ -291,7 +304,10 @@ function export_wp( $args = array() ) {
return;
foreach ( $nav_menus as $menu ) {
- echo "\t{$menu->term_id}nav_menu{$menu->slug}";
+ echo "\t";
+ echo '' . intval( $menu->term_id ) . '';
+ echo 'nav_menu';
+ echo '' . wxr_cdata( $menu->slug ) . '';
wxr_term_name( $menu );
echo "\n";
}
@@ -370,13 +386,13 @@ function export_wp( $args = array() ) {
- term_id ?>slug; ?>parent ? $cats[$c->parent]->slug : ''; ?>
+ term_id ); ?>slug ); ?>parent ? $cats[$c->parent]->slug : '' ); ?>
- term_id ?>slug; ?>
+ term_id ); ?>slug ); ?>
- term_id ?>taxonomy; ?>slug; ?>parent ? $terms[$t->parent]->slug : ''; ?>
+ term_id ); ?>taxonomy ); ?>slug ); ?>parent ? $terms[$t->parent]->slug : '' ); ?>
@@ -434,20 +450,20 @@ function export_wp( $args = array() ) {
*/
echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
?>
- ID; ?>
- post_date; ?>
- post_date_gmt; ?>
- comment_status; ?>
- ping_status; ?>
- post_name; ?>
- post_status; ?>
- post_parent; ?>
- menu_order; ?>
- post_type; ?>
- post_password; ?>
-
+ ID ); ?>
+ post_date ); ?>
+ post_date_gmt ); ?>
+ comment_status ); ?>
+ ping_status ); ?>
+ post_name ); ?>
+ post_status ); ?>
+ post_parent ); ?>
+ menu_order ); ?>
+ post_type ); ?>
+ post_password ); ?>
+
post_type == 'attachment' ) : ?>
- ID ); ?>
+ ID ) ); ?>
get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
@@ -468,26 +484,27 @@ function export_wp( $args = array() ) {
continue;
?>
- meta_key; ?>
+ meta_key ); ?>
meta_value ); ?>
get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
+ $_comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
+ $comments = array_map( 'get_comment', $_comments );
foreach ( $comments as $c ) : ?>
- comment_ID; ?>
+ comment_ID ); ?>
comment_author ); ?>
- comment_author_email; ?>
+ comment_author_email ); ?>
comment_author_url ); ?>
- comment_author_IP; ?>
- comment_date; ?>
- comment_date_gmt; ?>
+ comment_author_IP ); ?>
+ comment_date ); ?>
+ comment_date_gmt ); ?>
comment_content ) ?>
- comment_approved; ?>
- comment_type; ?>
- comment_parent; ?>
- user_id; ?>
+ comment_approved ); ?>
+ comment_type ); ?>
+ comment_parent ); ?>
+ user_id ); ?>
get_results( $wpdb->prepare( "SELECT * FROM $wpdb->commentmeta WHERE comment_id = %d", $c->comment_ID ) );
foreach ( $c_meta as $meta ) :
/**
@@ -507,7 +524,7 @@ function export_wp( $args = array() ) {
}
?>
- meta_key; ?>
+ meta_key ); ?>
meta_value ); ?>