Ticket #5642: 5642.r8786.2.diff
File 5642.r8786.2.diff, 14.7 KB (added by , 16 years ago) |
---|
-
link-template.php
1 1 <?php 2 /** 3 * WordPress Link Template Functions 4 * 5 * @package WordPress 6 * @subpackage Template 7 */ 2 8 3 9 /** 10 * the_permalink() - {@internal Missing Short Description}} 11 * 12 * {@internal Missing Long Description}} 13 * 14 * @since 1.2.0 15 * @uses apply_filters() 16 */ 4 17 function the_permalink() { 5 18 echo apply_filters('the_permalink', get_permalink()); 6 19 } 7 20 8 21 9 22 /** 23 * user_trailingshashit() - {@internal Missing Short Description}} 24 * 25 * {@internal Missing Long Description}} 26 * 27 * @since 2.2.0 28 * 10 29 * Conditionally adds a trailing slash if the permalink structure 11 30 * has a trailing slash, strips the trailing slash if not 12 * @ global object Uses $wp_rewrite31 * @uses $wp_rewrite 13 32 * @param $string string a URL with or without a trailing slash 14 33 * @param $type_of_url string the type of URL being considered (e.g. single, category, etc) for use in the filter 15 34 * @return string … … 27 46 return $string; 28 47 } 29 48 30 49 /** 50 * permalink_anchor() - {@internal Missing Short Description}} 51 * 52 * {@internal Missing Long Description}} 53 * 54 * @since 0.71 55 * 56 * @param unknown_type $mode 57 */ 31 58 function permalink_anchor($mode = 'id') { 32 59 global $post; 33 60 switch ( strtolower($mode) ) { … … 42 69 } 43 70 } 44 71 45 72 /** 73 * get_permalink() - {@internal Missing Short Description}} 74 * 75 * {@internal Missing Long Description}} 76 * 77 * @since 1.0.0 78 * 79 * @param unknown_type $id 80 * @return unknown 81 */ 46 82 function get_permalink($id = 0, $leavename=false) { 47 83 $rewritecode = array( 48 84 '%year%', … … 119 155 } 120 156 } 121 157 122 // get permalink from post ID 158 /** 159 * post_permalink() - Retrieve permalink from post ID 160 * 161 * {@internal Missing Long Description}} 162 * 163 * @since 1.0.0 164 * 165 * @param unknown_type $post_id 166 * @param unknown_type $deprecated 167 * @return unknown 168 */ 123 169 function post_permalink($post_id = 0, $deprecated = '') { 124 170 return get_permalink($post_id); 125 171 } 126 172 127 173 // Respects page_on_front. Use this one. 174 /** 175 * get_page_link() - {@internal Missing Short Description}} 176 * 177 * {@internal Missing Long Description}} 178 * 179 * @since 1.5.0 180 * 181 * @param unknown_type $id 182 * @return unknown 183 */ 128 184 function get_page_link($id = false, $leavename = false) { 129 185 global $post; 130 186 … … 140 196 return apply_filters('page_link', $link, $id); 141 197 } 142 198 143 // Ignores page_on_front. Internal use only. 199 /** 200 * _get_page_link() - {@internal Missing Short Description}} 201 * 202 * {@internal Missing Long Description}} 203 * 204 * Ignores page_on_front. Internal use only. 205 * 206 * @since 2.1.0 207 * @access private 208 * 209 * @param unknown_type $id 210 * @return unknown 211 */ 144 212 function _get_page_link( $id = false, $leavename = false ) { 145 213 global $post, $wp_rewrite; 146 214 … … 163 231 return apply_filters( '_get_page_link', $link, $id ); 164 232 } 165 233 234 /** 235 * get_attachment_link() - {@internal Missing Short Description}} 236 * 237 * {@internal Missing Long Description}} 238 * 239 * @since 2.0.0 240 * 241 * @param unknown_type $id 242 * @return unknown 243 */ 166 244 function get_attachment_link($id = false) { 167 245 global $post, $wp_rewrite; 168 246 … … 194 272 return apply_filters('attachment_link', $link, $id); 195 273 } 196 274 275 /** 276 * get_year_link() - {@internal Missing Short Description}} 277 * 278 * {@internal Missing Long Description}} 279 * 280 * @since 1.5.0 281 * 282 * @param unknown_type $year 283 * @return unknown 284 */ 197 285 function get_year_link($year) { 198 286 global $wp_rewrite; 199 287 if ( !$year ) … … 207 295 } 208 296 } 209 297 298 /** 299 * get_month_link() - {@internal Missing Short Description}} 300 * 301 * {@internal Missing Long Description}} 302 * 303 * @since 1.0.0 304 * 305 * @param unknown_type $year 306 * @param unknown_type $month 307 * @return unknown 308 */ 210 309 function get_month_link($year, $month) { 211 310 global $wp_rewrite; 212 311 if ( !$year ) … … 223 322 } 224 323 } 225 324 325 /** 326 * get_day_link() - {@internal Missing Short Description}} 327 * 328 * {@internal Missing Long Description}} 329 * 330 * @since 1.0.0 331 * 332 * @param unknown_type $year 333 * @param unknown_type $month 334 * @param unknown_type $day 335 * @return unknown 336 */ 226 337 function get_day_link($year, $month, $day) { 227 338 global $wp_rewrite; 228 339 if ( !$year ) … … 243 354 } 244 355 } 245 356 357 /** 358 * get_feed_link() - {@internal Missing Short Description}} 359 * 360 * {@internal Missing Long Description}} 361 * 362 * @since 1.5.0 363 * 364 * @param unknown_type $feed 365 * @return unknown 366 */ 246 367 function get_feed_link($feed = '') { 247 368 global $wp_rewrite; 248 369 … … 272 393 return apply_filters('feed_link', $output, $feed); 273 394 } 274 395 396 /** 397 * get_post_comments_feed_link() - {@internal Missing Short Description}} 398 * 399 * {@internal Missing Long Description}} 400 * 401 * @since 2.2.0 402 * 403 * @param unknown_type $post_id 404 * @param unknown_type $feed 405 * @return unknown 406 */ 275 407 function get_post_comments_feed_link($post_id = '', $feed = '') { 276 408 global $id; 277 409 … … 297 429 return apply_filters('post_comments_feed_link', $url); 298 430 } 299 431 300 /** post_comments_feed_link() - Output the comment feed link for a post. 432 /** 433 * post_comments_feed_link() - Output the comment feed link for a post. 301 434 * 302 * Prints out the comment feed link for a post. 303 * anchor. If no link text is specified, default text is used. If no post ID304 * is specified, the current post is used.435 * Prints out the comment feed link for a post. Link text is placed in the 436 * anchor. If no link text is specified, default text is used. If no post 437 * ID is specified, the current post is used. 305 438 * 306 439 * @package WordPress 307 440 * @subpackage Feed 308 441 * @since 2.5 309 442 * 310 * @param string Descriptive text 311 * @param int Optional post ID. Default to current post. 443 * @param string $link_text Descriptive text 444 * @param int $post_id Optional post ID. Default to current post. 445 * @param string $feed Optional. {@internal Missing Description}} 312 446 * @return string Link to the comment feed for the current post 313 447 */ 314 448 function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) { … … 356 490 return $link; 357 491 } 358 492 359 /** Get the feed link for a given category 493 /** 494 * get_category_feed_link() - Get the feed link for a category 360 495 * 361 * Returns a link to the feed for all post s in a given category. A specific feed can be requested362 * or left blank to get the default feed.496 * Returns a link to the feed for all post in a given category. A specific 497 * feed can be requested or left blank to get the default feed. 363 498 * 364 499 * @package WordPress 365 500 * @subpackage Feed … … 399 534 return $link; 400 535 } 401 536 537 /** 538 * get_tag_feed_link() - {@internal Missing Short Description}} 539 * 540 * {@internal Missing Long Description}} 541 * 542 * @since 2.3.0 543 * 544 * @param unknown_type $tag_id 545 * @param unknown_type $feed 546 * @return unknown 547 */ 402 548 function get_tag_feed_link($tag_id, $feed = '') { 403 549 $tag_id = (int) $tag_id; 404 550 … … 428 574 return $link; 429 575 } 430 576 577 /** 578 * get_search_feed_link() - {@internal Missing Short Description}} 579 * 580 * {@internal Missing Long Description}} 581 * 582 * @since 2.5.0 583 * 584 * @param unknown_type $search_query 585 * @param unknown_type $feed 586 * @return unknown 587 */ 431 588 function get_search_feed_link($search_query = '', $feed = '') { 432 589 if ( empty($search_query) ) 433 590 $search = attribute_escape(get_search_query()); … … 444 601 return $link; 445 602 } 446 603 604 /** 605 * get_search_comment_feed_link() - {@internal Missing Short Description}} 606 * 607 * {@internal Missing Long Description}} 608 * 609 * @since 2.5.0 610 * 611 * @param unknown_type $search_query 612 * @param unknown_type $feed 613 * @return unknown 614 */ 447 615 function get_search_comments_feed_link($search_query = '', $feed = '') { 448 616 if ( empty($search_query) ) 449 617 $search = attribute_escape(get_search_query()); … … 460 628 return $link; 461 629 } 462 630 631 /** 632 * get_edit_post_link() - {@internal Missing Short Description}} 633 * 634 * {@internal Missing Long Description}} 635 * 636 * @since 2.3.0 637 * 638 * @param unknown_type $id 639 * @return unknown 640 */ 463 641 function get_edit_post_link( $id = 0, $context = 'display' ) { 464 642 if ( !$post = &get_post( $id ) ) 465 643 return; … … 500 678 return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context ); 501 679 } 502 680 681 /** 682 * edit_post_link() - {@internal Missing Short Description}} 683 * 684 * {@internal Missing Long Description}} 685 * 686 * @since 1.0.0 687 * 688 * @param unknown_type $link 689 * @param unknown_type $before 690 * @param unknown_type $after 691 */ 503 692 function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) { 504 693 global $post; 505 694 … … 515 704 echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after; 516 705 } 517 706 707 /** 708 * get_edit_comment_link() - {@internal Missing Short Description}} 709 * 710 * {@internal Missing Long Description}} 711 * 712 * @since 2.3.0 713 * 714 * @param unknown_type $comment_id 715 * @return unknown 716 */ 518 717 function get_edit_comment_link( $comment_id = 0 ) { 519 718 $comment = &get_comment( $comment_id ); 520 719 $post = &get_post( $comment->comment_post_ID ); … … 531 730 return apply_filters( 'get_edit_comment_link', $location ); 532 731 } 533 732 733 /** 734 * edit_comment_link() - {@internal Missing Short Description}} 735 * 736 * {@internal Missing Long Description}} 737 * 738 * @since 1.0.0 739 * 740 * @param unknown_type $link 741 * @param unknown_type $before 742 * @param unknown_type $after 743 */ 534 744 function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) { 535 745 global $comment, $post; 536 746 … … 572 782 573 783 // Navigation links 574 784 785 /** 786 * get_previous_post() - {@internal Missing Short Description}} 787 * 788 * {@internal Missing Long Description}} 789 * 790 * @since 1.5.0 791 * 792 * @param unknown_type $in_same_cat 793 * @param unknown_type $excluded_categories 794 * @return unknown 795 */ 575 796 function get_previous_post($in_same_cat = false, $excluded_categories = '') { 576 797 return get_adjacent_post($in_same_cat, $excluded_categories); 577 798 } 578 799 800 /** 801 * get_next_post() - {@internal Missing Short Description}} 802 * 803 * {@internal Missing Long Description}} 804 * 805 * @since 1.5.0 806 * 807 * @param unknown_type $in_same_cat 808 * @param unknown_type $excluded_categories 809 * @return unknown 810 */ 579 811 function get_next_post($in_same_cat = false, $excluded_categories = '') { 580 812 return get_adjacent_post($in_same_cat, $excluded_categories, false); 581 813 } 582 814 815 /** 816 * get_adjacent_post() - {@internal Missing Short Description}} 817 * 818 * {@internal Missing Long Description}} 819 * 820 * @since 2.5.0 821 * 822 * @param unknown_type $in_same_cat 823 * @param unknown_type $excluded_categories 824 * @param unknown_type $previous 825 * @return unknown 826 */ 583 827 function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true) { 584 828 global $post, $wpdb; 585 829 … … 623 867 return $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort"); 624 868 } 625 869 870 /** 871 * previous_post_link() - {@internal Missing Short Description}} 872 * 873 * {@internal Missing Long Description}} 874 * 875 * @since 1.5.0 876 * 877 * @param unknown_type $format 878 * @param unknown_type $link 879 * @param unknown_type $in_same_cat 880 * @param unknown_type $excluded_categories 881 */ 626 882 function previous_post_link($format='« %link', $link='%title', $in_same_cat = false, $excluded_categories = '') { 627 883 adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true); 628 884 } 629 885 886 /** 887 * next_post_link() - {@internal Missing Short Description}} 888 * 889 * {@internal Missing Long Description}} 890 * 891 * @since 1.5.0 892 * 893 * @param unknown_type $format 894 * @param unknown_type $link 895 * @param unknown_type $in_same_cat 896 * @param unknown_type $excluded_categories 897 */ 630 898 function next_post_link($format='%link »', $link='%title', $in_same_cat = false, $excluded_categories = '') { 631 899 adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false); 632 900 } 633 901 902 /** 903 * adjacent_post_link() - {@internal Missing Short Description}} 904 * 905 * {@internal Missing Long Description}} 906 * 907 * @since 2.5.0 908 * 909 * @param unknown_type $format 910 * @param unknown_type $link 911 * @param unknown_type $in_same_cat 912 * @param unknown_type $excluded_categories 913 * @param unknown_type $previous 914 */ 634 915 function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) { 635 916 if ( $previous && is_attachment() ) 636 917 $post = & get_post($GLOBALS['post']->post_parent); … … 656 937 echo apply_filters( "{$adjacent}_post_link", $format, $link ); 657 938 } 658 939 940 /** 941 * get_pagenum_link() - {@internal Missing Short Description}} 942 * 943 * {@internal Missing Long Description}} 944 * 945 * @since 1.5.0 946 * 947 * @param unknown_type $pagenum 948 * @return unknown 949 */ 659 950 function get_pagenum_link($pagenum = 1) { 660 951 global $wp_rewrite; 661 952 … … 710 1001 return $result; 711 1002 } 712 1003 1004 /** 1005 * get_next_posts_page_link() - {@internal Missing Short Description}} 1006 * 1007 * {@internal Missing Long Description}} 1008 * 1009 * @since 2.0.10 Backported 1010 * @since 2.1.3 1011 * 1012 * @param unknown_type $max_page 1013 * @return unknown 1014 */ 713 1015 function get_next_posts_page_link($max_page = 0) { 714 1016 global $paged; 715 1017 … … 722 1024 } 723 1025 } 724 1026 1027 /** 1028 * next_posts() - {@internal Missing Short Description}} 1029 * 1030 * {@internal Missing Long Description}} 1031 * 1032 * @since 0.71 1033 * 1034 * @param unknown_type $max_page 1035 */ 725 1036 function next_posts($max_page = 0) { 726 1037 echo clean_url(get_next_posts_page_link($max_page)); 727 1038 } 728 1039 1040 /** 1041 * next_posts_link() - {@internal Missing Short Description}} 1042 * 1043 * {@internal Missing Long Description}} 1044 * 1045 * @since 0.71 1046 * 1047 * @param unknown_type $label 1048 * @param unknown_type $max_page 1049 */ 729 1050 function next_posts_link($label='Next Page »', $max_page=0) { 730 1051 global $paged, $wp_query; 731 1052 if ( !$max_page ) { … … 742 1063 } 743 1064 } 744 1065 1066 /** 1067 * get_previous_posts_page_link() - {@internal Missing Short Description}} 1068 * 1069 * {@internal Missing Long Description}} 1070 * 1071 * @since 2.0.10 Backported 1072 * @since 2.1.3 1073 * 1074 * @return unknown 1075 */ 745 1076 function get_previous_posts_page_link() { 746 1077 global $paged; 747 1078 … … 753 1084 } 754 1085 } 755 1086 1087 /** 1088 * previous_posts() - {@internal Missing Short Description}} 1089 * 1090 * {@internal Missing Long Description}} 1091 * 1092 * @since 0.71 1093 * 1094 */ 756 1095 function previous_posts() { 757 1096 echo clean_url(get_previous_posts_page_link()); 758 1097 } 759 1098 1099 /** 1100 * previous_posts_link() - {@internal Missing Short Description}} 1101 * 1102 * {@internal Missing Long Description}} 1103 * 1104 * @since 0.71 1105 * 1106 * @param unknown_type $label 1107 */ 760 1108 function previous_posts_link($label='« Previous Page') { 761 1109 global $paged; 762 1110 if ( (!is_single()) && ($paged > 1) ) { … … 767 1115 } 768 1116 } 769 1117 1118 /** 1119 * posts_nav_link() - {@internal Missing Short Description}} 1120 * 1121 * {@internal Missing Long Description}} 1122 * 1123 * @since 0.71 1124 * 1125 * @param unknown_type $sep 1126 * @param unknown_type $prelabel 1127 * @param unknown_type $nxtlabel 1128 */ 770 1129 function posts_nav_link($sep=' — ', $prelabel='« Previous Page', $nxtlabel='Next Page »') { 771 1130 global $wp_query; 772 1131 if ( !is_singular() ) {