From c1ce7ddc38883c07fb1c761928f0e320b3c47490 Mon Sep 17 00:00:00 2001 From: scribu Date: Fri, 17 Sep 2010 17:07:11 +0000 Subject: [PATCH] Remove extraneous sanitization of category_name. Leave it to wp_tax_query(). See #12891 git-svn-id: https://develop.svn.wordpress.org/trunk@15625 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 29 ++++------------------------- 1 file changed, 4 insertions(+), 25 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 99d43a1a7a..a7b7df4cd1 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1877,35 +1877,14 @@ class WP_Query { // Category stuff for nice URLs if ( '' != $q['category_name'] && !$this->is_singular ) { - $q['category_name'] = implode('/', array_map('sanitize_title', explode('/', $q['category_name']))); - $reqcat = get_category_by_path($q['category_name']); - $q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name']))); - $cat_paths = '/' . trim($q['category_name'], '/'); - $q['category_name'] = sanitize_title(basename($cat_paths)); - - $cat_paths = '/' . trim(urldecode($q['category_name']), '/'); - $q['category_name'] = sanitize_title(basename($cat_paths)); - $cat_paths = explode('/', $cat_paths); - $cat_path = ''; - foreach ( (array) $cat_paths as $pathdir ) - $cat_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir); - - //if we don't match the entire hierarchy fallback on just matching the nicename - if ( empty($reqcat) ) - $reqcat = get_category_by_path($q['category_name'], false); - - if ( !empty($reqcat) ) - $reqcat = $reqcat->term_id; - else - $reqcat = 0; - - $q['cat'] = $reqcat; + $q['category_name'] = str_replace( '%2F', '/', urlencode(urldecode($q['category_name'])) ); + $q['category_name'] = '/' . trim( $q['category_name'], '/' ); $tax_query[] = array( 'taxonomy' => 'category', - 'terms' => array( $q['cat'] ), + 'terms' => array( basename( $q['category_name'] ) ), 'operator' => 'IN', - 'field' => 'term_id' + 'field' => 'slug' ); }