Changeset 12658
- Timestamp:
- 01/08/2010 08:44:45 AM (15 years ago)
- Location:
- trunk/wp-includes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions.php
r12656 r12658 2751 2751 2752 2752 /** 2753 * Clean up an array, comma- or space-separated list of IDs 2754 * 2755 * @since 3.0.0 2756 * 2757 * @param array|string $list 2758 * @return array Sanitized array of IDs 2759 */ 2760 function wp_parse_id_list($list) { 2761 if ( !is_array($list) ) 2762 $list = preg_split('/[\s,]+/', $list); 2763 2764 return array_unique(array_map('absint', $list)); 2765 } 2766 2767 /** 2753 2768 * Determines if default embed handlers should be loaded. 2754 2769 * -
trunk/wp-includes/taxonomy.php
r12598 r12658 572 572 * terms whose count is 0 according to the given taxonomy. 573 573 * 574 * exclude - Default is an empty string. Acomma- or space-delimited string574 * exclude - Default is an empty array. An array, comma- or space-delimited string 575 575 * of term ids to exclude from the return array. If 'include' is non-empty, 576 576 * 'exclude' is ignored. 577 577 * 578 * exclude_tree - A comma- or space-delimited string of term ids to exclude 579 * from the return array, along with all of their descendant terms according to 580 * the primary taxonomy. If 'include' is non-empty, 'exclude_tree' is ignored. 581 * 582 * include - Default is an empty string. A comma- or space-delimited string 578 * exclude_tree - Default is an empty array. An array, comma- or space-delimited 579 * string of term ids to exclude from the return array, along with all of their 580 * descendant terms according to the primary taxonomy. If 'include' is non-empty, 581 * 'exclude_tree' is ignored. 582 * 583 * include - Default is an empty array. An array, comma- or space-delimited string 583 584 * of term ids to include in the return array. 584 585 * 585 * number - The maximum number of terms to return. Default is empty.586 * number - The maximum number of terms to return. Default is to return them all. 586 587 * 587 588 * offset - The number by which to offset the terms query. … … 652 653 653 654 $defaults = array('orderby' => 'name', 'order' => 'ASC', 654 'hide_empty' => true, 'exclude' => '', 'exclude_tree' => '', 'include' => '',655 'hide_empty' => true, 'exclude' => array(), 'exclude_tree' => array(), 'include' => array(), 655 656 'number' => '', 'fields' => 'all', 'slug' => '', 'parent' => '', 656 657 'hierarchical' => true, 'child_of' => 0, 'get' => '', 'name__like' => '', … … 720 721 $exclude = ''; 721 722 $exclude_tree = ''; 722 $interms = preg_split('/[\s,]+/',$include); 723 if ( count($interms) ) { 724 foreach ( (array) $interms as $interm ) { 725 if (empty($inclusions)) 726 $inclusions = ' AND ( t.term_id = ' . intval($interm) . ' '; 727 else 728 $inclusions .= ' OR t.term_id = ' . intval($interm) . ' '; 729 } 723 $interms = wp_parse_id_list($include); 724 foreach ( $interms as $interm ) { 725 if ( empty($inclusions) ) 726 $inclusions = ' AND ( t.term_id = ' . intval($interm) . ' '; 727 else 728 $inclusions .= ' OR t.term_id = ' . intval($interm) . ' '; 730 729 } 731 730 } … … 736 735 737 736 $exclusions = ''; 738 if ( ! 739 $excluded_trunks = preg_split('/[\s,]+/',$exclude_tree);740 foreach ( (array)$excluded_trunks as $extrunk ) {737 if ( !empty( $exclude_tree ) ) { 738 $excluded_trunks = wp_parse_id_list($exclude_tree); 739 foreach ( $excluded_trunks as $extrunk ) { 741 740 $excluded_children = (array) get_terms($taxonomies[0], array('child_of' => intval($extrunk), 'fields' => 'ids')); 742 741 $excluded_children[] = $extrunk; 743 foreach( (array) $excluded_children as $exterm ) { 744 if ( empty($exclusions) ) 745 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' '; 746 else 747 $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' '; 748 749 } 750 } 751 } 752 if ( !empty($exclude) ) { 753 $exterms = preg_split('/[\s,]+/',$exclude); 754 if ( count($exterms) ) { 755 foreach ( (array) $exterms as $exterm ) { 742 foreach( $excluded_children as $exterm ) { 756 743 if ( empty($exclusions) ) 757 744 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' '; … … 759 746 $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' '; 760 747 } 748 } 749 } 750 751 if ( !empty($exclude) ) { 752 $exterms = wp_parse_id_list($exclude); 753 foreach ( $exterms as $exterm ) { 754 if ( empty($exclusions) ) 755 $exclusions = ' AND ( t.term_id <> ' . intval($exterm) . ' '; 756 else 757 $exclusions .= ' AND t.term_id <> ' . intval($exterm) . ' '; 761 758 } 762 759 } … … 835 832 if ( ! $term->count ) { 836 833 $children = _get_term_children($term->term_id, $terms, $taxonomies[0]); 837 if ( is_array($children) )834 if ( is_array($children) ) 838 835 foreach ( $children as $child ) 839 836 if ( $child->count )
Note: See TracChangeset
for help on using the changeset viewer.