Make WordPress Core

Changeset 2068


Ignore:
Timestamp:
01/07/2005 10:01:59 PM (19 years ago)
Author:
saxmatt
Message:

Some feed template function cleanup.

Location:
trunk
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-atom.php

    r2046 r2068  
    1616  xmlns:dc="http://purl.org/dc/elements/1.1/">
    1717    <title><?php bloginfo_rss('name') ?></title>
    18     <link rel="alternate" type="text/html" href="<?php bloginfo_rss('url') ?>" />
     18    <link rel="alternate" type="text/html" href="<?php bloginfo_rss('home') ?>" />
    1919    <tagline><?php bloginfo_rss("description") ?></tagline>
    2020    <modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', get_lastpostmodified('GMT')); ?></modified>
    2121    <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate('blog')); ?></copyright>
    22     <generator url="http://wordpress.org/" version="<?php echo $wp_version ?>">WordPress</generator>
     22    <generator url="http://wordpress.org/" version="<?php bloginfo_rss('version'); ?>">WordPress</generator>
    2323   
    2424    <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
     
    2929        <title><?php the_title_rss() ?></title>
    3030        <link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />
    31         <id><?php bloginfo_rss("url") ?>?p=<?php echo $id; ?></id>
    32         <modified><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_modified_gmt); ?></modified>
    33         <issued><?php echo mysql2date('Y-m-d\TH:i:s\Z', $post->post_date_gmt); ?></issued>
     31        <id><?php the_guid(); ?></id>
     32        <modified><?php the_time('Y-m-d\TH:i:s\Z'); ?></modified>
     33        <issued>  <?php the_time('Y-m-d\TH:i:s\Z'); ?></issued>
    3434        <?php the_category_rss('rdf') ?>
    35         <summary type="text/html" mode="escaped"><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></summary>
     35        <summary type="text/html" mode="escaped"><?php the_excerpt_rss(); ?></summary>
    3636<?php if (!get_settings('rss_use_excerpt')) : ?>
    3737    <?php if ( strlen( $post->post_content ) ) : ?>
     
    4141    <?php endif; ?>
    4242<?php else : ?>
    43         <content type="text/html" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss('', 2) ?>]]></content>
     43        <content type="text/html" mode="escaped" xml:base="<?php permalink_single_rss() ?>"><![CDATA[<?php the_excerpt_rss() ?>]]></content>
    4444<?php endif; ?>
    4545    </entry>
  • trunk/wp-includes/comment-functions.php

    r2060 r2068  
    5959function comments_link( $file = '', $echo = true ) {
    6060    echo get_comments_link();
    61 }
    62 
    63 function comment_link_rss() {
    64     echo get_comments_link();
    6561}
    6662
     
    146142}
    147143
    148 function comment_author_rss() {
    149     $author = apply_filters('comment_author_rss', get_comment_author() );
    150     echo $author;
    151 }
    152 
    153144function get_comment_author_email() {
    154145    global $comment;
     
    245236}
    246237
    247 function comment_text_rss() {
    248     $comment_text = get_comment_text();
    249     $comment_text = apply_filters('comment_text_rss', $comment_text);
    250     echo $comment_text;
    251 }
    252 
    253238function get_comment_excerpt() {
    254239    global $comment;
     
    298283function comment_time( $d = '' ) {
    299284    echo get_comment_time();
    300 }
    301 
    302 function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = 'wp-commentsrss2.php') {
    303     $url = comments_rss($commentsrssfilename);
    304     echo "<a href='$url'>$link_text</a>";
    305 }
    306 
    307 function comments_rss($commentsrssfilename = 'wp-commentsrss2.php') {
    308     global $id;
    309     global $querystring_start, $querystring_equal, $querystring_separator;
    310 
    311     if ('' != get_settings('permalink_structure'))
    312         $url = trailingslashit( get_permalink() ) . 'feed/';
    313     else
    314         $url = get_settings('siteurl') . "/$commentsrssfilename?p=$id";
    315 
    316     return $url;
    317285}
    318286
  • trunk/wp-includes/template-functions-author.php

    r1997 r2068  
    141141}
    142142
    143 function get_author_rss_link($echo = false, $author_id, $author_nicename) {
    144        global $querystring_start, $querystring_equal;
    145        $auth_ID = $author_id;
    146        $permalink_structure = get_settings('permalink_structure');
    147 
    148        if ('' == $permalink_structure) {
    149            $file = get_settings('siteurl') . '/wp-rss2.php';
    150            $link = $file . $querystring_start . 'author' . $querystring_equal . $author_id;
    151        } else {
    152            $link = get_author_link(0, $author_id, $author_nicename);
    153            $link = $link . "feed/";
    154        }
    155 
    156        if ($echo) echo $link;
    157        return $link;
    158 }
    159 
    160143function wp_list_authors($args = '') {
    161144    parse_str($args, $r);
  • trunk/wp-includes/template-functions-category.php

    r2045 r2068  
    4242    if ($echo) echo $catlink;
    4343    return $catlink;
    44 }
    45 
    46 function get_category_rss_link($echo = false, $category_id, $category_nicename) {
    47        global $querystring_start, $querystring_equal;
    48        $cat_ID = $category_id;
    49        $permalink_structure = get_settings('permalink_structure');
    50 
    51        if ('' == $permalink_structure) {
    52                $file = get_settings('siteurl') . '/wp-rss2.php';
    53         $link = $file . $querystring_start . 'cat' . $querystring_equal . $category_id;
    54        } else {
    55         $link = get_category_link(0, $category_id, $category_nicename);
    56                $link = $link . "feed/";
    57        }
    58 
    59        if ($echo) echo $link;
    60        return $link;
    6144}
    6245
     
    119102}
    120103
    121 function the_category_rss($type = 'rss') {
    122     $categories = get_the_category();
    123     $the_list = '';
    124     foreach ($categories as $category) {
    125         $category->cat_name = convert_chars($category->cat_name);
    126         if ('rdf' == $type) {
    127             $the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>";
    128         } else {
    129             $the_list .= "\n\t<category>$category->cat_name</category>";
    130         }
    131     }
    132     echo apply_filters('the_category_rss', $the_list);
    133 }
    134 
    135104function get_the_category_by_ID($cat_ID) {
    136105    global $cache_categories, $wpdb;
  • trunk/wp-includes/template-functions-general.php

    r2032 r2068  
    5959    $info = get_bloginfo($show);
    6060    $info = apply_filters('bloginfo', $info);
    61     echo convert_chars($info);
    62 }
    63 
    64 function bloginfo_rss($show='') {
    65     $info = strip_tags(get_bloginfo($show));
    66     echo convert_chars($info);
    67 }
    68 
    69 function bloginfo_unicode($show='') {
    70     $info = get_bloginfo($show);
    7161    echo convert_chars($info);
    7262}
     
    612602}
    613603
    614 function the_time($d='', $echo = true) {
    615     global $id, $post;
    616     if ($d=='') {
    617         $the_time = mysql2date(get_settings('time_format'), $post->post_date);
    618     } else {
    619         $the_time = mysql2date($d, $post->post_date);
    620     }
    621     $the_time = apply_filters('the_time', $the_time);
    622     if ($echo) {
    623         echo $the_time;
    624     } else {
    625         return $the_time;
    626     }
     604function the_time( $d = '' ) {
     605    echo apply_filters('the_time', get_the_time( $d ) );
     606}
     607
     608function get_the_time( $d = '' ) {
     609    global $id, $post;
     610    if ( '' == $d )
     611        $the_time = date( get_settings('time_format'), get_post_time() );
     612    else
     613        $the_time = mysql2date( $d, get_post_time() );
     614    return apply_filters('get_the_time', $the_time);
     615}
     616
     617function get_post_time( $gmt = false ) { // returns timestamp
     618    global $post;
     619    if ( $gmt )
     620        $time = mysql2date('U', $post->post_date_gmt);
     621    else
     622        $time = mysql2date('U', $post->post_date);
     623    return apply_filters('get_the_time', $time);
    627624}
    628625
  • trunk/wp-includes/template-functions-links.php

    r1997 r2068  
    2121            break;
    2222    }
    23 }
    24 
    25 function permalink_single_rss($file = '') {
    26     echo get_permalink();
    2723}
    2824
  • trunk/wp-includes/template-functions-post.php

    r2046 r2068  
    4040}
    4141
    42 function the_title_rss() {
    43     $title = get_the_title();
    44     $title = apply_filters('the_title', $title);
    45     $title = apply_filters('the_title_rss', $title);
    46     echo $title;
    47 }
    48 
    4942function get_the_title($id = 0) {
    5043    global $post, $wpdb;
     
    5952    return $title;
    6053}
     54
     55function get_the_guid( $id = 0 ) {
     56    global $post, $wpdb;
     57    $guid = $post->guid;
     58
     59    if ( 0 != $id )
     60        $title = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE ID = $id");
     61    $guid = apply_filters('get_the_guid', $guid);
     62    return $guid;
     63}
     64
     65function the_guid( $id = 0 ) {
     66    echo get_the_guid();
     67}
     68
    6169
    6270function the_content($more_link_text = '(more...)', $stripteaser = 0, $more_file = '') {
     
    6573    $content = str_replace(']]>', ']]&gt;', $content);
    6674    echo $content;
    67 }
    68 
    69 function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
    70     $content = get_the_content($more_link_text, $stripteaser, $more_file);
    71     $content = apply_filters('the_content', $content);
    72     if ($cut && !$encode_html) {
    73         $encode_html = 2;
    74     }
    75     if ($encode_html == 1) {
    76         $content = wp_specialchars($content);
    77         $cut = 0;
    78     } elseif ($encode_html == 0) {
    79         $content = make_url_footnote($content);
    80     } elseif ($encode_html == 2) {
    81         $content = strip_tags($content);
    82     }
    83     if ($cut) {
    84         $blah = explode(' ', $content);
    85         if (count($blah) > $cut) {
    86             $k = $cut;
    87             $use_dotdotdot = 1;
    88         } else {
    89             $k = count($blah);
    90             $use_dotdotdot = 0;
    91         }
    92         for ($i=0; $i<$k; $i++) {
    93             $excerpt .= $blah[$i].' ';
    94         }
    95         $excerpt .= ($use_dotdotdot) ? '...' : '';
    96         $content = $excerpt;
    97     }
    98     $content = str_replace(']]>', ']]&gt;', $content);
    99     echo $content;
    10075}
    10176
     
    141116function the_excerpt() {
    142117    echo apply_filters('the_excerpt', get_the_excerpt());
    143 }
    144 
    145 function the_excerpt_rss($cut = 0, $encode_html = FALSE) {
    146     $output = get_the_excerpt(true);
    147 
    148     $output = convert_chars($output);
    149     if ($cut && !$encode_html) {
    150         $encode_html = 2;
    151     }
    152     if ($encode_html == 1) {
    153         $output = wp_specialchars($output);
    154         $cut = 0;
    155     } elseif ($encode_html === 0) {
    156         $output = make_url_footnote($output);
    157     } elseif ($encode_html == 2) {
    158         $output = strip_tags($output);
    159         $output = str_replace('&', '&amp;', $output);
    160     }
    161     if ($cut) {
    162         $excerpt = '';
    163         $blah = explode(' ', $output);
    164         if (count($blah) > $cut) {
    165             $k = $cut;
    166             $use_dotdotdot = 1;
    167         } else {
    168             $k = count($blah);
    169             $use_dotdotdot = 0;
    170         }
    171         for ($i=0; $i<$k; $i++) {
    172             $excerpt .= $blah[$i].' ';
    173         }
    174         $excerpt .= ($use_dotdotdot) ? '...' : '';
    175         $output = $excerpt;
    176     }
    177     $output = str_replace(']]>', ']]&gt;', $output);
    178     echo apply_filters('the_excerpt_rss', $output);
    179118}
    180119
  • trunk/wp-includes/template-functions.php

    r1967 r2068  
    2020require($curpath . 'comment-functions.php');
    2121
     22require($curpath . 'feed-functions.php');
     23
    2224?>
  • trunk/wp-includes/vars.php

    r2059 r2068  
    159159
    160160add_filter('comment_excerpt', 'convert_chars');
     161add_filter('the_excerpt_rss', 'convert_chars');
    161162
    162163// Places to balance tags on input
  • trunk/wp-rdf.php

    r1888 r2068  
    4747    <?php the_category_rss('rdf') ?>
    4848<?php if (get_settings('rss_use_excerpt')) : ?>
    49     <description><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></description>
     49    <description><?php the_excerpt_rss() ?></description>
    5050<?php else : ?>
    5151    <description><?php the_content_rss('', 0, '', get_settings('rss_excerpt_length'), 2) ?></description>
  • trunk/wp-rss.php

    r1888 r2068  
    2727if (get_settings('rss_use_excerpt')) {
    2828?>
    29             <description><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></description>
     29            <description><?php the_excerpt_rss() ?></description>
    3030<?php
    3131} else { // use content
  • trunk/wp-rss2.php

    r2046 r2068  
    1313<?php echo '<?xml version="1.0" encoding="'.get_settings('blog_charset').'"?'.'>'; ?>
    1414
    15 <!-- generator="wordpress/<?php echo $wp_version ?>" -->
     15<!-- generator="wordpress/<?php bloginfo_rss('version') ?>" -->
    1616<rss version="2.0"
    1717    xmlns:content="http://purl.org/rss/1.0/modules/content/"
     
    2020
    2121<channel>
    22     <title><?php bloginfo_rss('name') ?></title>
     22    <title><?php bloginfo_rss('name'); ?></title>
    2323    <link><?php bloginfo_rss('url') ?></link>
    2424    <description><?php bloginfo_rss("description") ?></description>
    25     <copyright>Copyright <?php echo mysql2date('Y', get_lastpostdate()); ?></copyright>
    2625    <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', get_lastpostmodified('GMT'), 0); ?></pubDate>
    27     <generator>http://wordpress.org/?v=<?php echo $wp_version ?></generator>
     26    <generator>http://wordpress.org/?v=<?php bloginfo_rss('version'); ?></generator>
    2827
    2928    <?php $items_count = 0; if ($posts) { foreach ($posts as $post) { start_wp(); ?>
     
    3231        <link><?php permalink_single_rss() ?></link>
    3332        <comments><?php comments_link(); ?></comments>
    34         <pubDate><?php echo mysql2date('D, d M Y H:i:s +0000', $post->post_date_gmt, 0); ?></pubDate>
     33        <pubDate><?php the_time('D, d M Y H:i:s +0000'); ?></pubDate>
    3534        <?php the_category_rss() ?>
     35
    3636        <guid><?php the_permalink($id); ?></guid>
    3737<?php if (get_settings('rss_use_excerpt')) : ?>
    38         <description><?php the_excerpt_rss('', 2) ?></description>
     38        <description><?php the_excerpt_rss() ?></description>
    3939<?php else : ?>
    40         <description><?php the_excerpt_rss(get_settings('rss_excerpt_length'), 2) ?></description>
    41     <?php if ( strlen( $post->post_content ) ) : ?>
     40        <description><?php the_excerpt_rss() ?></description>
    4241        <content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>
    43     <?php else : ?>
    44         <content:encoded><![CDATA[<?php the_excerpt_rss(); ?>]]></content:encoded>
    45     <?php endif; ?>
    4642<?php endif; ?>
    4743        <wfw:commentRSS><?php echo comments_rss(); ?></wfw:commentRSS>
    48 <?php
    49 $custom_fields = get_post_custom();
    50 if( is_array( $custom_fields ) ) {
    51     while( list( $key, $val ) = each( $custom_fields ) ) {
    52         if( $key == 'enclosure' ) {
    53             if (is_array($val)) {
    54                 foreach($val as $enc) {
    55                     $enclosure = split( "\n", $enc );
    56                     print "<enclosure url='".trim( $enclosure[ 0 ] )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
    57                 }
    58             }
    59         }
    60     }
    61 }
    62 ?>
     44<?php rss_enclosure(); ?>
    6345    </item>
    6446    <?php $items_count++; if (($items_count == get_settings('posts_per_rss')) && empty($m)) { break; } } } ?>
Note: See TracChangeset for help on using the changeset viewer.