Export: Remove extra whitespace from `<title>`, `<content:encoded>`, and `<excerpt:encoded>` elements in WXR files.

Props sgastard, juliarrr, aristath, SergeyBiryukov.
Fixes #46575.
Built from https://develop.svn.wordpress.org/trunk@45216


git-svn-id: http://core.svn.wordpress.org/trunk@45025 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2019-04-16 15:57:53 +00:00
parent 373a759c6b
commit c28e516c80
2 changed files with 18 additions and 23 deletions

View File

@ -530,22 +530,10 @@ function export_wp( $args = array() ) {
// Begin Loop.
foreach ( $posts as $post ) {
setup_postdata( $post );
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
?>
<item>
<title>
<?php
/** This filter is documented in wp-includes/feed.php */
echo apply_filters( 'the_title_rss', $post->post_title );
?>
</title>
<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 wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description></description>
<content:encoded>
<?php
$title = apply_filters( 'the_title_rss', $post->post_title );
/**
* Filters the post content used for WXR exports.
*
@ -553,11 +541,8 @@ function export_wp( $args = array() ) {
*
* @param string $post_content Content of the current post.
*/
echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
?>
</content:encoded>
<excerpt:encoded>
<?php
$content = wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
/**
* Filters the post excerpt used for WXR exports.
*
@ -565,9 +550,19 @@ function export_wp( $args = array() ) {
*
* @param string $post_excerpt Excerpt for the current post.
*/
echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
$excerpt = wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
$is_sticky = is_sticky( $post->ID ) ? 1 : 0;
?>
</excerpt:encoded>
<item>
<title><?php echo $title; ?></title>
<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 wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator>
<guid isPermaLink="false"><?php the_guid(); ?></guid>
<description></description>
<content:encoded><?php echo $content; ?></content:encoded>
<excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded>
<wp:post_id><?php echo intval( $post->ID ); ?></wp:post_id>
<wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date>
<wp:post_date_gmt><?php echo wxr_cdata( $post->post_date_gmt ); ?></wp:post_date_gmt>

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.2-beta3-45215';
$wp_version = '5.2-beta3-45216';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.