From 352ac8bf35a38905465a0723af8a552b75612153 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Fri, 7 Feb 2020 17:33:06 +0000 Subject: [PATCH] Posts, Post Types: Introduce a filter which allows the addition of `__trashed` suffixes on post slugs to be skipped. Fixes #46433 Built from https://develop.svn.wordpress.org/trunk@47203 git-svn-id: http://core.svn.wordpress.org/trunk@47003 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 15 ++++++++++++++- wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 9913223e3f..982c7dc752 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -3843,7 +3843,20 @@ function wp_insert_post( $postarr, $wp_error = false ) { // If a trashed post has the desired slug, change it and let this post have it. if ( 'trash' !== $post_status && $post_name ) { - wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID ); + /** + * Filters whether or not to add a `__trashed` suffix to trashed posts that match the name of the updated post. + * + * @since 5.4.0 + * + * @param bool $add_trashed_suffix Whether to attempt to add the suffix. + * @param string $post_name The name of the post being updated. + * @param int $post_ID Post ID. + */ + $add_trashed_suffix = apply_filters( 'add_trashed_suffix_to_trashed_posts', true, $post_name, $post_ID ); + + if ( $add_trashed_suffix ) { + wp_add_trashed_suffix_to_post_name_for_trashed_posts( $post_name, $post_ID ); + } } // When trashing an existing post, change its slug to allow non-trashed posts to use it. diff --git a/wp-includes/version.php b/wp-includes/version.php index e7d9e5ae58..8fbf647e83 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.4-alpha-47202'; +$wp_version = '5.4-alpha-47203'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.