diff options
author | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-04-04 16:44:15 +0000 |
---|---|---|
committer | donncha <donncha@7be80a69-a1ef-0310-a953-fb0f7c49ff36> | 2008-04-04 16:44:15 +0000 |
commit | 7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc (patch) | |
tree | c6fd23b598f3994eddb18cb1c0f2e8d95ff054fa /wp-includes/feed.php | |
parent | f650f48c048bfbbb2ae702b6425d87e39358d748 (diff) | |
download | wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.tar.gz wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.tar.xz wordpress-mu-7740e89de3e1bc0cc636120e3ca8ab9e97e4d3cc.zip |
Merged with WordPress 2.5, unstable, only for testing
git-svn-id: http://svn.automattic.com/wordpress-mu/trunk@1218 7be80a69-a1ef-0310-a953-fb0f7c49ff36
Diffstat (limited to 'wp-includes/feed.php')
-rw-r--r-- | wp-includes/feed.php | 170 |
1 files changed, 84 insertions, 86 deletions
diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 8f9219c..4cf5e67 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -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&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&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&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); +} + ?> |