Make WordPress Core


Ignore:
Timestamp:
04/19/2007 10:26:52 PM (19 years ago)
Author:
markjaquith
Message:

Roll tags out of 2.2 -- reverts [5272], [5271], [5257], [5254], [5253], [5251], [5250], [5243], [5235], [5234], [5232], [5231], [5229], [5228], [5217], [5216], [5215], [5213], half of [5210], [5209], [5205], [5203], [5201], [5196], [5184], [5168], [5163], [5162], [5150], [5149], [5148], [5147], [5113], [5112], [5111], and [5110]

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/wp-includes/category.php

    r5248 r5289  
    11<?php
    2 
    3 define('TAXONOMY_CATEGORY', 1);
    4 define('TAXONOMY_TAG', 2);
    52
    63function get_all_category_ids() {
     
    8178        else
    8279            $where .= ' AND category_count > 0';
    83     } else {
    84         $where .= ' AND ( type & ' . TAXONOMY_CATEGORY . ' != 0 ) ';
    85     }
    86 
    87    
     80    }
    8881
    8982    if ( !empty($number) )
     
    214207}
    215208
    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 
    225209// Get the ID of a category from its name
    226210function get_cat_ID($cat_name='General') {
     
    345329    return $children;
    346330}
    347 
    348 // Tags
    349 
    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     else
    360         $args['orderby'] = "cat_" . $args['orderby'];  // restricts order by to cat_ID and cat_name fields
    361     $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 include
    373         $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                 else
    380                     $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                 else
    397                     $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     else
    415         $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 
    429331?>
Note: See TracChangeset for help on using the changeset viewer.