From 7b0c0703f5aa4c56040a8a5fb9513ca1b6a6fe4e Mon Sep 17 00:00:00 2001 From: matt Date: Fri, 16 May 2008 02:35:24 +0000 Subject: [PATCH] Fix default taxonomy query var. Populate taxonomy and term query vars ASAP. Fixes template fall-through. Hat tip: andy git-svn-id: http://svn.automattic.com/wordpress/trunk@7940 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/classes.php | 11 ++++++++++- wp-includes/taxonomy.php | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/wp-includes/classes.php b/wp-includes/classes.php index 0d866faac..4da97f13f 100644 --- a/wp-includes/classes.php +++ b/wp-includes/classes.php @@ -140,6 +140,10 @@ class WP { $this->public_query_vars = apply_filters('query_vars', $this->public_query_vars); + foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) + if ( isset($t->query_var) ) + $taxonomy_query_vars[$t->query_var] = $taxonomy; + for ($i=0; $ipublic_query_vars); $i += 1) { $wpvar = $this->public_query_vars[$i]; if (isset($this->extra_query_vars[$wpvar])) @@ -153,8 +157,13 @@ class WP { elseif (!empty($perma_query_vars[$wpvar])) $this->query_vars[$wpvar] = $perma_query_vars[$wpvar]; - if ( !empty( $this->query_vars[$wpvar] ) ) + if ( !empty( $this->query_vars[$wpvar] ) ) { $this->query_vars[$wpvar] = (string) $this->query_vars[$wpvar]; + if ( in_array( $wpvar, $taxonomy_query_vars ) ) { + $this->query_vars['taxonomy'] = $taxonomy_query_vars[$wpvar]; + $this->query_vars['term'] = $this->query_vars[$wpvar]; + } + } } foreach ($this->private_query_vars as $var) { diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 4955f07db..7ff488fca 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -159,7 +159,7 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) { $args = wp_parse_args($args, $defaults); if ( false !== $args['query_var'] && !empty($wp) ) { - if ( empty($args['query_var']) ) + if ( true === $args['query_var'] ) $args['query_var'] = $taxonomy; $args['query_var'] = sanitize_title_with_dashes($args['query_var']); $wp->add_query_var($args['query_var']);