Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_widget_rss_output [ WordPress Function ]

wp_widget_rss_output ( $rss, $args = array() )
Parameters:
  • (string|array|object) $rss RSS url.
  • (array) $args Widget arguments.
Defined at:



Display the RSS entries in a list.

Source


<?php
function wp_widget_rss_output$rss$args = array() ) {
    if ( 
is_string$rss ) ) {
        
$rss fetch_feed($rss);
    } elseif ( 
is_array($rss) && isset($rss['url']) ) {
        
$args $rss;
        
$rss fetch_feed($rss['url']);
    } elseif ( !
is_object($rss) ) {
        return;
    }

    if ( 
is_wp_error($rss) ) {
        if ( 
is_admin() || current_user_can('manage_options') )
            echo 
'<p>' sprintf__('<strong>RSS Error</strong>: %s'), $rss->get_error_message() ) . '</p>';
        return;
    }

    
$default_args = array( 'show_author' => 0'show_date' => 0'show_summary' => );
    
$args wp_parse_args$args$default_args );
    
extract$argsEXTR_SKIP );

    
$items = (int) $items;
    if ( 
$items || 20 $items )
        
$items 10;
    
$show_summary  = (int) $show_summary;
    
$show_author   = (int) $show_author;
    
$show_date     = (int) $show_date;

    if ( !
$rss->get_item_quantity() ) {
        echo 
'<ul><li>' __'An error has occurred; the feed is probably down. Try again later.' ) . '</li></ul>';
        
$rss->__destruct();
        unset(
$rss);
        return;
    }

    echo 
'<ul>';
    foreach ( 
$rss->get_items(0$items) as $item ) {
        
$link $item->get_link();
        while ( 
stristr($link'http') != $link )
            
$link substr($link1);
        
$link esc_url(strip_tags($link));
        
$title esc_attr(strip_tags($item->get_title()));
        if ( empty(
$title) )
            
$title __('Untitled');

        
$desc str_replace( array("\n""\r"), ' 'esc_attrstrip_tags( @html_entity_decode$item->get_description(), ENT_QUOTESget_option('blog_charset') ) ) ) );
        
$desc wp_html_excerpt$desc360 );

        
// Append ellipsis. Change existing [...] to [&hellip;].
        
if ( '[...]' == substr$desc, -) )
            
$desc substr$desc0, -) . '[&hellip;]';
        elseif ( 
'[&hellip;]' != substr$desc, -10 ) )
            
$desc .= ' [&hellip;]';

        
$desc esc_html$desc );

        if ( 
$show_summary ) {
            
$summary "<div class='rssSummary'>$desc</div>";
        } else {
            
$summary '';
        }

        
$date '';
        if ( 
$show_date ) {
            
$date $item->get_date'U' );

            if ( 
$date ) {
                
$date ' <span class="rss-date">' date_i18nget_option'date_format' ), $date ) . '</span>';
            }
        }

        
$author '';
        if ( 
$show_author ) {
            
$author $item->get_author();
            if ( 
is_object($author) ) {
                
$author $author->get_name();
                
$author ' <cite>' esc_htmlstrip_tags$author ) ) . '</cite>';
            }
        }

        if ( 
$link == '' ) {
            echo 
"<li>$title{$date}{$summary}{$author}</li>";
        } else {
            echo 
"<li><a class='rsswidget' href='$link' title='$desc'>$title</a>{$date}{$summary}{$author}</li>";
        }
    }
    echo 
'</ul>';
    
$rss->__destruct();
    unset(
$rss);
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

Kullanýcý Tartýþmalarý [ wordpress.org ]

- Bulunamadý -

Yeni bir konu yaz ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics