Version Description
- Add "default" parameter to fill image container if no image is fetch or if it is offline
- Add more control over numeric format in max, size, title & summarylength parameters
Download this release
Release Info
Developer | briKou |
Plugin | FEEDZY RSS Feeds Lite |
Version | 1.4 |
Comparing to | |
See all releases |
Code changes from version 1.03 to 1.4
- feedzy-rss-feed.php +77 -14
- feedzy-rss-style.css +0 -1
- readme.txt +13 -2
feedzy-rss-feed.php
CHANGED
@@ -5,7 +5,7 @@
|
|
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.
|
9 |
* Text Domain: feedzy_rss_translate
|
10 |
*/
|
11 |
|
@@ -28,17 +28,17 @@ if (!function_exists('feedzy_rss_load_textdomain')) {
|
|
28 |
|
29 |
//Enqueue custom CSS
|
30 |
function register_feedzy_custom_style() {
|
31 |
-
wp_register_style( 'feedzy-
|
32 |
}
|
33 |
function print_feedzy_custom_style() {
|
34 |
-
global $
|
35 |
-
if ( ! $
|
36 |
return;
|
37 |
|
38 |
-
wp_print_styles('feedzy-
|
39 |
}
|
40 |
-
add_action('wp_footer', 'print_feedzy_custom_style');
|
41 |
add_action('init', 'register_feedzy_custom_style');
|
|
|
42 |
|
43 |
|
44 |
//This function will get an image from the feed
|
@@ -69,13 +69,13 @@ if (!function_exists('scrapeImage')) {
|
|
69 |
if (!function_exists('feedzy_rss')) {
|
70 |
function feedzy_rss( $atts, $content="" ) {
|
71 |
|
72 |
-
global $
|
73 |
-
$
|
74 |
|
75 |
//Retrieve & extract shorcode parameters
|
76 |
extract(shortcode_atts(array(
|
77 |
"feeds" => '', //comma separated feeds url
|
78 |
-
"max" => '
|
79 |
"feed_title" => 'yes', //display feed title true/false
|
80 |
"target" => '_blank', //_blank, _self
|
81 |
"title" => '', //strip title after X char
|
@@ -83,22 +83,34 @@ if (!function_exists('feedzy_rss')) {
|
|
83 |
"summary" => 'yes', //strip title
|
84 |
"summarylength" => '', //strip summary after X char
|
85 |
"thumb" => 'yes', //yes, no
|
86 |
-
"
|
|
|
87 |
), $atts));
|
88 |
$count = 0;
|
89 |
|
90 |
-
if(!
|
|
|
|
|
|
|
91 |
$size = '150';
|
92 |
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
if (!class_exists('SimplePie'))
|
94 |
require_once(ABSPATH . WPINC . '/class-feed.php');
|
95 |
|
96 |
if (!empty ($feeds)) {
|
|
|
97 |
$feedURL = explode(',',$feeds);
|
98 |
$feedURL = array_splice($feedURL, 0, 3);
|
99 |
if (count($feedURL) === 1) {
|
100 |
$feedURL = $feedURL[0];
|
101 |
};
|
|
|
102 |
}
|
103 |
|
104 |
//Process SimplePie
|
@@ -116,15 +128,19 @@ if (!function_exists('feedzy_rss')) {
|
|
116 |
$feed->handle_content_type();
|
117 |
|
118 |
if ($feed->error()) {
|
|
|
119 |
$content .= '<div id="message" class="error"><p>'. __( 'Sorry, this feed is currently unavailable or does not exists anymore.', 'feedzy_rss_translate' ) .'</p></div>';
|
|
|
120 |
}
|
121 |
|
122 |
$content .= '<div class="feedzy-rss">';
|
123 |
|
124 |
if($feed_title == 'yes'){
|
|
|
125 |
$content .= '<div class="rss_header">';
|
126 |
$content .= '<h2><a href="'. $feed->get_permalink() .'">'. $feed->get_title() .'</a> <span> '. $feed->get_description() .'</span></h2>';
|
127 |
$content .= '</div>';
|
|
|
128 |
}
|
129 |
|
130 |
//Loop through RSS feed
|
@@ -137,66 +153,111 @@ if (!function_exists('feedzy_rss')) {
|
|
137 |
//Fetch image thumbnail
|
138 |
if($thumb == 'yes'){
|
139 |
$thethumbnail = "";
|
|
|
140 |
if ($enclosure = $item->get_enclosure()) {
|
141 |
foreach ((array) $enclosure->get_link() as $thumbnail){
|
|
|
142 |
$pattern= '/https?:\/\/.*\.(?:jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/iU';
|
143 |
$imgsrc = $thumbnail;
|
144 |
preg_match($pattern, $imgsrc, $matches);
|
145 |
$thumbnail = $matches[0];
|
|
|
146 |
if (!empty($thumbnail)){
|
|
|
147 |
$thethumbnail = $thumbnail;
|
148 |
break;
|
|
|
149 |
}
|
|
|
150 |
}
|
151 |
}
|
|
|
152 |
if(empty($thethumbnail)) {
|
|
|
153 |
$feedDescription = $item->get_description();
|
154 |
$image = returnImage($feedDescription);
|
155 |
$thethumbnail = scrapeImage($image);
|
|
|
156 |
}
|
|
|
157 |
if(empty($thethumbnail)) {
|
|
|
158 |
$feedDescription = $item->get_content();
|
159 |
$image = returnImage($feedDescription);
|
160 |
$thethumbnail = scrapeImage($image);
|
|
|
161 |
}
|
162 |
}
|
|
|
163 |
//Build element DOM
|
164 |
$content .= '<div class="rss_item">';
|
165 |
if($thumb == 'yes'){
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
167 |
$content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
|
168 |
$content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image:url('.$thethumbnail.');" alt="'.$item->get_title().'"></span/></a>';
|
|
|
|
|
|
|
|
|
|
|
|
|
169 |
} else {
|
|
|
170 |
$content .= '<span class="rss_image" style="width:'. $size .'px; height:'. $size .'px;" /></span>';
|
|
|
171 |
}
|
172 |
}
|
173 |
$content .= '<span class="title"><a href="'. $item->get_permalink() .'" target="'. $target .'">';
|
174 |
if(is_numeric($title) && strlen($item->get_title()) > $title){
|
|
|
175 |
$content .= preg_replace('/\s+?(\S+)?$/', '', substr($item->get_title(), 0, $title)) .'...';
|
|
|
176 |
} else {
|
|
|
177 |
$content .= $item->get_title();
|
|
|
178 |
}
|
179 |
$content .= '</a></span>';
|
180 |
$content .= '<div class="rss_content">';
|
181 |
if($meta == 'yes'){
|
|
|
182 |
$content .= '<small>'. __( 'Posted by', 'feedzy_rss_translate' ) .' ';
|
|
|
183 |
if ($author = $item->get_author()) {
|
|
|
184 |
$domain = parse_url($item->get_permalink());
|
185 |
$content .= '<a href="http://'. $domain["host"]. '" target="'. $target .'" title="'.$domain["host"].'" >'. $author->get_name() .' </a>';
|
|
|
186 |
}
|
|
|
187 |
$content .= __( 'on', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('date_format')) .' '. __( 'at', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('time_format'));
|
188 |
$content .= '</small>';
|
|
|
189 |
}
|
190 |
if($summary == 'yes'){
|
|
|
191 |
$content .= '<p>';
|
192 |
$description = trim(strip_tags($item->get_description()));
|
193 |
$description = trim(chop($description,'[…]'));
|
|
|
194 |
if(is_numeric($summarylength) && strlen($description) > $summarylength){
|
|
|
195 |
$content .= preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $summarylength)) .' […]';
|
|
|
196 |
} else {
|
197 |
-
|
|
|
|
|
198 |
}
|
199 |
-
|
|
|
|
|
200 |
}
|
201 |
$content .= '</div>';
|
202 |
$content .= '</div>';
|
@@ -215,9 +276,11 @@ if (!function_exists('feedzy_rss')) {
|
|
215 |
if (!function_exists('insertThumbnailRSS')) {
|
216 |
function insertThumbnailRSS($content) {
|
217 |
global $post;
|
|
|
218 |
if ( has_post_thumbnail( $post->ID ) ){
|
219 |
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
|
220 |
}
|
|
|
221 |
return $content;
|
222 |
}
|
223 |
add_filter('the_excerpt_rss', 'insertThumbnailRSS');
|
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.4
|
9 |
* Text Domain: feedzy_rss_translate
|
10 |
*/
|
11 |
|
28 |
|
29 |
//Enqueue custom CSS
|
30 |
function register_feedzy_custom_style() {
|
31 |
+
wp_register_style( 'feedzy-style', plugins_url('/feedzy-rss-style.css', __FILE__ ), NULL, NULL);
|
32 |
}
|
33 |
function print_feedzy_custom_style() {
|
34 |
+
global $feedzyStyle;
|
35 |
+
if ( ! $feedzyStyle )
|
36 |
return;
|
37 |
|
38 |
+
wp_print_styles('feedzy-style');
|
39 |
}
|
|
|
40 |
add_action('init', 'register_feedzy_custom_style');
|
41 |
+
add_action('wp_footer', 'print_feedzy_custom_style');
|
42 |
|
43 |
|
44 |
//This function will get an image from the feed
|
69 |
if (!function_exists('feedzy_rss')) {
|
70 |
function feedzy_rss( $atts, $content="" ) {
|
71 |
|
72 |
+
global $feedzyStyle;
|
73 |
+
$feedzyStyle = true;
|
74 |
|
75 |
//Retrieve & extract shorcode parameters
|
76 |
extract(shortcode_atts(array(
|
77 |
"feeds" => '', //comma separated feeds url
|
78 |
+
"max" => '', //number of feeds items
|
79 |
"feed_title" => 'yes', //display feed title true/false
|
80 |
"target" => '_blank', //_blank, _self
|
81 |
"title" => '', //strip title after X char
|
83 |
"summary" => 'yes', //strip title
|
84 |
"summarylength" => '', //strip summary after X char
|
85 |
"thumb" => 'yes', //yes, no
|
86 |
+
"default" => '', //default thumb if no image found (only if thumb is set to yes)
|
87 |
+
"size" => '' //thumbs pixel size
|
88 |
), $atts));
|
89 |
$count = 0;
|
90 |
|
91 |
+
if(empty($max) || !ctype_digit($max))
|
92 |
+
$max = '5';
|
93 |
+
|
94 |
+
if(empty($size) || !ctype_digit($size))
|
95 |
$size = '150';
|
96 |
|
97 |
+
if(!empty($title) && !ctype_digit($title))
|
98 |
+
$title = '';
|
99 |
+
|
100 |
+
if(!empty($summarylength) && !ctype_digit($summarylength))
|
101 |
+
$summarylength = '';
|
102 |
+
|
103 |
if (!class_exists('SimplePie'))
|
104 |
require_once(ABSPATH . WPINC . '/class-feed.php');
|
105 |
|
106 |
if (!empty ($feeds)) {
|
107 |
+
|
108 |
$feedURL = explode(',',$feeds);
|
109 |
$feedURL = array_splice($feedURL, 0, 3);
|
110 |
if (count($feedURL) === 1) {
|
111 |
$feedURL = $feedURL[0];
|
112 |
};
|
113 |
+
|
114 |
}
|
115 |
|
116 |
//Process SimplePie
|
128 |
$feed->handle_content_type();
|
129 |
|
130 |
if ($feed->error()) {
|
131 |
+
|
132 |
$content .= '<div id="message" class="error"><p>'. __( 'Sorry, this feed is currently unavailable or does not exists anymore.', 'feedzy_rss_translate' ) .'</p></div>';
|
133 |
+
|
134 |
}
|
135 |
|
136 |
$content .= '<div class="feedzy-rss">';
|
137 |
|
138 |
if($feed_title == 'yes'){
|
139 |
+
|
140 |
$content .= '<div class="rss_header">';
|
141 |
$content .= '<h2><a href="'. $feed->get_permalink() .'">'. $feed->get_title() .'</a> <span> '. $feed->get_description() .'</span></h2>';
|
142 |
$content .= '</div>';
|
143 |
+
|
144 |
}
|
145 |
|
146 |
//Loop through RSS feed
|
153 |
//Fetch image thumbnail
|
154 |
if($thumb == 'yes'){
|
155 |
$thethumbnail = "";
|
156 |
+
|
157 |
if ($enclosure = $item->get_enclosure()) {
|
158 |
foreach ((array) $enclosure->get_link() as $thumbnail){
|
159 |
+
|
160 |
$pattern= '/https?:\/\/.*\.(?:jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/iU';
|
161 |
$imgsrc = $thumbnail;
|
162 |
preg_match($pattern, $imgsrc, $matches);
|
163 |
$thumbnail = $matches[0];
|
164 |
+
|
165 |
if (!empty($thumbnail)){
|
166 |
+
|
167 |
$thethumbnail = $thumbnail;
|
168 |
break;
|
169 |
+
|
170 |
}
|
171 |
+
|
172 |
}
|
173 |
}
|
174 |
+
|
175 |
if(empty($thethumbnail)) {
|
176 |
+
|
177 |
$feedDescription = $item->get_description();
|
178 |
$image = returnImage($feedDescription);
|
179 |
$thethumbnail = scrapeImage($image);
|
180 |
+
|
181 |
}
|
182 |
+
|
183 |
if(empty($thethumbnail)) {
|
184 |
+
|
185 |
$feedDescription = $item->get_content();
|
186 |
$image = returnImage($feedDescription);
|
187 |
$thethumbnail = scrapeImage($image);
|
188 |
+
|
189 |
}
|
190 |
}
|
191 |
+
|
192 |
//Build element DOM
|
193 |
$content .= '<div class="rss_item">';
|
194 |
if($thumb == 'yes'){
|
195 |
+
if(!empty($thethumbnail) && !empty($default)){
|
196 |
+
|
197 |
+
$content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
|
198 |
+
$content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image: none, url('.$thethumbnail.'), url('.$default.');" alt="'.$item->get_title().'"></span/></a>';
|
199 |
+
|
200 |
+
} else if(!empty($thethumbnail)) {
|
201 |
+
|
202 |
$content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
|
203 |
$content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image:url('.$thethumbnail.');" alt="'.$item->get_title().'"></span/></a>';
|
204 |
+
|
205 |
+
} else if(empty($thethumbnail) && !empty($default)){
|
206 |
+
|
207 |
+
$content .= '<a href="'.$item->get_permalink().'" class="rss_image" target="'. $target .'" style="width:'. $size .'px; height:'. $size .'px;" title="'.$item->get_title().'" >';
|
208 |
+
$content .= '<span style="width:'. $size .'px; height:'. $size .'px; background-image:url('.$default.');" alt="'.$item->get_title().'"></span/></a>';
|
209 |
+
|
210 |
} else {
|
211 |
+
|
212 |
$content .= '<span class="rss_image" style="width:'. $size .'px; height:'. $size .'px;" /></span>';
|
213 |
+
|
214 |
}
|
215 |
}
|
216 |
$content .= '<span class="title"><a href="'. $item->get_permalink() .'" target="'. $target .'">';
|
217 |
if(is_numeric($title) && strlen($item->get_title()) > $title){
|
218 |
+
|
219 |
$content .= preg_replace('/\s+?(\S+)?$/', '', substr($item->get_title(), 0, $title)) .'...';
|
220 |
+
|
221 |
} else {
|
222 |
+
|
223 |
$content .= $item->get_title();
|
224 |
+
|
225 |
}
|
226 |
$content .= '</a></span>';
|
227 |
$content .= '<div class="rss_content">';
|
228 |
if($meta == 'yes'){
|
229 |
+
|
230 |
$content .= '<small>'. __( 'Posted by', 'feedzy_rss_translate' ) .' ';
|
231 |
+
|
232 |
if ($author = $item->get_author()) {
|
233 |
+
|
234 |
$domain = parse_url($item->get_permalink());
|
235 |
$content .= '<a href="http://'. $domain["host"]. '" target="'. $target .'" title="'.$domain["host"].'" >'. $author->get_name() .' </a>';
|
236 |
+
|
237 |
}
|
238 |
+
|
239 |
$content .= __( 'on', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('date_format')) .' '. __( 'at', 'feedzy_rss_translate' ) .' '. $item->get_date(get_option('time_format'));
|
240 |
$content .= '</small>';
|
241 |
+
|
242 |
}
|
243 |
if($summary == 'yes'){
|
244 |
+
|
245 |
$content .= '<p>';
|
246 |
$description = trim(strip_tags($item->get_description()));
|
247 |
$description = trim(chop($description,'[…]'));
|
248 |
+
|
249 |
if(is_numeric($summarylength) && strlen($description) > $summarylength){
|
250 |
+
|
251 |
$content .= preg_replace('/\s+?(\S+)?$/', '', substr($description, 0, $summarylength)) .' […]';
|
252 |
+
|
253 |
} else {
|
254 |
+
|
255 |
+
$content .= $description .' […]';
|
256 |
+
|
257 |
}
|
258 |
+
|
259 |
+
$content .= '</p>';
|
260 |
+
|
261 |
}
|
262 |
$content .= '</div>';
|
263 |
$content .= '</div>';
|
276 |
if (!function_exists('insertThumbnailRSS')) {
|
277 |
function insertThumbnailRSS($content) {
|
278 |
global $post;
|
279 |
+
|
280 |
if ( has_post_thumbnail( $post->ID ) ){
|
281 |
$content = '' . get_the_post_thumbnail( $post->ID, 'thumbnail' ) . '' . $content;
|
282 |
}
|
283 |
+
|
284 |
return $content;
|
285 |
}
|
286 |
add_filter('the_excerpt_rss', 'insertThumbnailRSS');
|
feedzy-rss-style.css
CHANGED
@@ -3,7 +3,6 @@
|
|
3 |
* Plugin URI: http://b-website.com/
|
4 |
* Author: Brice CAPOBIANCO - b*web
|
5 |
*/
|
6 |
-
|
7 |
.feedzy-rss .rss_item {
|
8 |
border-bottom: 1px solid #eee;
|
9 |
padding: 1em 0 2em;
|
3 |
* Plugin URI: http://b-website.com/
|
4 |
* Author: Brice CAPOBIANCO - b*web
|
5 |
*/
|
|
|
6 |
.feedzy-rss .rss_item {
|
7 |
border-bottom: 1px solid #eee;
|
8 |
padding: 1em 0 2em;
|
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.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -95,6 +95,13 @@ By activating this plugin, your cover picture will be inserted into your RSS fee
|
|
95 |
* Default : yes
|
96 |
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
**size**
|
99 |
|
100 |
* Description : If an image is available and is required to display, you may specify its size in pixels. The image is cropped with CSS to be perfectly square. Do not include "px".
|
@@ -109,7 +116,7 @@ By activating this plugin, your cover picture will be inserted into your RSS fee
|
|
109 |
|
110 |
= Advanced example =
|
111 |
|
112 |
-
`[feedzy-rss feeds="http://b-website.com/feed" max="2" feed_title="yes" target="_blank" title="50" meta="yes" summary="yes" summarylength="300" thumb="yes" size="100"]`
|
113 |
|
114 |
|
115 |
== Installation ==
|
@@ -132,6 +139,10 @@ Yes it is.
|
|
132 |
== Changelog ==
|
133 |
|
134 |
|
|
|
|
|
|
|
|
|
135 |
= 1.03 =
|
136 |
* Shortcode can now be displayed everywhere in the page (CSS is loaded via global var)
|
137 |
|
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.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
95 |
* Default : yes
|
96 |
|
97 |
|
98 |
+
**default**
|
99 |
+
|
100 |
+
* Description : Default thumbnail URL if no image is found in the feed or if the fetched image is offline (fallback). Will be used only if thumb parameter is set to yes.
|
101 |
+
* Format : URL
|
102 |
+
* Default : empty
|
103 |
+
|
104 |
+
|
105 |
**size**
|
106 |
|
107 |
* Description : If an image is available and is required to display, you may specify its size in pixels. The image is cropped with CSS to be perfectly square. Do not include "px".
|
116 |
|
117 |
= Advanced example =
|
118 |
|
119 |
+
`[feedzy-rss feeds="http://b-website.com/feed" max="2" feed_title="yes" target="_blank" title="50" meta="yes" summary="yes" summarylength="300" thumb="yes" size="100" default="default-image.jpg"]`
|
120 |
|
121 |
|
122 |
== Installation ==
|
139 |
== Changelog ==
|
140 |
|
141 |
|
142 |
+
= 1.4 =
|
143 |
+
* Add "default" parameter to fill image container if no image is fetch or if it is offline
|
144 |
+
* Add more control over numeric format in max, size, title & summarylength parameters
|
145 |
+
|
146 |
= 1.03 =
|
147 |
* Shortcode can now be displayed everywhere in the page (CSS is loaded via global var)
|
148 |
|