WordPress.org

Make WordPress Core


Ignore:
Timestamp:
04/16/2019 03:56:48 PM (8 months ago)
Author:
SergeyBiryukov
Message:

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

Props sgastard, juliarrr, aristath, SergeyBiryukov.
Fixes #46575.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/export.php

    r44566 r45216  
    531531            foreach ( $posts as $post ) {
    532532                setup_postdata( $post );
    533                 $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
    534                 ?>
    535     <item>
    536         <title>
    537                 <?php
     533
    538534                /** This filter is documented in wp-includes/feed.php */
    539                 echo apply_filters( 'the_title_rss', $post->post_title );
    540                 ?>
    541         </title>
    542         <link><?php the_permalink_rss(); ?></link>
    543         <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
    544         <dc:creator><?php echo wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator>
    545         <guid isPermaLink="false"><?php the_guid(); ?></guid>
    546         <description></description>
    547         <content:encoded>
    548                 <?php
     535                $title = apply_filters( 'the_title_rss', $post->post_title );
     536
    549537                /**
    550538                 * Filters the post content used for WXR exports.
     
    554542                 * @param string $post_content Content of the current post.
    555543                 */
    556                 echo wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
    557                 ?>
    558         </content:encoded>
    559         <excerpt:encoded>
    560                 <?php
     544                $content = wxr_cdata( apply_filters( 'the_content_export', $post->post_content ) );
     545
    561546                /**
    562547                 * Filters the post excerpt used for WXR exports.
     
    566551                 * @param string $post_excerpt Excerpt for the current post.
    567552                 */
    568                 echo wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
     553                $excerpt = wxr_cdata( apply_filters( 'the_excerpt_export', $post->post_excerpt ) );
     554
     555                $is_sticky = is_sticky( $post->ID ) ? 1 : 0;
    569556                ?>
    570         </excerpt:encoded>
     557    <item>
     558        <title><?php echo $title; ?></title>
     559        <link><?php the_permalink_rss(); ?></link>
     560        <pubDate><?php echo mysql2date( 'D, d M Y H:i:s +0000', get_post_time( 'Y-m-d H:i:s', true ), false ); ?></pubDate>
     561        <dc:creator><?php echo wxr_cdata( get_the_author_meta( 'login' ) ); ?></dc:creator>
     562        <guid isPermaLink="false"><?php the_guid(); ?></guid>
     563        <description></description>
     564        <content:encoded><?php echo $content; ?></content:encoded>
     565        <excerpt:encoded><?php echo $excerpt; ?></excerpt:encoded>
    571566        <wp:post_id><?php echo intval( $post->ID ); ?></wp:post_id>
    572567        <wp:post_date><?php echo wxr_cdata( $post->post_date ); ?></wp:post_date>
Note: See TracChangeset for help on using the changeset viewer.