Code cleanup: wp-includes/feed.php
git-svn-id: http://svn.automattic.com/wordpress/trunk@4393 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
cd5cb736ec
commit
6c7037a96d
|
@ -23,27 +23,26 @@ function the_title_rss() {
|
||||||
function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
|
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 = get_the_content($more_link_text, $stripteaser, $more_file);
|
||||||
$content = apply_filters('the_content_rss', $content);
|
$content = apply_filters('the_content_rss', $content);
|
||||||
if ($cut && !$encode_html) {
|
if ( $cut && !$encode_html )
|
||||||
$encode_html = 2;
|
$encode_html = 2;
|
||||||
}
|
if ( 1== $encode_html ) {
|
||||||
if ($encode_html == 1) {
|
|
||||||
$content = wp_specialchars($content);
|
$content = wp_specialchars($content);
|
||||||
$cut = 0;
|
$cut = 0;
|
||||||
} elseif ($encode_html == 0) {
|
} elseif ( 0 == $encode_html ) {
|
||||||
$content = make_url_footnote($content);
|
$content = make_url_footnote($content);
|
||||||
} elseif ($encode_html == 2) {
|
} elseif ( 2 == $encode_html ) {
|
||||||
$content = strip_tags($content);
|
$content = strip_tags($content);
|
||||||
}
|
}
|
||||||
if ($cut) {
|
if ( $cut ) {
|
||||||
$blah = explode(' ', $content);
|
$blah = explode(' ', $content);
|
||||||
if (count($blah) > $cut) {
|
if ( count($blah) > $cut ) {
|
||||||
$k = $cut;
|
$k = $cut;
|
||||||
$use_dotdotdot = 1;
|
$use_dotdotdot = 1;
|
||||||
} else {
|
} else {
|
||||||
$k = count($blah);
|
$k = count($blah);
|
||||||
$use_dotdotdot = 0;
|
$use_dotdotdot = 0;
|
||||||
}
|
}
|
||||||
for ($i=0; $i<$k; $i++) {
|
for ( $i=0; $i<$k; $i++ ) {
|
||||||
$excerpt .= $blah[$i].' ';
|
$excerpt .= $blah[$i].' ';
|
||||||
}
|
}
|
||||||
$excerpt .= ($use_dotdotdot) ? '...' : '';
|
$excerpt .= ($use_dotdotdot) ? '...' : '';
|
||||||
|
@ -59,7 +58,7 @@ function the_excerpt_rss() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function permalink_single_rss($file = '') {
|
function permalink_single_rss($file = '') {
|
||||||
echo get_permalink();
|
echo get_permalink();
|
||||||
}
|
}
|
||||||
|
|
||||||
function comment_link() {
|
function comment_link() {
|
||||||
|
@ -87,7 +86,7 @@ function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '
|
||||||
function comments_rss($commentsrssfilename = '') {
|
function comments_rss($commentsrssfilename = '') {
|
||||||
global $id;
|
global $id;
|
||||||
|
|
||||||
if ('' != get_option('permalink_structure'))
|
if ( '' != get_option('permalink_structure') )
|
||||||
$url = trailingslashit( get_permalink() ) . 'feed/';
|
$url = trailingslashit( get_permalink() ) . 'feed/';
|
||||||
else
|
else
|
||||||
$url = get_option('home') . "/$commentsrssfilename?feed=rss2&p=$id";
|
$url = get_option('home') . "/$commentsrssfilename?feed=rss2&p=$id";
|
||||||
|
@ -96,50 +95,51 @@ function comments_rss($commentsrssfilename = '') {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
|
function get_author_rss_link($echo = false, $author_id, $author_nicename) {
|
||||||
$auth_ID = $author_id;
|
$auth_ID = $author_id;
|
||||||
$permalink_structure = get_option('permalink_structure');
|
$permalink_structure = get_option('permalink_structure');
|
||||||
|
|
||||||
if ('' == $permalink_structure) {
|
if ( '' == $permalink_structure ) {
|
||||||
$link = get_option('home') . '?feed=rss2&author=' . $author_id;
|
$link = get_option('home') . '?feed=rss2&author=' . $author_id;
|
||||||
} else {
|
} else {
|
||||||
$link = get_author_posts_url($author_id, $author_nicename);
|
$link = get_author_posts_url($author_id, $author_nicename);
|
||||||
$link = $link . "feed/";
|
$link = $link . "feed/";
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = apply_filters('author_feed_link', $link);
|
|
||||||
|
|
||||||
if ($echo) echo $link;
|
$link = apply_filters('author_feed_link', $link);
|
||||||
return $link;
|
|
||||||
|
if ( $echo )
|
||||||
|
echo $link;
|
||||||
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
|
function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
|
||||||
$permalink_structure = get_option('permalink_structure');
|
$permalink_structure = get_option('permalink_structure');
|
||||||
|
|
||||||
if ('' == $permalink_structure) {
|
if ( '' == $permalink_structure ) {
|
||||||
$link = get_option('home') . '?feed=rss2&cat=' . $cat_ID;
|
$link = get_option('home') . '?feed=rss2&cat=' . $cat_ID;
|
||||||
} else {
|
} else {
|
||||||
$link = get_category_link($cat_ID);
|
$link = get_category_link($cat_ID);
|
||||||
$link = $link . "feed/";
|
$link = $link . "feed/";
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = apply_filters('category_feed_link', $link);
|
$link = apply_filters('category_feed_link', $link);
|
||||||
|
|
||||||
if ($echo) echo $link;
|
if ( $echo )
|
||||||
return $link;
|
echo $link;
|
||||||
|
return $link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_the_category_rss($type = 'rss') {
|
function get_the_category_rss($type = 'rss') {
|
||||||
$categories = get_the_category();
|
$categories = get_the_category();
|
||||||
$the_list = '';
|
$the_list = '';
|
||||||
foreach ($categories as $category) {
|
foreach ( (array) $categories as $category ) {
|
||||||
$category->cat_name = convert_chars($category->cat_name);
|
$category->cat_name = convert_chars($category->cat_name);
|
||||||
if ('rdf' == $type) {
|
if ( 'rdf' == $type )
|
||||||
$the_list .= "\n\t\t<dc:subject>$category->cat_name</dc:subject>\n";
|
$the_list .= "\n\t\t<dc:subject>$category->cat_name</dc:subject>\n";
|
||||||
} else {
|
else
|
||||||
$the_list .= "\n\t\t<category>$category->cat_name</category>\n";
|
$the_list .= "\n\t\t<category>$category->cat_name</category>\n";
|
||||||
}
|
}
|
||||||
}
|
return apply_filters('the_category_rss', $the_list, $type);
|
||||||
return apply_filters('the_category_rss', $the_list, $type);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function the_category_rss($type = 'rss') {
|
function the_category_rss($type = 'rss') {
|
||||||
|
@ -148,14 +148,15 @@ function the_category_rss($type = 'rss') {
|
||||||
|
|
||||||
function rss_enclosure() {
|
function rss_enclosure() {
|
||||||
global $id, $post;
|
global $id, $post;
|
||||||
if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return;
|
if ( !empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password) )
|
||||||
|
return;
|
||||||
|
|
||||||
$custom_fields = get_post_custom();
|
$custom_fields = get_post_custom();
|
||||||
if( is_array( $custom_fields ) ) {
|
if ( is_array($custom_fields) ) {
|
||||||
while( list( $key, $val ) = each( $custom_fields ) ) {
|
while ( list($key, $val) = each($custom_fields) ) {
|
||||||
if( $key == 'enclosure' ) {
|
if ( $key == 'enclosure' ) {
|
||||||
if (is_array($val)) {
|
if ( is_array($val) ) {
|
||||||
foreach($val as $enc) {
|
foreach ( (array) $val as $enc ) {
|
||||||
$enclosure = split( "\n", $enc );
|
$enclosure = split( "\n", $enc );
|
||||||
print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
|
print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue