Ticket #16282: both.16282.2.diff

File both.16282.2.diff, 775 bytes (added by scribu, 2 years ago)

Actually works

Line 
1Index: wp-includes/taxonomy.php
2===================================================================
3--- wp-includes/taxonomy.php    (revision 17357)
4+++ wp-includes/taxonomy.php    (working copy)
5@@ -879,7 +879,7 @@
6 
7        if ( 'slug' == $field ) {
8                $field = 't.slug';
9-               $value = sanitize_title($value);
10+               $value = sanitize_title_for_query($value);
11                if ( empty($value) )
12                        return false;
13        } else if ( 'name' == $field ) {
14@@ -2824,7 +2824,12 @@
15                if ( is_int($term) ) {
16                        $term = &get_term($term, $taxonomy);
17                } else {
18-                       $term = &get_term_by('slug', $term, $taxonomy);
19+                       $term_obj = &get_term_by('slug', $term, $taxonomy);
20+
21+                       if ( !$term_obj || is_wp_error($term_obj) )
22+                               $term_obj = &get_term_by('name', $term, $taxonomy);
23+
24+                       $term = &$term_obj;
25                }
26        }
27