root/branches/2.0/wp-includes/feed-functions.php

Revision 4343, 4.3 kB (checked in by markjaquith, 2 years ago)

Better tabbing and newlining for RSS categories. Props coffee2code and Nazgul. fixes #1156

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 <?php
2
3 function get_bloginfo_rss($show = '') {
4     $info = strip_tags(get_bloginfo($show));
5     return convert_chars($info);
6 }
7
8 function bloginfo_rss($show = '') {
9     echo get_bloginfo_rss($show);
10 }
11
12 function get_the_title_rss() {
13     $title = get_the_title();
14     $title = apply_filters('the_title', $title);
15     $title = apply_filters('the_title_rss', $title);
16     return $title;
17 }
18
19 function the_title_rss() {
20     echo get_the_title_rss();
21 }
22
23 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
24     $content = get_the_content($more_link_text, $stripteaser, $more_file);
25     $content = apply_filters('the_content_rss', $content);
26     if ($cut && !$encode_html) {
27         $encode_html = 2;
28     }
29     if ($encode_html == 1) {
30         $content = wp_specialchars($content);
31         $cut = 0;
32     } elseif ($encode_html == 0) {
33         $content = make_url_footnote($content);
34     } elseif ($encode_html == 2) {
35         $content = strip_tags($content);
36     }
37     if ($cut) {
38         $blah = explode(' ', $content);
39         if (count($blah) > $cut) {
40             $k = $cut;
41             $use_dotdotdot = 1;
42         } else {
43             $k = count($blah);
44             $use_dotdotdot = 0;
45         }
46         for ($i=0; $i<$k; $i++) {
47             $excerpt .= $blah[$i].' ';
48         }
49         $excerpt .= ($use_dotdotdot) ? '...' : '';
50         $content = $excerpt;
51     }
52     $content = str_replace(']]>', ']]&gt;', $content);
53     echo $content;
54 }
55
56 function the_excerpt_rss() {
57     $output = get_the_excerpt(true);
58     echo apply_filters('the_excerpt_rss', $output);
59 }
60
61 function permalink_single_rss($file = '') {
62     echo get_permalink();
63 }
64
65 function comment_link() {
66     echo get_comment_link();
67 }
68
69 function get_comment_author_rss() {
70     return apply_filters('comment_author_rss', get_comment_author() );
71 }
72 function comment_author_rss() {
73     echo get_comment_author_rss();
74 }
75
76 function comment_text_rss() {
77     $comment_text = get_comment_text();
78     $comment_text = apply_filters('comment_text_rss', $comment_text);
79     echo $comment_text;
80 }
81
82 function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '') {
83     $url = comments_rss($commentsrssfilename);
84     echo "<a href='$url'>$link_text</a>";
85 }
86
87 function comments_rss($commentsrssfilename = '') {
88     global $id;
89
90     if ('' != get_settings('permalink_structure'))
91         $url = trailingslashit( get_permalink() ) . 'feed/';
92     else
93         $url = get_settings('home') . "/$commentsrssfilename?feed=rss2&amp;p=$id";
94
95     return apply_filters('post_comments_feed_link', $url);
96 }
97
98 function get_author_rss_link($echo = false, $author_id, $author_nicename) {
99        $auth_ID = $author_id;
100        $permalink_structure = get_settings('permalink_structure');
101
102        if ('' == $permalink_structure) {
103                  $link = get_settings('home') . '?feed=rss2&amp;author=' . $author_id;
104        } else {
105                  $link = get_author_link(0, $author_id, $author_nicename);
106                  $link = $link . "feed/";
107        }
108             
109              $link = apply_filters('author_feed_link', $link);
110
111        if ($echo) echo $link;
112        return $link;
113 }
114
115 function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
116        $permalink_structure = get_settings('permalink_structure');
117
118        if ('' == $permalink_structure) {
119                  $link = get_settings('home') . '?feed=rss2&amp;cat=' . $cat_ID;
120        } else {
121                  $link = get_category_link($cat_ID);
122                  $link = $link . "feed/";
123        }
124
125              $link = apply_filters('category_feed_link', $link);
126
127        if ($echo) echo $link;
128        return $link;
129 }
130
131 function the_category_rss($type = 'rss') {
132     $categories = get_the_category();
133     $the_list = '';
134     foreach ($categories as $category) {
135         $category->cat_name = convert_chars($category->cat_name);
136         if ('rdf' == $type) {
137             $the_list .= "\n\t\t<dc:subject>$category->cat_name</dc:subject>\n";
138         } else {
139             $the_list .= "\n\t\t<category>$category->cat_name</category>\n";
140         }
141     }
142     echo apply_filters('the_category_rss', $the_list, $type);
143 }
144
145 function rss_enclosure() {
146     global $id, $post;
147     if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return;
148
149     $custom_fields = get_post_custom();
150     if( is_array( $custom_fields ) ) {
151         while( list( $key, $val ) = each( $custom_fields ) ) {
152             if( $key == 'enclosure' ) {
153                 if (is_array($val)) {
154                     foreach($val as $enc) {
155                         $enclosure = split( "\n", $enc );
156                         print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
157                     }
158                 }
159             }
160         }
161     }
162 }
163
164 ?>
Note: See TracBrowser for help on using the browser.