Some feed template function cleanup.

git-svn-id: http://svn.automattic.com/wordpress/trunk@2068 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
saxmatt 2005-01-07 22:01:59 +00:00
parent 3440138f04
commit 7f98c031a7
13 changed files with 210 additions and 219 deletions

View File

@ -15,11 +15,11 @@ $more = 1;
xmlns="http://purl.org/atom/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<title><?php bloginfo_rss('name') ?></title>
<link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>" />
<link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
<tagline><?php bloginfo_rss("description") ?></tagline>
<modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></modified>
<copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></copyright>
<generator url="http://wordpress.org/" version="<?php echo $wp_version ?>">WordPress</generator>
<generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
<entry>
@ -28,11 +28,11 @@ $more = 1;
</author>
<title><?php the_title_rss() ?></title>
<link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
<id><?php bloginfo_rss("url") ?>?p=<?php echo $id; ?></id>
<modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_modified_gmt); ?></modified>
<issued><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt); ?></issued>
<id><?php the_guid(); ?></id>
<modified><?php the_time('Y-m-d\TH:i:s\Z'); ?></modified>
<issued> <?php the_time('Y-m-d\TH:i:s\Z'); ?></issued>
<?php the_category_rss('rdf') ?>
<summary type="text/html" mode="escaped"><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></summary>
<summary type="text/html" mode="escaped"><?php the_excerpt_rss(); ?></summary>
<?php if (!get_settings('rss_use_excerpt')) : ?>
<?php if ( strlen( $post->post_content ) ) : ?>
<content type="text/html" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_content('', 0, '') ?>]]></content>
@ -40,7 +40,7 @@ $more = 1;
<content type="text/html" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss(); ?>]]></content>
<?php endif; ?>
<?php else : ?>
<content type="text/html" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss('', 2) ?>]]></content>
<content type="text/html" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss() ?>]]></content>
<?php endif; ?>
</entry>
<?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>

View File

@ -60,10 +60,6 @@ function comments_link( $file = '', $echo = true ) {
echo get_comments_link();
}
function comment_link_rss() {
echo get_comments_link();
}
function comments_popup_script($width=400, $height=400, $file='') {
global $wpcommentspopupfile, $wptrackbackpopupfile, $wppingbackpopupfile, $wpcommentsjavascript;
@ -145,11 +141,6 @@ function comment_author() {
echo $author;
}
function comment_author_rss() {
$author = apply_filters('comment_author_rss', get_comment_author() );
echo $author;
}
function get_comment_author_email() {
global $comment;
return apply_filters('get_comment_author_email', $comment->comment_author_email);
@ -244,12 +235,6 @@ function comment_text() {
echo apply_filters('comment_text', get_comment_text() );
}
function comment_text_rss() {
$comment_text = get_comment_text();
$comment_text = apply_filters('comment_text_rss', $comment_text);
echo $comment_text;
}
function get_comment_excerpt() {
global $comment;
$comment_text = strip_tags($comment->comment_content);
@ -299,23 +284,6 @@ function comment_time( $d = '' ) {
echo get_comment_time();
}
function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'wp-commentsrss2.php') {
$url = comments_rss($commentsrssfilename);
echo "<a href='$url'>$link_text</a>";
}
function comments_rss($commentsrssfilename = 'wp-commentsrss2.php') {
global $id;
global $querystring_start, $querystring_equal, $querystring_separator;
if ('' != get_settings('permalink_structure'))
$url = trailingslashit( get_permalink() ) . 'feed/';
else
$url = get_settings('siteurl') . "/$commentsrssfilename?p=$id";
return $url;
}
function get_trackback_url() {
global $id;
$tb_url = get_settings('siteurl') . '/wp-trackback.php/' . $id;

View File

@ -0,0 +1,154 @@
<?php
function bloginfo_rss($show='') {
$info = strip_tags(get_bloginfo($show));
echo convert_chars($info);
}
function the_title_rss() {
$title = get_the_title();
$title = apply_filters('the_title', $title);
$title = apply_filters('the_title_rss', $title);
echo $title;
}
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);
$content = apply_filters('the_content', $content);
if ($cut && !$encode_html) {
$encode_html = 2;
}
if ($encode_html == 1) {
$content = wp_specialchars($content);
$cut = 0;
} elseif ($encode_html == 0) {
$content = make_url_footnote($content);
} elseif ($encode_html == 2) {
$content = strip_tags($content);
}
if ($cut) {
$blah = explode(' ', $content);
if (count($blah) > $cut) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
}
function the_excerpt_rss() {
$output = get_the_excerpt(true);
echo apply_filters('the_excerpt_rss', $output);
}
function permalink_single_rss($file = '') {
echo get_permalink();
}
function comment_link_rss() {
echo get_comments_link();
}
function comment_author_rss() {
$author = apply_filters('comment_author_rss', get_comment_author() );
echo $author;
}
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 = 'wp-commentsrss2.php') {
$url = comments_rss($commentsrssfilename);
echo "<a href='$url'>$link_text</a>";
}
function comments_rss($commentsrssfilename = 'wp-commentsrss2.php') {
global $id;
global $querystring_start, $querystring_equal, $querystring_separator;
if ('' != get_settings('permalink_structure'))
$url = trailingslashit( get_permalink() ) . 'feed/';
else
$url = get_settings('siteurl') . "/$commentsrssfilename?p=$id";
return $url;
}
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
global $querystring_start, $querystring_equal;
$auth_ID = $author_id;
$permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) {
$file = get_settings('siteurl') . '/wp-rss2.php';
$link = $file . $querystring_start . 'author' . $querystring_equal . $author_id;
} else {
$link = get_author_link(0, $author_id, $author_nicename);
$link = $link . "feed/";
}
if ($echo) echo $link;
return $link;
}
function get_category_rss_link($echo = false, $category_id, $category_nicename) {
global $querystring_start, $querystring_equal;
$cat_ID = $category_id;
$permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) {
$file = get_settings('siteurl') . '/wp-rss2.php';
$link = $file . $querystring_start . 'cat' . $querystring_equal . $category_id;
} else {
$link = get_category_link(0, $category_id, $category_nicename);
$link = $link . "feed/";
}
if ($echo) echo $link;
return $link;
}
function the_category_rss($type = 'rss') {
$categories = get_the_category();
$the_list = '';
foreach ($categories as $category) {
$category->cat_name = convert_chars($category->cat_name);
if ('rdf' == $type) {
$the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>";
} else {
$the_list .= "\n\t<category>$category->cat_name</category>";
}
}
echo apply_filters('the_category_rss', $the_list);
}
function rss_enclosure() {
global $id;
$custom_fields = get_post_custom();
if( is_array( $custom_fields ) ) {
while( list( $key, $val ) = each( $custom_fields ) ) {
if( $key == 'enclosure' ) {
if (is_array($val)) {
foreach($val as $enc) {
$enclosure = split( "\n", $enc );
print "<enclosure url='".trim( $enclosure[ 0 ] )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
}
}
}
}
}
}
?>

View File

@ -140,23 +140,6 @@ function get_author_link($echo = false, $author_id, $author_nicename) {
return $link;
}
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
global $querystring_start, $querystring_equal;
$auth_ID = $author_id;
$permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) {
$file = get_settings('siteurl') . '/wp-rss2.php';
$link = $file . $querystring_start . 'author' . $querystring_equal . $author_id;
} else {
$link = get_author_link(0, $author_id, $author_nicename);
$link = $link . "feed/";
}
if ($echo) echo $link;
return $link;
}
function wp_list_authors($args = '') {
parse_str($args, $r);
if (!isset($r['optioncount'])) $r['optioncount'] = false;

View File

@ -43,23 +43,6 @@ function get_category_link($echo = false, $category_id, $category_nicename) {
return $catlink;
}
function get_category_rss_link($echo = false, $category_id, $category_nicename) {
global $querystring_start, $querystring_equal;
$cat_ID = $category_id;
$permalink_structure = get_settings('permalink_structure');
if ('' == $permalink_structure) {
$file = get_settings('siteurl') . '/wp-rss2.php';
$link = $file . $querystring_start . 'cat' . $querystring_equal . $category_id;
} else {
$link = get_category_link(0, $category_id, $category_nicename);
$link = $link . "feed/";
}
if ($echo) echo $link;
return $link;
}
function the_category($separator = '', $parents='') {
$categories = get_the_category();
if (empty($categories)) {
@ -118,20 +101,6 @@ function the_category($separator = '', $parents='') {
echo apply_filters('the_category', $thelist);
}
function the_category_rss($type = 'rss') {
$categories = get_the_category();
$the_list = '';
foreach ($categories as $category) {
$category->cat_name = convert_chars($category->cat_name);
if ('rdf' == $type) {
$the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>";
} else {
$the_list .= "\n\t<category>$category->cat_name</category>";
}
}
echo apply_filters('the_category_rss', $the_list);
}
function get_the_category_by_ID($cat_ID) {
global $cache_categories, $wpdb;
if ( !$cache_categories[$cat_ID] ) {

View File

@ -61,16 +61,6 @@ function bloginfo($show='') {
echo convert_chars($info);
}
function bloginfo_rss($show='') {
$info = strip_tags(get_bloginfo($show));
echo convert_chars($info);
}
function bloginfo_unicode($show='') {
$info = get_bloginfo($show);
echo convert_chars($info);
}
function get_bloginfo($show='') {
switch($show) {
@ -611,19 +601,26 @@ function the_date($d='', $before='', $after='', $echo = true) {
}
}
function the_time($d='', $echo = true) {
global $id, $post;
if ($d=='') {
$the_time = mysql2date(get_settings('time_format'), $post->post_date);
} else {
$the_time = mysql2date($d, $post->post_date);
}
$the_time = apply_filters('the_time', $the_time);
if ($echo) {
echo $the_time;
} else {
return $the_time;
}
function the_time( $d = '' ) {
echo apply_filters('the_time', get_the_time( $d ) );
}
function get_the_time( $d = '' ) {
global $id, $post;
if ( '' == $d )
$the_time = date( get_settings('time_format'), get_post_time() );
else
$the_time = mysql2date( $d, get_post_time() );
return apply_filters('get_the_time', $the_time);
}
function get_post_time( $gmt = false ) { // returns timestamp
global $post;
if ( $gmt )
$time = mysql2date('U', $post->post_date_gmt);
else
$time = mysql2date('U', $post->post_date);
return apply_filters('get_the_time', $time);
}
function the_weekday() {

View File

@ -22,10 +22,6 @@ function permalink_anchor($mode = 'id') {
}
}
function permalink_single_rss($file = '') {
echo get_permalink();
}
function get_permalink($id = false) {
global $post, $wpdb;

View File

@ -39,13 +39,6 @@ function the_title($before = '', $after = '', $echo = true) {
}
}
function the_title_rss() {
$title = get_the_title();
$title = apply_filters('the_title', $title);
$title = apply_filters('the_title_rss', $title);
echo $title;
}
function get_the_title($id = 0) {
global $post, $wpdb;
$title = $post->post_title;
@ -59,6 +52,21 @@ function get_the_title($id = 0) {
return $title;
}
function get_the_guid( $id = 0 ) {
global $post, $wpdb;
$guid = $post->guid;
if ( 0 != $id )
$title = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE ID = $id");
$guid = apply_filters('get_the_guid', $guid);
return $guid;
}
function the_guid( $id = 0 ) {
echo get_the_guid();
}
function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, $stripteaser, $more_file);
$content = apply_filters('the_content', $content);
@ -66,39 +74,6 @@ function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file
echo $content;
}
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);
$content = apply_filters('the_content', $content);
if ($cut && !$encode_html) {
$encode_html = 2;
}
if ($encode_html == 1) {
$content = wp_specialchars($content);
$cut = 0;
} elseif ($encode_html == 0) {
$content = make_url_footnote($content);
} elseif ($encode_html == 2) {
$content = strip_tags($content);
}
if ($cut) {
$blah = explode(' ', $content);
if (count($blah) > $cut) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '...' : '';
$content = $excerpt;
}
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;
}
function get_the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
global $id, $post, $more, $single, $withcomments, $page, $pages, $multipage, $numpages;
global $preview;
@ -142,42 +117,6 @@ function the_excerpt() {
echo apply_filters('the_excerpt', get_the_excerpt());
}
function the_excerpt_rss($cut = 0, $encode_html = FALSE) {
$output = get_the_excerpt(true);
$output = convert_chars($output);
if ($cut && !$encode_html) {
$encode_html = 2;
}
if ($encode_html == 1) {
$output = wp_specialchars($output);
$cut = 0;
} elseif ($encode_html === 0) {
$output = make_url_footnote($output);
} elseif ($encode_html == 2) {
$output = strip_tags($output);
$output = str_replace('&', '&amp;', $output);
}
if ($cut) {
$excerpt = '';
$blah = explode(' ', $output);
if (count($blah) > $cut) {
$k = $cut;
$use_dotdotdot = 1;
} else {
$k = count($blah);
$use_dotdotdot = 0;
}
for ($i=0; $i<$k; $i++) {
$excerpt .= $blah[$i].' ';
}
$excerpt .= ($use_dotdotdot) ? '...' : '';
$output = $excerpt;
}
$output = str_replace(']]>', ']]&gt;', $output);
echo apply_filters('the_excerpt_rss', $output);
}
function get_the_excerpt($fakeit = true) {
global $id, $post;
$output = '';

View File

@ -19,4 +19,6 @@ require($curpath . 'template-functions-category.php');
/***** Comment tags *****/
require($curpath . 'comment-functions.php');
require($curpath . 'feed-functions.php');
?>

View File

@ -158,6 +158,7 @@ add_filter('comment_text', 'convert_smilies', 20);
add_filter('comment_text_rss', 'htmlspecialchars');
add_filter('comment_excerpt', 'convert_chars');
add_filter('the_excerpt_rss', 'convert_chars');
// Places to balance tags on input
add_filter('content_save_pre', 'balanceTags', 50);

View File

@ -46,7 +46,7 @@ add_filter('the_content', 'trim');
<dc:creator><?php the_author() ?> (mailto:<?php the_author_email() ?>)</dc:creator>
<?php the_category_rss('rdf') ?>
<?php if (get_settings('rss_use_excerpt')) : ?>
<description><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></description>
<description><?php the_excerpt_rss() ?></description>
<?php else : ?>
<description><?php the_content_rss('', 0, '', get_settings('rss_excerpt_length'), 2) ?></description>
<content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>

View File

@ -26,7 +26,7 @@ $more = 1;
<?php
if (get_settings('rss_use_excerpt')) {
?>
<description><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></description>
<description><?php the_excerpt_rss() ?></description>
<?php
} else { // use content
?>

View File

@ -12,55 +12,37 @@ $more = 1;
?>
<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
<!-- generator="wordpress/<?php echo $wp_version ?>" -->
<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
>
<channel>
<title><?php bloginfo_rss('name') ?></title>
<title><?php bloginfo_rss('name'); ?></title>
<link><?php bloginfo_rss('url') ?></link>
<description><?php bloginfo_rss("description") ?></description>
<copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate()); ?></copyright>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), 0); ?></pubDate>
<generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>
<generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
<?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
<item>
<title><?php the_title_rss() ?></title>
<link><?php permalink_single_rss() ?></link>
<comments><?php comments_link(); ?></comments>
<pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post->post_date_gmt, 0); ?></pubDate>
<pubDate><?php the_time('D, d M Y H:i:s +0000'); ?></pubDate>
<?php the_category_rss() ?>
<guid><?php the_permalink($id); ?></guid>
<?php if (get_settings('rss_use_excerpt')) : ?>
<description><?php the_excerpt_rss('', 2) ?></description>
<description><?php the_excerpt_rss() ?></description>
<?php else : ?>
<description><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></description>
<?php if ( strlen( $post->post_content ) ) : ?>
<description><?php the_excerpt_rss() ?></description>
<content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
<?php else : ?>
<content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
<?php endif; ?>
<?php endif; ?>
<wfw:commentRSS><?php echo comments_rss(); ?></wfw:commentRSS>
<?php
$custom_fields = get_post_custom();
if( is_array( $custom_fields ) ) {
while( list( $key, $val ) = each( $custom_fields ) ) {
if( $key == 'enclosure' ) {
if (is_array($val)) {
foreach($val as $enc) {
$enclosure = split( "\n", $enc );
print "<enclosure url='".trim( $enclosure[ 0 ] )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
}
}
}
}
}
?>
<?php rss_enclosure(); ?>
</item>
<?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
</channel>
</rss>
</rss>