Check out the demo video. * Author: Aakash Chakravarthy * Version: 2.6 */ define('SRR_VERSION', '2.6'); define('SRR_URL', plugin_dir_url( __FILE__ )); // Include the required scripts & styles function srr_public_scripts(){ wp_enqueue_script('jquery-easy-ticker-js', 'https://cdn.rawgit.com/vaakash/jquery-easy-ticker/92e6e76c/jquery.easy-ticker.min.js', array( 'jquery', 'super-rss-reader-js' )); wp_enqueue_script('super-rss-reader-js', SRR_URL . 'public/js/script.min.js', array( 'jquery' )); wp_enqueue_style('super-rss-reader-css', SRR_URL . 'public/css/style.min.css'); } add_action('wp_enqueue_scripts', 'srr_public_scripts'); // Default color styles function srr_color_styles(){ return array( 'No style' => 'none', 'Grey' => 'grey', 'Dark' => 'dark', 'Orange' => 'orange', 'Simple modern' => 'smodern' ); } function srr_defaults(){ return array( 'title' => '', 'urls' => '', 'tab_titles' => '', 'count' => 5, 'show_date' => 0, 'show_desc' => 1, 'show_author' => 0, 'show_thumb' => 1, 'open_newtab' => 1, 'strip_desc' => 100, 'read_more' => '[...]', 'rich_desc' => 0 , 'color_style' => 'none', 'enable_ticker' => 1, 'visible_items' => 5, 'strip_title' => 0, 'ticker_speed' => 4, ); } // The main RSS Parser function srr_rss_parser($instance){ $instance = wp_parse_args($instance, srr_defaults()); $urls = stripslashes($instance['urls']); $tab_titles = stripslashes($instance['tab_titles']); $count = intval($instance['count']); $show_date = intval($instance['show_date']); $show_desc = intval($instance['show_desc']); $show_author = intval($instance['show_author']); $show_thumb = stripslashes($instance['show_thumb']); $open_newtab = intval($instance['open_newtab']); $strip_desc = intval($instance['strip_desc']); $strip_title = intval($instance['strip_title']); $read_more = htmlspecialchars($instance['read_more']); $rich_desc = intval($instance['rich_desc']); $color_style = stripslashes($instance['color_style']); $enable_ticker = intval($instance['enable_ticker']); $visible_items = intval($instance['visible_items']); $ticker_speed = intval($instance['ticker_speed']) * 1000; if(empty($urls)){ return ''; } $rand = array(); $url = explode(',', $urls); $tab_title = explode(',', $tab_titles); $ucount = count($url); // Generate the Tabs if($ucount > 1){ echo ''; } for($i=0; $i<$ucount; $i++){ // Get the Feed URL $feedUrl = trim($url[$i]); if(isset($url[$i])){ $rss = fetch_feed($feedUrl); }else{ return ''; } if( method_exists( $rss, 'enable_order_by_date' ) ){ $rss->enable_order_by_date(false); } // Check for feed errors if (!is_wp_error( $rss ) ){ $maxitems = $rss->get_item_quantity($count); $rss_items = $rss->get_items(0, $maxitems); $rss_title = esc_attr(strip_tags($rss->get_title())); $rss_desc = esc_attr(strip_tags($rss->get_description())); }else{ echo '

RSS Error: ' . $rss->get_error_message() . '

'; continue; } $randAttr = isset($rand[$i]) ? ' data-id="srr-tab-' . $rand[$i] . '" ' : ''; // Outer Wrap start echo '
'; // Check feed items if ($maxitems == 0){ echo '
No items.
'; }else{ $j=1; // Loop through each feed item foreach ($rss_items as $item){ // Get the link $link = $item->get_link(); while ( stristr($link, 'http') != $link ){ $link = substr($link, 1); } $link = esc_url(strip_tags($link)); // Get the item title $title = esc_attr(strip_tags($item->get_title())); if ( empty($title) ) $title = __('No Title'); if( $strip_title != 0 ){ $titleLen = strlen($title); $title = wp_html_excerpt( $title, $strip_title ); $title = ($titleLen > $strip_title) ? $title . ' ...' : $title; } // Open links in new tab $newtab = ($open_newtab) ? ' target="_blank"' : ''; // Get the date $date = $item->get_date('j F Y'); // Get thumbnail if present @since v2.2 $thumb = ''; if ($show_thumb == 1 && $enclosure = $item->get_enclosure()){ $thumburl = $enclosure->get_thumbnail(); if(!empty($thumburl)) $thumb = '' . $title . ''; } // Get the description $desc = ''; if( $rich_desc == 1 ){ $desc = strip_tags( str_replace( 'eval', '', $item->get_description() ) , '

'); }else{ $rmore = ''; $desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option('blog_charset') ) ) ) ); if($strip_desc != 0){ $desc = wp_html_excerpt( $desc, $strip_desc ); $rmore = (!empty($read_more)) ? '' . $read_more . '' : ''; if ( '[...]' == substr( $desc, -5 ) ) $desc = substr( $desc, 0, -5 ); elseif ( '[…]' != substr( $desc, -10 ) ) $desc .= ''; $desc = esc_html( $desc ); } $desc = $thumb . $desc . ' ' . $rmore; } // Get the author $author = $item->get_author(); if ( is_object($author) ) { $author = $author->get_name(); $author = esc_html(strip_tags($author)); } echo "\n\n\t"; // Display the feed items echo '

'; echo ''; echo '
'; if($show_date && !empty($date)) echo ''; if($show_author && !empty($author)) echo ' - ' . $author . ''; echo '
'; if($show_desc) echo '

' . $desc . '

'; echo '
'; // End display $j++; } } // Outer wrap end echo "\n\n
\n\n" ; if ( ! is_wp_error($rss) ) $rss->__destruct(); unset($rss); } } class super_rss_reader_widget extends WP_Widget{ // Initialize public function __construct(){ $widget_ops = array( 'classname' => 'widget_super_rss_reader', 'description' => 'Enhanced RSS feed reader widget with advanced features.' ); $control_ops = array('width' => 500, 'height' => 500); parent::__construct('super_rss_reader', 'Super RSS Reader', $widget_ops, $control_ops); } // Display the Widget public function widget($args, $instance){ extract($args); if(empty($instance['title'])){ $title = ''; }else{ $title = $before_title . apply_filters('widget_title', $instance['title'], $instance, $this->id_base) . $after_title; } echo $before_widget . $title; echo "\n" . '
' . "\n"; srr_rss_parser($instance); echo "\n" . '
' . "\n"; echo $after_widget; } // Save settings public function update($new_instance, $old_instance){ $instance = $old_instance; $instance['title'] = stripslashes($new_instance['title']); $instance['urls'] = stripslashes($new_instance['urls']); $instance['tab_titles'] = stripslashes($new_instance['tab_titles']); $instance['count'] = intval($new_instance['count']); $instance['show_date'] = intval($new_instance['show_date']); $instance['show_desc'] = intval($new_instance['show_desc']); $instance['show_author'] = intval($new_instance['show_author']); $instance['show_thumb'] = stripslashes($new_instance['show_thumb']); $instance['open_newtab'] = intval($new_instance['open_newtab']); $instance['strip_desc'] = intval($new_instance['strip_desc']); $instance['strip_title'] = intval($new_instance['strip_title']); $instance['read_more'] = stripslashes($new_instance['read_more']); $instance['rich_desc'] = stripslashes($new_instance['rich_desc']); $instance['color_style'] = stripslashes($new_instance['color_style']); $instance['enable_ticker'] = intval($new_instance['enable_ticker']); $instance['visible_items'] = intval($new_instance['visible_items']); $instance['ticker_speed'] = intval($new_instance['ticker_speed']); return $instance; } // HJA Widget form public function form($instance){ $instance = wp_parse_args((array) $instance, srr_defaults()); $title = htmlspecialchars($instance['title']); $urls = htmlspecialchars($instance['urls']); $tab_titles = htmlspecialchars($instance['tab_titles']); $count = intval($instance['count']); $show_date = intval($instance['show_date']); $show_desc = intval($instance['show_desc']); $show_author = intval($instance['show_author']); $show_thumb = intval($instance['show_thumb']); $open_newtab = intval($instance['open_newtab']); $strip_desc = intval($instance['strip_desc']); $strip_title = intval($instance['strip_title']); $read_more = htmlspecialchars($instance['read_more']); $rich_desc = htmlspecialchars($instance['rich_desc']); $color_style = stripslashes($instance['color_style']); $enable_ticker = intval($instance['enable_ticker']); $visible_items = intval($instance['visible_items']); $ticker_speed = intval($instance['ticker_speed']); ?>
Can enter multiple RSS/atom feed URLs seperated by a comma.
Enter corresponding tab titles seperated by a comma.

Settings

/>
/>
/>
/>
/>    
/>    
Note: You have enabled "Full/Rich HTML" Please make sure that the feed(s) are from trusted sources and do not contain any harmful scripts. If there are some aligment issues in the description, please use custom CSS to fix that.

Other settings

get_field_name('color_style') . '" id="' . $this->get_field_id('color_style') . '">'; foreach($color_styles as $k => $v){ echo ''; } echo ''; ?>

Set value less than 20 to show visible feed items. Example: 5 items
Set value greater than 20 for fixed widget height. Example: 400 px
/>
seconds

Thank you for using Super RSS Reader. If you found it useful, please buy me a coffee !

Buy me a coffee !

Report issue | Rate 5 stars & review | v