[wp-trac] [WordPress Trac] #20480: Can't access original slug with wp_unique_post_slug filter

WordPress Trac wp-trac at lists.automattic.com
Thu Jun 28 20:45:50 UTC 2012


#20480: Can't access original slug with wp_unique_post_slug filter
--------------------------+------------------------------
 Reporter:  bradyvercher  |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Permalinks    |     Version:  3.3
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------------------

Comment (by coffee2code):

 +1

 As @johnbillion said, the `wp_unique_post_slug` filter is of limited, or
 at least diminished, use if the original slug isn't also passed. If
 passed, then any hooked functions could easily detect if
 `wp_unique_post_slug()` modified the incoming slug due to a conflict and
 could act accordingly (perhaps using different slug renaming logic or for
 logging).

 And as @bradyvercher most recently mentioned, a `pre_wp_unique_post_slug`
 filter could be useful and justified here for a few reasons:

 * The `wp_unique_post_slug()` function (and thus the filter) is not high
 use, so won't impact performance
 * `wp_unique_post_slug()` performs database queries (perhaps repeatedly
 until a unique slug is found), all of which may be rendered moot if a
 hooking function's intent is to implement its own slug generation/handling
 logic. The pre slug could short-circuit that unnecessary effort.

 Attached [attachment:20480.2.diff] which amends original patch to add pre
 filter and some phpDocs.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20480#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list