Add ignore_empty option to wp_count_terms(). see #4189

git-svn-id: https://develop.svn.wordpress.org/trunk@5596 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2007-05-30 01:05:44 +00:00
parent 7480586494
commit 1bb6925679
1 changed files with 10 additions and 2 deletions

View File

@ -39,10 +39,18 @@ function register_taxonomy( $taxonomy, $object_type, $args = array() ) {
$wp_taxonomies[$taxonomy] = (object) $args;
}
function wp_count_terms( $taxonomy ) {
function wp_count_terms( $taxonomy, $args = array() ) {
global $wpdb;
return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy'");
$defaults = array('ignore_empty' => false);
$args = wp_parse_args($args, $defaults);
extract($args);
$where = '';
if ( $ignore_empty )
$where = 'AND count > 0';
return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy' $where");
}
/**