Make WordPress Core

Ticket #5642: 5642.r8786.2.diff

File 5642.r8786.2.diff, 14.7 KB (added by jacobsantos, 15 years ago)

Completed link-template.php file based off of r9247

  • link-template.php

     
    11<?php
     2/**
     3 * WordPress Link Template Functions
     4 *
     5 * @package WordPress
     6 * @subpackage Template
     7 */
    28
    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 */
    417function the_permalink() {
    518        echo apply_filters('the_permalink', get_permalink());
    619}
    720
    821
    922/**
     23 * user_trailingshashit() - {@internal Missing Short Description}}
     24 *
     25 * {@internal Missing Long Description}}
     26 *
     27 * @since 2.2.0
     28 *
    1029 * Conditionally adds a trailing slash if the permalink structure
    1130 * has a trailing slash, strips the trailing slash if not
    12  * @global object Uses $wp_rewrite
     31 * @uses $wp_rewrite
    1332 * @param $string string a URL with or without a trailing slash
    1433 * @param $type_of_url string the type of URL being considered (e.g. single, category, etc) for use in the filter
    1534 * @return string
     
    2746        return $string;
    2847}
    2948
    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 */
    3158function permalink_anchor($mode = 'id') {
    3259        global $post;
    3360        switch ( strtolower($mode) ) {
     
    4269        }
    4370}
    4471
    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 */
    4682function get_permalink($id = 0, $leavename=false) {
    4783        $rewritecode = array(
    4884                '%year%',
     
    119155        }
    120156}
    121157
    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 */
    123169function post_permalink($post_id = 0, $deprecated = '') {
    124170        return get_permalink($post_id);
    125171}
    126172
    127173// 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 */
    128184function get_page_link($id = false, $leavename = false) {
    129185        global $post;
    130186
     
    140196        return apply_filters('page_link', $link, $id);
    141197}
    142198
    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 */
    144212function _get_page_link( $id = false, $leavename = false ) {
    145213        global $post, $wp_rewrite;
    146214
     
    163231        return apply_filters( '_get_page_link', $link, $id );
    164232}
    165233
     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 */
    166244function get_attachment_link($id = false) {
    167245        global $post, $wp_rewrite;
    168246
     
    194272        return apply_filters('attachment_link', $link, $id);
    195273}
    196274
     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 */
    197285function get_year_link($year) {
    198286        global $wp_rewrite;
    199287        if ( !$year )
     
    207295        }
    208296}
    209297
     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 */
    210309function get_month_link($year, $month) {
    211310        global $wp_rewrite;
    212311        if ( !$year )
     
    223322        }
    224323}
    225324
     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 */
    226337function get_day_link($year, $month, $day) {
    227338        global $wp_rewrite;
    228339        if ( !$year )
     
    243354        }
    244355}
    245356
     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 */
    246367function get_feed_link($feed = '') {
    247368        global $wp_rewrite;
    248369
     
    272393        return apply_filters('feed_link', $output, $feed);
    273394}
    274395
     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 */
    275407function get_post_comments_feed_link($post_id = '', $feed = '') {
    276408        global $id;
    277409
     
    297429        return apply_filters('post_comments_feed_link', $url);
    298430}
    299431
    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.
    301434 *
    302  * Prints out the comment feed link for a post.  Link text is placed in the
    303  * anchor.  If no link text is specified, default text is used.  If no post ID
    304  * 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.
    305438 *
    306439 * @package WordPress
    307440 * @subpackage Feed
    308441 * @since 2.5
    309442 *
    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}}
    312446 * @return string Link to the comment feed for the current post
    313447*/
    314448function post_comments_feed_link( $link_text = '', $post_id = '', $feed = '' ) {
     
    356490        return $link;
    357491}
    358492
    359 /** Get the feed link for a given category
     493/**
     494 * get_category_feed_link() - Get the feed link for a category
    360495 *
    361  * Returns a link to the feed for all posts in a given category.  A specific feed can be requested
    362  * 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.
    363498 *
    364499 * @package WordPress
    365500 * @subpackage Feed
     
    399534        return $link;
    400535}
    401536
     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 */
    402548function get_tag_feed_link($tag_id, $feed = '') {
    403549        $tag_id = (int) $tag_id;
    404550
     
    428574        return $link;
    429575}
    430576
     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 */
    431588function get_search_feed_link($search_query = '', $feed = '') {
    432589        if ( empty($search_query) )
    433590                $search = attribute_escape(get_search_query());
     
    444601        return $link;
    445602}
    446603
     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 */
    447615function get_search_comments_feed_link($search_query = '', $feed = '') {
    448616        if ( empty($search_query) )
    449617                $search = attribute_escape(get_search_query());
     
    460628        return $link;
    461629}
    462630
     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 */
    463641function get_edit_post_link( $id = 0, $context = 'display' ) {
    464642        if ( !$post = &get_post( $id ) )
    465643                return;
     
    500678        return apply_filters( 'get_edit_post_link', admin_url("$file.php?{$action}$var=$post->ID"), $post->ID, $context );
    501679}
    502680
     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 */
    503692function edit_post_link( $link = 'Edit This', $before = '', $after = '' ) {
    504693        global $post;
    505694
     
    515704        echo $before . apply_filters( 'edit_post_link', $link, $post->ID ) . $after;
    516705}
    517706
     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 */
    518717function get_edit_comment_link( $comment_id = 0 ) {
    519718        $comment = &get_comment( $comment_id );
    520719        $post = &get_post( $comment->comment_post_ID );
     
    531730        return apply_filters( 'get_edit_comment_link', $location );
    532731}
    533732
     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 */
    534744function edit_comment_link( $link = 'Edit This', $before = '', $after = '' ) {
    535745        global $comment, $post;
    536746
     
    572782
    573783// Navigation links
    574784
     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 */
    575796function get_previous_post($in_same_cat = false, $excluded_categories = '') {
    576797        return get_adjacent_post($in_same_cat, $excluded_categories);
    577798}
    578799
     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 */
    579811function get_next_post($in_same_cat = false, $excluded_categories = '') {
    580812        return get_adjacent_post($in_same_cat, $excluded_categories, false);
    581813}
    582814
     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 */
    583827function get_adjacent_post($in_same_cat = false, $excluded_categories = '', $previous = true) {
    584828        global $post, $wpdb;
    585829
     
    623867        return $wpdb->get_row("SELECT p.* FROM $wpdb->posts AS p $join $where $sort");
    624868}
    625869
     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 */
    626882function previous_post_link($format='&laquo; %link', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    627883        adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
    628884}
    629885
     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 */
    630898function next_post_link($format='%link &raquo;', $link='%title', $in_same_cat = false, $excluded_categories = '') {
    631899        adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, false);
    632900}
    633901
     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 */
    634915function adjacent_post_link($format, $link, $in_same_cat = false, $excluded_categories = '', $previous = true) {
    635916        if ( $previous && is_attachment() )
    636917                $post = & get_post($GLOBALS['post']->post_parent);
     
    656937        echo apply_filters( "{$adjacent}_post_link", $format, $link );
    657938}
    658939
     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 */
    659950function get_pagenum_link($pagenum = 1) {
    660951        global $wp_rewrite;
    661952
     
    7101001        return $result;
    7111002}
    7121003
     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 */
    7131015function get_next_posts_page_link($max_page = 0) {
    7141016        global $paged;
    7151017
     
    7221024        }
    7231025}
    7241026
     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 */
    7251036function next_posts($max_page = 0) {
    7261037        echo clean_url(get_next_posts_page_link($max_page));
    7271038}
    7281039
     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 */
    7291050function next_posts_link($label='Next Page &raquo;', $max_page=0) {
    7301051        global $paged, $wp_query;
    7311052        if ( !$max_page ) {
     
    7421063        }
    7431064}
    7441065
     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 */
    7451076function get_previous_posts_page_link() {
    7461077        global $paged;
    7471078
     
    7531084        }
    7541085}
    7551086
     1087/**
     1088 * previous_posts() - {@internal Missing Short Description}}
     1089 *
     1090 * {@internal Missing Long Description}}
     1091 *
     1092 * @since 0.71
     1093 *
     1094 */
    7561095function previous_posts() {
    7571096        echo clean_url(get_previous_posts_page_link());
    7581097}
    7591098
     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 */
    7601108function previous_posts_link($label='&laquo; Previous Page') {
    7611109        global $paged;
    7621110        if ( (!is_single())     && ($paged > 1) ) {
     
    7671115        }
    7681116}
    7691117
     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 */
    7701129function posts_nav_link($sep=' &#8212; ', $prelabel='&laquo; Previous Page', $nxtlabel='Next Page &raquo;') {
    7711130        global $wp_query;
    7721131        if ( !is_singular() ) {