2005-01-07 17:01:59 -05:00
|
|
|
<?php
|
|
|
|
|
2005-02-25 10:52:28 -05:00
|
|
|
function get_bloginfo_rss($show = '') {
|
|
|
|
$info = strip_tags(get_bloginfo($show));
|
2007-03-28 21:35:50 -04:00
|
|
|
return apply_filters('get_bloginfo_rss', convert_chars($info));
|
2005-02-25 10:52:28 -05:00
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-02-25 10:52:28 -05:00
|
|
|
function bloginfo_rss($show = '') {
|
2007-03-28 21:35:50 -04:00
|
|
|
echo apply_filters('bloginfo_rss', get_bloginfo_rss($show));
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2007-02-24 02:33:29 -05:00
|
|
|
function get_wp_title_rss($sep = '»') {
|
|
|
|
$title = wp_title($sep, false);
|
2007-09-18 12:32:22 -04:00
|
|
|
if ( is_wp_error( $title ) )
|
|
|
|
return $title->get_error_message();
|
2007-02-24 02:33:29 -05:00
|
|
|
$title = apply_filters('get_wp_title_rss', $title);
|
|
|
|
return $title;
|
|
|
|
}
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2007-03-28 21:29:09 -04:00
|
|
|
function wp_title_rss($sep = '»') {
|
|
|
|
echo apply_filters('wp_title_rss', get_wp_title_rss($sep));
|
|
|
|
}
|
|
|
|
|
2005-12-15 17:20:06 -05:00
|
|
|
function get_the_title_rss() {
|
2005-01-07 17:01:59 -05:00
|
|
|
$title = get_the_title();
|
|
|
|
$title = apply_filters('the_title_rss', $title);
|
2005-12-15 17:20:06 -05:00
|
|
|
return $title;
|
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-12-15 17:20:06 -05:00
|
|
|
function the_title_rss() {
|
|
|
|
echo get_the_title_rss();
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-01-07 17:01:59 -05:00
|
|
|
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
|
|
|
|
$content = get_the_content($more_link_text, $stripteaser, $more_file);
|
2005-11-17 18:17:06 -05:00
|
|
|
$content = apply_filters('the_content_rss', $content);
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( $cut && !$encode_html )
|
2005-01-07 17:01:59 -05:00
|
|
|
$encode_html = 2;
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( 1== $encode_html ) {
|
2005-01-07 17:01:59 -05:00
|
|
|
$content = wp_specialchars($content);
|
|
|
|
$cut = 0;
|
2006-10-13 09:49:39 -04:00
|
|
|
} elseif ( 0 == $encode_html ) {
|
2005-01-07 17:01:59 -05:00
|
|
|
$content = make_url_footnote($content);
|
2006-10-13 09:49:39 -04:00
|
|
|
} elseif ( 2 == $encode_html ) {
|
2005-01-07 17:01:59 -05:00
|
|
|
$content = strip_tags($content);
|
|
|
|
}
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( $cut ) {
|
2005-01-07 17:01:59 -05:00
|
|
|
$blah = explode(' ', $content);
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( count($blah) > $cut ) {
|
2005-01-07 17:01:59 -05:00
|
|
|
$k = $cut;
|
|
|
|
$use_dotdotdot = 1;
|
|
|
|
} else {
|
|
|
|
$k = count($blah);
|
|
|
|
$use_dotdotdot = 0;
|
|
|
|
}
|
2006-12-06 22:57:23 -05:00
|
|
|
for ( $i=0; $i<$k; $i++ )
|
2005-01-07 17:01:59 -05:00
|
|
|
$excerpt .= $blah[$i].' ';
|
|
|
|
$excerpt .= ($use_dotdotdot) ? '...' : '';
|
|
|
|
$content = $excerpt;
|
|
|
|
}
|
|
|
|
$content = str_replace(']]>', ']]>', $content);
|
|
|
|
echo $content;
|
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-01-07 17:01:59 -05:00
|
|
|
function the_excerpt_rss() {
|
2007-09-13 17:27:26 -04:00
|
|
|
$output = get_the_excerpt();
|
2005-01-07 17:01:59 -05:00
|
|
|
echo apply_filters('the_excerpt_rss', $output);
|
|
|
|
}
|
|
|
|
|
2007-08-21 14:27:45 -04:00
|
|
|
function the_permalink_rss() {
|
|
|
|
echo apply_filters('the_permalink_rss', get_permalink());
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2005-01-31 05:06:12 -05:00
|
|
|
function comment_link() {
|
|
|
|
echo get_comment_link();
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-12-15 17:20:06 -05:00
|
|
|
function get_comment_author_rss() {
|
|
|
|
return apply_filters('comment_author_rss', get_comment_author() );
|
|
|
|
}
|
2006-12-06 22:57:23 -05:00
|
|
|
|
|
|
|
|
2005-01-07 17:01:59 -05:00
|
|
|
function comment_author_rss() {
|
2005-12-15 17:20:06 -05:00
|
|
|
echo get_comment_author_rss();
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-01-07 17:01:59 -05:00
|
|
|
function comment_text_rss() {
|
|
|
|
$comment_text = get_comment_text();
|
|
|
|
$comment_text = apply_filters('comment_text_rss', $comment_text);
|
|
|
|
echo $comment_text;
|
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2007-02-23 03:31:07 -05:00
|
|
|
function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'nolongerused') {
|
2007-02-25 08:26:18 -05:00
|
|
|
$url = get_post_comments_feed_link();
|
2005-01-07 17:01:59 -05:00
|
|
|
echo "<a href='$url'>$link_text</a>";
|
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2007-02-23 03:31:07 -05:00
|
|
|
function comments_rss($commentsrssfilename = 'nolongerused') {
|
|
|
|
return get_post_comments_feed_link();
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-01-07 17:01:59 -05:00
|
|
|
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
|
2007-03-22 20:59:21 -04:00
|
|
|
$auth_ID = (int) $author_id;
|
2006-10-13 09:49:39 -04:00
|
|
|
$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);
|
2007-09-12 18:24:28 -04:00
|
|
|
$link = trailingslashit($link) . user_trailingslashit('feed', 'feed');
|
2006-10-13 09:49:39 -04:00
|
|
|
}
|
2005-01-07 17:01:59 -05:00
|
|
|
|
2006-10-13 09:49:39 -04:00
|
|
|
$link = apply_filters('author_feed_link', $link);
|
2005-01-07 17:01:59 -05:00
|
|
|
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( $echo )
|
|
|
|
echo $link;
|
|
|
|
return $link;
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2007-11-09 15:31:24 -05:00
|
|
|
/** get_category_feed_link() - Get the feed link for a given category
|
|
|
|
*
|
|
|
|
* Returns a link to the feed for all post in a given category. A specific feed can be requested
|
|
|
|
* or left blank to get the default feed.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Feed
|
|
|
|
* @since 2.4
|
|
|
|
*
|
|
|
|
* @param int $cat_id ID of a category
|
|
|
|
* @param string $feed Feed type
|
|
|
|
* @return string Link to the feed for the category specified by $cat_id
|
|
|
|
*/
|
2007-11-09 15:12:04 -05:00
|
|
|
function get_category_feed_link($cat_id, $feed = 'rss2') {
|
|
|
|
$cat_id = (int) $cat_id;
|
|
|
|
|
|
|
|
$category = get_category($cat_id);
|
|
|
|
|
|
|
|
if ( empty($category) || is_wp_error($category) )
|
|
|
|
return false;
|
|
|
|
|
2006-10-13 09:49:39 -04:00
|
|
|
$permalink_structure = get_option('permalink_structure');
|
2005-01-07 17:01:59 -05:00
|
|
|
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( '' == $permalink_structure ) {
|
2007-11-09 15:12:04 -05:00
|
|
|
$link = get_option('home') . "?feed=$feed&cat=" . $cat_id;
|
2006-10-13 09:49:39 -04:00
|
|
|
} else {
|
2007-11-09 15:12:04 -05:00
|
|
|
$link = get_category_link($cat_id);
|
|
|
|
if( 'rss2' == $feed )
|
|
|
|
$feed_link = 'feed';
|
|
|
|
else
|
|
|
|
$feed_link = "feed/$feed";
|
|
|
|
|
|
|
|
$link = trailingslashit($link) . user_trailingslashit($feed_link, 'feed');
|
2006-10-13 09:49:39 -04:00
|
|
|
}
|
2005-01-07 17:01:59 -05:00
|
|
|
|
2007-11-09 15:12:04 -05:00
|
|
|
$link = apply_filters('category_feed_link', $link, $feed);
|
|
|
|
|
|
|
|
return $link;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
|
|
|
|
$link = get_category_feed_link($cat_ID, $feed = 'rss2');
|
2005-02-26 01:12:16 -05:00
|
|
|
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( $echo )
|
|
|
|
echo $link;
|
|
|
|
return $link;
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2006-09-26 14:05:06 -04:00
|
|
|
function get_the_category_rss($type = 'rss') {
|
2006-10-13 09:49:39 -04:00
|
|
|
$categories = get_the_category();
|
2007-08-29 17:10:20 -04:00
|
|
|
$tags = get_the_tags();
|
2007-01-25 03:37:26 -05:00
|
|
|
$home = get_bloginfo_rss('home');
|
2006-10-13 09:49:39 -04:00
|
|
|
$the_list = '';
|
2007-08-29 17:10:20 -04:00
|
|
|
$cat_names = array();
|
|
|
|
|
|
|
|
$filter = 'rss';
|
|
|
|
if ( 'atom' == $type )
|
|
|
|
$filter = 'raw';
|
|
|
|
|
|
|
|
if ( !empty($categories) ) foreach ( (array) $categories as $category ) {
|
2007-09-03 19:32:58 -04:00
|
|
|
$cat_names[] = sanitize_term_field('name', $category->name, $category->term_id, 'category', $filter);
|
2007-08-29 17:10:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( !empty($tags) ) foreach ( (array) $tags as $tag ) {
|
2007-09-03 19:32:58 -04:00
|
|
|
$cat_names[] = sanitize_term_field('name', $tag->name, $tag->term_id, 'post_tag', $filter);
|
2007-08-29 17:10:20 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$cat_names = array_unique($cat_names);
|
|
|
|
|
|
|
|
foreach ( $cat_names as $cat_name ) {
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( 'rdf' == $type )
|
2007-05-25 11:55:30 -04:00
|
|
|
$the_list .= "\n\t\t<dc:subject><![CDATA[$cat_name]]></dc:subject>\n";
|
2007-09-01 04:33:08 -04:00
|
|
|
elseif ( 'atom' == $type )
|
2007-08-29 17:10:20 -04:00
|
|
|
$the_list .= sprintf( '<category scheme="%1$s" term="%2$s" />', attribute_escape( apply_filters( 'get_bloginfo_rss', get_bloginfo( 'url' ) ) ), attribute_escape( $cat_name ) );
|
2006-10-13 09:49:39 -04:00
|
|
|
else
|
2007-05-25 11:55:30 -04:00
|
|
|
$the_list .= "\n\t\t<category><![CDATA[$cat_name]]></category>\n";
|
2006-10-13 09:49:39 -04:00
|
|
|
}
|
2007-08-29 17:10:20 -04:00
|
|
|
|
2006-10-13 09:49:39 -04:00
|
|
|
return apply_filters('the_category_rss', $the_list, $type);
|
2006-09-26 14:05:06 -04:00
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2006-09-26 14:05:06 -04:00
|
|
|
function the_category_rss($type = 'rss') {
|
|
|
|
echo get_the_category_rss($type);
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
|
2007-09-01 00:43:27 -04:00
|
|
|
function get_tag_feed_link($tag_id, $feed = 'rss2') {
|
|
|
|
$tag_id = (int) $tag_id;
|
|
|
|
|
|
|
|
$tag = get_tag($tag_id);
|
2007-09-03 19:19:20 -04:00
|
|
|
|
2007-09-01 00:43:27 -04:00
|
|
|
if ( empty($tag) || is_wp_error($tag) )
|
|
|
|
return false;
|
2007-09-03 19:19:20 -04:00
|
|
|
|
2007-09-01 00:43:27 -04:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2007-01-25 03:37:26 -05:00
|
|
|
function html_type_rss() {
|
2007-01-25 03:48:18 -05:00
|
|
|
$type = get_bloginfo('html_type');
|
2007-03-07 00:29:15 -05:00
|
|
|
if (strpos($type, 'xhtml') !== false)
|
2007-01-25 03:37:26 -05:00
|
|
|
$type = 'xhtml';
|
|
|
|
else
|
|
|
|
$type = 'html';
|
|
|
|
echo $type;
|
|
|
|
}
|
|
|
|
|
2006-12-06 22:57:23 -05:00
|
|
|
|
2005-01-07 17:01:59 -05:00
|
|
|
function rss_enclosure() {
|
2005-03-22 12:49:19 -05:00
|
|
|
global $id, $post;
|
2006-10-13 09:49:39 -04:00
|
|
|
if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
|
|
|
|
return;
|
2005-03-22 12:49:19 -05:00
|
|
|
|
2007-02-24 01:30:51 -05:00
|
|
|
foreach (get_post_custom() as $key => $val) {
|
2007-02-23 18:47:57 -05:00
|
|
|
if ($key == 'enclosure') {
|
|
|
|
foreach ((array)$val as $enc) {
|
|
|
|
$enclosure = split("\n", $enc);
|
2007-02-24 01:30:51 -05:00
|
|
|
echo apply_filters('rss_enclosure', '<enclosure url="' . trim(htmlspecialchars($enclosure[0])) . '" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
|
2005-01-07 17:01:59 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-23 18:47:57 -05:00
|
|
|
function atom_enclosure() {
|
|
|
|
global $id, $post;
|
|
|
|
if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
|
|
|
|
return;
|
|
|
|
|
2007-02-24 01:30:51 -05:00
|
|
|
foreach (get_post_custom() as $key => $val) {
|
2007-02-23 18:47:57 -05:00
|
|
|
if ($key == 'enclosure') {
|
|
|
|
foreach ((array)$val as $enc) {
|
|
|
|
$enclosure = split("\n", $enc);
|
2007-02-24 01:30:51 -05:00
|
|
|
echo apply_filters('atom_enclosure', '<link href="' . trim(htmlspecialchars($enclosure[0])) . '" rel="enclosure" length="' . trim($enclosure[1]) . '" type="' . trim($enclosure[2]) . '" />' . "\n");
|
2007-02-23 18:47:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-19 11:42:30 -04:00
|
|
|
/**
|
|
|
|
* prep_atom_text_construct() - determine if given string of data is
|
|
|
|
* type 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.
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Feed
|
2007-10-19 12:27:09 -04:00
|
|
|
* @since 2.4
|
2007-10-19 11:42:30 -04:00
|
|
|
*
|
|
|
|
* @param string $data input string
|
|
|
|
* @return array $result array(type, value)
|
|
|
|
* @link http://www.atomenabled.org/developers/syndication/atom-format-spec.php#rfc.section.3.1
|
|
|
|
*/
|
|
|
|
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));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-01 00:43:27 -04:00
|
|
|
?>
|