Make WordPress Core

Ticket #5634: 5634.r8786.diff

File 5634.r8786.diff, 10.7 KB (added by jacobsantos, 16 years ago)

Updated patch for r8786.

  • category-template.php

     
    11<?php
     2/**
     3 * Category Template Tags and API.
     4 *
     5 * @package WordPress
     6 * @subpackage Template
     7 */
    28
     9/**
     10 * {@internal Missing Short Description}}
     11 *
     12 * {@internal Missing Long Description}}
     13 *
     14 * @since 1.2.0
     15 *
     16 * @param unknown_type $id
     17 * @param unknown_type $before
     18 * @param unknown_type $after
     19 * @return unknown
     20 */
    321function get_category_children( $id, $before = '/', $after = '', $visited = array() ) {
    422        if ( 0 == $id )
    523                return '';
    624
    725        $chain = '';
    8         // TODO: consult hierarchy
     26        /** TODO: consult hierarchy */
    927        $cat_ids = get_all_category_ids();
    1028        foreach ( (array) $cat_ids as $cat_id ) {
    1129                if ( $cat_id == $id )
     
    2341        return $chain;
    2442}
    2543
     44/**
     45 * {@internal Missing Short Description}}
     46 *
     47 * {@internal Missing Long Description}}
     48 *
     49 * @since 1.0.0
     50 *
     51 * @param unknown_type $category_id
     52 * @return unknown
     53 */
    2654function get_category_link( $category_id ) {
    2755        global $wp_rewrite;
    2856        $catlink = $wp_rewrite->get_category_permastruct();
     
    4573        return apply_filters( 'category_link', $catlink, $category_id );
    4674}
    4775
     76/**
     77 * {@internal Missing Short Description}}
     78 *
     79 * {@internal Missing Long Description}}
     80 *
     81 * @since 1.2.0
     82 *
     83 * @param unknown_type $id
     84 * @param unknown_type $link
     85 * @param unknown_type $separator
     86 * @param unknown_type $nicename
     87 * @return unknown
     88 */
    4889function get_category_parents( $id, $link = FALSE, $separator = '/', $nicename = FALSE, $visited = array() ) {
    4990        $chain = '';
    5091        $parent = &get_category( $id );
     
    68109        return $chain;
    69110}
    70111
     112/**
     113 * {@internal Missing Short Description}}
     114 *
     115 * {@internal Missing Long Description}}
     116 *
     117 * @since 0.71
     118 * @uses $post
     119 * @global mixed $term_cache
     120 *
     121 * @param unknown_type $id
     122 * @return unknown
     123 */
    71124function get_the_category( $id = false ) {
    72125        global $post;
    73126
     
    91144        return $categories;
    92145}
    93146
     147/**
     148 * {@internal Missing Short Description}}
     149 *
     150 * {@internal Missing Long Description}}
     151 *
     152 * @since 2.3.0
     153 *
     154 * @param unknown_type $a
     155 * @param unknown_type $b
     156 * @return unknown
     157 */
    94158function _usort_terms_by_name( $a, $b ) {
    95159        return strcmp( $a->name, $b->name );
    96160}
    97161
     162/**
     163 * {@internal Missing Short Description}}
     164 *
     165 * {@internal Missing Long Description}}
     166 *
     167 * @since 2.3.0
     168 *
     169 * @param unknown_type $a
     170 * @param unknown_type $b
     171 * @return unknown
     172 */
    98173function _usort_terms_by_ID( $a, $b ) {
    99174        if ( $a->term_id > $b->term_id )
    100175                return 1;
     
    104179                return 0;
    105180}
    106181
     182/**
     183 * {@internal Missing Short Description}}
     184 *
     185 * {@internal Missing Long Description}}
     186 *
     187 * @since 0.71
     188 *
     189 * @param unknown_type $cat_ID
     190 * @return unknown
     191 */
    107192function get_the_category_by_ID( $cat_ID ) {
    108193        $cat_ID = (int) $cat_ID;
    109194        $category = &get_category( $cat_ID );
     
    112197        return $category->name;
    113198}
    114199
     200/**
     201 * {@internal Missing Short Description}}
     202 *
     203 * {@internal Missing Long Description}}
     204 *
     205 * @since 1.5.1
     206 *
     207 * @param unknown_type $separator
     208 * @param unknown_type $parents
     209 * @return unknown
     210 */
    115211function get_the_category_list( $separator = '', $parents='', $post_id = false ) {
    116212        global $wp_rewrite;
    117213        $categories = get_the_category( $post_id );
     
    170266        return apply_filters( 'the_category', $thelist, $separator, $parents );
    171267}
    172268
    173 /*
    174  * in_category() - Checks whether the current post is within a particular category
     269/**
     270 * Checks whether the current post is within a particular category.
    175271 *
    176  * This function checks to see if the post is within the supplied category.  The categoy
    177  * can be specified by number or name and will be checked as a name first to allow for categories with numeric names.
    178  * Note: Prior to v2.5 of WordPress category names where not supported.
     272 * This function checks to see if the post is within the supplied category. The
     273 * category can be specified by number or name and will be checked as a name
     274 * first to allow for categories with numeric names. Note: Prior to v2.5 of
     275 * WordPress category names were not supported.
    179276 *
    180277 * @since 1.2.0
    181278 *
    182279 * @param int|string $category
    183280 * @return bool true if the post is in the supplied category
    184281*/
    185 function in_category( $category ) { // Check if the current post is in the given category
     282function in_category( $category ) {
    186283        global $post;
    187284
    188285        if ( empty( $category ) )
     
    204301                return false;
    205302}
    206303
     304/**
     305 * {@internal Missing Short Description}}
     306 *
     307 * @since 0.71
     308 *
     309 * @param unknown_type $separator
     310 * @param unknown_type $parents
     311 */
    207312function the_category( $separator = '', $parents='', $post_id = false ) {
    208313        echo get_the_category_list( $separator, $parents, $post_id );
    209314}
    210315
     316/**
     317 * {@internal Missing Short Description}}
     318 *
     319 * {@internal Missing Long Description}}
     320 *
     321 * @since 1.0.0
     322 *
     323 * @param unknown_type $category
     324 * @return unknown
     325 */
    211326function category_description( $category = 0 ) {
    212327        global $cat;
    213328        if ( !$category )
     
    216331        return get_term_field( 'description', $category, 'category' );
    217332}
    218333
     334/**
     335 * {@internal Missing Short Description}}
     336 *
     337 * {@internal Missing Long Description}}
     338 *
     339 * @since 2.1.0
     340 *
     341 * @param unknown_type $args
     342 * @return unknown
     343 */
    219344function wp_dropdown_categories( $args = '' ) {
    220345        $defaults = array(
    221346                'show_option_all' => '', 'show_option_none' => '',
     
    271396        return $output;
    272397}
    273398
     399/**
     400 * {@internal Missing Short Description}}
     401 *
     402 * {@internal Missing Long Description}}
     403 *
     404 * @since 2.1.0
     405 *
     406 * @param unknown_type $args
     407 * @return unknown
     408 */
    274409function wp_list_categories( $args = '' ) {
    275410        $defaults = array(
    276411                'show_option_all' => '', 'orderby' => 'name',
     
    337472                return $output;
    338473}
    339474
     475/**
     476 * {@internal Missing Short Description}}
     477 *
     478 * {@internal Missing Long Description}}
     479 *
     480 * @since 2.3.0
     481 *
     482 * @param unknown_type $args
     483 * @return unknown
     484 */
    340485function wp_tag_cloud( $args = '' ) {
    341486        $defaults = array(
    342487                'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45,
     
    373518 * Generates a tag cloud (heatmap) from provided data
    374519 *
    375520 * TODO: Complete
     521 * $tags = prefetched tag array ( get_tags() )
     522 * $args['format'] = 'flat' => whitespace separated, 'list' => UL, 'array' => array()
     523 * $args['orderby'] = 'name', 'count'
    376524 *
    377  * @since 2.6
     525 * @since 2.3.0
    378526 *
    379  * $tags = array of objects with the properties 'name', 'link', 'id', and 'count'
    380  * $args['format'] = 'flat' => whitespace separated, 'list' => UL, 'array' => array()
    381  * $args['orderby'] = 'name', 'count'
    382 */
     527 * @param unknown_type $tags
     528 * @param unknown_type $args
     529 * @return unknown
     530 */
    383531function wp_generate_tag_cloud( $tags, $args = '' ) {
    384532        global $wp_rewrite;
    385533        $defaults = array(
     
    460608// Helper functions
    461609//
    462610
     611/**
     612 * {@internal Missing Short Description}}
     613 *
     614 * {@internal Missing Long Description}}
     615 *
     616 * @since 2.1.0
     617 *
     618 * @return unknown
     619 */
    463620function walk_category_tree() {
    464621        $walker = new Walker_Category;
    465622        $args = func_get_args();
    466623        return call_user_func_array(array( &$walker, 'walk' ), $args );
    467624}
    468625
     626/**
     627 * {@internal Missing Short Description}}
     628 *
     629 * {@internal Missing Long Description}}
     630 *
     631 * @since 2.1.0
     632 *
     633 * @return unknown
     634 */
    469635function walk_category_dropdown_tree() {
    470636        $walker = new Walker_CategoryDropdown;
    471637        $args = func_get_args();
     
    476642// Tags
    477643//
    478644
     645/**
     646 * {@internal Missing Short Description}}
     647 *
     648 * {@internal Missing Long Description}}
     649 *
     650 * @since 2.3.0
     651 *
     652 * @param unknown_type $tag_id
     653 * @return unknown
     654 */
    479655function get_tag_link( $tag_id ) {
    480656        global $wp_rewrite;
    481657        $taglink = $wp_rewrite->get_tag_permastruct();
     
    495671        return apply_filters( 'tag_link', $taglink, $tag_id );
    496672}
    497673
     674/**
     675 * {@internal Missing Short Description}}
     676 *
     677 * {@internal Missing Long Description}}
     678 *
     679 * @since 2.3.0
     680 *
     681 * @param unknown_type $id
     682 * @return unknown
     683 */
    498684function get_the_tags( $id = 0 ) {
    499685        return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) );
    500686}
    501687
     688/**
     689 * {@internal Missing Short Description}}
     690 *
     691 * {@internal Missing Long Description}}
     692 *
     693 * @since 2.3.0
     694 *
     695 * @param unknown_type $before
     696 * @param unknown_type $sep
     697 * @param unknown_type $after
     698 * @return unknown
     699 */
    502700function get_the_tag_list( $before = '', $sep = '', $after = '' ) {
    503701        return apply_filters( 'the_tags', get_the_term_list( 0, 'post_tag', $before, $sep, $after ) );
    504702}
    505703
     704/**
     705 * {@internal Missing Short Description}}
     706 *
     707 * {@internal Missing Long Description}}
     708 *
     709 * @since 2.3.0
     710 *
     711 * @param unknown_type $before
     712 * @param unknown_type $sep
     713 * @param unknown_type $after
     714 * @return unknown
     715 */
    506716function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) {
    507717        return the_terms( 0, 'post_tag', $before, $sep, $after );
    508718}
    509719
     720/**
     721 * {@internal Missing Short Description}}
     722 *
     723 * {@internal Missing Long Description}}
     724 *
     725 * @since 2.5.0
     726 *
     727 * @param unknown_type $id
     728 * @param unknown_type $taxonomy
     729 * @return unknown
     730 */
    510731function get_the_terms( $id = 0, $taxonomy ) {
    511732        global $post;
    512733
     
    528749        return $terms;
    529750}
    530751
     752/**
     753 * {@internal Missing Short Description}}
     754 *
     755 * {@internal Missing Long Description}}
     756 *
     757 * @since 2.5.0
     758 *
     759 * @param unknown_type $id
     760 * @param unknown_type $taxonomy
     761 * @param unknown_type $before
     762 * @param unknown_type $sep
     763 * @param unknown_type $after
     764 * @return unknown
     765 */
    531766function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '' ) {
    532767        $terms = get_the_terms( $id, $taxonomy );
    533768
     
    549784        return $before . join( $sep, $term_links ) . $after;
    550785}
    551786
     787/**
     788 * {@internal Missing Short Description}}
     789 *
     790 * {@internal Missing Long Description}}
     791 *
     792 * @since 2.5.0
     793 *
     794 * @param unknown_type $id
     795 * @param unknown_type $taxonomy
     796 * @param unknown_type $before
     797 * @param unknown_type $sep
     798 * @param unknown_type $after
     799 * @return unknown
     800 */
    552801function the_terms( $id, $taxonomy, $before = '', $sep = '', $after = '' ) {
    553802        $return = get_the_term_list( $id, $taxonomy, $before, $sep, $after );
    554803        if ( is_wp_error( $return ) )
     
    558807}
    559808
    560809/**
    561  * Check if the current post has the given tag
     810 * Check if the current post has the given tag.
    562811 *
    563  * @package WordPress
    564  * @since 2.6
     812 * @since 2.6.0
    565813 *
    566814 * @uses wp_get_object_terms() Gets the tags.
    567815 *
    568  * @param string|int|array $tag Optional. The tag name/id/slug or array of them to check for
    569  * @return bool True if the current post has the given tag, or any tag, if no tag specified
     816 * @param string|int|array $tag Optional. The tag name/id/slug or array of them to check for.
     817 * @return bool True if the current post has the given tag, or any tag, if no tag specified.
    570818 */
    571819function has_tag( $tag = '' ) {
    572820        global $post;