Changeset 13486
- Timestamp:
- 02/28/2010 05:59:39 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/query.php
r13318 r13486 222 222 223 223 /** 224 * Whether the current page query has the given taxonomy slug or contains taxonomy. 224 * Whether the current query is for the given taxonomy and/or term. 225 * 226 * If no taxonomy argument is set, returns true if any taxonomy is queried. 227 * If the taxonomy argument is passed but no term argument, returns true 228 * if the taxonomy or taxonomies in the argument are being queried. 229 * If both taxonomy and term arguments are passed, returns true 230 * if the current query is for a term contained in the terms argument 231 * which has a taxonomy contained in the taxonomy argument. 225 232 * 226 233 * @since 2.5.0 227 234 * @uses $wp_query 228 235 * 229 * @param string|array $slug Optional. Slug or slugs to check in current query. 236 * @param string|array $taxonomy Optional. Taxonomy slug or slugs to check in current query. 237 * @param int|array|string $term. Optional. A single or array of, The term's ID, Name or Slug 230 238 * @return bool 231 239 */ 232 function is_tax( $slug = '' ) { 233 global $wp_query; 234 235 if ( !$wp_query->is_tax ) 240 function is_tax( $taxonomy = '', $term = '' ) { 241 global $wp_query, $wp_taxonomies; 242 243 $queried_object = $wp_query->get_queried_object(); 244 $tax_array = array_intersect(array_keys($wp_taxonomies), (array) $taxonomy); 245 $term_array = (array) $term; 246 247 if ( ! ( $wp_query->is_tax || $wp_query->is_category || $wp_query->is_tag ) ) 236 248 return false; 237 249 238 if ( empty( $slug) )250 if ( empty( $taxonomy ) ) 239 251 return true; 240 252 241 return in_array( get_query_var('taxonomy'), (array) $slug ); 253 if ( empty( $term ) ) // Only a Taxonomy provided 254 return isset($queried_object->taxonomy) && count( $tax_array ) && in_array($queried_object->taxonomy, $tax_array); 255 256 return isset($queried_object->term_id) && 257 count(array_intersect( 258 array($queried_object->term_id, $queried_object->name, $queried_object->slug), 259 $term_array 260 )); 242 261 } 243 262
Note: See TracChangeset
for help on using the changeset viewer.