Ticket #8614: exclude_tree_terms.diff
File exclude_tree_terms.diff, 3.4 KB (added by , 16 years ago) |
---|
-
wp-includes/taxonomy.php
534 534 * of term ids to exclude from the return array. If 'include' is non-empty, 535 535 * 'exclude' is ignored. 536 536 * 537 * exclude_tree - A comma- or space-delimited string of term ids to exclude 538 * from the return array, along with all of their descendant terms according to 539 * the primary taxonomy. If 'include' is non-empty, 'exclude_tree' is ignored. 540 * 537 541 * include - Default is an empty string. A comma- or space-delimited string 538 542 * of term ids to include in the return array. 539 543 * … … 604 608 $in_taxonomies = "'" . implode("', '", $taxonomies) . "'"; 605 609 606 610 $defaults = array('orderby' => 'name', 'order' => 'ASC', 607 'hide_empty' => true, 'exclude' => '', ' include' => '',611 'hide_empty' => true, 'exclude' => '', 'exclude_tree' => '', 'include' => '', 608 612 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 609 613 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', 610 614 'pad_counts' => false, 'offset' => '', 'search' => ''); … … 668 672 $inclusions = ''; 669 673 if ( !empty($include) ) { 670 674 $exclude = ''; 675 $exclude_tree = ''; 671 676 $interms = preg_split('/[\s,]+/',$include); 672 677 if ( count($interms) ) { 673 678 foreach ( (array) $interms as $interm ) { … … 684 689 $where .= $inclusions; 685 690 686 691 $exclusions = ''; 692 if ( ! empty( $exclude_tree ) ) { 693 $excluded_trunks = preg_split('/[\s,]+/',$exclude_tree); 694 foreach( (array) $excluded_trunks as $extrunk ) { 695 $excluded_children = (array) get_terms($taxonomies[0], array('child_of' => intval($extrunk), 'fields' => 'ids')); 696 $excluded_children[] = $extrunk; 697 foreach( (array) $excluded_children as $exterm ) { 698 if ( empty($exclusions) ) 699 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' '; 700 else 701 $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' '; 702 703 } 704 } 705 } 687 706 if ( !empty($exclude) ) { 688 707 $exterms = preg_split('/[\s,]+/',$exclude); 689 708 if ( count($exterms) ) { 690 709 foreach ( (array) $exterms as $exterm ) { 691 if ( empty($exclusions))710 if ( empty($exclusions) ) 692 711 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' '; 693 712 else 694 713 $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' '; -
wp-includes/category-template.php
443 445 * 'feed_image' - See {@link get_categories()}. 444 446 * 'child_of' (int) default is 0 - See {@link get_categories()}. 445 447 * 'exclude' (string) - See {@link get_categories()}. 448 * 'exclude_tree' (string) - See {@link get_categories()}. 446 449 * 'echo' (bool|int) default is 1 - Whether to display or retrieve content. 447 450 * 'current_category' (int) - See {@link get_categories()}. 448 451 * 'hierarchical' (bool) - See {@link get_categories()}. … … 461 464 'style' => 'list', 'show_count' => 0, 462 465 'hide_empty' => 1, 'use_desc_for_title' => 1, 463 466 'child_of' => 0, 'feed' => '', 'feed_type' => '', 464 'feed_image' => '', 'exclude' => '', ' current_category' => 0,467 'feed_image' => '', 'exclude' => '', 'exclude_tree' => '', 'current_category' => 0, 465 468 'hierarchical' => true, 'title_li' => __( 'Categories' ), 466 469 'echo' => 1, 'depth' => 0 467 470 );