X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/f9001779751f83dc8a10e478bfecb4d8dd5f964c..61343b82c4f0da4c68e4c6373daafff4a81efdd1:/wp-admin/includes/export.php?ds=sidebyside diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php index 2efd0405..ae08c3c1 100644 --- a/wp-admin/includes/export.php +++ b/wp-admin/includes/export.php @@ -13,7 +13,7 @@ * * @since 2.5.0 */ -define( 'WXR_VERSION', '1.1' ); +define( 'WXR_VERSION', '1.2' ); /** * Generates the WXR export file for download @@ -49,7 +49,7 @@ function export_wp( $args = array() ) { } else { $post_types = get_post_types( array( 'can_export' => true ) ); $esses = array_fill( 0, count($post_types), '%s' ); - $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (". implode(',',$esses) .")", $post_types ); + $where = $wpdb->prepare( "{$wpdb->posts}.post_type IN (" . implode( ',', $esses ) . ')', $post_types ); } if ( $args['status'] && ( 'post' == $args['content'] || 'page' == $args['content'] ) ) @@ -117,13 +117,14 @@ function export_wp( $args = array() ) { * @since 2.1.0 * * @param string $str String to wrap in XML CDATA tag. + * @return string */ function wxr_cdata( $str ) { if ( seems_utf8( $str ) == false ) $str = utf8_encode( $str ); // $str = ent2ncr(esc_html($str)); - $str = ""; + $str = '', ']]]]>', $str ) . ']]>'; return $str; } @@ -237,13 +238,13 @@ function export_wp( $args = array() ) { global $wpdb; $authors = array(); - $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts" ); + $results = $wpdb->get_results( "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_status != 'auto-draft'" ); foreach ( (array) $results as $result ) $authors[] = get_userdata( $result->post_author ); $authors = array_filter( $authors ); - foreach( $authors as $author ) { + foreach ( $authors as $author ) { echo "\t"; echo '' . $author->ID . ''; echo '' . $author->user_login . ''; @@ -278,7 +279,7 @@ function export_wp( $args = array() ) { * @since 2.3.0 */ function wxr_post_taxonomy() { - global $post; + $post = get_post(); $taxonomies = get_object_taxonomies( $post->post_type ); if ( empty( $taxonomies ) ) @@ -290,6 +291,13 @@ function export_wp( $args = array() ) { } } + function wxr_filter_postmeta( $return_me, $meta_key ) { + if ( '_edit_lock' == $meta_key ) + $return_me = true; + return $return_me; + } + add_filter( 'wxr_export_skip_postmeta', 'wxr_filter_postmeta', 10, 2 ); + echo '\n"; ?> @@ -324,7 +332,7 @@ function export_wp( $args = array() ) { - + @@ -350,7 +358,7 @@ function export_wp( $args = array() ) { // fetch 20 posts at a time rather than loading the entire table into memory while ( $next_posts = array_splice( $post_ids, 0, 20 ) ) { - $where = "WHERE ID IN (" . join( ',', $next_posts ) . ")"; + $where = 'WHERE ID IN (' . join( ',', $next_posts ) . ')'; $posts = $wpdb->get_results( "SELECT * FROM {$wpdb->posts} $where" ); // Begin Loop @@ -363,7 +371,7 @@ function export_wp( $args = array() ) { - + post_content ) ); ?> post_excerpt ) ); ?> @@ -384,14 +392,17 @@ function export_wp( $args = array() ) { get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) ); - if ( $postmeta ) : foreach( $postmeta as $meta ) : if ( $meta->meta_key != '_edit_lock' ) : ?> + foreach ( $postmeta as $meta ) : + if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) + continue; + ?> meta_key; ?> meta_value ); ?> - + get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) ); - if ( $comments ) : foreach ( $comments as $c ) : ?> + foreach ( $comments as $c ) : ?> comment_ID; ?> comment_author ); ?> @@ -405,8 +416,15 @@ function export_wp( $args = array() ) { 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 ) : ?> + + meta_key; ?> + meta_value ); ?> + + - +