#20480 closed defect (bug) (fixed)
Can't access original slug with wp_unique_post_slug filter
Reported by: | bradyvercher | Owned by: | nacin |
---|---|---|---|
Milestone: | 3.5 | Priority: | normal |
Severity: | normal | Version: | 3.3 |
Component: | Permalinks | Keywords: | has-patch |
Focuses: | Cc: |
Description
This is a follow up to #14111.
The slug passed to the 'wp_unique_post_slug' filter may already be suffixed by the time it's accessible. This requires the default suffix algorithm to be reversed if a developer wants access to the original slug in order to apply their own uniqueness algorithm.
It would be great if the original slug was passed as a parameter in the current filter, or if a new filter was added before the default uniqueness algorithms are executed.
Attachments (2)
Change History (9)
#1
@
13 years ago
- Severity changed from trivial to normal
- Type changed from enhancement to defect (bug)
- Version changed from 3.3.1 to 3.3
#3
@
13 years ago
That should do it. Thanks!
As an enhancement, something like a pre_wp_unique_post_slug
filter that operates similar to this patch might also be beneficial so plugins can bypass the default processing.
@
12 years ago
Adds wp_unique_post_slug
filter as proposed in 20480.patch; adds pre_wp_unique_post_slug
filter; adds some phpDoc
#4
@
12 years ago
+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 20480.2.diff which amends original patch to add pre filter and some phpDocs.
#5
follow-up:
↓ 7
@
12 years ago
- Milestone changed from Awaiting Review to 3.5
Sounds good. Can we consider the pre_* filter in a separate ticket?
I'd class this as a bug. The filter has limited use without passing the original slug.