wordpress源码:get_terms 中 exclude_tree 里的 $taxonomies[0]??
moliu 2015-12-06 08:03:18 get_terms 中 exclude_tree 里的 $taxonomies[0]??为什么不是 $taxonomies??
@param string|array $taxonomies Taxonomy name or list of Taxonomy names.
@type array|string $exclude Array or comma/space-separated string of term ids to exclude.
If $include is non-empty, $exclude is ignored. Default empty array.
@type array|string $exclude_tree Array or comma/space-separated string of term ids to exclude
along with all of their descendant terms. If $include is non-empty, $exclude_tree is ignored.
Default empty array.
@type int $child_of Term ID to retrieve child terms of. If multiple taxonomies are passed, $child_of is ignored. Default 0.
@type bool|int $hide_empty Whether to hide terms not assigned to any posts. Accepts
1|true or 0|false. Default 1|true.
function get_terms( $taxonomies, $args = '' )
$exclusions = array();
if ( ! empty( $exclude_tree ) ) {
$exclude_tree = wp_parse_id_list( $exclude_tree );
$excluded_children = $exclude_tree;
foreach ( $exclude_tree as $extrunk ) {
$excluded_children = array_merge(
$excluded_children,
(array) get_terms( $taxonomies[0], array( 'child_of' => intval( $extrunk ), 'fields' => 'ids', 'hide_empty' => 0 ) )
); //为什么这里不是 $taxonomies??
}
$exclusions = array_merge( $excluded_children, $exclusions );
}
if ( ! empty( $exclude ) ) {
$exclusions = array_merge( wp_parse_id_list( $exclude ), $exclusions );
}