Make WordPress Core

Changeset 36607

Timestamp:
02/21/2016 09:44:14 PM (8 years ago)
Author:
ericlewis
Message:

Posts: Non-trashed posts should take slug priority over trashed posts.

When determining a unique post slug, trashed posts are taken into account. Previously, new posts would add suffixes to their slugs (e.g. about-2) when a post in the trash had the desired slug (e.g. about).

To avoid this behavior, when a post is trashed its slug (i.e. post_name) is now suffixed with -%trashed%. The post's pre-trash slug is stored as post meta, and if the post is restored from trash, its desired slug is reapplied.

For existing trashed posts which don't have the -%trashed% suffix, the suffix is added when a post with its desired slug is created.

Props ocean90, boonebgorges, ryan, SergeyBiryukov, coffee2code, helen, williamsba1.
See #11863.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r36569 r36607  
    32423242    $post_parent = apply_filters( 'wp_insert_post_parent', $post_parent, $post_ID, compact( array_keys( $postarr ) ), $postarr );
    32433243
     3244
     3245
     3246
     3247
     3248
     3249
     3250
     3251
     3252
     3253
     3254
     3255
     3256
     3257
     3258
     3259
     3260
     3261
     3262
     3263
     3264
     3265
    32443266    $post_name = wp_unique_post_slug( $post_name, $post_ID, $post_status, $post_type, $post_parent );
    32453267
     
    60346056    }
    60356057}
     6058
     6059
     6060
     6061
     6062
     6063
     6064
     6065
     6066
     6067
     6068
     6069
     6070
     6071
     6072
     6073
     6074
     6075
     6076
     6077
     6078
     6079
     6080
     6081
     6082
     6083
     6084
     6085
     6086
     6087
     6088
     6089
     6090
     6091
     6092
     6093
     6094
     6095
     6096
     6097
     6098
     6099
     6100
     6101
     6102
     6103
     6104
     6105
     6106
     6107
     6108
     6109
     6110
     6111
     6112
     6113
Note: See TracChangeset for help on using the changeset viewer.