FEEDZY RSS Feeds Lite - Version 1.5.1

Version Description

Download this release

Release Info

Developer briKou
Plugin Icon 128x128 FEEDZY RSS Feeds Lite
Version 1.5.1
Comparing to
See all releases

Code changes from version 1.5 to 1.5.1

Files changed (3) hide show
  1. feedzy-rss-feed.php +215 -93
  2. feedzy-rss-feeds.php +0 -336
  3. readme.txt +2 -2
feedzy-rss-feed.php CHANGED
@@ -3,19 +3,30 @@
3
  * Plugin Name: FEEDZY RSS Feeds by b*web
4
  * Plugin URI: http://b-website.com/feedzy-rss-feeds-plugin-wordpress-gratuit-utilisant-simplepie
5
  * Description: FEEDZY RSS Feeds is a small and lightweight plugin. Fast and easy to use, it aggregates RSS feeds into your WordPress site through simple shortcodes.
6
- * Author: Brice CAPOBIANCO - b*web
7
  * Author URI: http://b-website.com/
8
- * Version: 1.01
9
  * Text Domain: feedzy_rss_translate
10
  */
11
 
12
 
13
- // Exit if accessed directly
14
- if ( ! defined( 'ABSPATH' ) ) {
 
 
 
 
 
 
 
 
15
  exit;
16
  }
17
 
18
- //Load plugin textdomain
 
 
 
19
  if (!function_exists('feedzy_rss_load_textdomain')) {
20
  function feedzy_rss_load_textdomain() {
21
  $path = dirname(plugin_basename( __FILE__ )) . '/langs/';
@@ -24,22 +35,35 @@ if (!function_exists('feedzy_rss_load_textdomain')) {
24
  add_action('init', 'feedzy_rss_load_textdomain');
25
  }
26
 
27
- //Enqueue custom CSS
28
- if (!function_exists('feedzy_rss_enqueue_custom_style')) {
29
- function feedzy_rss_enqueue_custom_style() {
30
- global $post;
31
- if(function_exists('has_shortcode')) {
32
- if(isset($post->post_content) AND has_shortcode( $post->post_content, 'feedzy-rss')) {
33
- wp_enqueue_style( 'feedzy_rss_CSS', plugins_url('/feedzy-rss-style.css', __FILE__ ), NULL, NULL);
34
- }
35
- }
36
- }
37
- add_action( 'wp_enqueue_scripts', 'feedzy_rss_enqueue_custom_style');
 
 
 
 
 
 
 
 
38
  }
 
 
 
39
 
40
- //This function will get an image from the feed
41
- if (!function_exists('returnImage')) {
42
- function returnImage ($text) {
 
 
43
  $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
44
  $pattern = "/<img[^>]+\>/i";
45
  preg_match($pattern, $text, $matches);
@@ -48,9 +72,12 @@ if (!function_exists('returnImage')) {
48
  }
49
  }
50
 
51
- //This function will filter out image url which we got from previous returnImage() function
52
- if (!function_exists('scrapeImage')) {
53
- function scrapeImage($text) {
 
 
 
54
  $pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/';
55
  preg_match($pattern, $text, $link);
56
  $link = $link[1];
@@ -59,36 +86,69 @@ if (!function_exists('scrapeImage')) {
59
  }
60
  }
61
 
62
- //Main shortcode function
 
 
 
63
  if (!function_exists('feedzy_rss')) {
64
  function feedzy_rss( $atts, $content="" ) {
 
 
 
65
  //Retrieve & extract shorcode parameters
66
  extract(shortcode_atts(array(
67
  "feeds" => '', //comma separated feeds url
68
- "max" => '5', //number of feeds items
69
- "feed_title" => 'yes', //display feed title true/false
70
  "target" => '_blank', //_blank, _self
71
  "title" => '', //strip title after X char
72
  "meta" => 'yes', //yes, no
73
  "summary" => 'yes', //strip title
74
  "summarylength" => '', //strip summary after X char
75
  "thumb" => 'yes', //yes, no
76
- "size" => '150' //thumbs pixel size
 
 
77
  ), $atts));
78
  $count = 0;
79
 
80
- if(!is_numeric($size))
 
 
 
 
 
 
81
  $size = '150';
82
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83
  if (!class_exists('SimplePie'))
84
  require_once(ABSPATH . WPINC . '/class-feed.php');
85
 
86
  if (!empty ($feeds)) {
 
87
  $feedURL = explode(',',$feeds);
88
  $feedURL = array_splice($feedURL, 0, 3);
89
  if (count($feedURL) === 1) {
90
  $feedURL = $feedURL[0];
91
  };
 
92
  }
93
 
94
  //Process SimplePie
@@ -106,91 +166,148 @@ if (!function_exists('feedzy_rss')) {
106
  $feed->handle_content_type();
107
 
108
  if ($feed->error()) {
 
109
  $content .= '<div id="message" class="error"><p>'. __( 'Sorry, this feed is currently unavailable or does not exists anymore.', 'feedzy_rss_translate' ) .'</p></div>';
 
110
  }
111
 
112
  $content .= '<div class="feedzy-rss">';
113
 
114
  if($feed_title == 'yes'){
 
115
  $content .= '<div class="rss_header">';
116
  $content .= '<h2><a href="'. $feed->get_permalink() .'">'. $feed->get_title() .'</a> <span> '. $feed->get_description() .'</span></h2>';
117
  $content .= '</div>';
 
118
  }
119
 
120
  //Loop through RSS feed
121
  foreach ($feed->get_items() as $item){
122
 
123
- if($count >= $max)
124
- break;
125
- $count++;
126
-
127
- //Fetch image thumbnail
128
- if($thumb == 'yes'){
129
- $thethumbnail = "";
130
- if ($enclosure = $item->get_enclosure()) {
131
- foreach ((array) $enclosure->get_link() as $thumbnail){
132
- $pattern= '/https?:\/\/.*\.(?:jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/iU';
133
- $imgsrc = $thumbnail;
134
- preg_match($pattern, $imgsrc, $matches);
135
- $thumbnail = $matches[0];
136
- if (!empty($thumbnail)){
137
- $thethumbnail = $thumbnail;
138
- break;
139
- }
140
  }
141
  }
142
- if(empty($thethumbnail)) {
143
- $feedDescription = $item->get_description();
144
- $image = returnImage($feedDescription);
145
- $thethumbnail = scrapeImage($image);
146
- }
147
- if(empty($thethumbnail)) {
148
- $feedDescription = $item->get_content();
149
- $image = returnImage($feedDescription);
150
- $thethumbnail = scrapeImage($image);
151
- }
152
  }
153
- //Build element DOM
154
- $content .= '<div class="rss_item">';
155
- if($thumb == 'yes'){
156
- if(!empty($thethumbnail)) {
157
- $content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
158
- $content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image:url('.$thethumbnail.');" alt="'.$item->get_title().'"></span/></a>';
159
- } else {
160
- $content .= '<span class="rss_image" style="width:'. $size .'px; height:'. $size .'px;" /></span>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
  }
162
- }
163
- $content .= '<span class="title"><a href="'. $item->get_permalink() .'" target="'. $target .'">';
164
- if(is_numeric($title) && strlen($item->get_title()) > $title){
165
- $content .= preg_replace('/\s+?(\S+)?$/', '', substr($item->get_title(), 0, $title)) .'...';
166
- } else {
167
- $content .= $item->get_title();
168
- }
169
- $content .= '</a></span>';
170
- $content .= '<div class="rss_content">';
171
- if($meta == 'yes'){
172
- $content .= '<small>'. __( 'Posted by', 'feedzy_rss_translate' ) .' ';
173
- if ($author = $item->get_author()) {
174
- $domain = parse_url($item->get_permalink());
175
- $content .= '<a href="http://'. $domain["host"]. '" target="'. $target .'" title="'.$domain["host"].'" >'. $author->get_name() .' </a>';
 
176
  }
177
- $content .= __( 'on', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('date_format')) .' '. __( 'at', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('time_format'));
178
- $content .= '</small>';
179
- }
180
- if($summary == 'yes'){
181
- $content .= '<p>';
182
- $description = trim(strip_tags($item->get_description()));
183
- $description = trim(chop($description,'[&hellip;]'));
184
- if(is_numeric($summarylength) && strlen($description) > $summarylength){
185
- $content .= preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $summarylength)) .' […]';
186
  } else {
187
- $content .= $description .' […]';
 
 
188
  }
189
- $content .= '</p>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
190
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
191
  $content .= '</div>';
192
- $content .= '</div>';
193
 
 
 
194
  } //endforeach
195
 
196
  $content .= '</div>';
@@ -200,15 +317,20 @@ if (!function_exists('feedzy_rss')) {
200
  add_shortcode( 'feedzy-rss', 'feedzy_rss' );
201
  }
202
 
203
- //Insert cover picture to main rss feed
204
- if (!function_exists('insertThumbnailRSS')) {
205
- function insertThumbnailRSS($content) {
 
 
 
206
  global $post;
 
207
  if ( has_post_thumbnail( $post->ID ) ){
208
  $content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
209
  }
 
210
  return $content;
211
  }
212
- add_filter('the_excerpt_rss', 'insertThumbnailRSS');
213
- add_filter('the_content_feed', 'insertThumbnailRSS');
214
  }
3
  * Plugin Name: FEEDZY RSS Feeds by b*web
4
  * Plugin URI: http://b-website.com/feedzy-rss-feeds-plugin-wordpress-gratuit-utilisant-simplepie
5
  * Description: FEEDZY RSS Feeds is a small and lightweight plugin. Fast and easy to use, it aggregates RSS feeds into your WordPress site through simple shortcodes.
6
+ * Author: Brice CAPOBIANCO
7
  * Author URI: http://b-website.com/
8
+ * Version: 1.5.1
9
  * Text Domain: feedzy_rss_translate
10
  */
11
 
12
 
13
+ /***************************************************************
14
+ * SECURITY : Exit if accessed directly
15
+ ***************************************************************/
16
+ if ( !function_exists('add_action') ) {
17
+ header('Status: 403 Forbidden');
18
+ header('HTTP/1.1 403 Forbidden');
19
+ exit();
20
+ }
21
+
22
+ if ( !defined('ABSPATH') ) {
23
  exit;
24
  }
25
 
26
+
27
+ /***************************************************************
28
+ * Load plugin textdomain
29
+ ***************************************************************/
30
  if (!function_exists('feedzy_rss_load_textdomain')) {
31
  function feedzy_rss_load_textdomain() {
32
  $path = dirname(plugin_basename( __FILE__ )) . '/langs/';
35
  add_action('init', 'feedzy_rss_load_textdomain');
36
  }
37
 
38
+
39
+ /***************************************************************
40
+ * Load plugin files
41
+ ***************************************************************/
42
+ require_once( plugin_dir_path( __FILE__ ) . '/feedzy-rss-feeds-ui.php' );
43
+
44
+
45
+ /***************************************************************
46
+ * Enqueue custom CSS
47
+ ***************************************************************/
48
+ function feedzy_register_custom_style() {
49
+ wp_register_style( 'feedzy-style', plugins_url('css/feedzy-rss-feeds.css', __FILE__ ), NULL, NULL);
50
+ }
51
+ function feedzy_print_custom_style() {
52
+ global $feedzyStyle;
53
+ if ( ! $feedzyStyle )
54
+ return;
55
+
56
+ wp_print_styles('feedzy-style');
57
  }
58
+ add_action('init', 'feedzy_register_custom_style');
59
+ add_action('wp_footer', 'feedzy_print_custom_style');
60
+
61
 
62
+ /***************************************************************
63
+ * Get an image from the feed
64
+ ***************************************************************/
65
+ if (!function_exists('feedzy_returnImage')) {
66
+ function feedzy_returnImage ($text) {
67
  $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
68
  $pattern = "/<img[^>]+\>/i";
69
  preg_match($pattern, $text, $matches);
72
  }
73
  }
74
 
75
+
76
+ /***************************************************************
77
+ * Filter out image url which we got from previous returnImage() function
78
+ ***************************************************************/
79
+ if (!function_exists('feedzy_scrapeImage')) {
80
+ function feedzy_scrapeImage($text) {
81
  $pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/';
82
  preg_match($pattern, $text, $link);
83
  $link = $link[1];
86
  }
87
  }
88
 
89
+
90
+ /***************************************************************
91
+ * Main shortcode function
92
+ ***************************************************************/
93
  if (!function_exists('feedzy_rss')) {
94
  function feedzy_rss( $atts, $content="" ) {
95
+
96
+ global $feedzyStyle;
97
+ $feedzyStyle = true;
98
  //Retrieve & extract shorcode parameters
99
  extract(shortcode_atts(array(
100
  "feeds" => '', //comma separated feeds url
101
+ "max" => '5', //number of feeds items (0 for unlimited)
102
+ "feed_title" => 'yes', //display feed title yes/no
103
  "target" => '_blank', //_blank, _self
104
  "title" => '', //strip title after X char
105
  "meta" => 'yes', //yes, no
106
  "summary" => 'yes', //strip title
107
  "summarylength" => '', //strip summary after X char
108
  "thumb" => 'yes', //yes, no
109
+ "default" => '', //default thumb URL if no image found (only if thumb is set to yes)
110
+ "size" => '', //thumbs pixel size
111
+ "keywords_title" => '' //only display item if title contains specific keywords (comma-separated list/case sensitive)
112
  ), $atts));
113
  $count = 0;
114
 
115
+ if($max == '0'){
116
+ $max = '999';
117
+ } else if(empty($max) || !ctype_digit($max)) {
118
+ $max = '5';
119
+ }
120
+
121
+ if(empty($size) || !ctype_digit($size))
122
  $size = '150';
123
 
124
+ if(!empty($title) && !ctype_digit($title))
125
+ $title = '';
126
+
127
+ if(!empty($keywords_title))
128
+ $keywords_title = array_map('trim', explode(',', $keywords_title));
129
+
130
+ if(!empty($summarylength) && !ctype_digit($summarylength))
131
+ $summarylength = '';
132
+
133
+ if(!empty($default)){
134
+ $default = $default;
135
+ } else {
136
+ $default = plugins_url('img/feedzy-default.jpg', __FILE__ );
137
+ }
138
+
139
+
140
+
141
  if (!class_exists('SimplePie'))
142
  require_once(ABSPATH . WPINC . '/class-feed.php');
143
 
144
  if (!empty ($feeds)) {
145
+
146
  $feedURL = explode(',',$feeds);
147
  $feedURL = array_splice($feedURL, 0, 3);
148
  if (count($feedURL) === 1) {
149
  $feedURL = $feedURL[0];
150
  };
151
+
152
  }
153
 
154
  //Process SimplePie
166
  $feed->handle_content_type();
167
 
168
  if ($feed->error()) {
169
+
170
  $content .= '<div id="message" class="error"><p>'. __( 'Sorry, this feed is currently unavailable or does not exists anymore.', 'feedzy_rss_translate' ) .'</p></div>';
171
+
172
  }
173
 
174
  $content .= '<div class="feedzy-rss">';
175
 
176
  if($feed_title == 'yes'){
177
+
178
  $content .= '<div class="rss_header">';
179
  $content .= '<h2><a href="'. $feed->get_permalink() .'">'. $feed->get_title() .'</a> <span> '. $feed->get_description() .'</span></h2>';
180
  $content .= '</div>';
181
+
182
  }
183
 
184
  //Loop through RSS feed
185
  foreach ($feed->get_items() as $item){
186
 
187
+ $continue = true;
188
+ //Check if keywords are in title
189
+ if(!empty($keywords_title)){
190
+ $continue = false;
191
+ foreach($keywords_title as $keyword){
192
+ if (strpos($item->get_title(), $keyword) !== false) {
193
+ $continue = true;
 
 
 
 
 
 
 
 
 
 
194
  }
195
  }
196
+
 
 
 
 
 
 
 
 
 
197
  }
198
+
199
+ if($continue == true){
200
+
201
+ //Count items
202
+ if($count >= $max)
203
+ break;
204
+ $count++;
205
+
206
+ //Fetch image thumbnail
207
+ if($thumb == 'yes'){
208
+ $thethumbnail = "";
209
+
210
+ if ($enclosure = $item->get_enclosure()) {
211
+ foreach ((array) $enclosure->get_link() as $thumbnail){
212
+
213
+ $pattern= '/https?:\/\/.*\.(?:jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/iU';
214
+ $imgsrc = $thumbnail;
215
+ preg_match($pattern, $imgsrc, $matches);
216
+ $thumbnail = $matches[0];
217
+
218
+ if (!empty($thumbnail)){
219
+
220
+ $thethumbnail = $thumbnail;
221
+ break;
222
+
223
+ }
224
+
225
+ }
226
+ }
227
+
228
+ if(empty($thethumbnail)) {
229
+
230
+ $feedDescription = $item->get_description();
231
+ $image = feedzy_returnImage($feedDescription);
232
+ $thethumbnail = feedzy_scrapeImage($image);
233
+
234
+ }
235
+
236
+ if(empty($thethumbnail)) {
237
+
238
+ $feedDescription = $item->get_content();
239
+ $image = feedzy_returnImage($feedDescription);
240
+ $thethumbnail = feedzy_scrapeImage($image);
241
+
242
+ }
243
  }
244
+
245
+ //Build element DOM
246
+ $content .= '<div class="rss_item">';
247
+ if($thumb == 'yes'){
248
+ if(!empty($thethumbnail)){
249
+
250
+ $content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
251
+ $content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image: none, url('.$thethumbnail.'), url('.$default.');" alt="'.$item->get_title().'"></span/></a>';
252
+
253
+ } else if(empty($thethumbnail)){
254
+
255
+ $content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
256
+ $content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image:url('.$default.');" alt="'.$item->get_title().'"></span/></a>';
257
+
258
+ }
259
  }
260
+ $content .= '<span class="title"><a href="'. $item->get_permalink() .'" target="'. $target .'">';
261
+ if(is_numeric($title) && strlen($item->get_title()) > $title){
262
+
263
+ $content .= preg_replace('/\s+?(\S+)?$/', '', substr($item->get_title(), 0, $title)) .'...';
264
+
 
 
 
 
265
  } else {
266
+
267
+ $content .= $item->get_title();
268
+
269
  }
270
+ $content .= '</a></span>';
271
+ $content .= '<div class="rss_content">';
272
+ if($meta == 'yes'){
273
+
274
+ $content .= '<small>'. __( 'Posted by', 'feedzy_rss_translate' ) .' ';
275
+
276
+ if ($author = $item->get_author()) {
277
+
278
+ $domain = parse_url($item->get_permalink());
279
+ $content .= '<a href="http://'. $domain["host"]. '" target="'. $target .'" title="'.$domain["host"].'" >'. $author->get_name() .' </a>';
280
+
281
+ }
282
+
283
+ $content .= __( 'on', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('date_format')) .' '. __( 'at', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('time_format'));
284
+ $content .= '</small>';
285
+
286
  }
287
+ if($summary == 'yes'){
288
+
289
+ $content .= '<p>';
290
+ $description = trim(strip_tags($item->get_description()));
291
+ $description = trim(chop($description,'[&hellip;]'));
292
+
293
+ if(is_numeric($summarylength) && strlen($description) > $summarylength){
294
+
295
+ $content .= preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $summarylength)) .' […]';
296
+
297
+ } else {
298
+
299
+ $content .= $description .' […]';
300
+
301
+ }
302
+
303
+ $content .= '</p>';
304
+
305
+ }
306
+ $content .= '</div>';
307
  $content .= '</div>';
 
308
 
309
+ } //endContinue
310
+
311
  } //endforeach
312
 
313
  $content .= '</div>';
317
  add_shortcode( 'feedzy-rss', 'feedzy_rss' );
318
  }
319
 
320
+
321
+ /***************************************************************
322
+ * Insert cover picture to main rss feed
323
+ ***************************************************************/
324
+ if (!function_exists('feedzy_insert_thumbnail_RSS')) {
325
+ function feedzy_insert_thumbnail_RSS($content) {
326
  global $post;
327
+
328
  if ( has_post_thumbnail( $post->ID ) ){
329
  $content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
330
  }
331
+
332
  return $content;
333
  }
334
+ add_filter('the_excerpt_rss', 'feedzy_insert_thumbnail_RSS');
335
+ add_filter('the_content_feed', 'feedzy_insert_thumbnail_RSS');
336
  }
feedzy-rss-feeds.php DELETED
@@ -1,336 +0,0 @@
1
- <?php
2
- /**
3
- * Plugin Name: FEEDZY RSS Feeds by b*web
4
- * Plugin URI: http://b-website.com/feedzy-rss-feeds-plugin-wordpress-gratuit-utilisant-simplepie
5
- * Description: FEEDZY RSS Feeds is a small and lightweight plugin. Fast and easy to use, it aggregates RSS feeds into your WordPress site through simple shortcodes.
6
- * Author: Brice CAPOBIANCO
7
- * Author URI: http://b-website.com/
8
- * Version: 1.5
9
- * Text Domain: feedzy_rss_translate
10
- */
11
-
12
-
13
- /***************************************************************
14
- * SECURITY : Exit if accessed directly
15
- ***************************************************************/
16
- if ( !function_exists('add_action') ) {
17
- header('Status: 403 Forbidden');
18
- header('HTTP/1.1 403 Forbidden');
19
- exit();
20
- }
21
-
22
- if ( !defined('ABSPATH') ) {
23
- exit;
24
- }
25
-
26
-
27
- /***************************************************************
28
- * Load plugin textdomain
29
- ***************************************************************/
30
- if (!function_exists('feedzy_rss_load_textdomain')) {
31
- function feedzy_rss_load_textdomain() {
32
- $path = dirname(plugin_basename( __FILE__ )) . '/langs/';
33
- $loaded = load_plugin_textdomain( 'feedzy_rss_translate', false, $path);
34
- }
35
- add_action('init', 'feedzy_rss_load_textdomain');
36
- }
37
-
38
-
39
- /***************************************************************
40
- * Load plugin files
41
- ***************************************************************/
42
- require_once( plugin_dir_path( __FILE__ ) . '/feedzy-rss-feeds-ui.php' );
43
-
44
-
45
- /***************************************************************
46
- * Enqueue custom CSS
47
- ***************************************************************/
48
- function feedzy_register_custom_style() {
49
- wp_register_style( 'feedzy-style', plugins_url('css/feedzy-rss-feeds.css', __FILE__ ), NULL, NULL);
50
- }
51
- function feedzy_print_custom_style() {
52
- global $feedzyStyle;
53
- if ( ! $feedzyStyle )
54
- return;
55
-
56
- wp_print_styles('feedzy-style');
57
- }
58
- add_action('init', 'feedzy_register_custom_style');
59
- add_action('wp_footer', 'feedzy_print_custom_style');
60
-
61
-
62
- /***************************************************************
63
- * Get an image from the feed
64
- ***************************************************************/
65
- if (!function_exists('feedzy_returnImage')) {
66
- function feedzy_returnImage ($text) {
67
- $text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
68
- $pattern = "/<img[^>]+\>/i";
69
- preg_match($pattern, $text, $matches);
70
- $text = $matches[0];
71
- return $text;
72
- }
73
- }
74
-
75
-
76
- /***************************************************************
77
- * Filter out image url which we got from previous returnImage() function
78
- ***************************************************************/
79
- if (!function_exists('feedzy_scrapeImage')) {
80
- function feedzy_scrapeImage($text) {
81
- $pattern = '/src=[\'"]?([^\'" >]+)[\'" >]/';
82
- preg_match($pattern, $text, $link);
83
- $link = $link[1];
84
- $link = urldecode($link);
85
- return $link;
86
- }
87
- }
88
-
89
-
90
- /***************************************************************
91
- * Main shortcode function
92
- ***************************************************************/
93
- if (!function_exists('feedzy_rss')) {
94
- function feedzy_rss( $atts, $content="" ) {
95
-
96
- global $feedzyStyle;
97
- $feedzyStyle = true;
98
- //Retrieve & extract shorcode parameters
99
- extract(shortcode_atts(array(
100
- "feeds" => '', //comma separated feeds url
101
- "max" => '5', //number of feeds items (0 for unlimited)
102
- "feed_title" => 'yes', //display feed title yes/no
103
- "target" => '_blank', //_blank, _self
104
- "title" => '', //strip title after X char
105
- "meta" => 'yes', //yes, no
106
- "summary" => 'yes', //strip title
107
- "summarylength" => '', //strip summary after X char
108
- "thumb" => 'yes', //yes, no
109
- "default" => '', //default thumb URL if no image found (only if thumb is set to yes)
110
- "size" => '', //thumbs pixel size
111
- "keywords_title" => '' //only display item if title contains specific keywords (comma-separated list/case sensitive)
112
- ), $atts));
113
- $count = 0;
114
-
115
- if($max == '0'){
116
- $max = '999';
117
- } else if(empty($max) || !ctype_digit($max)) {
118
- $max = '5';
119
- }
120
-
121
- if(empty($size) || !ctype_digit($size))
122
- $size = '150';
123
-
124
- if(!empty($title) && !ctype_digit($title))
125
- $title = '';
126
-
127
- if(!empty($keywords_title))
128
- $keywords_title = array_map('trim', explode(',', $keywords_title));
129
-
130
- if(!empty($summarylength) && !ctype_digit($summarylength))
131
- $summarylength = '';
132
-
133
- if(!empty($default)){
134
- $default = $default;
135
- } else {
136
- $default = plugins_url('img/feedzy-default.jpg', __FILE__ );
137
- }
138
-
139
-
140
-
141
- if (!class_exists('SimplePie'))
142
- require_once(ABSPATH . WPINC . '/class-feed.php');
143
-
144
- if (!empty ($feeds)) {
145
-
146
- $feedURL = explode(',',$feeds);
147
- $feedURL = array_splice($feedURL, 0, 3);
148
- if (count($feedURL) === 1) {
149
- $feedURL = $feedURL[0];
150
- };
151
-
152
- }
153
-
154
- //Process SimplePie
155
- $feed = new SimplePie();
156
- $feed->set_feed_url($feedURL);
157
- $feed->enable_cache(true);
158
- $feed->enable_order_by_date(true);
159
- $feed->set_cache_class( 'WP_Feed_Cache' );
160
- $feed->set_file_class( 'WP_SimplePie_File' );
161
- $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 7200, $feedURL ) );
162
- do_action_ref_array( 'wp_feed_options', array( $feed, $feedURL ) );
163
- $feed->strip_comments(true);
164
- $feed->strip_htmltags(false);
165
- $feed->init();
166
- $feed->handle_content_type();
167
-
168
- if ($feed->error()) {
169
-
170
- $content .= '<div id="message" class="error"><p>'. __( 'Sorry, this feed is currently unavailable or does not exists anymore.', 'feedzy_rss_translate' ) .'</p></div>';
171
-
172
- }
173
-
174
- $content .= '<div class="feedzy-rss">';
175
-
176
- if($feed_title == 'yes'){
177
-
178
- $content .= '<div class="rss_header">';
179
- $content .= '<h2><a href="'. $feed->get_permalink() .'">'. $feed->get_title() .'</a> <span> '. $feed->get_description() .'</span></h2>';
180
- $content .= '</div>';
181
-
182
- }
183
-
184
- //Loop through RSS feed
185
- foreach ($feed->get_items() as $item){
186
-
187
- $continue = true;
188
- //Check if keywords are in title
189
- if(!empty($keywords_title)){
190
- $continue = false;
191
- foreach($keywords_title as $keyword){
192
- if (strpos($item->get_title(), $keyword) !== false) {
193
- $continue = true;
194
- }
195
- }
196
-
197
- }
198
-
199
- if($continue == true){
200
-
201
- //Count items
202
- if($count >= $max)
203
- break;
204
- $count++;
205
-
206
- //Fetch image thumbnail
207
- if($thumb == 'yes'){
208
- $thethumbnail = "";
209
-
210
- if ($enclosure = $item->get_enclosure()) {
211
- foreach ((array) $enclosure->get_link() as $thumbnail){
212
-
213
- $pattern= '/https?:\/\/.*\.(?:jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/iU';
214
- $imgsrc = $thumbnail;
215
- preg_match($pattern, $imgsrc, $matches);
216
- $thumbnail = $matches[0];
217
-
218
- if (!empty($thumbnail)){
219
-
220
- $thethumbnail = $thumbnail;
221
- break;
222
-
223
- }
224
-
225
- }
226
- }
227
-
228
- if(empty($thethumbnail)) {
229
-
230
- $feedDescription = $item->get_description();
231
- $image = feedzy_returnImage($feedDescription);
232
- $thethumbnail = feedzy_scrapeImage($image);
233
-
234
- }
235
-
236
- if(empty($thethumbnail)) {
237
-
238
- $feedDescription = $item->get_content();
239
- $image = feedzy_returnImage($feedDescription);
240
- $thethumbnail = feedzy_scrapeImage($image);
241
-
242
- }
243
- }
244
-
245
- //Build element DOM
246
- $content .= '<div class="rss_item">';
247
- if($thumb == 'yes'){
248
- if(!empty($thethumbnail)){
249
-
250
- $content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
251
- $content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image: none, url('.$thethumbnail.'), url('.$default.');" alt="'.$item->get_title().'"></span/></a>';
252
-
253
- } else if(empty($thethumbnail)){
254
-
255
- $content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
256
- $content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image:url('.$default.');" alt="'.$item->get_title().'"></span/></a>';
257
-
258
- }
259
- }
260
- $content .= '<span class="title"><a href="'. $item->get_permalink() .'" target="'. $target .'">';
261
- if(is_numeric($title) && strlen($item->get_title()) > $title){
262
-
263
- $content .= preg_replace('/\s+?(\S+)?$/', '', substr($item->get_title(), 0, $title)) .'...';
264
-
265
- } else {
266
-
267
- $content .= $item->get_title();
268
-
269
- }
270
- $content .= '</a></span>';
271
- $content .= '<div class="rss_content">';
272
- if($meta == 'yes'){
273
-
274
- $content .= '<small>'. __( 'Posted by', 'feedzy_rss_translate' ) .' ';
275
-
276
- if ($author = $item->get_author()) {
277
-
278
- $domain = parse_url($item->get_permalink());
279
- $content .= '<a href="http://'. $domain["host"]. '" target="'. $target .'" title="'.$domain["host"].'" >'. $author->get_name() .' </a>';
280
-
281
- }
282
-
283
- $content .= __( 'on', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('date_format')) .' '. __( 'at', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('time_format'));
284
- $content .= '</small>';
285
-
286
- }
287
- if($summary == 'yes'){
288
-
289
- $content .= '<p>';
290
- $description = trim(strip_tags($item->get_description()));
291
- $description = trim(chop($description,'[&hellip;]'));
292
-
293
- if(is_numeric($summarylength) && strlen($description) > $summarylength){
294
-
295
- $content .= preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $summarylength)) .' […]';
296
-
297
- } else {
298
-
299
- $content .= $description .' […]';
300
-
301
- }
302
-
303
- $content .= '</p>';
304
-
305
- }
306
- $content .= '</div>';
307
- $content .= '</div>';
308
-
309
- } //endContinue
310
-
311
- } //endforeach
312
-
313
- $content .= '</div>';
314
- return $content;
315
-
316
- } //end of feedzy_rss
317
- add_shortcode( 'feedzy-rss', 'feedzy_rss' );
318
- }
319
-
320
-
321
- /***************************************************************
322
- * Insert cover picture to main rss feed
323
- ***************************************************************/
324
- if (!function_exists('feedzy_insert_thumbnail_RSS')) {
325
- function feedzy_insert_thumbnail_RSS($content) {
326
- global $post;
327
-
328
- if ( has_post_thumbnail( $post->ID ) ){
329
- $content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
330
- }
331
-
332
- return $content;
333
- }
334
- add_filter('the_excerpt_rss', 'feedzy_insert_thumbnail_RSS');
335
- add_filter('the_content_feed', 'feedzy_insert_thumbnail_RSS');
336
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: RSS, SimplePie, shortcode, feed, thumbnail, image, rss feeds, aggregator
5
  Requires at least: 3.7
6
  Tested up to: 4.0
7
- Stable tag: 1.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -59,7 +59,7 @@ Plugin is now using the TinyMCE API to improve UI and makes it easy to insert sh
59
 
60
 
61
 
62
- [FULL DOCUMENTAION AND EXAMPLES](http://b-website.com/feedzy-rss-feeds-wordpress-plugin-using-simplepie "Documentation & examples")
63
 
64
 
65
 
4
  Tags: RSS, SimplePie, shortcode, feed, thumbnail, image, rss feeds, aggregator
5
  Requires at least: 3.7
6
  Tested up to: 4.0
7
+ Stable tag: 1.5.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
59
 
60
 
61
 
62
+ [FULL DOCUMENTATION AND EXAMPLES](http://b-website.com/feedzy-rss-feeds-wordpress-plugin-using-simplepie "Documentation & examples")
63
 
64
 
65