Skip to content

Commit

Permalink
Export: Create an export-specific filter for post titles.
Browse files Browse the repository at this point in the history
Since WordPress 2.5 and 2.6, `post_content` and `post_excerpt` have both had export-specific filters: `the_content_export`, and `the_excerpt_export`, respectively. `post_title`, however, has used `the_title_rss`, which behaves differently in two important ways:

- It strips HTML tags from the string.
- It HTML-encodes the title string.

These behaviours are not ideal for exports, since it changes the post title, resulting in data loss in export files, and incorrect post duplicate matching on import. This changes replaces the usage of `the_title_rss` with a new filter, `the_title_export`. The new filter is intended to be used in the same as `the_content_export` and `the_excerpt_export`.

Props jmdodd, audrasjb.
Fixes #52250.



git-svn-id: https://develop.svn.wordpress.org/trunk@50011 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information
pento committed Jan 25, 2021
1 parent 0ceee0f commit 0423761
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/wp-admin/includes/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -542,8 +542,14 @@ function wxr_filter_postmeta( $return_me, $meta_key ) {
foreach ( $posts as $post ) {
setup_postdata( $post );

/** This filter is documented in wp-includes/feed.php */
$title = apply_filters( 'the_title_rss', $post->post_title );
/**
* Filters the post title used for WXR exports.
*
* @since 5.7.0
*
* @param string $post_title Title of the current post.
*/
$title = wxr_cdata( apply_filters( 'the_title_export', $post->post_title ) );

/**
* Filters the post content used for WXR exports.
Expand Down

0 comments on commit 0423761

Please sign in to comment.