Use __trashed suffix rather than -%trashed% for trashed post slugs.

Percent signs are reserved characters in URIs. As such, it was impossible for
plugins to route requests to trashed posts, as happens in bbPress. The new
`__trashed` suffix should be sufficiently unique.

Also adds a test that demonstrates that the `__trashed` suffix can be
appended to slugs that contain the suffix somewhere other than the end of
the string.

Props netweb, ericlewis.
Fixes #11863.

git-svn-id: https://develop.svn.wordpress.org/trunk@37165 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
boonebgorges
2016-04-07 19:21:02 +00:00
parent 1a27ba9fd7
commit f1c3ec9010
2 changed files with 18 additions and 4 deletions

View File

@@ -6126,11 +6126,11 @@ function wp_add_trashed_suffix_to_post_name_for_post( $post ) {
$post = get_post( $post );
if ( strpos( $post->post_name, '-%trashed%' ) ) {
if ( '__trashed' === substr( $post->post_name, -9 ) ) {
return $post->post_name;
}
add_post_meta( $post->ID, '_wp_desired_post_slug', $post->post_name );
$post_name = _truncate_post_slug( $post->post_name, 190 ) . '-%trashed%';
$post_name = _truncate_post_slug( $post->post_name, 191 ) . '__trashed';
$wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
clean_post_cache( $post->ID );
return $post_name;