Make WordPress Core


Ignore:
Timestamp:
04/07/2016 07:21:02 PM (8 years ago)
Author:
boonebgorges
Message:

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.

File:
1 edited

Legend:

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

    r36945 r37165  
    61276127    $post = get_post( $post );
    61286128
    6129     if ( strpos( $post->post_name, '-%trashed%' ) ) {
     6129    if ( '__trashed' === substr( $post->post_name, -9 ) ) {
    61306130        return $post->post_name;
    61316131    }
    61326132    add_post_meta( $post->ID, '_wp_desired_post_slug', $post->post_name );
    6133     $post_name = _truncate_post_slug( $post->post_name, 190 ) . '-%trashed%';
     6133    $post_name = _truncate_post_slug( $post->post_name, 191 ) . '__trashed';
    61346134    $wpdb->update( $wpdb->posts, array( 'post_name' => $post_name ), array( 'ID' => $post->ID ) );
    61356135    clean_post_cache( $post->ID );
Note: See TracChangeset for help on using the changeset viewer.