PluginProbe
Super RSS Reader – Add attractive RSS Feed Widget / 4.7
Super RSS Reader – Add attractive RSS Feed Widget v4.7
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 | includes/feed.php +62 -46 4.44.7 View file →
@@ -17,32 +17,33 @@
17 17 }
18 18
19 19 public function html(){
20 20
21 - $urls = stripslashes( trim( $this->options['urls'] ) );
22 - $tab_titles = stripslashes( $this->options['tab_titles'] );
21 + $urls = trim( $this->options['urls'] );
22 + $tab_titles = $this->options['tab_titles'];
23 23 $count = intval( $this->options['count'] );
24 24
25 25 $show_date = intval( $this->options['show_date'] );
26 26 $show_desc = intval( $this->options['show_desc'] );
27 27 $show_author = intval( $this->options['show_author'] );
28 - $show_thumb = stripslashes( $this->options['show_thumb'] );
28 + $show_thumb = intval( $this->options['show_thumb'] );
29 29 $open_newtab = intval( $this->options['open_newtab'] );
30 30 $add_nofollow = intval( $this->options['add_nofollow'] );
31 31 $strip_desc = intval( $this->options['strip_desc'] );
32 32 $strip_title = intval( $this->options['strip_title'] );
33 - $date_format = htmlspecialchars( $this->options['date_format'] );
34 - $order_by = htmlspecialchars( $this->options['order_by'] );
35 - $read_more = htmlspecialchars( $this->options['read_more'] );
33 + $date_format = $this->options['date_format'];
34 + $date_timezone = $this->options['date_timezone'];
35 + $order_by = $this->options['order_by'];
36 + $read_more = $this->options['read_more'];
36 37 $rich_desc = intval( $this->options['rich_desc'] );
37 - $desc_type = htmlspecialchars( $this->options['desc_type'] );
38 - $thumbnail_position = htmlspecialchars( $this->options['thumbnail_position'] );
39 - $thumbnail_size = htmlspecialchars( $this->options['thumbnail_size'] );
40 - $thumbnail_default = htmlspecialchars( $this->options['thumbnail_default'] );
41 - $no_feed_text = htmlspecialchars( $this->options['no_feed_text'] );
38 + $desc_type = $this->options['desc_type'];
39 + $thumbnail_position = $this->options['thumbnail_position'];
40 + $thumbnail_size = $this->options['thumbnail_size'];
41 + $thumbnail_default = $this->options['thumbnail_default'];
42 + $no_feed_text = $this->options['no_feed_text'];
42 43
43 - $color_theme = stripslashes( $this->options['color_style'] );
44 - $display_type = stripslashes( $this->options['display_type'] );
44 + $color_theme = $this->options['color_style'];
45 + $display_type = $this->options['display_type'];
45 46 $visible_items = intval( $this->options['visible_items'] );
46 47 $ticker_speed = intval( $this->options['ticker_speed'] ) * 1000;
47 48
48 49 if( empty( $urls ) ){
@@ -57,9 +58,9 @@
57 58 $url_count = count( $urls );
58 59
59 60 $feeds = array();
60 61 $html = '';
61 - $no_feed_html = '<div>' . $no_feed_text . '</div>';
62 + $no_feed_html = '<div>' . wp_kses_post( $no_feed_text ) . '</div>';
62 63
63 64 $classes = array( 'srr-wrap', 'srr-style-' . $color_theme );
64 65 if( $display_type == 'vertical_ticker' ) array_push( $classes, 'srr-vticker' );
65 66 $class = implode( ' ', $classes );
@@ -66,14 +67,20 @@
66 67
67 68 // Fetch the feed
68 69 for( $i=0; $i < $url_count; $i++ ){
69 70 $feed_url = trim( $urls[$i] );
71 +
72 + // Skip if the RSS feed URL is same as the site URL
73 + if ( in_array( untrailingslashit( $feed_url ), array( site_url(), home_url() ), true ) ) {
74 + continue;
75 + }
76 +
70 77 $feed = fetch_feed( $feed_url );
71 78
72 79 if( is_wp_error( $feed ) ){
73 - $feed_title = 'Error';
80 + $feed_title = __( 'Error' );
74 81 }else{
75 - $feed_title = ( isset( $tab_titles[$i] ) && !empty( $tab_titles[$i] ) ) ? $tab_titles[$i] : esc_attr( strip_tags( $feed->get_title() ) );
82 + $feed_title = ( isset( $tab_titles[$i] ) && !empty( $tab_titles[$i] ) ) ? $tab_titles[$i] : strip_tags( $feed->get_title() );
76 83 }
77 84
78 85 $feeds[ $feed_url ] = array(
79 86 'id' => rand( 100, 999 ),
@@ -83,17 +90,13 @@
83 90 }
84 91
85 92 // Generate tabs
86 93 if( $url_count > 1 ){
87 - $html .= '<ul class="srr-tab-wrap srr-tab-style-' . $color_theme . ' srr-clearfix">';
94 + $html .= '<ul class="srr-tab-wrap srr-tab-style-' . esc_attr( $color_theme ) . ' srr-clearfix">';
88 95 foreach( $feeds as $url => $data ){
89 96 $id = $data[ 'id' ];
90 97 $feed = $data[ 'feed' ];
91 - if( is_wp_error( $feed ) ){
92 - $html .= '<li data-tab="srr-tab-' . $id . '">Error</li>';
93 - }else{
94 - $html .= '<li data-tab="srr-tab-' . $id . '">' . $data[ 'title' ] . '</li>';
95 - }
98 + $html .= '<li data-tab="srr-tab-' . esc_attr( $id ) . '">' . wp_kses_post( $data[ 'title' ] ) . '</li>';
96 99 }
97 100 $html .= '</ul>';
98 101 }
99 102
@@ -104,9 +107,9 @@
104 107 $feed = $data[ 'feed' ];
105 108
106 109 // Check for feed errors
107 110 if ( is_wp_error( $feed ) ){
108 - $html .= '<div class="srr-wrap srr-style-' . $color_theme .'" data-id="srr-tab-' . $id . '"><p>RSS Error: ' . $feed->get_error_message() . '</p></div>';
111 + $html .= '<div class="srr-wrap srr-style-' . esc_attr( $color_theme ) .'" data-id="srr-tab-' . esc_attr( $id ) . '"><p>RSS Error: ' . wp_kses_post( $feed->get_error_message() ) . '</p></div>';
109 112 continue;
110 113 }
111 114
112 115 if( method_exists( $feed, 'enable_order_by_date' ) ){
@@ -117,9 +120,9 @@
117 120 }
118 121 }
119 122
120 123 // Outer wrap start
121 - $html .= '<div class="' . $class . '" data-visible="' . $visible_items . '" data-speed="' . $ticker_speed . '" data-id="srr-tab-' . $id . '">';
124 + $html .= '<div class="' . esc_attr( $class ) . '" data-visible="' . esc_attr( $visible_items ) . '" data-speed="' . esc_attr( $ticker_speed ) . '" data-id="srr-tab-' . esc_attr( $id ) . '">';
122 125 $html .= '<div>';
123 126
124 127 $max_items = $feed->get_item_quantity();
125 128
@@ -137,12 +140,12 @@
137 140
138 141 // Link
139 142 $link = $item->get_link();
140 143 while ( stristr( $link, 'http' ) != $link ){ $link = substr( $link, 1 ); }
141 - $link = esc_url( strip_tags($link) );
144 + $link = strip_tags($link);
142 145
143 146 // Title
144 - $title = esc_attr( strip_tags( $item->get_title() ) );
147 + $title = strip_tags( $item->get_title() );
145 148 $title_full = $title;
146 149
147 150 if ( empty( $title ) ){
148 151 $title = __( 'No Title', 'super-rss-reader' );
@@ -157,12 +160,28 @@
157 160
158 161 // Add no follow attribute
159 162 $no_follow = $add_nofollow ? ' rel="nofollow noopener noreferrer"' : '';
160 163
164 + if( empty( $link ) ){
165 + $link = '#';
166 + $new_tab = '';
167 + }
168 +
161 169 // Date
162 - $date = date_i18n( $date_format, $item->get_date( 'U' ) );
163 - $date_full = esc_attr( $item->get_date() );
170 + $date = '';
171 + $date_full = strip_tags( $item->get_date() );
164 172
173 + if( strtolower( $date_format ) == 'relative' ){
174 + $item_date = $item->get_date( 'U' );
175 + if( $item_date ){
176 + $date = human_time_diff( $item_date, current_time( 'U' ) ) . ' ' . __( 'ago' );
177 + }else{
178 + $date = __( 'Today' );
179 + }
180 + }else{
181 + $date = SRR_Utilities::date_i18n( $date_format, $item->get_date( 'U' ), $date_timezone );
182 + }
183 +
165 184 // Thumbnail
166 185 $thumb = '';
167 186 if ( $show_thumb == 1 ){
168 187 $thumb_url = $this->get_thumbnail_url( $item, $thumbnail_default );
@@ -175,9 +194,9 @@
175 194 $thumb_style = '';
176 195 foreach( $thumb_styles as $prop => $val ){
177 196 $thumb_style .= "$prop:$val;";
178 197 }
179 - $thumb = '<a href="' . $link . '" class="srr-thumb srr-thumb-' . $thumbnail_position . '" style="' . $thumb_style . '" ' . $new_tab . $no_follow . '><img src="' . $thumb_url . '" alt="' . $title_full . '" align="left" /></a>';
198 + $thumb = '<a href="' . esc_url( $link ) . '" class="srr-thumb srr-thumb-' . esc_attr( $thumbnail_position ) . '" style="' . esc_attr( $thumb_style ) . '" ' . $new_tab . $no_follow . '><img src="' . esc_url( $thumb_url ) . '" alt="' . esc_attr( $title_full ) . '" align="left"' . ( wp_lazy_loading_enabled( 'img', 'srr-thumbnail' ) ? ' loading="lazy"' : '' ) . ' /></a>';
180 199 }
181 200 }
182 201
183 202 // Description
@@ -184,29 +203,24 @@
184 203 $desc = '';
185 204 if( $show_desc ){
186 205 $desc_content = ( $desc_type == 'summary' ) ? $item->get_description() : $item->get_content();
187 206 if( $rich_desc ){
188 - $desc = strip_tags( $desc_content, '<p><a><img><em><strong><font><strike><s><u><i>' );
207 + $desc = wp_kses_post( strip_tags( $desc_content, '<p><a><img><em><strong><font><strike><s><u><i><br>' ) );
189 208 }else{
209 + $desc = str_replace( array( "\n", "\r" ), ' ', strip_tags( @html_entity_decode( $desc_content, ENT_QUOTES, get_option('blog_charset') ) ) );
190 210
191 - $desc = str_replace( array( "\n", "\r" ), ' ', esc_attr( strip_tags( @html_entity_decode( $desc_content, ENT_QUOTES, get_option('blog_charset') ) ) ) );
192 - $read_more_link = '';
193 -
194 211 if( $strip_desc != 0 ){
195 212 $desc = wp_trim_words( $desc, $strip_desc );
196 - $read_more_link = !empty( $read_more ) ? ' <a href="' . $link . '" title="' . __( 'Read more', 'super-rss-reader' ) . '"' . $new_tab . $no_follow . ' class="srr-read-more">' . $read_more . '</a>' : '';
197 -
198 213 if ( '[...]' == substr( $desc, -5 ) ){
199 214 $desc = substr( $desc, 0, -5 );
200 215 }elseif ( '[&hellip;]' != substr( $desc, -10 ) ){
201 216 $desc .= '';
202 217 }
203 -
204 - $desc = esc_html( $desc );
205 218 }
206 219
207 - $desc = trim( $desc );
220 + $desc = trim( esc_html( $desc ) );
208 221 if( !empty( $desc ) ){
222 + $read_more_link = !empty( $read_more ) ? ' <a href="' . esc_url( $link ) . '" title="' . esc_attr__( 'Read more', 'super-rss-reader' ) . '"' . $new_tab . $no_follow . ' class="srr-read-more">' . esc_html( $read_more ) . '</a>' : '';
209 223 $desc = $desc . $read_more_link;
210 224 }
211 225
212 226 }
@@ -212,12 +226,14 @@
212 226 }
213 227 }
214 228
215 229 // Author
216 - $author = $item->get_author();
217 - if ( is_object( $author ) ) {
218 - $author = $author->get_name();
219 - $author = esc_html( strip_tags( $author ) );
230 + $author = '';
231 + if( $show_author ){
232 + $author = $item->get_author();
233 + if ( is_object( $author ) ) {
234 + $author = strip_tags( $author->get_name() );
235 + }
220 236 }
221 237
222 238 $t_title = '';
223 239 $t_meta = '';
@@ -223,19 +239,19 @@
223 239 $t_meta = '';
224 240 $t_thumb = '';
225 241 $t_desc = '';
226 242
227 - $t_title .= '<div class="srr-title"><a href="' . $link . '"' . $new_tab . $no_follow . ' title="' . $title_full . '">' . $title . '</a></div>';
243 + $t_title .= '<div class="srr-title"><a href="' . esc_url( $link ) . '"' . $new_tab . $no_follow . ' title="' . esc_attr( $title_full ) . '">' . esc_html( $title ) . '</a></div>';
228 244
229 245 // Metadata
230 246 if( $show_date || $show_author ){
231 247 $t_meta .= '<div class="srr-meta">';
232 248 if( $show_date && !empty( $date ) ){
233 - $t_meta .= '<time class="srr-date" title="' . $date_full . ' UTC">' . $date . '</time>';
249 + $t_meta .= '<time class="srr-date" title="' . esc_attr( $date_full ) . ' UTC">' . esc_html( $date ) . '</time>';
234 250 }
235 251
236 252 if( $show_author && !empty( $author ) ){
237 - $t_meta .= ' - <cite class="srr-author">' . $author . '</cite>';
253 + $t_meta .= ' - <cite class="srr-author">' . esc_html( $author ) . '</cite>';
238 254 }
239 255 $t_meta .= '</div>'; // End meta
240 256 }
241 257
@@ -300,9 +316,9 @@
300 316 }
301 317
302 318 function process_items( $items, $count, $order_by ){
303 319
304 - if( count( $items ) == 0 || $order_by == 'default' ){
320 + if( count( $items ) == 0 ){
305 321 return $items;
306 322 }
307 323
308 324 // For shuffle order - Shuffle first and then slice as per count