home *** CD-ROM | disk | FTP | other *** search
/ MacAddict 108 / MacAddict108.iso / Software / Internet & Communication / WordPress 1.5.1.dmg / wordpress / wp-includes / feed-functions.php < prev    next >
Encoding:
PHP Script  |  2005-05-09  |  4.2 KB  |  158 lines

  1. <?php
  2.  
  3. function get_bloginfo_rss($show = '') {
  4.     $info = strip_tags(get_bloginfo($show));
  5.     return convert_chars($info);
  6. }
  7.  
  8. function bloginfo_rss($show = '') {
  9.     echo get_bloginfo_rss($show);
  10. }
  11.  
  12. function the_title_rss() {
  13.     $title = get_the_title();
  14.     $title = apply_filters('the_title', $title);
  15.     $title = apply_filters('the_title_rss', $title);
  16.     echo $title;
  17. }
  18.  
  19. function the_content_rss($more_link_text='(more...)', $stripteaser=0, $more_file='', $cut = 0, $encode_html = 0) {
  20.     $content = get_the_content($more_link_text, $stripteaser, $more_file);
  21.     $content = apply_filters('the_content', $content);
  22.     if ($cut && !$encode_html) {
  23.         $encode_html = 2;
  24.     }
  25.     if ($encode_html == 1) {
  26.         $content = wp_specialchars($content);
  27.         $cut = 0;
  28.     } elseif ($encode_html == 0) {
  29.         $content = make_url_footnote($content);
  30.     } elseif ($encode_html == 2) {
  31.         $content = strip_tags($content);
  32.     }
  33.     if ($cut) {
  34.         $blah = explode(' ', $content);
  35.         if (count($blah) > $cut) {
  36.             $k = $cut;
  37.             $use_dotdotdot = 1;
  38.         } else {
  39.             $k = count($blah);
  40.             $use_dotdotdot = 0;
  41.         }
  42.         for ($i=0; $i<$k; $i++) {
  43.             $excerpt .= $blah[$i].' ';
  44.         }
  45.         $excerpt .= ($use_dotdotdot) ? '...' : '';
  46.         $content = $excerpt;
  47.     }
  48.     $content = str_replace(']]>', ']]>', $content);
  49.     echo $content;
  50. }
  51.  
  52. function the_excerpt_rss() {
  53.     $output = get_the_excerpt(true);
  54.     echo apply_filters('the_excerpt_rss', $output);
  55. }
  56.  
  57. function permalink_single_rss($file = '') {
  58.     echo get_permalink();
  59. }
  60.  
  61. function comment_link() {
  62.     echo get_comment_link();
  63. }
  64.  
  65. function comment_author_rss() {
  66.     $author = apply_filters('comment_author_rss', get_comment_author() );
  67.     echo $author;
  68. }
  69.  
  70. function comment_text_rss() {
  71.     $comment_text = get_comment_text();
  72.     $comment_text = apply_filters('comment_text_rss', $comment_text);
  73.     echo $comment_text;
  74. }
  75.  
  76. function comments_rss_link($link_text = 'Comments RSS', $commentsrssfilename = '') {
  77.     $url = comments_rss($commentsrssfilename);
  78.     echo "<a href='$url'>$link_text</a>";
  79. }
  80.  
  81. function comments_rss($commentsrssfilename = '') {
  82.     global $id;
  83.  
  84.     if ('' != get_settings('permalink_structure'))
  85.         $url = trailingslashit( get_permalink() ) . 'feed/';
  86.     else
  87.         $url = get_settings('home') . "/$commentsrssfilename?feed=rss2&p=$id";
  88.  
  89.     return apply_filters('post_comments_feed_link', $url);
  90. }
  91.  
  92. function get_author_rss_link($echo = false, $author_id, $author_nicename) {
  93.        $auth_ID = $author_id;
  94.        $permalink_structure = get_settings('permalink_structure');
  95.  
  96.        if ('' == $permalink_structure) {
  97.                  $link = get_settings('home') . '?feed=rss2&author=' . $author_id;
  98.        } else {
  99.                  $link = get_author_link(0, $author_id, $author_nicename);
  100.                  $link = $link . "feed/";
  101.        }
  102.              
  103.              $link = apply_filters('author_feed_link', $link);
  104.  
  105.        if ($echo) echo $link;
  106.        return $link;
  107. }
  108.  
  109. function get_category_rss_link($echo = false, $cat_ID, $category_nicename) {
  110.        $permalink_structure = get_settings('permalink_structure');
  111.  
  112.        if ('' == $permalink_structure) {
  113.                  $link = get_settings('home') . '?feed=rss2&cat=' . $cat_ID;
  114.        } else {
  115.                  $link = get_category_link($cat_ID);
  116.                  $link = $link . "feed/";
  117.        }
  118.  
  119.              $link = apply_filters('category_feed_link', $link);
  120.  
  121.        if ($echo) echo $link;
  122.        return $link;
  123. }
  124.  
  125. function the_category_rss($type = 'rss') {
  126.     $categories = get_the_category();
  127.     $the_list = '';
  128.     foreach ($categories as $category) {
  129.         $category->cat_name = convert_chars($category->cat_name);
  130.         if ('rdf' == $type) {
  131.             $the_list .= "\n\t<dc:subject>$category->cat_name</dc:subject>";
  132.         } else {
  133.             $the_list .= "\n\t<category>$category->cat_name</category>";
  134.         }
  135.     }
  136.     echo apply_filters('the_category_rss', $the_list, $type);
  137. }
  138.  
  139. function rss_enclosure() {
  140.     global $id, $post;
  141.     if (!empty($post->post_password) && ($_COOKIE['wp-postpass_'.COOKIEHASH] != $post->post_password)) return;
  142.  
  143.     $custom_fields = get_post_custom();
  144.     if( is_array( $custom_fields ) ) {
  145.         while( list( $key, $val ) = each( $custom_fields ) ) { 
  146.             if( $key == 'enclosure' ) {
  147.                 if (is_array($val)) {
  148.                     foreach($val as $enc) {
  149.                         $enclosure = split( "\n", $enc );
  150.                         print "<enclosure url='".trim( htmlspecialchars($enclosure[ 0 ]) )."' length='".trim( $enclosure[ 1 ] )."' type='".trim( $enclosure[ 2 ] )."'/>\n";
  151.                     }
  152.                 }
  153.             }
  154.         }
  155.     }
  156. }
  157.  
  158. ?>