Changeset 5289 for branches/2.2/wp-includes/category.php
- Timestamp:
- 04/19/2007 10:26:52 PM (19 years ago)
- File:
-
- 1 edited
-
branches/2.2/wp-includes/category.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/wp-includes/category.php
r5248 r5289 1 1 <?php 2 3 define('TAXONOMY_CATEGORY', 1);4 define('TAXONOMY_TAG', 2);5 2 6 3 function get_all_category_ids() { … … 81 78 else 82 79 $where .= ' AND category_count > 0'; 83 } else { 84 $where .= ' AND ( type & ' . TAXONOMY_CATEGORY . ' != 0 ) '; 85 } 86 87 80 } 88 81 89 82 if ( !empty($number) ) … … 214 207 } 215 208 216 function get_category_by_slug( $slug ) {217 global $wpdb;218 $slug = sanitize_title( $slug );219 if ( empty( $slug ) )220 return false;221 $category = $wpdb->get_var( "SELECT * FROM $wpdb->categories WHERE category_nicename = '$slug' " );222 return get_category( $category );223 }224 225 209 // Get the ID of a category from its name 226 210 function get_cat_ID($cat_name='General') { … … 345 329 return $children; 346 330 } 347 348 // Tags349 350 function &get_tags($args = '') {351 global $wpdb, $category_links;352 353 $defaults = array('orderby' => 'name', 'order' => 'ASC',354 'hide_empty' => true, 'exclude' => '', 'include' => '',355 'number' => '');356 $args = wp_parse_args( $args, $defaults );357 if ( 'count' == $args['orderby'] )358 $args['orderby'] = 'tag_count';359 else360 $args['orderby'] = "cat_" . $args['orderby']; // restricts order by to cat_ID and cat_name fields361 $args['number'] = (int) $args['number'];362 extract($args);363 364 $key = md5( serialize( $args ) );365 if ( $cache = wp_cache_get( 'get_tags', 'category' ) )366 if ( isset( $cache[ $key ] ) )367 return apply_filters('get_tags', $cache[$key], $args);368 369 $where = 'cat_ID > 0';370 $inclusions = '';371 if ( !empty($include) ) {372 $child_of = 0; //ignore child_of and exclude params if using include373 $exclude = '';374 $incategories = preg_split('/[\s,]+/',$include);375 if ( count($incategories) ) {376 foreach ( $incategories as $incat ) {377 if (empty($inclusions))378 $inclusions = ' AND ( cat_ID = ' . intval($incat) . ' ';379 else380 $inclusions .= ' OR cat_ID = ' . intval($incat) . ' ';381 }382 }383 }384 385 if (!empty($inclusions))386 $inclusions .= ')';387 $where .= $inclusions;388 389 $exclusions = '';390 if ( !empty($exclude) ) {391 $excategories = preg_split('/[\s,]+/',$exclude);392 if ( count($excategories) ) {393 foreach ( $excategories as $excat ) {394 if (empty($exclusions))395 $exclusions = ' AND ( cat_ID <> ' . intval($excat) . ' ';396 else397 $exclusions .= ' AND cat_ID <> ' . intval($excat) . ' ';398 }399 }400 }401 402 if (!empty($exclusions))403 $exclusions .= ')';404 $exclusions = apply_filters('list_tags_exclusions', $exclusions, $args );405 $where .= $exclusions;406 407 if ( $hide_empty )408 $where .= ' AND tag_count > 0';409 410 $where .= ' AND ( type & ' . TAXONOMY_TAG . ' != 0 ) ';411 412 if ( !empty($number) )413 $number = 'LIMIT ' . $number;414 else415 $number = '';416 417 $tags = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE $where ORDER BY $orderby $order $number");418 419 if ( empty($tags) )420 return array();421 422 $cache[ $key ] = $tags;423 wp_cache_set( 'get_tags', $cache, 'category' );424 425 $tags = apply_filters('get_tags', $tags, $args);426 return $tags;427 }428 429 331 ?>
Note: See TracChangeset
for help on using the changeset viewer.