Make WordPress Core

Changeset 13787


Ignore:
Timestamp:
03/21/2010 02:52:00 AM (14 years ago)
Author:
dd32
Message:

When viewing a Parent term in a hierarchical taxonomy, display objects contained within children too. Props scribu. Fixes #12533

File:
1 edited

Legend:

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

    r13774 r13787  
    9595 * @return bool True if page is archive.
    9696 */
    97 function is_archive () {
     97function is_archive() {
    9898    global $wp_query;
    9999
     
    109109 * @return bool True if page is attachment.
    110110 */
    111 function is_attachment () {
     111function is_attachment() {
    112112    global $wp_query;
    113113
     
    269269 * @return bool
    270270 */
    271 function is_comments_popup () {
     271function is_comments_popup() {
    272272    global $wp_query;
    273273
     
    283283 * @return bool
    284284 */
    285 function is_date () {
     285function is_date() {
    286286    global $wp_query;
    287287
     
    297297 * @return bool
    298298 */
    299 function is_day () {
     299function is_day() {
    300300    global $wp_query;
    301301
     
    311311 * @return bool
    312312 */
    313 function is_feed () {
     313function is_feed() {
    314314    global $wp_query;
    315315
     
    325325 * @return bool
    326326 */
    327 function is_comment_feed () {
     327function is_comment_feed() {
    328328    global $wp_query;
    329329
     
    340340 * @return bool True, if front of site.
    341341 */
    342 function is_front_page () {
     342function is_front_page() {
    343343    // most likely case
    344344    if ( 'posts' == get_option('show_on_front') && is_home() )
     
    362362 * @return bool True if blog view homepage.
    363363 */
    364 function is_home () {
     364function is_home() {
    365365    global $wp_query;
    366366
     
    376376 * @return bool
    377377 */
    378 function is_month () {
     378function is_month() {
    379379    global $wp_query;
    380380
     
    430430 * @return bool
    431431 */
    432 function is_paged () {
     432function is_paged() {
    433433    global $wp_query;
    434434
     
    492492 * @return bool
    493493 */
    494 function is_search () {
     494function is_search() {
    495495    global $wp_query;
    496496
     
    513513 * @return bool
    514514 */
    515 function is_single ($post = '') {
     515function is_single($post = '') {
    516516    global $wp_query;
    517517
     
    558558 * @return bool
    559559 */
    560 function is_time () {
     560function is_time() {
    561561    global $wp_query;
    562562
     
    572572 * @return bool
    573573 */
    574 function is_trackback () {
     574function is_trackback() {
    575575    global $wp_query;
    576576
     
    586586 * @return bool
    587587 */
    588 function is_year () {
     588function is_year() {
    589589    global $wp_query;
    590590
     
    600600 * @return bool True, if nothing is found matching WordPress Query.
    601601 */
    602 function is_404 () {
     602function is_404() {
    603603    global $wp_query;
    604604
     
    11351135     * @access public
    11361136     */
    1137     function init () {
     1137    function init() {
    11381138        unset($this->posts);
    11391139        unset($this->query);
     
    12281228     * @param string|array $query
    12291229     */
    1230     function parse_query ($query) {
     1230    function parse_query($query) {
    12311231        if ( !empty($query) || !isset($this->query) ) {
    12321232            $this->init();
     
    19971997                $taxonomy = $q['taxonomy'];
    19981998                $tt[$taxonomy] = $q['term'];
    1999                 $terms = get_terms($q['taxonomy'], array('slug'=>$q['term']));
    20001999            } else {
    20012000                foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
    20022001                    if ( $t->query_var && '' != $q[$t->query_var] ) {
    2003                         $terms = get_terms($taxonomy, array('slug'=>$q[$t->query_var]));
    2004                         if ( !is_wp_error($terms) )
    2005                             break;
     2002                        $tt[$taxonomy] = $q[$t->query_var];
     2003                        break;
    20062004                    }
    20072005                }
    20082006            }
     2007
     2008            $terms = get_terms($taxonomy, array('slug' => $tt[$taxonomy], 'hide_empty' => !is_taxonomy_hierarchical($taxonomy)));
     2009
    20092010            if ( is_wp_error($terms) || empty($terms) ) {
    20102011                $whichcat = " AND 0 ";
    20112012            } else {
    2012                 foreach ( $terms as $term )
     2013                foreach ( $terms as $term ) {
    20132014                    $term_ids[] = $term->term_id;
     2015                    if ( is_taxonomy_hierarchical($taxonomy) ) {
     2016                        $children = get_term_children($term->term_id, $taxonomy);
     2017                        $term_ids = array_merge($term_ids, $children);
     2018                    }
     2019                }
    20142020                $post_ids = get_objects_in_term($term_ids, $taxonomy);
    2015                 if ( !is_wp_error($post_ids) && count($post_ids) ) {
     2021                if ( !is_wp_error($post_ids) && !empty($post_ids) ) {
    20162022                    $whichcat .= " AND $wpdb->posts.ID IN (" . implode(', ', $post_ids) . ") ";
    20172023                    $post_type = 'any';
     
    27352741     * @return WP_Query
    27362742     */
    2737     function WP_Query ($query = '') {
     2743    function WP_Query($query = '') {
    27382744        if (! empty($query)) {
    27392745            $this->query($query);
     
    27532759 * @return null If no link is found, null is returned.
    27542760 */
    2755 function wp_old_slug_redirect () {
     2761function wp_old_slug_redirect() {
    27562762    global $wp_query;
    27572763    if ( is_404() && '' != $wp_query->query_vars['name'] ) :
     
    28272833    return true;
    28282834}
    2829 
    28302835?>
Note: See TracChangeset for help on using the changeset viewer.