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.
Built from https://develop.svn.wordpress.org/trunk@37165


git-svn-id: http://core.svn.wordpress.org/trunk@37132 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Boone Gorges 2016-04-07 19:22:28 +00:00
parent 1c1daa7ba4
commit cfab9716e3
2 changed files with 3 additions and 3 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;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-RC1-37164';
$wp_version = '4.5-RC1-37165';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.