Ticket #20783: 20783.diff

File 20783.diff, 1.2 KB (added by coffee2code, 11 months ago)
Line 
1Index: wp-includes/taxonomy.php
2===================================================================
3--- wp-includes/taxonomy.php    (revision 21158)
4+++ wp-includes/taxonomy.php    (working copy)
5@@ -2233,9 +2233,11 @@
6  * @subpackage Taxonomy
7  * @since 2.3.0
8  * @uses $wpdb
9+ * @uses apply_filters() Will call the 'wp_unique_term_slug' filter and pass
10+ *  the resulting unique slug, the term, and the original slug.
11  *
12  * @param string $slug The string that will be tried for a unique slug
13- * @param object $term The term object that the $slug will belong too
14+ * @param object $term The term object that the $slug will belong to
15  * @return string Will return a true unique slug.
16  */
17 function wp_unique_term_slug($slug, $term) {
18@@ -2244,6 +2246,8 @@
19        if ( ! term_exists( $slug ) )
20                return $slug;
21 
22+       $original_slug = $slug;
23+
24        // If the taxonomy supports hierarchy and the term has a parent, make the slug unique
25        // by incorporating parent slugs.
26        if ( is_taxonomy_hierarchical($term->taxonomy) && !empty($term->parent) ) {
27@@ -2278,7 +2282,7 @@
28                $slug = $alt_slug;
29        }
30 
31-       return $slug;
32+       return apply_filters( 'wp_unique_term_slug', $slug, $term, $original_slug );
33 }
34 
35 /**