WordPress.org

Make WordPress Core

Changeset 15625


Ignore:
Timestamp:
09/17/2010 05:07:11 PM (8 years ago)
Author:
scribu
Message:

Remove extraneous sanitization of category_name. Leave it to wp_tax_query(). See #12891

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r15624 r15625  
    18781878        // Category stuff for nice URLs
    18791879        if ( '' != $q['category_name'] && !$this->is_singular ) {
    1880             $q['category_name'] = implode('/', array_map('sanitize_title', explode('/', $q['category_name'])));
    1881             $reqcat = get_category_by_path($q['category_name']);
    1882             $q['category_name'] = str_replace('%2F', '/', urlencode(urldecode($q['category_name'])));
    1883             $cat_paths = '/' . trim($q['category_name'], '/');
    1884             $q['category_name'] = sanitize_title(basename($cat_paths));
    1885 
    1886             $cat_paths = '/' . trim(urldecode($q['category_name']), '/');
    1887             $q['category_name'] = sanitize_title(basename($cat_paths));
    1888             $cat_paths = explode('/', $cat_paths);
    1889             $cat_path = '';
    1890             foreach ( (array) $cat_paths as $pathdir )
    1891                 $cat_path .= ( $pathdir != '' ? '/' : '' ) . sanitize_title($pathdir);
    1892 
    1893             //if we don't match the entire hierarchy fallback on just matching the nicename
    1894             if ( empty($reqcat) )
    1895                 $reqcat = get_category_by_path($q['category_name'], false);
    1896 
    1897             if ( !empty($reqcat) )
    1898                 $reqcat = $reqcat->term_id;
    1899             else
    1900                 $reqcat = 0;
    1901 
    1902             $q['cat'] = $reqcat;
     1880            $q['category_name'] = str_replace( '%2F', '/', urlencode(urldecode($q['category_name'])) );
     1881            $q['category_name'] = '/' . trim( $q['category_name'], '/' );
    19031882
    19041883            $tax_query[] = array(
    19051884                'taxonomy' => 'category',
    1906                 'terms' => array( $q['cat'] ),
     1885                'terms' => array( basename( $q['category_name'] ) ),
    19071886                'operator' => 'IN',
    1908                 'field' => 'term_id'
     1887                'field' => 'slug'
    19091888            );
    19101889        }
Note: See TracChangeset for help on using the changeset viewer.