]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/feed.php
Wordpress 2.5.1
[autoinstalls/wordpress.git] / wp-includes / feed.php
index 8f9219c597d35acbffc82c9b2709a7eb066e0516..4cf5e67653874605909830b4fa70e89bde7575c3 100644 (file)
@@ -2,12 +2,15 @@
 
 function get_bloginfo_rss($show = '') {
        $info = strip_tags(get_bloginfo($show));
-       return apply_filters('get_bloginfo_rss', convert_chars($info));
+       return apply_filters('get_bloginfo_rss', convert_chars($info), $show);
 }
 
-
 function bloginfo_rss($show = '') {
-       echo apply_filters('bloginfo_rss', get_bloginfo_rss($show));
+       echo apply_filters('bloginfo_rss', get_bloginfo_rss($show), $show);
+}
+
+function get_default_feed() {
+       return apply_filters('default_feed', 'rss2');
 }
 
 function get_wp_title_rss($sep = '»') {
@@ -76,80 +79,40 @@ function the_permalink_rss() {
 
 }
 
+function comment_guid() {
+       echo get_comment_guid();
+}
+
+function get_comment_guid() {
+       global $comment;
+
+       if ( !is_object($comment) )
+               return false;
+
+       return get_the_guid($comment->comment_post_ID) . '#comment-' . $comment->comment_ID;
+}
+
 function comment_link() {
        echo get_comment_link();
 }
 
-
 function get_comment_author_rss() {
        return apply_filters('comment_author_rss', get_comment_author() );
 }
 
-
 function comment_author_rss() {
        echo get_comment_author_rss();
 }
 
-
 function comment_text_rss() {
        $comment_text = get_comment_text();
        $comment_text = apply_filters('comment_text_rss', $comment_text);
        echo $comment_text;
 }
 
-
-function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'nolongerused') {
-       $url = get_post_comments_feed_link();
-       echo "<a href='$url'>$link_text</a>";
-}
-
-
-function comments_rss($commentsrssfilename = 'nolongerused') {
-       return get_post_comments_feed_link();
-}
-
-
-function get_author_rss_link($echo = false, $author_id, $author_nicename) {
-       $auth_ID = (int) $author_id;
-       $permalink_structure = get_option('permalink_structure');
-
-       if ( '' == $permalink_structure ) {
-               $link = get_option('home') . '?feed=rss2&amp;author=' . $author_id;
-       } else {
-               $link = get_author_posts_url($author_id, $author_nicename);
-               $link = trailingslashit($link) . user_trailingslashit('feed', 'feed');
-       }
-
-       $link = apply_filters('author_feed_link', $link);
-
-       if ( $echo )
-               echo $link;
-       return $link;
-}
-
-
-function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
-       $permalink_structure = get_option('permalink_structure');
-
-       if ( '' == $permalink_structure ) {
-               $link = get_option('home') . '?feed=rss2&amp;cat=' . $cat_ID;
-       } else {
-               $link = get_category_link($cat_ID);
-               $link = trailingslashit($link) . user_trailingslashit('feed', 'feed');
-       }
-
-       $link = apply_filters('category_feed_link', $link);
-
-       if ( $echo )
-               echo $link;
-       return $link;
-}
-
-
 function get_the_category_rss($type = 'rss') {
        $categories = get_the_category();
        $tags = get_the_tags();
-       $home = get_bloginfo_rss('home');
        $the_list = '';
        $cat_names = array();
 
@@ -179,37 +142,10 @@ function get_the_category_rss($type = 'rss') {
        return apply_filters('the_category_rss', $the_list, $type);
 }
 
-
 function the_category_rss($type = 'rss') {
        echo get_the_category_rss($type);
 }
 
-function get_tag_feed_link($tag_id, $feed = 'rss2') {
-       $tag_id = (int) $tag_id;
-
-       $tag = get_tag($tag_id);
-
-       if ( empty($tag) || is_wp_error($tag) )
-               return false;
-
-       $permalink_structure = get_option('permalink_structure');
-
-       if ( '' == $permalink_structure ) {
-               $link = get_option('home') . "?feed=$feed&amp;tag=" . $tag->slug;
-       } else {
-               $link = get_tag_link($tag->term_id);
-               if ( 'rss2' == $feed )
-                       $feed_link = 'feed';
-               else
-                       $feed_link = "feed/$feed";
-               $link = $link . user_trailingslashit($feed_link, 'feed');
-       }
-
-       $link = apply_filters('tag_feed_link', $link, $feed);
-
-       return $link;
-}
-
 function html_type_rss() {
        $type = get_bloginfo('html_type');
        if (strpos($type, 'xhtml') !== false)
@@ -221,8 +157,8 @@ function html_type_rss() {
 
 
 function rss_enclosure() {
-       global $id, $post;
-       if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
+       global $post;
+       if ( !empty($post->post_password) && (!isset($_COOKIE['wp-postpass_'.COOKIEHASH]) || $_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
                return;
 
        foreach (get_post_custom() as $key => $val) {
@@ -236,7 +172,7 @@ function rss_enclosure() {
 }
 
 function atom_enclosure() {
-       global $id, $post;
+       global $post;
        if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
                return;
 
@@ -250,4 +186,66 @@ function atom_enclosure() {
        }
 }
 
+/**
+ * prep_atom_text_construct() - Determine the type of a given string of data
+ *
+ * Tell whether the type is text, html, or xhtml, per RFC 4287 section 3.1.
+ *
+ * In the case of WordPress, text is defined as containing no markup,
+ * xhtml is defined as "well formed", and html as tag soup (i.e., the rest).
+ *
+ * Container div tags are added to xhtml values, per section 3.1.1.3.
+ *
+ * @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5
+ *
+ * @param string $data input string
+ * @return array $result array(type, value)
+ */
+function prep_atom_text_construct($data) {
+       if (strpos($data, '<') === false && strpos($data, '&') === false) {
+               return array('text', $data);
+       }
+
+       $parser = xml_parser_create();
+       xml_parse($parser, '<div>' . $data . '</div>', true);
+       $code = xml_get_error_code($parser);
+       xml_parser_free($parser);
+
+       if (!$code) {
+               if (strpos($data, '<') === false) {
+                       return array('text', $data);
+               } else {
+                       $data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
+                       return array('xhtml', $data);
+               }
+       }
+
+       if (strpos($data, ']]>') == false) {
+               return array('html', "<![CDATA[$data]]>");
+       } else {
+               return array('html', htmlspecialchars($data));
+       }
+}
+
+/**
+ * self_link() - Generate a correct link for the atom:self elemet
+ *
+ * Echo the link for the currently displayed feed in a XSS safe way.
+ *
+ * @package WordPress
+ * @subpackage Feed
+ * @since 2.5
+ *
+ */
+function self_link() {
+       echo 'http'
+               . ( $_SERVER['https'] == 'on' ? 's' : '' ) . '://'
+               . $_SERVER['HTTP_HOST']
+               . wp_specialchars(stripslashes($_SERVER['REQUEST_URI']), 1);
+}
+
 ?>