Changeset 13491
- Timestamp:
- 02/28/2010 07:37:24 AM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/edit-tags.php
r13450 r13491 231 231 } 232 232 233 if ( !empty($_GET['s']) ) { 234 $searchterms = trim(stripslashes($_GET['s'])); 235 $total_terms = count( get_terms( $taxonomy, array( 'search' => $searchterms, 'number' => 0, 'hide_empty' => 0 ) ) ); 236 } else { 237 $searchterms = ''; 238 $total_terms = wp_count_terms($taxonomy); 239 } 233 $searchterms = !empty($_GET['s']) ? trim(stripslashes($_GET['s'])) : ''; 240 234 241 235 $page_links = paginate_links( array( … … 244 238 'prev_text' => __('«'), 245 239 'next_text' => __('»'), 246 'total' => ceil( $total_terms/ $tags_per_page),240 'total' => ceil(wp_count_terms($taxonomy, array('search' => $searchterms)) / $tags_per_page), 247 241 'current' => $pagenum 248 242 )); -
trunk/wp-includes/taxonomy.php
r13430 r13491 872 872 873 873 $selects = array(); 874 if ( 'all' == $fields ) 875 $selects = array('t.*', 'tt.*'); 876 else if ( 'ids' == $fields || 'id=>parent' == $fields ) 877 $selects = array('t.term_id', 'tt.parent', 'tt.count'); 878 else if ( 'names' == $fields ) 879 $selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name'); 874 switch ( $fields ) { 875 case 'all': 876 $selects = array('t.*', 'tt.*'); 877 break; 878 case 'ids': 879 case 'id=>parent': 880 $selects = array('t.term_id', 'tt.parent', 'tt.count'); 881 break; 882 case 'names': 883 $selects = array('t.term_id', 'tt.parent', 'tt.count', 't.name'); 884 break; 885 case 'count': 886 $selects = array('COUNT(*)'); 887 } 880 888 $select_this = implode(', ', apply_filters( 'get_terms_fields', $selects, $args )); 881 889 882 890 $query = "SELECT $select_this FROM $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ($in_taxonomies) $where ORDER BY $orderby $order $limit"; 891 892 if ( 'count' == $fields ) { 893 $term_count = $wpdb->get_var($query); 894 return $term_count; 895 } 883 896 884 897 $terms = $wpdb->get_results($query); … … 1131 1144 * Count how many terms are in Taxonomy. 1132 1145 * 1133 * Default $args is 'ignore_empty' which can be <code>'ignore_empty=true'</code> 1134 * or <code>array('ignore_empty' => true);</code>. 1135 * 1136 * @package WordPress 1137 * @subpackage Taxonomy 1138 * @since 2.3.0 1139 * 1140 * @uses $wpdb 1146 * Default $args is 'hide_empty' which can be 'hide_empty=true' or array('hide_empty' => true). 1147 * 1148 * @package WordPress 1149 * @subpackage Taxonomy 1150 * @since 2.3.0 1151 * 1152 * @uses get_terms() 1141 1153 * @uses wp_parse_args() Turns strings into arrays and merges defaults into an array. 1142 1154 * 1143 1155 * @param string $taxonomy Taxonomy name 1144 * @param array|string $args Overwrite defaults 1156 * @param array|string $args Overwrite defaults. See get_terms() 1145 1157 * @return int How many terms are in $taxonomy 1146 1158 */ 1147 1159 function wp_count_terms( $taxonomy, $args = array() ) { 1148 global $wpdb; 1149 1150 $defaults = array('ignore_empty' => false); 1160 $defaults = array('hide_empty' => false); 1151 1161 $args = wp_parse_args($args, $defaults); 1152 extract($args, EXTR_SKIP); 1153 1154 $where = ''; 1155 if ( $ignore_empty ) 1156 $where = 'AND count > 0'; 1157 1158 return $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE taxonomy = %s $where", $taxonomy) ); 1162 1163 // backwards compatibility 1164 if ( isset($args['ignore_empty']) ) { 1165 $args['hide_empty'] = $args['ignore_empty']; 1166 unset($args['ignore_empty']); 1167 } 1168 1169 $args['fields'] = 'count'; 1170 1171 return get_terms($taxonomy, $args); 1159 1172 } 1160 1173
Note: See TracChangeset
for help on using the changeset viewer.