*
* @since 2.5.0
*/
-define( 'WXR_VERSION', '1.1' );
+define( 'WXR_VERSION', '1.2' );
/**
* Generates the WXR export file for download
* @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 = "<![CDATA[$str" . ( ( substr( $str, -1 ) == ']' ) ? ' ' : '' ) . ']]>';
+ $str = '<![CDATA[' . str_replace( ']]>', ']]]]><![CDATA[>', $str ) . ']]>';
return $str;
}
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<wp:author>";
echo '<wp:author_id>' . $author->ID . '</wp:author_id>';
echo '<wp:author_login>' . $author->user_login . '</wp:author_login>';
* @since 2.3.0
*/
function wxr_post_taxonomy() {
- global $post;
+ $post = get_post();
$taxonomies = get_object_taxonomies( $post->post_type );
if ( empty( $taxonomies ) )
}
}
+ 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 '<?xml version="1.0" encoding="' . get_bloginfo('charset') . "\" ?>\n";
?>
<link><?php bloginfo_rss( 'url' ); ?></link>
<description><?php bloginfo_rss( 'description' ); ?></description>
<pubDate><?php echo date( 'D, d M Y H:i:s +0000' ); ?></pubDate>
- <language><?php echo get_option( 'rss_language' ); ?></language>
+ <language><?php bloginfo_rss( 'language' ); ?></language>
<wp:wxr_version><?php echo WXR_VERSION; ?></wp:wxr_version>
<wp:base_site_url><?php echo wxr_site_url(); ?></wp:base_site_url>
<wp:base_blog_url><?php bloginfo_rss( 'url' ); ?></wp:base_blog_url>
<link><?php the_permalink_rss() ?></link>
<pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
<dc:creator><?php echo get_the_author_meta( 'login' ); ?></dc:creator>
- <guid isPermaLink="false"><?php esc_url( the_guid() ); ?></guid>
+ <guid isPermaLink="false"><?php the_guid(); ?></guid>
<description></description>
<content:encoded><?php echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) ); ?></content:encoded>
<excerpt:encoded><?php echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) ); ?></excerpt:encoded>
<?php endif; ?>
<?php wxr_post_taxonomy(); ?>
<?php $postmeta = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->postmeta WHERE post_id = %d", $post->ID ) );
- 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;
+ ?>
<wp:postmeta>
<wp:meta_key><?php echo $meta->meta_key; ?></wp:meta_key>
<wp:meta_value><?php echo wxr_cdata( $meta->meta_value ); ?></wp:meta_value>
</wp:postmeta>
-<?php endif; endforeach; ?>
+<?php endforeach; ?>
<?php $comments = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved <> 'spam'", $post->ID ) );
foreach ( $comments as $c ) : ?>
<wp:comment>