[wp-trac] [WordPress Trac] #14111: wp_unique_post_slug() doesn't have a filter

WordPress Trac wp-trac at lists.automattic.com
Mon Sep 19 21:16:36 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  |
-------------------------------------------------+-----------------------
Changes (by Vynce):

 * cc: Vynce (added)


Comment:

 on further reflection, the idiom used seems a bit fragile:

 {{{
 if ($some_condition || $other_condition) {
     do {
         fix_condition();
     } while ($some_condition)
 }
 }}}

 What happens -- even using the default, current uniquing -- if there's a
 feed that happens to be named 'common-slug-2'? wouldn't it be more
 straightforward and safer to change that to

 {{{
         $suffix = 2;
         while ( $post_name_check || in_array( $slug, $feeds ) ||
 apply_filters( 'wp_unique_post_slug_is_bad_attachment_slug', false, $slug
 ) ) {
                 $alt_post_name = substr ($slug, 0, 200 - ( strlen( $suffix
 ) + 1 ) ) . "-$suffix";
                 $post_name_check = $wpdb->get_var(
 $wpdb->prepare($check_sql, $alt_post_name, $post_ID ) );
                 $suffix++;
                 $slug = $alt_post_name;
         }
 }}}

 ?

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


More information about the wp-trac mailing list