Ticket #5634: 5634.r8786.diff
File 5634.r8786.diff, 10.7 KB (added by , 17 years ago) |
---|
-
category-template.php
1 1 <?php 2 /** 3 * Category Template Tags and API. 4 * 5 * @package WordPress 6 * @subpackage Template 7 */ 2 8 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 */ 3 21 function get_category_children( $id, $before = '/', $after = '', $visited = array() ) { 4 22 if ( 0 == $id ) 5 23 return ''; 6 24 7 25 $chain = ''; 8 / / TODO: consult hierarchy26 /** TODO: consult hierarchy */ 9 27 $cat_ids = get_all_category_ids(); 10 28 foreach ( (array) $cat_ids as $cat_id ) { 11 29 if ( $cat_id == $id ) … … 23 41 return $chain; 24 42 } 25 43 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 */ 26 54 function get_category_link( $category_id ) { 27 55 global $wp_rewrite; 28 56 $catlink = $wp_rewrite->get_category_permastruct(); … … 45 73 return apply_filters( 'category_link', $catlink, $category_id ); 46 74 } 47 75 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 */ 48 89 function get_category_parents( $id, $link = FALSE, $separator = '/', $nicename = FALSE, $visited = array() ) { 49 90 $chain = ''; 50 91 $parent = &get_category( $id ); … … 68 109 return $chain; 69 110 } 70 111 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 */ 71 124 function get_the_category( $id = false ) { 72 125 global $post; 73 126 … … 91 144 return $categories; 92 145 } 93 146 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 */ 94 158 function _usort_terms_by_name( $a, $b ) { 95 159 return strcmp( $a->name, $b->name ); 96 160 } 97 161 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 */ 98 173 function _usort_terms_by_ID( $a, $b ) { 99 174 if ( $a->term_id > $b->term_id ) 100 175 return 1; … … 104 179 return 0; 105 180 } 106 181 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 */ 107 192 function get_the_category_by_ID( $cat_ID ) { 108 193 $cat_ID = (int) $cat_ID; 109 194 $category = &get_category( $cat_ID ); … … 112 197 return $category->name; 113 198 } 114 199 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 */ 115 211 function get_the_category_list( $separator = '', $parents='', $post_id = false ) { 116 212 global $wp_rewrite; 117 213 $categories = get_the_category( $post_id ); … … 170 266 return apply_filters( 'the_category', $thelist, $separator, $parents ); 171 267 } 172 268 173 /* 174 * in_category() - Checks whether the current post is within a particular category269 /** 270 * Checks whether the current post is within a particular category. 175 271 * 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. 179 276 * 180 277 * @since 1.2.0 181 278 * 182 279 * @param int|string $category 183 280 * @return bool true if the post is in the supplied category 184 281 */ 185 function in_category( $category ) { // Check if the current post is in the given category282 function in_category( $category ) { 186 283 global $post; 187 284 188 285 if ( empty( $category ) ) … … 204 301 return false; 205 302 } 206 303 304 /** 305 * {@internal Missing Short Description}} 306 * 307 * @since 0.71 308 * 309 * @param unknown_type $separator 310 * @param unknown_type $parents 311 */ 207 312 function the_category( $separator = '', $parents='', $post_id = false ) { 208 313 echo get_the_category_list( $separator, $parents, $post_id ); 209 314 } 210 315 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 */ 211 326 function category_description( $category = 0 ) { 212 327 global $cat; 213 328 if ( !$category ) … … 216 331 return get_term_field( 'description', $category, 'category' ); 217 332 } 218 333 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 */ 219 344 function wp_dropdown_categories( $args = '' ) { 220 345 $defaults = array( 221 346 'show_option_all' => '', 'show_option_none' => '', … … 271 396 return $output; 272 397 } 273 398 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 */ 274 409 function wp_list_categories( $args = '' ) { 275 410 $defaults = array( 276 411 'show_option_all' => '', 'orderby' => 'name', … … 337 472 return $output; 338 473 } 339 474 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 */ 340 485 function wp_tag_cloud( $args = '' ) { 341 486 $defaults = array( 342 487 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, … … 373 518 * Generates a tag cloud (heatmap) from provided data 374 519 * 375 520 * TODO: Complete 521 * $tags = prefetched tag array ( get_tags() ) 522 * $args['format'] = 'flat' => whitespace separated, 'list' => UL, 'array' => array() 523 * $args['orderby'] = 'name', 'count' 376 524 * 377 * @since 2. 6525 * @since 2.3.0 378 526 * 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 */ 383 531 function wp_generate_tag_cloud( $tags, $args = '' ) { 384 532 global $wp_rewrite; 385 533 $defaults = array( … … 460 608 // Helper functions 461 609 // 462 610 611 /** 612 * {@internal Missing Short Description}} 613 * 614 * {@internal Missing Long Description}} 615 * 616 * @since 2.1.0 617 * 618 * @return unknown 619 */ 463 620 function walk_category_tree() { 464 621 $walker = new Walker_Category; 465 622 $args = func_get_args(); 466 623 return call_user_func_array(array( &$walker, 'walk' ), $args ); 467 624 } 468 625 626 /** 627 * {@internal Missing Short Description}} 628 * 629 * {@internal Missing Long Description}} 630 * 631 * @since 2.1.0 632 * 633 * @return unknown 634 */ 469 635 function walk_category_dropdown_tree() { 470 636 $walker = new Walker_CategoryDropdown; 471 637 $args = func_get_args(); … … 476 642 // Tags 477 643 // 478 644 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 */ 479 655 function get_tag_link( $tag_id ) { 480 656 global $wp_rewrite; 481 657 $taglink = $wp_rewrite->get_tag_permastruct(); … … 495 671 return apply_filters( 'tag_link', $taglink, $tag_id ); 496 672 } 497 673 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 */ 498 684 function get_the_tags( $id = 0 ) { 499 685 return apply_filters( 'get_the_tags', get_the_terms( $id, 'post_tag' ) ); 500 686 } 501 687 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 */ 502 700 function get_the_tag_list( $before = '', $sep = '', $after = '' ) { 503 701 return apply_filters( 'the_tags', get_the_term_list( 0, 'post_tag', $before, $sep, $after ) ); 504 702 } 505 703 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 */ 506 716 function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) { 507 717 return the_terms( 0, 'post_tag', $before, $sep, $after ); 508 718 } 509 719 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 */ 510 731 function get_the_terms( $id = 0, $taxonomy ) { 511 732 global $post; 512 733 … … 528 749 return $terms; 529 750 } 530 751 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 */ 531 766 function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after = '' ) { 532 767 $terms = get_the_terms( $id, $taxonomy ); 533 768 … … 549 784 return $before . join( $sep, $term_links ) . $after; 550 785 } 551 786 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 */ 552 801 function the_terms( $id, $taxonomy, $before = '', $sep = '', $after = '' ) { 553 802 $return = get_the_term_list( $id, $taxonomy, $before, $sep, $after ); 554 803 if ( is_wp_error( $return ) ) … … 558 807 } 559 808 560 809 /** 561 * Check if the current post has the given tag 810 * Check if the current post has the given tag. 562 811 * 563 * @package WordPress 564 * @since 2.6 812 * @since 2.6.0 565 813 * 566 814 * @uses wp_get_object_terms() Gets the tags. 567 815 * 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. 570 818 */ 571 819 function has_tag( $tag = '' ) { 572 820 global $post;