Make WordPress Core

Changeset 5596


Ignore:
Timestamp:
05/30/2007 01:05:44 AM (17 years ago)
Author:
ryan
Message:

Add ignore_empty option to wp_count_terms(). see #4189

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r5594 r5596  
    4040}
    4141
    42 function wp_count_terms( $taxonomy ) {
    43     global $wpdb;
    44 
    45     return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy'");
     42function wp_count_terms( $taxonomy, $args = array() ) {
     43    global $wpdb;
     44
     45    $defaults = array('ignore_empty' => false);
     46    $args = wp_parse_args($args, $defaults);
     47    extract($args);
     48
     49    $where = '';
     50    if ( $ignore_empty )
     51        $where = 'AND count > 0';
     52
     53    return $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = '$taxonomy' $where");
    4654}
    4755
Note: See TracChangeset for help on using the changeset viewer.