PluginProbe
Super RSS Reader – Add attractive RSS Feed Widget / 2.0
Super RSS Reader – Add attractive RSS Feed Widget v2.0
trunk 0.8 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 3.0 3.1 3.2 4.0 4.0.1 4.1 4.2 4.3 4.4 4.4.1 4.5 4.6 4.7 4.8 All 33 releases
← All changes | super-rss-reader.php +41 -116 2.42.0 View file →
@@ -4,9 +4,9 @@
4 4 Plugin URI: http://www.aakashweb.com/wordpress-plugins/super-rss-reader/
5 5 Author URI: http://www.aakashweb.com/
6 6 Description: Super RSS Reader is jQuery based RSS reader widget, which displays the RSS feeds in the widget in an attractive way. It uses the jQuery easy ticker plugin to add a news ticker like effect to the RSS feeds. Multiple RSS feeds can be added for a single widget and they get seperated in tabs. <a href="http://www.youtube.com/watch?v=02aOG_-98Tg" target="_blank" title="Super RSS Reader demo video">Check out the demo video</a>.
7 7 Author: Aakash Chakravarthy
8 -Version: 2.4
8 +Version: 2.0
9 9 */
10 10
11 11 if(!defined('WP_CONTENT_URL')) {
12 12 $srr_url = get_option('siteurl') . '/wp-content/plugins/' . plugin_basename(dirname(__FILE__)).'/';
@@ -13,37 +13,31 @@
13 13 }else{
14 14 $srr_url = WP_CONTENT_URL . '/plugins/' . plugin_basename(dirname(__FILE__)) . '/';
15 15 }
16 16
17 -define('SRR_VERSION', '2.4');
17 +define('SRR_VERSION', '2.0');
18 18 define('SRR_AUTHOR', 'Aakash Chakravarthy');
19 19 define('SRR_URL', $srr_url);
20 20
21 -## Include the required scripts
22 -function srr_public_scripts(){
21 +## Include the required scripts and styles
22 +if( !is_admin()){
23 23 // jQuery
24 - wp_enqueue_script('jquery');
24 + wp_deregister_script('jquery');
25 + wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"), false, '1.3.2');
26 + wp_enqueue_script('jquery');
25 27
26 28 // Super RSS Reader JS and CSS
27 29 wp_register_script('super-rss-reader-js', SRR_URL . 'public/srr-js.js');
28 30 wp_enqueue_script(array('jquery', 'super-rss-reader-js'));
29 -}
30 -add_action('wp_enqueue_scripts', 'srr_public_scripts');
31 -
32 -## Include the required styles
33 -function srr_public_styles(){
34 31 wp_register_style('super-rss-reader-css', SRR_URL . 'public/srr-css.css');
35 32 wp_enqueue_style('super-rss-reader-css');
36 33 }
37 -add_action('wp_enqueue_scripts', 'srr_public_styles');
38 34
39 35 ## Default color styles
40 36 $srr_color_styles = array(
41 37 'No style' => 'none',
42 38 'Grey' => 'grey',
43 - 'Dark' => 'dark',
44 - 'Orange' => 'orange',
45 - 'Simple modern' => 'smodern'
39 + 'Dark' => 'dark'
46 40 );
47 41
48 42 ## The main RSS Parser
49 43 function srr_rss_parser($instance){
@@ -52,17 +46,12 @@
52 46 $count = intval($instance['count']);
53 47 $show_date = intval($instance['show_date']);
54 48 $show_desc = intval($instance['show_desc']);
55 49 $show_author = intval($instance['show_author']);
56 - $show_thumb = stripslashes($instance['show_thumb']);
57 - $open_newtab = intval($instance['open_newtab']);
58 50 $strip_desc = intval($instance['strip_desc']);
59 - $strip_title = intval($instance['strip_title']);
60 - $read_more = htmlspecialchars($instance['read_more']);
61 51 $color_style = stripslashes($instance['color_style']);
62 52 $enable_ticker = intval($instance['enable_ticker']);
63 53 $visible_items = intval($instance['visible_items']);
64 - $ticker_speed = intval($instance['ticker_speed']) * 1000;
65 54
66 55 if(empty($urls)){
67 56 return '';
68 57 }
@@ -68,31 +57,30 @@
68 57 }
69 58
70 59 $rand = array();
71 60 $url = explode(',', $urls);
72 - $ucount = count($url);
73 61
74 62 // Generate the Tabs
75 - if($ucount > 1){
63 + if(count($url) > 1){
76 64 echo '<ul class="srr-tab-wrap srr-tab-style-' . $color_style . ' srr-clearfix">';
77 - for($i=0; $i<$ucount; $i++){
65 + for($i=0; $i<count($url); $i++){
78 66 // Get the Feed URL
79 67 $feedUrl = trim($url[$i]);
80 68 $rss = fetch_feed($feedUrl);
69 + if (is_wp_error($rss)){
70 + if (is_admin() || current_user_can('manage_options')){
71 + echo '<p><strong>RSS Error</strong>:' . $rss->get_error_message() . '</p>';
72 + return;
73 + }
74 + }
75 + $rss_title = esc_attr(strip_tags($rss->get_title()));
81 76 $rand[$i] = rand(0, 999);
82 -
83 - if (!is_wp_error($rss)){
84 - $rss_title = esc_attr(strip_tags($rss->get_title()));
85 - echo '<li data-tab="srr-tab-' . $rand[$i] . '">' . $rss_title . '</li>';
86 - }else{
87 - echo '<li data-tab="srr-tab-' . $rand[$i] . '">Error</li>';
88 - }
89 -
77 + echo '<li data-tab="srr-tab-' . $rand[$i] . '">' . $rss_title . '</li>';
90 78 }
91 79 echo '</ul>';
92 80 }
93 81
94 - for($i=0; $i<$ucount; $i++){
82 + for($i=0; $i<count($url); $i++){
95 83 // Get the Feed URL
96 84 $feedUrl = trim($url[$i]);
97 85 if(isset($url[$i])){
98 86 $rss = fetch_feed($feedUrl);
@@ -101,21 +89,16 @@
101 89 }
102 90
103 91 // Check for feed errors
104 92 if (!is_wp_error( $rss ) ){
105 - $maxitems = $rss->get_item_quantity($count);
93 + $maxitems = $rss->get_item_quantity($count);
106 94 $rss_items = $rss->get_items(0, $maxitems);
107 95 $rss_title = esc_attr(strip_tags($rss->get_title()));
108 96 $rss_desc = esc_attr(strip_tags($rss->get_description()));
109 - }else{
110 - echo '<div class="srr-wrap srr-style-' . $color_style .'" data-id="srr-tab-' . $rand[$i] . '"><p>RSS Error: ' . $rss->get_error_message() . '</p></div>';
111 - continue;
112 97 }
113 -
114 - $randAttr = isset($rand[$i]) ? ' data-id="srr-tab-' . $rand[$i] . '" ' : '';
115 -
98 +
116 99 // Outer Wrap start
117 - echo '<div class="srr-wrap ' . (($enable_ticker == 1 ) ? 'srr-vticker' : '' ) . ' srr-style-' . $color_style . '" data-visible="' . $visible_items . '" data-speed="' . $ticker_speed . '"' . $randAttr . '><div>';
100 + echo '<div class="srr-wrap ' . (($enable_ticker == 1 ) ? 'srr-vticker' : '' ) . ' srr-style-' . $color_style . '" data-visible="' . $visible_items . '" data-id="srr-tab-' . $rand[$i] . '"><div>';
118 101
119 102 // Check feed items
120 103 if ($maxitems == 0){
121 104 echo '<div>No items.</div>';
@@ -130,41 +113,24 @@
130 113
131 114 // Get the item title
132 115 $title = esc_attr(strip_tags($item->get_title()));
133 116 if ( empty($title) )
134 - $title = __('No Title');
117 + $title = __('Untitled');
135 118
136 - if($strip_title != 0){
137 - $titleLen = strlen($title);
138 - $title = wp_html_excerpt( $title, $strip_title );
139 - $title = ($titleLen > $strip_title) ? $title . ' ...' : $title;
140 - }
141 -
142 119 // Get the date
143 120 $date = $item->get_date('j F Y');
144 121
145 - // Get thumbnail if present @since v2.2
146 - $thumb = '';
147 - if ($show_thumb == 1 && $enclosure = $item->get_enclosure()){
148 - $thumburl = $enclosure->get_thumbnail();
149 - if(!empty($thumburl))
150 - $thumb = '<img src="' . $thumburl . '" alt="' . $title . '" class="srr-thumb" align="left"/>';
151 - }
152 -
153 122 // Get the description
154 123 $desc = str_replace( array("\n", "\r"), ' ', esc_attr( strip_tags( @html_entity_decode( $item->get_description(), ENT_QUOTES, get_option('blog_charset') ) ) ) );
124 +
155 125 if($strip_desc != 0){
156 126 $desc = wp_html_excerpt( $desc, $strip_desc );
157 - $rmore = (!empty($read_more)) ? '<a href="' . $link . '" title="Read more">' . $read_more . '</a>' : '';
158 -
159 127 if ( '[...]' == substr( $desc, -5 ) )
160 - $desc = substr( $desc, 0, -5 );
128 + $desc = substr( $desc, 0, -5 ) . '[&hellip;]';
161 129 elseif ( '[&hellip;]' != substr( $desc, -10 ) )
162 - $desc .= '';
163 -
164 - $desc = esc_html( $desc );
130 + $desc .= ' [&hellip;]';
165 131 }
166 - $desc = $thumb . $desc . ' ' . $rmore;
132 + $desc = esc_html( $desc );
167 133
168 134 // Get the author
169 135 $author = $item->get_author();
170 136 if ( is_object($author) ) {
@@ -170,31 +136,18 @@
170 136 if ( is_object($author) ) {
171 137 $author = $author->get_name();
172 138 $author = esc_html(strip_tags($author));
173 139 }
174 -
175 - // Open links in new tab
176 - $newtab = ($open_newtab) ? ' target="_blank"' : '';
177 140
178 141 echo "\n\n\t";
179 142
180 143 // Display the feed items
181 144 echo '<div class="srr-item ' . (($j%2 == 0) ? 'even' : 'odd') . '">';
182 - echo '<div class="srr-title"><a href="' . $link . '"' . $newtab . ' title="Posted on ' . $date . '">' . $title . '</a></div>';
183 - echo '<div class="srr-meta">';
184 -
185 - if($show_date && !empty($date))
186 - echo '<time class="srr-date">' . $date . '</time>';
187 -
188 - if($show_author && !empty($author))
189 - echo ' - <cite class="srr-author">' . $author . '</cite>';
190 -
145 + echo '<a href="' . $link . '" title="Posted on ' . $date . '">' .$title . '</a>';
146 + if($show_date) echo '<br/><em class="srr-date">' . $date . '</em>';
147 + if($show_author) echo ' - <cite class="srr-author">' . $author . '</cite>';
148 + if($show_desc) echo '<p class="srr-summary">' . $desc . '</p>';
191 149 echo '</div>';
192 -
193 - if($show_desc)
194 - echo '<p class="srr-summary srr-clearfix">' . $desc . '</p>';
195 -
196 - echo '</div>';
197 150 // End display
198 151
199 152 $j++;
200 153 }
@@ -229,12 +182,12 @@
229 182 }
230 183
231 184 echo $before_widget . $title;
232 185 echo "\n" . '
233 - <!-- Start - Super RSS Reader v' . SRR_VERSION . '-->
186 + <!-- Start - Super RSS Reader -->
234 187 <div class="super-rss-reader-widget">' . "\n";
235 188
236 - srr_rss_parser($instance);
189 + srr_rss_parser($instance, $instance['urls']);
237 190
238 191 echo "\n" . '</div>
239 192 <!-- End - Super RSS Reader -->
240 193 ' . "\n";
@@ -250,18 +203,13 @@
250 203 $instance['count'] = intval($new_instance['count']);
251 204 $instance['show_date'] = intval($new_instance['show_date']);
252 205 $instance['show_desc'] = intval($new_instance['show_desc']);
253 206 $instance['show_author'] = intval($new_instance['show_author']);
254 - $instance['show_thumb'] = stripslashes($new_instance['show_thumb']);
255 - $instance['open_newtab'] = intval($new_instance['open_newtab']);
256 207 $instance['strip_desc'] = intval($new_instance['strip_desc']);
257 - $instance['strip_title'] = intval($new_instance['strip_title']);
258 - $instance['read_more'] = stripslashes($new_instance['read_more']);
259 208
260 209 $instance['color_style'] = stripslashes($new_instance['color_style']);
261 210 $instance['enable_ticker'] = intval($new_instance['enable_ticker']);
262 211 $instance['visible_items'] = intval($new_instance['visible_items']);
263 - $instance['ticker_speed'] = intval($new_instance['ticker_speed']);
264 212
265 213 return $instance;
266 214 }
267 215
@@ -270,12 +218,11 @@
270 218 global $srr_color_styles;
271 219
272 220 $instance = wp_parse_args( (array) $instance, array(
273 221 'title' => '', 'urls' => '', 'count' => 5,
274 - 'show_date' => 0, 'show_desc' => 1, 'show_author' => 0, 'show_thumb' => 1,
275 - 'open_newtab' => 1, 'strip_desc' => 100, 'read_more' => '[...]',
276 - 'color_style' => 'none', 'enable_ticker' => 1, 'visible_items' => 5,
277 - 'strip_title' => 0, 'ticker_speed' => 2,
222 + 'show_date' => 0, 'show_desc' => 1, 'show_author' => 0,
223 + 'strip_desc' => 100, 'color_style' => 'none', 'enable_ticker' => 1,
224 + 'visible_items' => 5
278 225 ));
279 226
280 227 $title = htmlspecialchars($instance['title']);
281 228 $urls = htmlspecialchars($instance['urls']);
@@ -283,18 +230,13 @@
283 230 $count = intval($instance['count']);
284 231 $show_date = intval($instance['show_date']);
285 232 $show_desc = intval($instance['show_desc']);
286 233 $show_author = intval($instance['show_author']);
287 - $show_thumb = intval($instance['show_thumb']);
288 - $open_newtab = intval($instance['open_newtab']);
289 234 $strip_desc = intval($instance['strip_desc']);
290 - $strip_title = intval($instance['strip_title']);
291 - $read_more = htmlspecialchars($instance['read_more']);
292 235
293 236 $color_style = stripslashes($instance['color_style']);
294 237 $enable_ticker = intval($instance['enable_ticker']);
295 238 $visible_items = intval($instance['visible_items']);
296 - $ticker_speed = intval($instance['ticker_speed']);
297 239
298 240 ?>
299 241 <div class="srr_settings">
300 242 <table width="100%" height="72" border="0">
@@ -323,28 +265,17 @@
323 265 <tr>
324 266 <td height="32"><input id="<?php echo $this->get_field_id('show_date'); ?>" type="checkbox" name="<?php echo $this->get_field_name('show_date'); ?>" value="1" <?php echo $show_date == "1" ? 'checked="checked"' : ""; ?> /></td>
325 267 <td><label for="<?php echo $this->get_field_id('show_date'); ?>">Show Date</label></td>
326 268 <td><label for="<?php echo $this->get_field_id('strip_desc');?>">Strip description</label></td>
327 - <td><input id="<?php echo $this->get_field_id('strip_desc');?>" name="<?php echo $this->get_field_name('strip_desc'); ?>" type="text" value="<?php echo $strip_desc; ?>" class="widefat" title="The number of charaters to be displayed. Use 0 to disable stripping"/> </td>
269 + <td><input id="<?php echo $this->get_field_id('strip_desc');?>" name="<?php echo $this->get_field_name('strip_desc'); ?>" type="text" value="<?php echo $strip_desc; ?>" class="widefat" title="Use 0 to avoid striping the description of the feed"/>
270 + </td>
328 271 </tr>
329 272 <tr>
330 273 <td height="29"><input id="<?php echo $this->get_field_id('show_author'); ?>" type="checkbox" name="<?php echo $this->get_field_name('show_author'); ?>" value="1" <?php echo $show_author == "1" ? 'checked="checked"' : ""; ?> /></td>
331 274 <td><label for="<?php echo $this->get_field_id('show_author'); ?>">Show Author</label></td>
332 - <td><label for="<?php echo $this->get_field_id('read_more'); ?>">Read more text</label></td>
333 - <td><input id="<?php echo $this->get_field_name('read_more'); ?>" name="<?php echo $this->get_field_name('read_more'); ?>" type="text" value="<?php echo $read_more; ?>" class="widefat" title="Leave blank to hide read more text"/></td>
275 + <td>&nbsp;</td>
276 + <td>&nbsp;</td>
334 277 </tr>
335 - <tr>
336 - <td height="29"><input id="<?php echo $this->get_field_id('open_newtab'); ?>" type="checkbox" name="<?php echo $this->get_field_name('open_newtab'); ?>" value="1" <?php echo $open_newtab == "1" ? 'checked="checked"' : ""; ?> /></td>
337 - <td><label for="<?php echo $this->get_field_id('open_newtab'); ?>">Open links in new tab</label></td>
338 - <td><label for="<?php echo $this->get_field_id('strip_title'); ?>">Strip Title</label></td>
339 - <td><input id="<?php echo $this->get_field_id('strip_title');?>" name="<?php echo $this->get_field_name('strip_title'); ?>" type="text" value="<?php echo $strip_title; ?>" class="widefat" title="The number of charaters to be displayed. Use 0 to disable stripping"/></td>
340 - </tr>
341 - <tr>
342 - <td height="29"><input id="<?php echo $this->get_field_id('show_thumb'); ?>" type="checkbox" name="<?php echo $this->get_field_name('show_thumb'); ?>" value="1" <?php echo $show_thumb == "1" ? 'checked="checked"' : ""; ?> /></td>
343 - <td><label for="<?php echo $this->get_field_id('show_thumb'); ?>">Show thumbnail if present</label></td>
344 - <td>&nbsp;</td>
345 - <td>&nbsp;</td>
346 - </tr>
347 278 </table>
348 279 </div>
349 280
350 281 <div class="srr_settings">
@@ -370,18 +301,12 @@
370 301 <td height="36"><label for="<?php echo $this->get_field_id('visible_items');?>">Visible items: </label></td>
371 302 <td><input id="<?php echo $this->get_field_id('visible_items');?>" name="<?php echo $this->get_field_name('visible_items'); ?>" type="text" value="<?php echo $visible_items; ?>" class="widefat" title="The no of feed items to be visible."/>
372 303 </td>
373 304 </tr>
374 - <tr>
375 - <td height="36"><label for="<?php echo $this->get_field_id('ticker_speed');?>">Ticker speed: </label></td>
376 - <td><input id="<?php echo $this->get_field_id('ticker_speed');?>" name="<?php echo $this->get_field_name('ticker_speed'); ?>" type="text" value="<?php echo $ticker_speed; ?>" title="Speed of the ticker in seconds"/> seconds
377 - </td>
378 - </tr>
379 305 </table>
380 306 </div>
381 307
382 - <div class="srr_support"> <a href="http://facebook.com/aakashweb" class="srr_fblike" target="_blank">Like</a> | <a href="http://bit.ly/srrDonate" target="_blank" style="color: #FF6600" title="If you like this plugin, then just make a small donation and it will be helpful for the plugin's development.">Donate</a> | <a href="http://www.aakashweb.com/wordpress-plugins/super-rss-reader/" target="_blank">Support</a></div>
383 - <small>Please donate and share this plugin to show your support. Thank you :)</small>
308 + <div class="srr_support"> <a href="http://facebook.com/aakashweb" class="srr_fblike" target="_blank">Like</a> | <a href="http://bit.ly/srrdonate" target="_blank" style="color: #FF6600" title="If you like this plugin, then just make a small donation and it will be helpful for the plugin's development.">Donate</a> | <a href="http://www.aakashweb.com/wordpress-plugins/super-rss-reader/" target="_blank">Support</a></div>
384 309
385 310 <?php
386 311 }
387 312 }