<?php

/*
Plugin Name: WP-RSSImport_NoReplace
Plugin URI: http://www.bueltge.de/wp-rss-import-plugin/55/
Description: List a RSS-Feed in your WP-Blog, only headlines or with description.
Author: Frank Bueltge
Version: 3.5
License: GPL
Author URI: http://www.bueltge.de
Update Server: http://www.bueltge.de/
Min WP Version: 1.5
Max WP Version: 2.0.4
*/ 

/*
Original and Idea: Dave Wolf, http://www.davewolf.net
Thx to Thomas Fischer, http://www.securityfocus.de and Gunnar Tillmann http://www.gunnart.de for a better code

USAGE: Use following code with a PHP-Plugin for WordPress:
Example: <?php RSSImport(10,"http://www.bueltge.de/feed/",true,false); ?> 
*/

require_once(ABSPATH.'wp-includes/rss-functions.php');

function 
RSSImport($display=0,$feedurl,$displaydescriptions=false,$truncatetitle=true) {

if (
$feedurl) {
    
$rss fetch_rss($feedurl);
    echo 
wptexturize('<ul>');
        foreach (
$rss->items as $item) {
                if (
$display == 0) {
                break;
                }
                
$href $item['link'];
                
$desc trim($item['description']);
                
$item['fulltitle']=$item['title'];
                if(
$truncatetitle){
                    if(
strlen($item['title'])>30)
                        {
                            
$item['title']=substr($item['title'],0,30)." ... ";
                        }
                }
              echo 
wptexturize('<li>');
              echo 
wptexturize('<a href="'.$href.'" title="'.$item['fulltitle'].'">'.$item['title'].'</a>');
                    if(
$displaydescriptions && $desc<>"") echo wptexturize('<br />'."\n".$desc."\n");
                    
$display--;
              echo 
wptexturize('</li>');
        }
    echo 
wptexturize('</ul>');
     }
}
?>