PUM_Helpers::taxonomy_selectlist_query( $taxonomies = array(), $args = array(), $include_total = false )
Description Description
Source Source
File: classes/Helpers.php
public static function taxonomy_selectlist_query( $taxonomies = array(), $args = array(), $include_total = false ) { if ( empty ( $taxonomies ) ) { $taxonomies = array( 'category' ); } $args = wp_parse_args( $args, array( 'hide_empty' => false, 'number' => 10, 'search' => '', 'include' => null, 'exclude' => null, 'offset' => 0, 'page' => null, ) ); if ( $args['page'] ) { $args['offset'] = ( $args['page'] - 1 ) * $args['number']; } // Query Caching. static $queries = array(); $key = md5( serialize( $args ) ); if ( ! isset( $queries[ $key ] ) ) { $terms = array(); foreach ( get_terms( $taxonomies, $args ) as $term ) { $terms[ $term->term_id ] = $term->name; } $total_args = $args; unset( $total_args['number'] ); unset( $total_args['offset'] ); $results = array( 'items' => $terms, 'total_count' => $include_total ? wp_count_terms( $taxonomies, $total_args ) : null, ); $queries[ $key ] = $results; } else { $results = $queries[ $key ]; } return ! $include_total ? $results['items'] : $results; }
Expand full source code Collapse full source code View on Trac