X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/5aa86a9053fb0fa15846bb60aac2fb8fdfff524a..888fa4ed68091f3314f711c5f6fe75858bf5410b:/wp-admin/includes/export.php diff --git a/wp-admin/includes/export.php b/wp-admin/includes/export.php index 6aa85a85..162e0072 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 @@ -30,7 +30,14 @@ function export_wp( $args = array() ) { ); $args = wp_parse_args( $args, $defaults ); - do_action( 'export_wp' ); + /** + * Fires at the beginning of an export, before any headers are sent. + * + * @since 2.3.0 + * + * @param array $args An array of export arguments. + */ + do_action( 'export_wp', $args ); $sitename = sanitize_key( get_bloginfo( 'name' ) ); if ( ! empty($sitename) ) $sitename .= '.'; @@ -117,13 +124,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,7 +245,7 @@ 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 ); @@ -278,7 +286,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 ) ) @@ -331,7 +339,7 @@ function export_wp( $args = array() ) { - + @@ -349,7 +357,10 @@ function export_wp( $args = array() ) { - + ID ) ? 1 : 0; ?> + <?php echo apply_filters( 'the_title_rss', $post->post_title ); ?> - - + + - post_content ) ); ?> - post_excerpt ) ); ?> + post_content ) ); + ?> + post_excerpt ) ); + ?> ID; ?> post_date; ?> post_date_gmt; ?> @@ -392,6 +422,18 @@ function export_wp( $args = array() ) { get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) ); foreach ( $postmeta as $meta ) : + /** + * Filter whether to selectively skip post meta used for WXR exports. + * + * Returning a truthy value to the filter will skip the current meta + * object from being exported. + * + * @since 3.3.0 + * + * @param bool $skip Whether to skip the current post meta. Default false. + * @param string $meta_key Current meta key. + * @param object $meta Current meta object. + */ if ( apply_filters( 'wxr_export_skip_postmeta', false, $meta->meta_key, $meta ) ) continue; ?>