[wp-trac] [WordPress Trac] #14111: wp_unique_post_slug() doesn't have a filter
WordPress Trac
wp-trac at lists.automattic.com
Tue Sep 20 10:05:03 UTC 2011
#14111: wp_unique_post_slug() doesn't have a filter
-------------------------------------------------+-----------------------
Reporter: Viper007Bond | Owner: westi
Type: enhancement | Status: reopened
Priority: lowest | Milestone: 3.3
Component: Permalinks | Version:
Severity: trivial | Resolution:
Keywords: has-patch needs-testing westi-likes |
-------------------------------------------------+-----------------------
Comment (by westi):
Replying to [comment:14 Vynce]:
> Summary: i would recommend instead inserting the hook cloaser to line
2835:
>
> {{{ $alt_post_name = substr( $slug, 0, 200 – ( strlen( $suffix ) + 1 ) )
. “-$suffix”; }}}
>
> Reasoning: the way [18546] was implemented the uniqueness does not
appear to take
> into account the filter. for instance, assume I have a filter that
> converts that – to a _.
>
> 1. first, i create post ‘counting’
> 1. then i try to create ‘counting’ and that’s not unique, so I go
into the loop and get ‘counting-2′, which is unique, so i exit the loop
with counting-2, which i filter to ‘counting_2′.
> 1. then i try to create ‘counting’ and that’s not unique, so i go
into the loop and get ‘counting-2′, which is unique, so i exit the loop
with counting-2, which i filter to ‘counting_2′ — which isn’t unique.
> 1. chaos
>
> If, on the other hand, the filter were on line 2835, then I believe
> it would actually unique the value that was going to be used, instead
> of something else.
>
The idea behind the new hook is to give you full control over the slug -
this means that if you want to implement a different slug format then you
will need to do the uniqueness checking yourself.
This is the normal way WordPress provides for plugins to override
behaviour.
It is more efficient to implement it this way than to run a filter call
for every slug variant that WordPress would test.
However, I am actually considering moving this new filter to the top of
the function so that the work that WordPress is doing is not wasted when
the filter is used.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14111#comment:16>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list