| 2689 | |
| 2690 | /** |
| 2691 | * Display the links to the topics and reply feeds. |
| 2692 | * |
| 2693 | * @since bbPress (rXXXX) |
| 2694 | * |
| 2695 | * @param array $args Optional arguments. |
| 2696 | */ |
| 2697 | function bbp_feed_links( $args = array() ) { |
| 2698 | if ( !current_theme_supports('bbp-automatic-feed-links') ) { |
| 2699 | return; |
| 2700 | } |
| 2701 | |
| 2702 | $defaults = array( |
| 2703 | /* translators: Separator between blog name and feed type in feed links */ |
| 2704 | 'separator' => _x('»', 'feed link'), |
| 2705 | /* translators: 1: blog title, 2: separator (raquo) */ |
| 2706 | 'bbp-all-topics' => __('%1$s %2$s All Topics Feed'), |
| 2707 | /* translators: 1: blog title, 2: separator (raquo) */ |
| 2708 | 'bbp-all-replies' => __('%1$s %2$s All Replies Feed'), |
| 2709 | /* translators: 1: blog name, 2: separator(raquo), 3: forum title */ |
| 2710 | 'bbp-single-forum-topics' => __('%1$s %2$s %3$s Forum Feed'), |
| 2711 | /* translators: 1: blog name, 2: separator(raquo), 3: topic title */ |
| 2712 | 'bbp-single-topic' => __('%1$s %2$s %3$s Feed'), |
| 2713 | /* translators: 1: blog name, 2: separator(raquo), 3: topic tag name */ |
| 2714 | 'bbp-topic-tag' => __('%1$s %2$s %3$s Topic Tag Feed'), |
| 2715 | ); |
| 2716 | |
| 2717 | $args = bbp_parse_args( $args, $defaults ); |
| 2718 | |
| 2719 | // Add the all topics and all replies RSS feeds everywhere |
| 2720 | echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr( sprintf( $args['bbp-all-topics'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( bbp_get_forums_url() ) . "feed/\" />\n"; |
| 2721 | echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr( sprintf( $args['bbp-all-replies'], get_bloginfo('name'), $args['separator'] ) ) . '" href="' . esc_url( bbp_get_topics_url() ) . "feed/\" />\n"; |
| 2722 | |
| 2723 | // If viewing a single forum include the single forum topics and replies RSS feeds |
| 2724 | if ( bbp_is_single_forum() ) { |
| 2725 | $forum_id = 0; |
| 2726 | $forum_id = bbp_get_forum_id( $forum_id ); |
| 2727 | |
| 2728 | $title = sprintf( $args['bbp-single-forum-topics'], get_bloginfo('name'), $args['separator'], bbp_get_forum_title($forum_id ) ); |
| 2729 | $href = bbp_get_forum_permalink( $forum_id ); |
| 2730 | |
| 2731 | // If viewing a single topic include the single topic replies RSS feed |
| 2732 | } elseif ( bbp_is_single_topic() ) { |
| 2733 | $topic_id = 0; |
| 2734 | $topic_id = bbp_get_topic_id( $topic_id ); |
| 2735 | |
| 2736 | $title = sprintf( $args['bbp-single-topic'], get_bloginfo('name'), $args['separator'], bbp_get_topic_title($topic_id ) ); |
| 2737 | $href = bbp_get_topic_permalink( $topic_id ); |
| 2738 | |
| 2739 | // If viewing a topic tag include the topic tag RSS feed |
| 2740 | } elseif ( bbp_is_topic_tag() ) { |
| 2741 | $term = get_queried_object(); |
| 2742 | |
| 2743 | if ( $term ) { |
| 2744 | $title = sprintf( $args['bbp-topic-tag'], get_bloginfo('name'), $args['separator'], $term->name ); |
| 2745 | $href = get_tag_feed_link( $term->term_id ); |
| 2746 | } |
| 2747 | } |
| 2748 | |
| 2749 | // Output the links to <head> |
| 2750 | if ( isset($title) && isset($href) ) { |
| 2751 | echo '<link rel="alternate" type="application/rss+xml" title="' . esc_attr( $title ) . '" href="' . esc_url( $href ) . 'feed/" />' . "\n"; |
| 2752 | } |
| 2753 | } |