Changeset 14711 for trunk/wp-includes/link-template.php
- Timestamp:
- 05/17/2010 04:21:12 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/link-template.php
r14702 r14711 569 569 */ 570 570 function get_category_feed_link($cat_id, $feed = '') { 571 $cat_id = (int) $cat_id; 572 573 $category = get_category($cat_id); 574 575 if ( empty($category) || is_wp_error($category) ) 571 return get_term_feed_link($cat_id, 'category', $feed); 572 } 573 574 /** 575 * Retrieve the feed link for a taxonomy. 576 * 577 * Returns a link to the feed for all post in a given term. A specific feed 578 * can be requested or left blank to get the default feed. 579 * 580 * @since 3.0 581 * 582 * @param int $term_id ID of a category. 583 * @param string $taxonomy Optional. Taxonomy of $term_id 584 * @param string $feed Optional. Feed type. 585 * @return string Link to the feed for the taxonomy specified by $term_id and $taxonomy. 586 */ 587 function get_term_feed_link( $term_id, $taxonomy = 'category', $feed = '' ) { 588 global $wp_rewrite; 589 590 $term_id = ( int ) $term_id; 591 592 $term = get_term( $term_id, $taxonomy ); 593 594 if ( empty( $term ) || is_wp_error( $term ) ) 576 595 return false; 577 596 578 if ( empty( $feed) )597 if ( empty( $feed ) ) 579 598 $feed = get_default_feed(); 580 599 581 $permalink_structure = get_option( 'permalink_structure');600 $permalink_structure = get_option( 'permalink_structure' ); 582 601 583 602 if ( '' == $permalink_structure ) { 584 $link = home_url("?feed=$feed&cat=" . $cat_id); 603 if ( 'category' == $taxonomy ) { 604 $link = home_url("?feed=$feed&cat=$term_id"); 605 } 606 elseif ( 'post_tag' == $taxonomy ) { 607 $link = home_url("?feed=$feed&tag=$term->slug"); 608 } else { 609 $t = get_taxonomy( $taxonomy ); 610 $link = home_url("?feed=$feed&$t->query_var=$term->slug"); 611 } 585 612 } else { 586 $link = get_category_link($cat_id); 587 if( $feed == get_default_feed() ) 588 $feed_link = 'feed'; 589 else 590 $feed_link = "feed/$feed"; 591 592 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 593 } 594 595 $link = apply_filters('category_feed_link', $link, $feed); 596 597 return $link; 598 } 599 600 /** 601 * Retrieve permalink for feed of tag. 602 * 603 * @since 2.3.0 604 * 605 * @param int $tag_id Tag ID. 606 * @param string $feed Optional. Feed type. 607 * @return string 608 */ 609 function get_tag_feed_link($tag_id, $feed = '') { 610 $tag_id = (int) $tag_id; 611 612 $tag = get_tag($tag_id); 613 614 if ( empty($tag) || is_wp_error($tag) ) 615 return false; 616 617 $permalink_structure = get_option('permalink_structure'); 618 619 if ( empty($feed) ) 620 $feed = get_default_feed(); 621 622 if ( '' == $permalink_structure ) { 623 $link = home_url("?feed=$feed&tag=" . $tag->slug); 624 } else { 625 $link = get_tag_link($tag->term_id); 613 $link = get_term_link( $term_id, $term->taxonomy ); 626 614 if ( $feed == get_default_feed() ) 627 615 $feed_link = 'feed'; 628 616 else 629 617 $feed_link = "feed/$feed"; 630 $link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed'); 631 } 632 633 $link = apply_filters('tag_feed_link', $link, $feed); 618 619 $link = trailingslashit( $link ) . user_trailingslashit( $feed_link, 'feed' ); 620 } 621 622 if ( 'category' == $taxonomy ) 623 $link = apply_filters( 'category_feed_link', $link, $feed ); 624 elseif ( 'post_tag' == $taxonomy ) 625 $link = apply_filters( 'category_feed_link', $link, $feed ); 626 else 627 $link = apply_filters( 'taxonomy_feed_link', $link, $feed, $taxonomy ); 628 634 629 635 630 return $link; 631 } 632 633 /** 634 * Retrieve permalink for feed of tag. 635 * 636 * @since 2.3.0 637 * 638 * @param int $tag_id Tag ID. 639 * @param string $feed Optional. Feed type. 640 * @return string 641 */ 642 function get_tag_feed_link($tag_id, $feed = '') { 643 return get_term_feed_link($tag_id, 'post_tag', $feed); 636 644 } 637 645
Note: See TracChangeset
for help on using the changeset viewer.