3 function get_bloginfo_rss($show = '') {
4 $info = strip_tags(get_bloginfo($show));
5 return apply_filters('get_bloginfo_rss', convert_chars($info), $show);
8 function bloginfo_rss($show = '') {
9 echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show);
12 function get_default_feed() {
13 return apply_filters('default_feed', 'rss2');
16 function get_wp_title_rss($sep = '»') {
17 $title = wp_title($sep, false);
18 if ( is_wp_error( $title ) )
19 return $title->get_error_message();
20 $title = apply_filters('get_wp_title_rss', $title);
24 function wp_title_rss($sep = '»') {
25 echo apply_filters('wp_title_rss', get_wp_title_rss($sep));
28 function get_the_title_rss() {
29 $title = get_the_title();
30 $title = apply_filters('the_title_rss', $title);
35 function the_title_rss() {
36 echo get_the_title_rss();
40 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
41 $content = get_the_content($more_link_text, $stripteaser, $more_file);
42 $content = apply_filters('the_content_rss', $content);
43 if ( $cut && !$encode_html )
45 if ( 1== $encode_html ) {
46 $content = wp_specialchars($content);
48 } elseif ( 0 == $encode_html ) {
49 $content = make_url_footnote($content);
50 } elseif ( 2 == $encode_html ) {
51 $content = strip_tags($content);
54 $blah = explode(' ', $content);
55 if ( count($blah) > $cut ) {
62 for ( $i=0; $i<$k; $i++ )
63 $excerpt .= $blah[$i].' ';
64 $excerpt .= ($use_dotdotdot) ? '...' : '';
67 $content = str_replace(']]>', ']]>', $content);
72 function the_excerpt_rss() {
73 $output = get_the_excerpt();
74 echo apply_filters('the_excerpt_rss', $output);
77 function the_permalink_rss() {
78 echo apply_filters('the_permalink_rss', get_permalink());
82 function comment_guid() {
83 echo get_comment_guid();
86 function get_comment_guid() {
89 if ( !is_object($comment) )
92 return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
95 function comment_link() {
96 echo get_comment_link();
99 function get_comment_author_rss() {
100 return apply_filters('comment_author_rss', get_comment_author() );
103 function comment_author_rss() {
104 echo get_comment_author_rss();
107 function comment_text_rss() {
108 $comment_text = get_comment_text();
109 $comment_text = apply_filters('comment_text_rss', $comment_text);
113 function get_the_category_rss($type = 'rss') {
114 $categories = get_the_category();
115 $tags = get_the_tags();
117 $cat_names = array();
120 if ( 'atom' == $type )
123 if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
124 $cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
127 if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
128 $cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
131 $cat_names = array_unique($cat_names);
133 foreach ( $cat_names as $cat_name ) {
134 if ( 'rdf' == $type )
135 $the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
136 elseif ( 'atom' == $type )
137 $the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) );
139 $the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
142 return apply_filters('the_category_rss', $the_list, $type);
145 function the_category_rss($type = 'rss') {
146 echo get_the_category_rss($type);
149 function html_type_rss() {
150 $type = get_bloginfo('html_type');
151 if (strpos($type, 'xhtml') !== false)
159 function rss_enclosure() {
161 if ( !empty($post->post_password) && (!isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
164 foreach (get_post_custom() as $key => $val) {
165 if ($key == 'enclosure') {
166 foreach ((array)$val as $enc) {
167 $enclosure = split("\n", $enc);
168 echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
174 function atom_enclosure() {
176 if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
179 foreach (get_post_custom() as $key => $val) {
180 if ($key == 'enclosure') {
181 foreach ((array)$val as $enc) {
182 $enclosure = split("\n", $enc);
183 echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
190 * prep_atom_text_construct() - Determine the type of a given string of data
192 * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1.
194 * In the case of WordPress, text is defined as containing no markup,
195 * xhtml is defined as "well formed", and html as tag soup (i.e., the rest).
197 * Container div tags are added to xhtml values, per section 3.1.1.3.
199 * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
205 * @param string $data input string
206 * @return array $result array(type, value)
208 function prep_atom_text_construct($data) {
209 if (strpos($data, '<') === false && strpos($data, '&') === false) {
210 return array('text', $data);
213 $parser = xml_parser_create();
214 xml_parse($parser, '<div>' . $data . '</div>', true);
215 $code = xml_get_error_code($parser);
216 xml_parser_free($parser);
219 if (strpos($data, '<') === false) {
220 return array('text', $data);
222 $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
223 return array('xhtml', $data);
227 if (strpos($data, ']]>') == false) {
228 return array('html', "<![CDATA[$data]]>");
230 return array('html', htmlspecialchars($data));
235 * self_link() - Generate a correct link for the atom:self elemet
237 * Echo the link for the currently displayed feed in a XSS safe way.
244 function self_link() {
246 . ( $_SERVER['https'] == 'on' ? 's' : '' ) . '://'
247 . $_SERVER['HTTP_HOST']
248 . wp_specialchars(stripslashes($_SERVER['REQUEST_URI']), 1);