WP RSS Aggregator - Version 4.1.4

Version Description

(2014-05-16) = * Enhanced: Minor improvements to feed importing and handling. * Fixed bug: HTML entities were not being decoded in feed item titles.

Download this release

Release Info

Developer jeangalea
Plugin Icon 128x128 WP RSS Aggregator
Version 4.1.4
Comparing to
See all releases

Code changes from version 4.1.3 to 4.1.4

changelog.txt CHANGED
@@ -1,3 +1,7 @@
 
 
 
 
1
  4.1.3 (2014-04-28)
2
  Enhanced: Added a force feed option, for valid RSS feeds with incorrect header content types.
3
  Fixed bug: HTML entities in feed item titles are now being decoded.
1
+ 4.1.4 (2014-05-16)
2
+ Enhanced: Minor improvements to feed importing and handling.
3
+ Fixed bug: HTML entities were not being decoded in feed item titles.
4
+
5
  4.1.3 (2014-04-28)
6
  Enhanced: Added a force feed option, for valid RSS feeds with incorrect header content types.
7
  Fixed bug: HTML entities in feed item titles are now being decoded.
includes/admin-metaboxes.php CHANGED
@@ -625,7 +625,7 @@
625
  function wprss_remove_meta_boxes() {
626
  if ( 'wprss_feed' !== get_current_screen()->id ) return;
627
  // Remove meta boxes of other plugins that tend to appear on all posts
628
- remove_meta_box( 'wpseo_meta', 'wprss_feed' ,'normal' );
629
  remove_meta_box( 'postpsp', 'wprss_feed' ,'normal' );
630
  remove_meta_box( 'su_postmeta', 'wprss_feed' ,'normal' );
631
  remove_meta_box( 'woothemes-settings', 'wprss_feed' ,'normal' );
@@ -640,4 +640,4 @@
640
  remove_meta_box( 'trackbacksdiv22', 'wprss_feed' ,'advanced' );
641
  remove_meta_box( 'aiosp', 'wprss_feed' ,'advanced' );
642
  remove_action( 'post_submitbox_start', 'fpp_post_submitbox_start_action' );
643
- }
625
  function wprss_remove_meta_boxes() {
626
  if ( 'wprss_feed' !== get_current_screen()->id ) return;
627
  // Remove meta boxes of other plugins that tend to appear on all posts
628
+ //remove_meta_box( 'wpseo_meta', 'wprss_feed' ,'normal' );
629
  remove_meta_box( 'postpsp', 'wprss_feed' ,'normal' );
630
  remove_meta_box( 'su_postmeta', 'wprss_feed' ,'normal' );
631
  remove_meta_box( 'woothemes-settings', 'wprss_feed' ,'normal' );
640
  remove_meta_box( 'trackbacksdiv22', 'wprss_feed' ,'advanced' );
641
  remove_meta_box( 'aiosp', 'wprss_feed' ,'advanced' );
642
  remove_action( 'post_submitbox_start', 'fpp_post_submitbox_start_action' );
643
+ }
includes/admin-welcome.php CHANGED
@@ -74,8 +74,8 @@
74
 
75
  <h3>Changelog for v<?php echo WPRSS_VERSION; ?></h3>
76
  <ul>
77
- <li><strong>Enhanced:</strong> Added a force feed option, for valid RSS feeds with incorrect header content types.</li>
78
- <li><strong>Fixed bug:</strong> HTML entities in feed item titles are now being decoded.</li>
79
  </ul>
80
 
81
 
@@ -120,4 +120,4 @@
120
 
121
  </div>
122
 
123
- <?php update_option( 'wprss_pwsv', WPRSS_VERSION ); // Update the previous welcome screen version ?>
74
 
75
  <h3>Changelog for v<?php echo WPRSS_VERSION; ?></h3>
76
  <ul>
77
+ <li><strong>Enhanced:</strong> Minor improvements to feed importing and handling.</li>
78
+ <li><strong>Fixed bug:</strong> HTML entities were not being decoded in feed item titles.</li>
79
  </ul>
80
 
81
 
120
 
121
  </div>
122
 
123
+ <?php update_option( 'wprss_pwsv', WPRSS_VERSION ); // Update the previous welcome screen version ?>
includes/feed-display.php CHANGED
@@ -197,15 +197,18 @@
197
  // convert from Unix timestamp
198
  $date = date_i18n( $general_settings['date_format'], $timestamp );
199
 
 
 
 
200
  if ( $general_settings['title_link'] == 1 ) {
201
  $feed_item_title_link = $permalink;
202
  if ( $link_enclosure === 'true' && $enclosure !== '' ) {
203
  $feed_item_title_link = $enclosure;
204
  }
205
- $output .= "$link_before" . '<a ' . $display_settings['open'] . ' ' . $display_settings['follow'] . ' href="'. $feed_item_title_link . '">'. get_the_title(). '</a>';
206
  }
207
  else {
208
- $output .= "$link_before" . get_the_title();
209
  }
210
 
211
  if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 1 ) ) {
@@ -381,4 +384,4 @@
381
  $words = implode( ' ', $words ) . $append;
382
  /* Return the result */
383
  return rtrim( $words );
384
- }
197
  // convert from Unix timestamp
198
  $date = date_i18n( $general_settings['date_format'], $timestamp );
199
 
200
+ // Prepare the title. Decode any html entitities
201
+ $feed_item_title = html_entity_decode( get_the_title() );
202
+
203
  if ( $general_settings['title_link'] == 1 ) {
204
  $feed_item_title_link = $permalink;
205
  if ( $link_enclosure === 'true' && $enclosure !== '' ) {
206
  $feed_item_title_link = $enclosure;
207
  }
208
+ $output .= "$link_before" . '<a ' . $display_settings['open'] . ' ' . $display_settings['follow'] . ' href="'. $feed_item_title_link . '">'. $feed_item_title. '</a>';
209
  }
210
  else {
211
+ $output .= "$link_before" . $feed_item_title;
212
  }
213
 
214
  if ( ( $general_settings['source_enable'] == 1 ) && ( $general_settings['date_enable'] == 1 ) ) {
384
  $words = implode( ' ', $words ) . $append;
385
  /* Return the result */
386
  return rtrim( $words );
387
+ }
includes/feed-importing.php CHANGED
@@ -111,42 +111,24 @@
111
  * @since 3.0
112
  */
113
  function wprss_get_feed_items( $feed_url, $source ) {
114
- $general_settings = get_option( 'wprss_settings_general' );
115
- $feed_item_limit = $general_settings['limit_feed_items_imported'];
116
-
117
- // Don't fetch the feed if feed item limit is 0, there's no need, huge speed improvement
118
- // if ( $feed_item_limit === '' ) return;
119
-
120
  add_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_feed_cache_lifetime' );
121
-
122
- /* Disable caching of feeds */
123
  add_action( 'wp_feed_options', 'wprss_do_not_cache_feeds' );
 
124
  /* Fetch the feed from the soure URL specified */
125
  $feed = wprss_fetch_feed( $feed_url, $source );
126
- //$feed = new SimplePie();
127
- //$feed->set_feed_url( $feed_url );
128
- //$feed->init();
129
- /* Remove action here because we only don't want it active feed imports outside of our plugin */
130
- remove_action( 'wp_feed_options', 'wprss_do_not_cache_feeds' );
131
 
132
- //$feed = wprss_fetch_feed( $feed_url );
 
133
  remove_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_feed_cache_lifetime' );
134
 
135
  if ( !is_wp_error( $feed ) ) {
136
-
137
- // Figure out how many total items there are, but limit it to the number of items set in options.
138
- $maxitems = $feed->get_item_quantity( $feed_item_limit );
139
-
140
- if ( $maxitems == 0 ) { return; }
141
-
142
- // Build an array of all the items, starting with element 0 (first element).
143
- $items = $feed->get_items( 0, $maxitems );
144
- return $items;
145
  }
146
-
147
  else {
148
  wprss_log( 'Failed to fetch feed "' . $feed_url . '". ' . $feed->get_error_message() );
149
- return;
150
  }
151
  }
152
 
@@ -164,24 +146,17 @@
164
  * @since 3.5
165
  */
166
  function wprss_fetch_feed( $url, $source = NULL ) {
 
167
  require_once ( ABSPATH . WPINC . '/class-feed.php' );
168
 
169
  // Trim the URL
170
  $url = trim( $url );
171
 
 
172
  $feed = new SimplePie();
173
-
174
- // Commented out Sanitization, due to a conflict with google RSS image URLS.
175
- // With sanitization on, the urls get truncated from the front.
176
-
177
- // $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );
178
- // We must manually overwrite $feed->sanitize because SimplePie's
179
- // constructor sets it before we have a chance to set the sanitization class
180
- // $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
181
-
182
- $feed->set_cache_class( 'WP_Feed_Cache' );
183
- $feed->set_file_class( 'WP_SimplePie_File' );
184
-
185
  $feed->set_feed_url( $url );
186
  $feed->set_autodiscovery_level( SIMPLEPIE_LOCATOR_ALL );
187
 
@@ -195,22 +170,30 @@
195
  }
196
  }
197
 
 
198
  $feed->set_timeout( 30 );
199
 
200
  //$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
201
  $feed->enable_cache( FALSE );
 
 
202
  do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
203
 
 
204
  $tags_to_strip = apply_filters( 'wprss_feed_tags_to_strip', $feed->strip_htmltags, $source );
 
205
  $feed->strip_htmltags( $tags_to_strip );
206
 
 
207
  $feed->init();
208
  $feed->handle_content_type();
209
 
 
210
  if ( $feed->error() ) {
211
  return new WP_Error( 'simplepie-error', $feed->error() );
212
  }
213
 
 
214
  return $feed;
215
  }
216
 
@@ -418,4 +401,4 @@
418
  */
419
  function wprss_fetch_insert_all_feed_items_from_cron() {
420
  wprss_fetch_insert_all_feed_items( FALSE );
421
- }
111
  * @since 3.0
112
  */
113
  function wprss_get_feed_items( $feed_url, $source ) {
114
+ // Add filters and actions prior to fetching the feed items
 
 
 
 
 
115
  add_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_feed_cache_lifetime' );
 
 
116
  add_action( 'wp_feed_options', 'wprss_do_not_cache_feeds' );
117
+
118
  /* Fetch the feed from the soure URL specified */
119
  $feed = wprss_fetch_feed( $feed_url, $source );
 
 
 
 
 
120
 
121
+ // Remove previously added filters and actions
122
+ remove_action( 'wp_feed_options', 'wprss_do_not_cache_feeds' );
123
  remove_filter( 'wp_feed_cache_transient_lifetime' , 'wprss_feed_cache_lifetime' );
124
 
125
  if ( !is_wp_error( $feed ) ) {
126
+ // Return the items in the feed.
127
+ return $feed->get_items();
 
 
 
 
 
 
 
128
  }
 
129
  else {
130
  wprss_log( 'Failed to fetch feed "' . $feed_url . '". ' . $feed->get_error_message() );
131
+ return NULL;
132
  }
133
  }
134
 
146
  * @since 3.5
147
  */
148
  function wprss_fetch_feed( $url, $source = NULL ) {
149
+ // Import SimplePie
150
  require_once ( ABSPATH . WPINC . '/class-feed.php' );
151
 
152
  // Trim the URL
153
  $url = trim( $url );
154
 
155
+ // Initialize the Feed
156
  $feed = new SimplePie();
157
+ // Obselete method calls ?
158
+ //$feed->set_cache_class( 'WP_Feed_Cache' );
159
+ //$feed->set_file_class( 'WP_SimplePie_File' );
 
 
 
 
 
 
 
 
 
160
  $feed->set_feed_url( $url );
161
  $feed->set_autodiscovery_level( SIMPLEPIE_LOCATOR_ALL );
162
 
170
  }
171
  }
172
 
173
+ // Set timeout to 30s. Default: 15s
174
  $feed->set_timeout( 30 );
175
 
176
  //$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
177
  $feed->enable_cache( FALSE );
178
+
179
+ // Reference array action hook, for the feed object and the URL
180
  do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
181
 
182
+ // Prepare the tags to strip from the feed
183
  $tags_to_strip = apply_filters( 'wprss_feed_tags_to_strip', $feed->strip_htmltags, $source );
184
+ // Strip them
185
  $feed->strip_htmltags( $tags_to_strip );
186
 
187
+ // Fetch the feed
188
  $feed->init();
189
  $feed->handle_content_type();
190
 
191
+ // Convert the feed error into a WP_Error, if applicable
192
  if ( $feed->error() ) {
193
  return new WP_Error( 'simplepie-error', $feed->error() );
194
  }
195
 
196
+ // If no error, return the feed
197
  return $feed;
198
  }
199
 
401
  */
402
  function wprss_fetch_insert_all_feed_items_from_cron() {
403
  wprss_fetch_insert_all_feed_items( FALSE );
404
+ }
includes/feed-processing.php CHANGED
@@ -28,8 +28,7 @@
28
  *
29
  * @since 2.1
30
  */
31
- function wprss_feed_cache_lifetime( $seconds )
32
- {
33
  return 1; // one second
34
  }
35
 
@@ -520,53 +519,63 @@
520
 
521
 
522
  /**
523
- * Custom version of the WP fetch_feed() function, since we want custom sanitization of a feed
524
- *
525
- * Not being used at the moment, until we decide whether we can still use fetch_feed and modify its handling of sanitization
526
  *
527
  * @since 3.0
528
- *
529
  */
530
- /*function wprss_fetch_feed($url) {
531
- require_once (ABSPATH . WPINC . '/class-feed.php');
532
-
533
- $feed = new SimplePie();
534
-
535
- // $feed->set_sanitize_class( 'WP_SimplePie_Sanitize_KSES' );
536
- // We must manually overwrite $feed->sanitize because SimplePie's
537
- // constructor sets it before we have a chance to set the sanitization class
538
- // $feed->sanitize = new WP_SimplePie_Sanitize_KSES();
539
-
540
- $feed->set_cache_class( 'WP_Feed_Cache' );
541
- $feed->set_file_class( 'WP_SimplePie_File' );
542
-
543
- $feed->set_feed_url($url);
544
- $feed->strip_htmltags(array_merge($feed->strip_htmltags, array( 'h1', 'h2', 'h3', 'h4', 'h5', 'a' )));
545
- $feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
546
- do_action_ref_array( 'wp_feed_options', array( &$feed, $url ) );
547
- $feed->init();
548
- $feed->handle_content_type();
549
 
550
- if ( $feed->error() )
551
- return new WP_Error('simplepie-error', $feed->error());
552
 
553
- return $feed;
554
- }*/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
555
 
556
 
557
  /**
558
- * Deletes all imported feeds and re-imports everything
 
559
  *
560
- * @since 3.0
561
  */
562
- function wprss_feed_reset() {
563
- wp_schedule_single_event( time(), 'wprss_delete_all_feed_items_hook' );
564
- wprss_fetch_insert_all_feed_items( TRUE );
565
- }
566
 
567
- /* add_action( 'wp_feed_options', 'wprss_feed_options' );
568
- function wprss_feed_options( $feed) {
569
- $feed->strip_htmltags(array_merge($feed->strip_htmltags, array('h1', 'a', 'img','em')));
570
- }
571
 
572
- */
 
 
28
  *
29
  * @since 2.1
30
  */
31
+ function wprss_feed_cache_lifetime( $seconds ) {
 
32
  return 1; // one second
33
  }
34
 
519
 
520
 
521
  /**
522
+ * Deletes all imported feeds and re-imports everything
 
 
523
  *
524
  * @since 3.0
 
525
  */
526
+ function wprss_feed_reset() {
527
+ wp_schedule_single_event( time(), 'wprss_delete_all_feed_items_hook' );
528
+ wprss_fetch_insert_all_feed_items( TRUE );
529
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
530
 
 
 
531
 
532
+ /**
533
+ * Deletes N oldest feed items for the given source
534
+ *
535
+ * @since 4.2
536
+ */
537
+ function wprss_delete_oldest_feed_items( $n, $source ) {
538
+ // If the source does not exist, do nothing
539
+ if ( get_post( $source ) == NULL ) return;
540
+
541
+ // Make sure $n is an integer
542
+ $n = intval($n);
543
+
544
+ // Do nothing if n is zero or negative
545
+ if ( $n <= 0 ) return;
546
+
547
+ // Get the feed items, as an array, not WP_Query.
548
+ // We will need to perform some array operations
549
+ $feed_items = wprss_get_feed_items_for_source( $source );
550
+ $feed_items = $feed_items->get_posts();
551
+ // Get number of feed items
552
+ $count = count( $feed_items );
553
+
554
+ // Index of first feed item to delete
555
+ $start = $count - $n;
556
+ // Cut the array of feed items to get the items to delete
557
+ $to_delete = array_slice( $feed_items, $start );
558
+ // log -- for now
559
+ foreach( $to_delete as $fi ) {
560
+ wprss_log_obj( "To delete" , $fi->ID );
561
+ }
562
+ }
563
 
564
 
565
  /**
566
+ * Deletes the required number of feed items for the given source,
567
+ * to keep the number of feed items below its limit.
568
  *
569
+ * @since 4.2
570
  */
571
+ function wprss_truncate_feed_items_for_source( $source ) {
572
+ // Get the limit setting
573
+ $limit = get_post_meta( $source, 'wprss_limit', true );
 
574
 
575
+ // Calculate the number of feed items to delete
576
+ $feed_items = wprss_get_feed_items_for_source( $source );
577
+ $n = intval($feed_items->found_posts) - intval($limit);
 
578
 
579
+ // Delete the feed items
580
+ wprss_delete_oldest_feed_items( $n, $source );
581
+ }
readme.txt CHANGED
@@ -2,10 +2,10 @@
2
  Contributors: jeangalea
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X9GP6BL4BLXBJ
4
  Plugin URI: http://www.wprssaggregator.com
5
- Tags: rss, feeds, aggregation, autoblog aggregator, rss import, feed aggregator, rss aggregator, multiple rss feeds, multi rss feeds, rss multi importer, feed import, feed import, multiple feed import, feed aggregation, rss feader, feed reader, feed to post, multiple feeds, multi feed importer, multi feed import, multi import, autoblogging, autoblogger
6
  Requires at least: 3.3
7
  Tested up to: 3.8.1
8
- Stable tag: 4.1.3
9
  License: GPLv2 or later
10
  Imports and aggregates multiple RSS Feeds using SimplePie. Outputs feeds sorted by date (latest first).
11
 
@@ -68,9 +68,8 @@ Created by Jean Galea from [WP Mayor](http://www.wpmayor.com)
68
  WP RSS Aggregator uses the SimplePie class to import and handle feeds, and stores all feed sources and feed items as custom post types in the WordPress default table structure, thus no custom tables are added.
69
 
70
  = Translations =
71
- Italian - Davide De Maestri
72
-
73
- Spanish - Andrew Kurtis
74
 
75
  = As featured on =
76
  * [WP Beginner](http://www.wpbeginner.com/plugins/how-to-fetch-feeds-in-wordpress-using-wp-rss-aggregator/)
@@ -163,6 +162,10 @@ The full documentation section can be found on the [WP RSS Aggregator website](w
163
 
164
  == Changelog ==
165
 
 
 
 
 
166
  = 4.1.3 (2014-04-28) =
167
  * Enhanced: Added a force feed option, for valid RSS feeds with incorrect header content types.
168
  * Fixed bug: HTML entities in feed item titles are now being decoded.
2
  Contributors: jeangalea
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=X9GP6BL4BLXBJ
4
  Plugin URI: http://www.wprssaggregator.com
5
+ Tags: rss, feeds, aggregation, rss to post, autoblog aggregator, rss import, feed aggregator, rss aggregator, multiple rss feeds, multi rss feeds, rss multi importer, feed import, feed import, multiple feed import, feed aggregation, rss feader, feed reader, feed to post, multiple feeds, multi feed importer, multi feed import, multi import, autoblogging, autoblogger
6
  Requires at least: 3.3
7
  Tested up to: 3.8.1
8
+ Stable tag: 4.1.4
9
  License: GPLv2 or later
10
  Imports and aggregates multiple RSS Feeds using SimplePie. Outputs feeds sorted by date (latest first).
11
 
68
  WP RSS Aggregator uses the SimplePie class to import and handle feeds, and stores all feed sources and feed items as custom post types in the WordPress default table structure, thus no custom tables are added.
69
 
70
  = Translations =
71
+ * Italian - Davide De Maestri
72
+ * Spanish - Andrew Kurtis
 
73
 
74
  = As featured on =
75
  * [WP Beginner](http://www.wpbeginner.com/plugins/how-to-fetch-feeds-in-wordpress-using-wp-rss-aggregator/)
162
 
163
  == Changelog ==
164
 
165
+ = 4.1.4 (2014-05-16) =
166
+ * Enhanced: Minor improvements to feed importing and handling.
167
+ * Fixed bug: HTML entities were not being decoded in feed item titles.
168
+
169
  = 4.1.3 (2014-04-28) =
170
  * Enhanced: Added a force feed option, for valid RSS feeds with incorrect header content types.
171
  * Fixed bug: HTML entities in feed item titles are now being decoded.
wp-rss-aggregator.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: WP RSS Aggregator
4
  Plugin URI: http://www.wprssaggregator.com
5
  Description: Imports and aggregates multiple RSS Feeds using SimplePie
6
- Version: 4.1.3
7
  Author: Jean Galea
8
  Author URI: http://www.wprssaggregator.com
9
  License: GPLv2
@@ -29,7 +29,7 @@
29
 
30
  /**
31
  * @package WPRSSAggregator
32
- * @version 4.1.3
33
  * @since 1.0
34
  * @author Jean Galea <info@jeangalea.com>
35
  * @copyright Copyright (c) 2012-2014, Jean Galea
@@ -43,7 +43,7 @@
43
 
44
  // Set the version number of the plugin.
45
  if( !defined( 'WPRSS_VERSION' ) )
46
- define( 'WPRSS_VERSION', '4.1.3', true );
47
 
48
  // Set the database version number of the plugin.
49
  if( !defined( 'WPRSS_DB_VERSION' ) )
@@ -478,4 +478,4 @@
478
  */
479
  function wprss_disable() {
480
  return FALSE;
481
- }
3
  Plugin Name: WP RSS Aggregator
4
  Plugin URI: http://www.wprssaggregator.com
5
  Description: Imports and aggregates multiple RSS Feeds using SimplePie
6
+ Version: 4.1.4
7
  Author: Jean Galea
8
  Author URI: http://www.wprssaggregator.com
9
  License: GPLv2
29
 
30
  /**
31
  * @package WPRSSAggregator
32
+ * @version 4.1.4
33
  * @since 1.0
34
  * @author Jean Galea <info@jeangalea.com>
35
  * @copyright Copyright (c) 2012-2014, Jean Galea
43
 
44
  // Set the version number of the plugin.
45
  if( !defined( 'WPRSS_VERSION' ) )
46
+ define( 'WPRSS_VERSION', '4.1.4', true );
47
 
48
  // Set the database version number of the plugin.
49
  if( !defined( 'WPRSS_DB_VERSION' ) )
478
  */
479
  function wprss_disable() {
480
  return FALSE;
481
+ }