Version Description
(2014-12-06) = * Enhanced: Added output layouts for feed sources and feed items. * Enhanced: Updated EDD updater class to version 1.5. * Enhanced: Added time limit extending to prevent script from exhausting its execution time limit while importing. * Fixed bug: The "Delete and Re-import" button was deleting items but not re-importing. * Fixed bug: Non-object errors when a feed source is deleted while importing.
Download this release
Release Info
Developer | Mekku |
Plugin | WP RSS Aggregator |
Version | 4.6.6 |
Comparing to | |
See all releases |
Code changes from version 4.6.5 to 4.6.6
- changelog.txt +7 -0
- css/admin-styles.css +1 -0
- includes/admin-display.php +10 -9
- includes/admin-heartbeat.php +1 -1
- includes/admin-log.php +1 -1
- includes/admin-metaboxes.php +1 -0
- includes/custom-post-types.php +4 -2
- includes/feed-blacklist.php +5 -5
- includes/feed-display.php +162 -97
- includes/feed-importing.php +73 -8
- includes/feed-processing.php +67 -10
- includes/libraries/EDD_licensing/EDD_SL_Plugin_Updater.php +5 -10
- includes/shortcodes.php +32 -1
- js/heartbeat.js +1 -1
- readme.txt +8 -1
- wp-rss-aggregator.php +12 -3
changelog.txt
CHANGED
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
4.6.5 (2014-11-17)
|
2 |
Enhanced: Improved the logging.
|
3 |
Enhanced: Improved the licensing fields.
|
1 |
+
4.6.6 (2014-12-06)
|
2 |
+
Enhanced: Added output layouts for feed sources and feed items.
|
3 |
+
Enhanced: Updated EDD updater class to version 1.5.
|
4 |
+
Enhanced: Added time limit extending to prevent script from exhausting its execution time limit while importing.
|
5 |
+
Fixed bug: The "Delete and Re-import" button was deleting items but not re-importing.
|
6 |
+
Fixed bug: Non-object errors when a feed source is deleted while importing.
|
7 |
+
|
8 |
4.6.5 (2014-11-17)
|
9 |
Enhanced: Improved the logging.
|
10 |
Enhanced: Improved the licensing fields.
|
css/admin-styles.css
CHANGED
@@ -407,6 +407,7 @@ body.post-type-wprss_feed.edit-php table.wp-list-table.posts thead th#feed-count
|
|
407 |
width: 140px !important;
|
408 |
}
|
409 |
/* CATEGORIES */
|
|
|
410 |
body.post-type-wprss_feed.edit-php table.wp-list-table.posts thead th#category {
|
411 |
width: 130px !important;
|
412 |
}
|
407 |
width: 140px !important;
|
408 |
}
|
409 |
/* CATEGORIES */
|
410 |
+
body.post-type-wprss_feed_item.edit-php table.wp-list-table.posts thead th#category,
|
411 |
body.post-type-wprss_feed.edit-php table.wp-list-table.posts thead th#category {
|
412 |
width: 130px !important;
|
413 |
}
|
includes/admin-display.php
CHANGED
@@ -44,8 +44,9 @@
|
|
44 |
switch ( $column ) {
|
45 |
case 'errors':
|
46 |
$errors = get_post_meta( $post_id, 'wprss_error_last_import', true );
|
47 |
-
$showClass = ( $errors
|
48 |
-
$
|
|
|
49 |
echo "<i title=\"$msg\" class=\"fa fa-warning fa-fw wprss-feed-error-symbol $showClass\"></i>";
|
50 |
break;
|
51 |
case 'state':
|
@@ -348,15 +349,15 @@
|
|
348 |
admin_url( 'edit.php?post_type=wprss_feed_item&wprss_feed=' . $post->ID ),
|
349 |
$post->ID
|
350 |
);
|
351 |
-
$view_items_text = apply_filters( 'wprss_view_feed_items_row_action_text', 'View Items' );
|
352 |
-
$actions['view-items'] = '<a href="' . $view_items_link . '">' .
|
353 |
|
354 |
-
$fetch_items_row_action_text = apply_filters( 'wprss_fetch_items_row_action_text', 'Fetch Items' );
|
355 |
-
$actions[ 'fetch' ] = '<a href="javascript:;" class="wprss_ajax_action" pid="'. $post->ID .'" purl="'.home_url().'/wp-admin/admin-ajax.php">' .
|
356 |
|
357 |
-
$purge_feeds_row_action_text = apply_filters( 'wprss_purge_feeds_row_action_text', 'Delete Items' );
|
358 |
-
$purge_feeds_row_action_title = apply_filters( 'wprss_purge_feeds_row_action_title', 'Delete feed items imported by this feed source' );
|
359 |
-
$actions['purge-posts'] = "<a href='".admin_url("edit.php?post_type=wprss_feed&purge-feed-items=" . $post->ID . $page ) . "' title='" .
|
360 |
|
361 |
$actions['trash'] = $trash;
|
362 |
}
|
44 |
switch ( $column ) {
|
45 |
case 'errors':
|
46 |
$errors = get_post_meta( $post_id, 'wprss_error_last_import', true );
|
47 |
+
$showClass = ( $errors !== '' )? 'wprss-show' : '';
|
48 |
+
$default_msg = __( "This feed source experienced an error during the last feed fetch or validation check. Re-check the feed source URL or check the Error Log in the Debugging page for more details.", WPRSS_TEXT_DOMAIN );
|
49 |
+
$msg = strlen( $errors ) > 0 ? $errors : $default_msg;
|
50 |
echo "<i title=\"$msg\" class=\"fa fa-warning fa-fw wprss-feed-error-symbol $showClass\"></i>";
|
51 |
break;
|
52 |
case 'state':
|
349 |
admin_url( 'edit.php?post_type=wprss_feed_item&wprss_feed=' . $post->ID ),
|
350 |
$post->ID
|
351 |
);
|
352 |
+
$view_items_text = apply_filters( 'wprss_view_feed_items_row_action_text', __( 'View Items', WPRSS_TEXT_DOMAIN ) );
|
353 |
+
$actions['view-items'] = '<a href="' . $view_items_link . '">' . $view_items_text . '</a>';
|
354 |
|
355 |
+
$fetch_items_row_action_text = apply_filters( 'wprss_fetch_items_row_action_text', __( 'Fetch Items', WPRSS_TEXT_DOMAIN ) );
|
356 |
+
$actions[ 'fetch' ] = '<a href="javascript:;" class="wprss_ajax_action" pid="'. $post->ID .'" purl="'.home_url().'/wp-admin/admin-ajax.php">' . $fetch_items_row_action_text . '</a>';
|
357 |
|
358 |
+
$purge_feeds_row_action_text = apply_filters( 'wprss_purge_feeds_row_action_text', __( 'Delete Items', WPRSS_TEXT_DOMAIN ) );
|
359 |
+
$purge_feeds_row_action_title = apply_filters( 'wprss_purge_feeds_row_action_title', __( 'Delete feed items imported by this feed source', WPRSS_TEXT_DOMAIN ) );
|
360 |
+
$actions['purge-posts'] = "<a href='".admin_url("edit.php?post_type=wprss_feed&purge-feed-items=" . $post->ID . $page ) . "' title='" . $purge_feeds_row_action_title . "' >" . __( $purge_feeds_row_action_text, WPRSS_TEXT_DOMAIN ) . "</a>";
|
361 |
|
362 |
$actions['trash'] = $trash;
|
363 |
}
|
includes/admin-heartbeat.php
CHANGED
@@ -65,7 +65,7 @@ function wprss_feed_source_updates() {
|
|
65 |
|
66 |
// Add any error info
|
67 |
$errors = get_post_meta( $feed_id, 'wprss_error_last_import', true );
|
68 |
-
$feed_source_data['errors'] = $errors
|
69 |
}
|
70 |
// Send back all the IDs
|
71 |
$response['wprss_feed_sources_data'] = $feed_sources_data;
|
65 |
|
66 |
// Add any error info
|
67 |
$errors = get_post_meta( $feed_id, 'wprss_error_last_import', true );
|
68 |
+
$feed_source_data['errors'] = $errors;
|
69 |
}
|
70 |
// Send back all the IDs
|
71 |
$response['wprss_feed_sources_data'] = $feed_sources_data;
|
includes/admin-log.php
CHANGED
@@ -253,7 +253,7 @@
|
|
253 |
if( is_numeric( $_level ) && ($_level/2 >= 1) ) $options[ (int)$_level * -1 ] = $_label . ' and below';
|
254 |
}
|
255 |
|
256 |
-
krsort($options, defined('SORT_NATURAL' ? SORT_NATURAL : SORT_STRING)
|
257 |
?>
|
258 |
<select id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[<?php echo $field['field_id'] ?>]">
|
259 |
<?php
|
253 |
if( is_numeric( $_level ) && ($_level/2 >= 1) ) $options[ (int)$_level * -1 ] = $_label . ' and below';
|
254 |
}
|
255 |
|
256 |
+
krsort( $options, defined( 'SORT_NATURAL' ) ? SORT_NATURAL : SORT_STRING );
|
257 |
?>
|
258 |
<select id="<?php echo $field['field_id'] ?>" name="wprss_settings_general[<?php echo $field['field_id'] ?>]">
|
259 |
<?php
|
includes/admin-metaboxes.php
CHANGED
@@ -396,6 +396,7 @@
|
|
396 |
?>
|
397 |
<span class="invalid-feed-url">
|
398 |
<?php _e( '<strong>Invalid feed URL</strong> - Double check the feed source URL setting above.', WPRSS_TEXT_DOMAIN ) ?>
|
|
|
399 |
</span>
|
400 |
<?php
|
401 |
echo wpautop( sprintf( __( 'Not sure where to find the RSS feed on a website? <a target="_blank" href="%1$s">Click here</a> for a visual guide. ', WPRSS_TEXT_DOMAIN ), 'http://webtrends.about.com/od/webfeedsyndicationrss/ss/rss_howto.htm' ) );
|
396 |
?>
|
397 |
<span class="invalid-feed-url">
|
398 |
<?php _e( '<strong>Invalid feed URL</strong> - Double check the feed source URL setting above.', WPRSS_TEXT_DOMAIN ) ?>
|
399 |
+
<?php wprss_log_obj( 'Failed to preview feed.', $feed->get_error_message(), NULL, WPRSS_LOG_LEVEL_INFO ); ?>
|
400 |
</span>
|
401 |
<?php
|
402 |
echo wpautop( sprintf( __( 'Not sure where to find the RSS feed on a website? <a target="_blank" href="%1$s">Click here</a> for a visual guide. ', WPRSS_TEXT_DOMAIN ), 'http://webtrends.about.com/od/webfeedsyndicationrss/ss/rss_howto.htm' ) );
|
includes/custom-post-types.php
CHANGED
@@ -92,7 +92,7 @@
|
|
92 |
'show_in_menu' => 'edit.php?post_type=wprss_feed',
|
93 |
'show_in_admin_bar' => false,
|
94 |
'rewrite' => array(
|
95 |
-
'slug' => '
|
96 |
'with_front' => false,
|
97 |
),
|
98 |
'capability_type' => 'feed_source',
|
@@ -101,7 +101,9 @@
|
|
101 |
);
|
102 |
|
103 |
// Register the 'feed_item' post type
|
104 |
-
register_post_type( 'wprss_feed_item', $feed_item_args );
|
|
|
|
|
105 |
}
|
106 |
|
107 |
|
92 |
'show_in_menu' => 'edit.php?post_type=wprss_feed',
|
93 |
'show_in_admin_bar' => false,
|
94 |
'rewrite' => array(
|
95 |
+
'slug' => 'feed-items',
|
96 |
'with_front' => false,
|
97 |
),
|
98 |
'capability_type' => 'feed_source',
|
101 |
);
|
102 |
|
103 |
// Register the 'feed_item' post type
|
104 |
+
register_post_type( 'wprss_feed_item', $feed_item_args );
|
105 |
+
// Trigger action
|
106 |
+
do_action( 'wprss_registered_post_types' );
|
107 |
}
|
108 |
|
109 |
|
includes/feed-blacklist.php
CHANGED
@@ -131,12 +131,12 @@ function wprss_check_if_blacklist_item() {
|
|
131 |
$ID = $_GET['wprss_blacklist'];
|
132 |
// If the post does not exist, stop. Show a message
|
133 |
if ( get_post($ID) === NULL ) {
|
134 |
-
wp_die('The item you are trying to blacklist does not exist');
|
135 |
}
|
136 |
|
137 |
// If the post type is not correct,
|
138 |
if ( get_post_type($ID) !== wprss_blacklist_post_type() ) {
|
139 |
-
wp_die('The item you are trying to blacklist is not valid!');
|
140 |
}
|
141 |
|
142 |
check_admin_referer( 'blacklist-item-' . $ID, 'wprss_blacklist_item' );
|
@@ -167,7 +167,7 @@ function wprss_blacklist_cpt() {
|
|
167 |
'show_ui' => true,
|
168 |
'show_in_menu' => 'edit.php?post_type=wprss_feed',
|
169 |
'capability_type' => 'feed_source',
|
170 |
-
'supports' => array('title'),
|
171 |
'labels' => array(
|
172 |
'name' => __( 'Blacklist', WPRSS_TEXT_DOMAIN ),
|
173 |
'singular_name' => __( 'Blacklist', WPRSS_TEXT_DOMAIN ),
|
@@ -210,13 +210,13 @@ function wprss_blacklist_row_actions( $actions ) {
|
|
210 |
$nonced_url = wp_nonce_url( $plain_url, 'blacklist-item-' . $ID, 'wprss_blacklist_item' );
|
211 |
|
212 |
// Prepare the text
|
213 |
-
$text = apply_filters( 'wprss_blacklist_row_action_text', 'Delete Permanently &
|
214 |
$text = __( $text, WPRSS_TEXT_DOMAIN );
|
215 |
|
216 |
// Prepare the hint
|
217 |
$hint = apply_filters(
|
218 |
'wprss_blacklist_row_action_hint',
|
219 |
-
|
220 |
);
|
221 |
$hint = esc_attr( __( $hint, WPRSS_TEXT_DOMAIN ) );
|
222 |
|
131 |
$ID = $_GET['wprss_blacklist'];
|
132 |
// If the post does not exist, stop. Show a message
|
133 |
if ( get_post($ID) === NULL ) {
|
134 |
+
wp_die( __( 'The item you are trying to blacklist does not exist', WPRSS_TEXT_DOMAIN ) );
|
135 |
}
|
136 |
|
137 |
// If the post type is not correct,
|
138 |
if ( get_post_type($ID) !== wprss_blacklist_post_type() ) {
|
139 |
+
wp_die( __( 'The item you are trying to blacklist is not valid!', WPRSS_TEXT_DOMAIN ) );
|
140 |
}
|
141 |
|
142 |
check_admin_referer( 'blacklist-item-' . $ID, 'wprss_blacklist_item' );
|
167 |
'show_ui' => true,
|
168 |
'show_in_menu' => 'edit.php?post_type=wprss_feed',
|
169 |
'capability_type' => 'feed_source',
|
170 |
+
'supports' => array( 'title' ),
|
171 |
'labels' => array(
|
172 |
'name' => __( 'Blacklist', WPRSS_TEXT_DOMAIN ),
|
173 |
'singular_name' => __( 'Blacklist', WPRSS_TEXT_DOMAIN ),
|
210 |
$nonced_url = wp_nonce_url( $plain_url, 'blacklist-item-' . $ID, 'wprss_blacklist_item' );
|
211 |
|
212 |
// Prepare the text
|
213 |
+
$text = apply_filters( 'wprss_blacklist_row_action_text', htmlentities( __( 'Delete Permanently & Blacklist', WPRSS_TEXT_DOMAIN ) ) );
|
214 |
$text = __( $text, WPRSS_TEXT_DOMAIN );
|
215 |
|
216 |
// Prepare the hint
|
217 |
$hint = apply_filters(
|
218 |
'wprss_blacklist_row_action_hint',
|
219 |
+
__( 'The item will be deleted permanently, and its permalink will be recorded in the blacklist', WPRSS_TEXT_DOMAIN )
|
220 |
);
|
221 |
$hint = esc_attr( __( $hint, WPRSS_TEXT_DOMAIN ) );
|
222 |
|
includes/feed-display.php
CHANGED
@@ -6,6 +6,165 @@
|
|
6 |
*/
|
7 |
|
8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
/**
|
10 |
* Retrieve settings and prepare them for use in the display function
|
11 |
*
|
@@ -186,104 +345,10 @@
|
|
186 |
|
187 |
// FOR EACH ITEM
|
188 |
while ( $feed_items->have_posts() ) {
|
189 |
-
//
|
190 |
$feed_items->the_post();
|
191 |
-
//
|
192 |
-
$
|
193 |
-
$enclosure = get_post_meta( get_the_ID(), 'wprss_item_enclosure', true );
|
194 |
-
$feed_source_id = get_post_meta( get_the_ID(), 'wprss_feed_id', true );
|
195 |
-
$link_enclosure = get_post_meta( $feed_source_id, 'wprss_enclosure', true );
|
196 |
-
$source_name = get_the_title( $feed_source_id );
|
197 |
-
$source_url = get_post_meta( $feed_source_id, 'wprss_site_url', true );
|
198 |
-
$timestamp = get_the_time( 'U', get_the_ID() );
|
199 |
-
|
200 |
-
// Fallback for feeds created with older versions of the plugin
|
201 |
-
if ( $source_url === '' ) $source_url = get_post_meta( $feed_source_id, 'wprss_url', true );
|
202 |
-
// convert from Unix timestamp
|
203 |
-
$date = wprss_date_i18n( $timestamp );
|
204 |
-
|
205 |
-
// Prepare the title
|
206 |
-
$feed_item_title = get_the_title();
|
207 |
-
$feed_item_title_link = ( $link_enclosure === 'true' && $enclosure !== '' )? $enclosure : $permalink;
|
208 |
-
|
209 |
-
// Prepare the text that precedes the source
|
210 |
-
$text_preceding_source = wprss_get_general_setting('text_preceding_source');
|
211 |
-
$text_preceding_source = ltrim( __( $text_preceding_source, WPRSS_TEXT_DOMAIN ) . ' ' );
|
212 |
-
|
213 |
-
$text_preceding_date = wprss_get_general_setting('text_preceding_date');
|
214 |
-
$text_preceding_date = ltrim( __( $text_preceding_date, WPRSS_TEXT_DOMAIN ) . ' ' );
|
215 |
-
|
216 |
-
do_action( 'wprss_get_post_data' );
|
217 |
-
|
218 |
-
$meta = $extra_options;
|
219 |
-
$extra_meta = apply_filters( 'wprss_template_extra_meta', $meta, $args, get_the_ID() );
|
220 |
-
|
221 |
-
///////////////////////////////////////////////////////////////
|
222 |
-
// BEGIN TEMPLATE
|
223 |
-
|
224 |
-
// Begin output buffering
|
225 |
-
ob_start();
|
226 |
-
// Print the links before
|
227 |
-
echo $link_before;
|
228 |
-
|
229 |
-
// The Title
|
230 |
-
$item_title = wprss_link_display( $feed_item_title_link, $feed_item_title, wprss_get_general_setting('title_link') );
|
231 |
-
$item_title = apply_filters('wprss_item_title', $item_title, $feed_item_title_link, $feed_item_title, wprss_get_general_setting('title_link'));
|
232 |
-
echo $item_title;
|
233 |
-
|
234 |
-
do_action( 'wprss_after_feed_item_title', $extra_meta, $display_settings, get_the_ID() );
|
235 |
-
|
236 |
-
// FEED ITEM META ?>
|
237 |
-
<div class="wprss-feed-meta">
|
238 |
-
|
239 |
-
<!-- SOURCE -->
|
240 |
-
<?php if ( wprss_get_general_setting('source_enable') == 1 ) : ?>
|
241 |
-
<span class="feed-source">
|
242 |
-
<?php $source_link_text = apply_filters('wprss_item_source_link', wprss_link_display( $source_url, $source_name, $source_link )) ?>
|
243 |
-
<?php $source_link_text = $text_preceding_source . $source_link_text ?>
|
244 |
-
<?php echo $source_link_text ?>
|
245 |
-
</span>
|
246 |
-
<?php endif; ?>
|
247 |
-
|
248 |
-
<!-- DATE -->
|
249 |
-
<?php if ( wprss_get_general_setting('date_enable') == 1 ) : ?>
|
250 |
-
<span class='feed-date'>
|
251 |
-
<?php $date_text = apply_filters('wprss_item_date', $date) ?>
|
252 |
-
<?php $date_text = $text_preceding_date . $date_text; ?>
|
253 |
-
<?php echo $date_text; ?>
|
254 |
-
</span>
|
255 |
-
<?php endif; ?>
|
256 |
-
|
257 |
-
<!-- AUTHOR -->
|
258 |
-
<?php $author = get_post_meta( get_the_ID(), 'wprss_item_author', TRUE );
|
259 |
-
if ( wprss_get_general_setting('authors_enable') == 1 && $author !== NULL && is_string( $author ) && $author !== '' ) : ?>
|
260 |
-
<span class="feed-author">
|
261 |
-
<?php
|
262 |
-
$author_text = apply_filters( 'wprss_item_author', $author );
|
263 |
-
$author_prefix_text = apply_filters( 'wprss_author_prefix_text', 'By' );
|
264 |
-
_e( $author_prefix_text, WPRSS_TEXT_DOMAIN );
|
265 |
-
echo ' ' . $author_text;
|
266 |
-
?>
|
267 |
-
</span>
|
268 |
-
<?php endif; ?>
|
269 |
-
|
270 |
-
</div>
|
271 |
-
|
272 |
-
<?php // TIME AGO
|
273 |
-
if ( wprss_get_general_setting('date_enable') == 1 && wprss_get_general_setting('time_ago_format_enable') == 1 ) {
|
274 |
-
$time_ago = human_time_diff( $timestamp, time() ); ?>
|
275 |
-
<div class="wprss-time-ago">
|
276 |
-
<?php $time_ago_text = apply_filters('wprss_item_time_ago', $time_ago) ?>
|
277 |
-
<?php printf( __( '%1$s ago', WPRSS_TEXT_DOMAIN ), $time_ago_text ) ?>
|
278 |
-
</div>
|
279 |
-
<?php
|
280 |
-
}
|
281 |
-
|
282 |
-
// END TEMPLATE - Retrieve buffered output
|
283 |
-
$output .= ob_get_clean();
|
284 |
-
$output = apply_filters( 'wprss_single_feed_output', $output, $permalink );
|
285 |
-
$output .= "$link_after";
|
286 |
-
|
287 |
}
|
288 |
|
289 |
// OUTPUT LINKS AFTER LIST OF FEED ITEMS
|
6 |
*/
|
7 |
|
8 |
|
9 |
+
add_filter( 'the_content', 'wprss_render_feed_view' );
|
10 |
+
/**
|
11 |
+
* Display template for a feed source. Simulates a shortcode call.
|
12 |
+
*
|
13 |
+
* @since 4.6.6
|
14 |
+
*/
|
15 |
+
function wprss_render_feed_view( $content ) {
|
16 |
+
if ( get_post_type() === 'wprss_feed' && ! is_feed() ) {
|
17 |
+
$content = wprss_shortcode( array(
|
18 |
+
'source' => get_the_ID()
|
19 |
+
) );
|
20 |
+
}
|
21 |
+
return $content;
|
22 |
+
}
|
23 |
+
|
24 |
+
|
25 |
+
add_filter( 'the_content', 'wprss_render_feed_item_view' );
|
26 |
+
/**
|
27 |
+
* Display template for a feed source. Simulates a shortcode call.
|
28 |
+
*
|
29 |
+
* @since 4.6.6
|
30 |
+
*/
|
31 |
+
function wprss_render_feed_item_view( $content ) {
|
32 |
+
if ( get_post_type() === 'wprss_feed_item' && ! is_feed() ) {
|
33 |
+
$content = wprss_shortcode_single( array(
|
34 |
+
'id' => get_the_ID()
|
35 |
+
) );
|
36 |
+
}
|
37 |
+
return $content;
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Renders a single feed item.
|
43 |
+
*
|
44 |
+
* @param int $ID The ID of the feed item to render
|
45 |
+
* @param string $default The default text to return if something fails.
|
46 |
+
* @return string The output
|
47 |
+
* @since 4.6.6
|
48 |
+
*/
|
49 |
+
function wprss_render_feed_item( $ID = NULL, $default = '' ) {
|
50 |
+
$ID = ( $ID === NULL )? get_the_ID() : $ID;
|
51 |
+
if ( get_post_type( $ID ) !== 'wprss_feed_item' || is_feed() ) return $default;
|
52 |
+
|
53 |
+
// Prepare the options
|
54 |
+
$general_settings = get_option( 'wprss_settings_general' );
|
55 |
+
$display_settings = wprss_get_display_settings( $general_settings );
|
56 |
+
$excerpts_settings = get_option( 'wprss_settings_excerpts' );
|
57 |
+
$thumbnails_settings = get_option( 'wprss_settings_thumbnails' );
|
58 |
+
|
59 |
+
$args = wprss_get_shortcode_default_args( array() );
|
60 |
+
$extra_options = apply_filters( 'wprss_template_extra_options', array(), $args);
|
61 |
+
|
62 |
+
// Normalize the source_link option
|
63 |
+
$source_link = isset( $general_settings['source_link'] )? $general_settings['source_link'] : 0;
|
64 |
+
|
65 |
+
// Declare each item in $args as its own variable
|
66 |
+
extract( $args, EXTR_SKIP );
|
67 |
+
|
68 |
+
// Get the item meta
|
69 |
+
$permalink = get_post_meta( $ID, 'wprss_item_permalink', true );
|
70 |
+
$enclosure = get_post_meta( $ID, 'wprss_item_enclosure', true );
|
71 |
+
$feed_source_id = get_post_meta( $ID, 'wprss_feed_id', true );
|
72 |
+
$link_enclosure = get_post_meta( $feed_source_id, 'wprss_enclosure', true );
|
73 |
+
$source_name = get_the_title( $feed_source_id );
|
74 |
+
$source_url = get_post_meta( $feed_source_id, 'wprss_site_url', true );
|
75 |
+
$timestamp = get_the_time( 'U', $ID );
|
76 |
+
|
77 |
+
// Fallback for feeds created with older versions of the plugin
|
78 |
+
if ( $source_url === '' ) $source_url = get_post_meta( $feed_source_id, 'wprss_url', true );
|
79 |
+
// convert from Unix timestamp
|
80 |
+
$date = wprss_date_i18n( $timestamp );
|
81 |
+
|
82 |
+
// Prepare the title
|
83 |
+
$feed_item_title = get_the_title();
|
84 |
+
$feed_item_title_link = ( $link_enclosure === 'true' && $enclosure !== '' )? $enclosure : $permalink;
|
85 |
+
|
86 |
+
// Prepare the text that precedes the source
|
87 |
+
$text_preceding_source = wprss_get_general_setting('text_preceding_source');
|
88 |
+
$text_preceding_source = ltrim( __( $text_preceding_source, WPRSS_TEXT_DOMAIN ) . ' ' );
|
89 |
+
|
90 |
+
$text_preceding_date = wprss_get_general_setting('text_preceding_date');
|
91 |
+
$text_preceding_date = ltrim( __( $text_preceding_date, WPRSS_TEXT_DOMAIN ) . ' ' );
|
92 |
+
|
93 |
+
do_action( 'wprss_get_post_data' );
|
94 |
+
|
95 |
+
$meta = $extra_options;
|
96 |
+
$extra_meta = apply_filters( 'wprss_template_extra_meta', $meta, $args, $ID );
|
97 |
+
|
98 |
+
///////////////////////////////////////////////////////////////
|
99 |
+
// BEGIN TEMPLATE
|
100 |
+
|
101 |
+
// Prepare the output
|
102 |
+
$output = '';
|
103 |
+
// Begin output buffering
|
104 |
+
ob_start();
|
105 |
+
// Print the links before
|
106 |
+
echo $link_before;
|
107 |
+
|
108 |
+
// The Title
|
109 |
+
$item_title = wprss_link_display( $feed_item_title_link, $feed_item_title, wprss_get_general_setting('title_link') );
|
110 |
+
$item_title = apply_filters('wprss_item_title', $item_title, $feed_item_title_link, $feed_item_title, wprss_get_general_setting('title_link'));
|
111 |
+
echo $item_title;
|
112 |
+
|
113 |
+
do_action( 'wprss_after_feed_item_title', $extra_meta, $display_settings, $ID );
|
114 |
+
|
115 |
+
// FEED ITEM META
|
116 |
+
echo '<div class="wprss-feed-meta">';
|
117 |
+
|
118 |
+
// SOURCE
|
119 |
+
if ( wprss_get_general_setting('source_enable') == 1 ) {
|
120 |
+
echo '<span class="feed-source">';
|
121 |
+
$source_link_text = apply_filters('wprss_item_source_link', wprss_link_display( $source_url, $source_name, $source_link ) );
|
122 |
+
$source_link_text = $text_preceding_source . $source_link_text;
|
123 |
+
echo $source_link_text;
|
124 |
+
echo '</span>';
|
125 |
+
}
|
126 |
+
|
127 |
+
// DATE
|
128 |
+
if ( wprss_get_general_setting('date_enable') == 1 ) {
|
129 |
+
echo '<span class="feed-date">';
|
130 |
+
$date_text = apply_filters( 'wprss_item_date', $date );
|
131 |
+
$date_text = $text_preceding_date . $date_text;
|
132 |
+
echo $date_text;
|
133 |
+
echo '</span>';
|
134 |
+
}
|
135 |
+
|
136 |
+
// AUTHOR
|
137 |
+
$author = get_post_meta( $ID, 'wprss_item_author', TRUE );
|
138 |
+
if ( wprss_get_general_setting('authors_enable') == 1 && $author !== NULL && is_string( $author ) && $author !== '' ) {
|
139 |
+
echo '<span class="feed-author">';
|
140 |
+
$author_text = apply_filters( 'wprss_item_author', $author );
|
141 |
+
$author_prefix_text = apply_filters( 'wprss_author_prefix_text', 'By' );
|
142 |
+
_e( $author_prefix_text, WPRSS_TEXT_DOMAIN );
|
143 |
+
echo ' ' . $author_text;
|
144 |
+
echo '</span>';
|
145 |
+
}
|
146 |
+
|
147 |
+
echo '</div>';
|
148 |
+
|
149 |
+
// TIME AGO
|
150 |
+
if ( wprss_get_general_setting('date_enable') == 1 && wprss_get_general_setting('time_ago_format_enable') == 1 ) {
|
151 |
+
$time_ago = human_time_diff( $timestamp, time() );
|
152 |
+
echo '<div class="wprss-time-ago">';
|
153 |
+
$time_ago_text = apply_filters( 'wprss_item_time_ago', $time_ago );
|
154 |
+
printf( __( '%1$s ago', WPRSS_TEXT_DOMAIN ), $time_ago_text );
|
155 |
+
echo '</div>';
|
156 |
+
}
|
157 |
+
|
158 |
+
// END TEMPLATE - Retrieve buffered output
|
159 |
+
$output .= ob_get_clean();
|
160 |
+
$output = apply_filters( 'wprss_single_feed_output', $output, $permalink );
|
161 |
+
$output .= "$link_after";
|
162 |
+
|
163 |
+
// Print the output
|
164 |
+
return $output;
|
165 |
+
}
|
166 |
+
|
167 |
+
|
168 |
/**
|
169 |
* Retrieve settings and prepare them for use in the display function
|
170 |
*
|
345 |
|
346 |
// FOR EACH ITEM
|
347 |
while ( $feed_items->have_posts() ) {
|
348 |
+
// Get the item
|
349 |
$feed_items->the_post();
|
350 |
+
// Add the output
|
351 |
+
$output .= wprss_render_feed_item();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
352 |
}
|
353 |
|
354 |
// OUTPUT LINKS AFTER LIST OF FEED ITEMS
|
includes/feed-importing.php
CHANGED
@@ -23,7 +23,11 @@
|
|
23 |
*/
|
24 |
function wprss_fetch_insert_single_feed_items( $feed_ID ) {
|
25 |
wprss_log_obj( 'Starting import of feed', $feed_ID, null, WPRSS_LOG_LEVEL_INFO );
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
// Check if the feed source is active.
|
28 |
if ( wprss_is_feed_source_active( $feed_ID ) === FALSE && wprss_feed_source_force_next_fetch( $feed_ID ) === FALSE ) {
|
29 |
// If it is not active ( paused ), return without fetching the feed items.
|
@@ -36,7 +40,7 @@
|
|
36 |
wprss_log( 'Force feed flag removed', null, WPRSS_LOG_LEVEL_SYSTEM );
|
37 |
}
|
38 |
|
39 |
-
|
40 |
wprss_log_obj( 'Start of import time updated', date( 'Y-m-d H:i:s', $start_of_update), null, WPRSS_LOG_LEVEL_SYSTEM );
|
41 |
|
42 |
// Get the feed source URL from post meta, and filter it
|
@@ -141,6 +145,7 @@
|
|
141 |
}
|
142 |
|
143 |
update_post_meta( $feed_ID, 'wprss_last_update', $last_update_time = time() );
|
|
|
144 |
wprss_log_obj( 'Last import time updated', $last_update_time, null, WPRSS_LOG_LEVEL_SYSTEM );
|
145 |
|
146 |
// Insert the items into the db
|
@@ -160,7 +165,7 @@
|
|
160 |
wprss_log( 'Next update rescheduled', null, WPRSS_LOG_LEVEL_SYSTEM );
|
161 |
}
|
162 |
|
163 |
-
|
164 |
wprss_log_obj( 'Import complete', $feed_ID, __FUNCTION__, WPRSS_LOG_LEVEL_INFO );
|
165 |
}
|
166 |
|
@@ -227,8 +232,9 @@
|
|
227 |
}
|
228 |
}
|
229 |
|
230 |
-
// Set timeout
|
231 |
-
$
|
|
|
232 |
|
233 |
//$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
|
234 |
$feed->enable_cache( FALSE );
|
@@ -248,7 +254,8 @@
|
|
248 |
// Convert the feed error into a WP_Error, if applicable
|
249 |
if ( $feed->error() ) {
|
250 |
if ( $source !== NULL ) {
|
251 |
-
|
|
|
252 |
}
|
253 |
return new WP_Error( 'simplepie-error', $feed->error() );
|
254 |
}
|
@@ -436,7 +443,14 @@
|
|
436 |
// Check if newly fetched item already present in existing feed items,
|
437 |
// if not insert it into wp_posts and insert post meta.
|
438 |
if ( ! ( in_array( $permalink, $existing_permalinks ) ) ) {
|
439 |
-
wprss_log(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
440 |
|
441 |
// Apply filters that determine if the feed item should be inserted into the DB or not.
|
442 |
$item = apply_filters( 'wprss_insert_post_item_conditionals', $item, $feed_ID, $permalink );
|
@@ -501,7 +515,7 @@
|
|
501 |
wprss_log_obj( 'Item imported', $inserted_ID, null, WPRSS_LOG_LEVEL_INFO );
|
502 |
}
|
503 |
else {
|
504 |
-
update_post_meta( $source,
|
505 |
wprss_log_obj( 'Failed to insert post', $feed_item, 'wprss_items_insert_post > wp_insert_post' );
|
506 |
}
|
507 |
}
|
@@ -544,6 +558,29 @@
|
|
544 |
}
|
545 |
|
546 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
547 |
/**
|
548 |
* Fetches all feed items from all feed sources.
|
549 |
* Iteratively calls 'wprss_fetch_insert_single_feed_items' for all feed sources.
|
@@ -556,6 +593,7 @@
|
|
556 |
* @since 3.0
|
557 |
*/
|
558 |
function wprss_fetch_insert_all_feed_items( $all = TRUE ) {
|
|
|
559 |
// Get all feed sources
|
560 |
$feed_sources = wprss_get_all_feed_sources();
|
561 |
|
@@ -586,3 +624,30 @@
|
|
586 |
function wprss_fetch_insert_all_feed_items_from_cron() {
|
587 |
wprss_fetch_insert_all_feed_items( FALSE );
|
588 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
*/
|
24 |
function wprss_fetch_insert_single_feed_items( $feed_ID ) {
|
25 |
wprss_log_obj( 'Starting import of feed', $feed_ID, null, WPRSS_LOG_LEVEL_INFO );
|
26 |
+
|
27 |
+
global $wprss_importing_feed;
|
28 |
+
$wprss_importing_feed = $feed_ID;
|
29 |
+
register_shutdown_function( 'wprss_detect_exec_timeout' );
|
30 |
+
|
31 |
// Check if the feed source is active.
|
32 |
if ( wprss_is_feed_source_active( $feed_ID ) === FALSE && wprss_feed_source_force_next_fetch( $feed_ID ) === FALSE ) {
|
33 |
// If it is not active ( paused ), return without fetching the feed items.
|
40 |
wprss_log( 'Force feed flag removed', null, WPRSS_LOG_LEVEL_SYSTEM );
|
41 |
}
|
42 |
|
43 |
+
$start_of_update = wprss_flag_feed_as_updating( $feed_ID );
|
44 |
wprss_log_obj( 'Start of import time updated', date( 'Y-m-d H:i:s', $start_of_update), null, WPRSS_LOG_LEVEL_SYSTEM );
|
45 |
|
46 |
// Get the feed source URL from post meta, and filter it
|
145 |
}
|
146 |
|
147 |
update_post_meta( $feed_ID, 'wprss_last_update', $last_update_time = time() );
|
148 |
+
update_post_meta( $feed_ID, 'wprss_last_update_items', 0 );
|
149 |
wprss_log_obj( 'Last import time updated', $last_update_time, null, WPRSS_LOG_LEVEL_SYSTEM );
|
150 |
|
151 |
// Insert the items into the db
|
165 |
wprss_log( 'Next update rescheduled', null, WPRSS_LOG_LEVEL_SYSTEM );
|
166 |
}
|
167 |
|
168 |
+
wprss_flag_feed_as_idle( $feed_ID );
|
169 |
wprss_log_obj( 'Import complete', $feed_ID, __FUNCTION__, WPRSS_LOG_LEVEL_INFO );
|
170 |
}
|
171 |
|
232 |
}
|
233 |
}
|
234 |
|
235 |
+
// Set timeout limit
|
236 |
+
$fetch_time_limit = wprss_get_feed_fetch_time_limit();
|
237 |
+
$feed->set_timeout( $fetch_time_limit );
|
238 |
|
239 |
//$feed->set_cache_duration( apply_filters( 'wp_feed_cache_transient_lifetime', 12 * HOUR_IN_SECONDS, $url ) );
|
240 |
$feed->enable_cache( FALSE );
|
254 |
// Convert the feed error into a WP_Error, if applicable
|
255 |
if ( $feed->error() ) {
|
256 |
if ( $source !== NULL ) {
|
257 |
+
$msg = sprintf( __( 'Failed to fetch the RSS feed. Error: %s', WPRSS_TEXT_DOMAIN ), $feed->error() );
|
258 |
+
update_post_meta( $source, 'wprss_error_last_import', $msg );
|
259 |
}
|
260 |
return new WP_Error( 'simplepie-error', $feed->error() );
|
261 |
}
|
443 |
// Check if newly fetched item already present in existing feed items,
|
444 |
// if not insert it into wp_posts and insert post meta.
|
445 |
if ( ! ( in_array( $permalink, $existing_permalinks ) ) ) {
|
446 |
+
wprss_log( "Importing (unique) feed item (Source: $feed_ID)", null, WPRSS_LOG_LEVEL_INFO );
|
447 |
+
|
448 |
+
// Extend the importing time and refresh the feed's updating flag to reflect that it is active
|
449 |
+
$extend_time = wprss_flag_feed_as_updating( $feed_ID );
|
450 |
+
$extend_time_f = date( 'Y-m-d H:i:s', $extend_time );
|
451 |
+
$time_limit = wprss_get_item_import_time_limit();
|
452 |
+
wprss_log( "Extended execution time limit by {$time_limit}. (Current Time: {$extend_time_f})", null, WPRSS_LOG_LEVEL_INFO );
|
453 |
+
set_time_limit( $time_limit );
|
454 |
|
455 |
// Apply filters that determine if the feed item should be inserted into the DB or not.
|
456 |
$item = apply_filters( 'wprss_insert_post_item_conditionals', $item, $feed_ID, $permalink );
|
515 |
wprss_log_obj( 'Item imported', $inserted_ID, null, WPRSS_LOG_LEVEL_INFO );
|
516 |
}
|
517 |
else {
|
518 |
+
update_post_meta( $source, 'wprss_error_last_import', 'An error occurred while inserting a feed item into the database.' );
|
519 |
wprss_log_obj( 'Failed to insert post', $feed_item, 'wprss_items_insert_post > wp_insert_post' );
|
520 |
}
|
521 |
}
|
558 |
}
|
559 |
|
560 |
|
561 |
+
/**
|
562 |
+
* Returns the time limit for the importing of a single feed item.
|
563 |
+
* The value if filtered through 'wprss_item_import_time_limit'. The default value is WPRSS_ITEM_IMPORT_TIME_LIMIT.
|
564 |
+
*
|
565 |
+
* @since 4.6.6
|
566 |
+
* @return int The maximum amount of seconds allowed for a single feed item to import.
|
567 |
+
*/
|
568 |
+
function wprss_get_item_import_time_limit() {
|
569 |
+
return apply_filters( 'wprss_item_import_time_limit', WPRSS_ITEM_IMPORT_TIME_LIMIT );
|
570 |
+
}
|
571 |
+
|
572 |
+
/**
|
573 |
+
* Returns the time limit for a feed fetch operation.
|
574 |
+
* The value if filtered through 'wprss_feed_fetch_time_limit'. The default value is WPRSS_FEED_FETCH_TIME_LIMIT.
|
575 |
+
*
|
576 |
+
* @since 4.6.6
|
577 |
+
* @return int The maximum amount of seconds allowed for an RSS feed XML document to be fetched.
|
578 |
+
*/
|
579 |
+
function wprss_get_feed_fetch_time_limit() {
|
580 |
+
return apply_filters( 'wprss_feed_fetch_time_limit', WPRSS_FEED_FETCH_TIME_LIMIT );
|
581 |
+
}
|
582 |
+
|
583 |
+
|
584 |
/**
|
585 |
* Fetches all feed items from all feed sources.
|
586 |
* Iteratively calls 'wprss_fetch_insert_single_feed_items' for all feed sources.
|
593 |
* @since 3.0
|
594 |
*/
|
595 |
function wprss_fetch_insert_all_feed_items( $all = TRUE ) {
|
596 |
+
wprss_log( 'Importing from all sources...', __FUNCTION__, WPRSS_LOG_LEVEL_SYSTEM );
|
597 |
// Get all feed sources
|
598 |
$feed_sources = wprss_get_all_feed_sources();
|
599 |
|
624 |
function wprss_fetch_insert_all_feed_items_from_cron() {
|
625 |
wprss_fetch_insert_all_feed_items( FALSE );
|
626 |
}
|
627 |
+
|
628 |
+
|
629 |
+
/**
|
630 |
+
* Shutdown function for detecting if the PHP script reaches the maximum execution time limit
|
631 |
+
* while importing a feed.
|
632 |
+
*
|
633 |
+
* @since 4.6.6
|
634 |
+
*/
|
635 |
+
function wprss_detect_exec_timeout() {
|
636 |
+
// Get last error
|
637 |
+
if ( $error = error_get_last() ){
|
638 |
+
// Check if it is an E_ERROR and if it is a max exec time limit error
|
639 |
+
if ( $error['type'] === E_ERROR && stripos( $error['message'], 'maximum execution' ) === 0 ) {
|
640 |
+
// If the importing process was running
|
641 |
+
if ( array_key_exists( 'wprss_importing_feed', $GLOBALS ) && $GLOBALS['wprss_importing_feed'] !== NULL ) {
|
642 |
+
// Get the ID of the feed that was importing
|
643 |
+
$feed_ID = $GLOBALS['wprss_importing_feed'];
|
644 |
+
// Perform clean up
|
645 |
+
wprss_flag_feed_as_idle( $feed_ID );
|
646 |
+
$msg = sprintf( __( 'The PHP script timed out while importing an item from this feed, after %d seconds.', WPRSS_TEXT_DOMAIN ), wprss_get_item_import_time_limit() );
|
647 |
+
update_post_meta( $feed_ID, 'wprss_error_last_import', $msg );
|
648 |
+
// Log the error
|
649 |
+
wprss_log( 'The PHP script timed out while importing feed #' . $feed_ID, NULL, WPRSS_LOG_LEVEL_ERROR );
|
650 |
+
}
|
651 |
+
}
|
652 |
+
}
|
653 |
+
}
|
includes/feed-processing.php
CHANGED
@@ -1,4 +1,7 @@
|
|
1 |
<?php
|
|
|
|
|
|
|
2 |
/**
|
3 |
* Feed processing related functions
|
4 |
*
|
@@ -228,7 +231,7 @@
|
|
228 |
*/
|
229 |
function wprss_update_feed_meta( $meta_id, $post_id, $meta_key, $meta_value ) {
|
230 |
$post = get_post( $post_id );
|
231 |
-
if ( $post->post_status === 'publish' && $post->post_type === 'wprss_feed' ) {
|
232 |
if ( $meta_key === 'wprss_url' )
|
233 |
wprss_change_fb_url( $post_id, $meta_value );
|
234 |
}
|
@@ -302,6 +305,7 @@
|
|
302 |
* @since 3.0
|
303 |
*/
|
304 |
function wprss_delete_all_feed_items() {
|
|
|
305 |
$args = array(
|
306 |
'post_type' => 'wprss_feed_item',
|
307 |
'cache_results' => false, // Disable caching, used for one-off queries
|
@@ -310,16 +314,37 @@
|
|
310 |
'posts_per_page' => -1,
|
311 |
);
|
312 |
|
313 |
-
//$feed_items = new WP_Query( $args );
|
314 |
-
|
315 |
$feed_item_ids = get_posts( $args );
|
316 |
foreach( $feed_item_ids as $feed_item_id ) {
|
317 |
$purge = wp_delete_post( $feed_item_id, true ); // delete the feed item, skipping trash
|
318 |
}
|
319 |
wp_reset_postdata();
|
|
|
|
|
320 |
}
|
321 |
|
322 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
323 |
/**
|
324 |
* Returns whether or not the feed source is updating.
|
325 |
*
|
@@ -328,19 +353,39 @@
|
|
328 |
*
|
329 |
*/
|
330 |
function wprss_is_feed_source_updating( $id ) {
|
|
|
331 |
$is_updating_meta = get_post_meta( $id, 'wprss_feed_is_updating', TRUE );
|
332 |
-
|
|
|
333 |
if ( $is_updating_meta === '' ) {
|
|
|
334 |
return FALSE;
|
335 |
}
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
return FALSE;
|
342 |
}
|
343 |
|
|
|
344 |
return TRUE;
|
345 |
}
|
346 |
|
@@ -567,8 +612,20 @@
|
|
567 |
*/
|
568 |
function wprss_feed_reset() {
|
569 |
wp_schedule_single_event( time(), 'wprss_delete_all_feed_items_hook' );
|
570 |
-
|
571 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
|
573 |
|
574 |
/**
|
1 |
<?php
|
2 |
+
|
3 |
+
define( 'WPRSS_TRANSIENT_NAME_IS_REIMPORTING', 'is_reimporting' );
|
4 |
+
|
5 |
/**
|
6 |
* Feed processing related functions
|
7 |
*
|
231 |
*/
|
232 |
function wprss_update_feed_meta( $meta_id, $post_id, $meta_key, $meta_value ) {
|
233 |
$post = get_post( $post_id );
|
234 |
+
if ( $post !== NULL && $post->post_status === 'publish' && $post->post_type === 'wprss_feed' ) {
|
235 |
if ( $meta_key === 'wprss_url' )
|
236 |
wprss_change_fb_url( $post_id, $meta_value );
|
237 |
}
|
305 |
* @since 3.0
|
306 |
*/
|
307 |
function wprss_delete_all_feed_items() {
|
308 |
+
wprss_log( sprintf( 'Deleting all feed items...'), __FUNCTION__, WPRSS_LOG_LEVEL_SYSTEM );
|
309 |
$args = array(
|
310 |
'post_type' => 'wprss_feed_item',
|
311 |
'cache_results' => false, // Disable caching, used for one-off queries
|
314 |
'posts_per_page' => -1,
|
315 |
);
|
316 |
|
|
|
|
|
317 |
$feed_item_ids = get_posts( $args );
|
318 |
foreach( $feed_item_ids as $feed_item_id ) {
|
319 |
$purge = wp_delete_post( $feed_item_id, true ); // delete the feed item, skipping trash
|
320 |
}
|
321 |
wp_reset_postdata();
|
322 |
+
wprss_log( sprintf( 'All feed items deleted: %1$d', count($feed_item_ids) ), __FUNCTION__, WPRSS_LOG_LEVEL_INFO );
|
323 |
+
do_action('wprss_delete_all_feed_items_after', $feed_item_ids);
|
324 |
}
|
325 |
|
326 |
|
327 |
+
/**
|
328 |
+
* Marks the feed source as 'updating' (importing).
|
329 |
+
*
|
330 |
+
* @since 4.6.6
|
331 |
+
* @return int The time value set in the 'updating' meta field
|
332 |
+
*/
|
333 |
+
function wprss_flag_feed_as_updating( $feed_ID ) {
|
334 |
+
update_post_meta( $feed_ID, 'wprss_feed_is_updating', $start_time = time() );
|
335 |
+
return $start_time;
|
336 |
+
}
|
337 |
+
|
338 |
+
/**
|
339 |
+
* Marks the feed source as 'idle' (not importing).
|
340 |
+
*
|
341 |
+
* @since 4.6.6
|
342 |
+
*/
|
343 |
+
function wprss_flag_feed_as_idle( $feed_ID ) {
|
344 |
+
delete_post_meta( $feed_ID, 'wprss_feed_is_updating' );
|
345 |
+
}
|
346 |
+
|
347 |
+
|
348 |
/**
|
349 |
* Returns whether or not the feed source is updating.
|
350 |
*
|
353 |
*
|
354 |
*/
|
355 |
function wprss_is_feed_source_updating( $id ) {
|
356 |
+
// Get the 'updating' meta field
|
357 |
$is_updating_meta = get_post_meta( $id, 'wprss_feed_is_updating', TRUE );
|
358 |
+
|
359 |
+
// Check if the feed has the 'updating' meta field set
|
360 |
if ( $is_updating_meta === '' ) {
|
361 |
+
// If not, then the feed is not updating
|
362 |
return FALSE;
|
363 |
}
|
364 |
+
|
365 |
+
// Get the limit used for the feed
|
366 |
+
$limit = get_post_meta( $id, 'wprss_limit', true );
|
367 |
+
if ( $limit === '' || intval( $limit ) <= 0 ) {
|
368 |
+
$global_limit = wprss_get_general_setting('limit_feed_items_imported');
|
369 |
+
$limit = ( $global_limit === '' || intval( $global_limit ) <= 0 ) ? NULL : $global_limit;
|
370 |
+
}
|
371 |
+
|
372 |
+
// Calculate the allowed maximum time, based on the maximum number of items allowed to be
|
373 |
+
// imported from this source.
|
374 |
+
// If no limit is used, 60s (1min) is used.
|
375 |
+
$single_item_time_limit = wprss_get_item_import_time_limit();
|
376 |
+
$allowed_time = $limit === NULL ? 60 : $single_item_time_limit * intval( $limit );
|
377 |
+
|
378 |
+
// Calculate how many seconds have passed since the feed last signalled that it is updating
|
379 |
+
$diff = time() - $is_updating_meta;
|
380 |
+
|
381 |
+
// If the difference is greater than the allowed maximum amount of time, mark the feed as idle.
|
382 |
+
if ( $diff > $allowed_time ) {
|
383 |
+
wprss_flag_feed_as_idle( $id );
|
384 |
+
// Feed is not updating
|
385 |
return FALSE;
|
386 |
}
|
387 |
|
388 |
+
// Feed is updating
|
389 |
return TRUE;
|
390 |
}
|
391 |
|
612 |
*/
|
613 |
function wprss_feed_reset() {
|
614 |
wp_schedule_single_event( time(), 'wprss_delete_all_feed_items_hook' );
|
615 |
+
set_transient( WPRSS_TRANSIENT_NAME_IS_REIMPORTING, true );
|
616 |
}
|
617 |
+
|
618 |
+
|
619 |
+
|
620 |
+
function wprss_schedule_reimport_all($deleted_ids) {
|
621 |
+
if( !get_transient( WPRSS_TRANSIENT_NAME_IS_REIMPORTING ) )
|
622 |
+
return;
|
623 |
+
|
624 |
+
wprss_log( 'Re-import scheduled...', __FUNCTION__, WPRSS_LOG_LEVEL_SYSTEM);
|
625 |
+
delete_transient( WPRSS_TRANSIENT_NAME_IS_REIMPORTING );
|
626 |
+
wprss_fetch_insert_all_feed_items( TRUE );
|
627 |
+
}
|
628 |
+
add_action('wprss_delete_all_feed_items_after', 'wprss_schedule_reimport_all');
|
629 |
|
630 |
|
631 |
/**
|
includes/libraries/EDD_licensing/EDD_SL_Plugin_Updater.php
CHANGED
@@ -7,14 +7,13 @@
|
|
7 |
* Allows plugins to use their own update API.
|
8 |
*
|
9 |
* @author Pippin Williamson
|
10 |
-
* @version 1.
|
11 |
*/
|
12 |
class EDD_SL_Plugin_Updater {
|
13 |
private $api_url = '';
|
14 |
private $api_data = array();
|
15 |
private $name = '';
|
16 |
private $slug = '';
|
17 |
-
private $did_check = false;
|
18 |
|
19 |
/**
|
20 |
* Class constructor.
|
@@ -35,7 +34,7 @@ class EDD_SL_Plugin_Updater {
|
|
35 |
$this->version = $_api_data['version'];
|
36 |
|
37 |
// Set up hooks.
|
38 |
-
|
39 |
add_action( 'admin_init', array( $this, 'show_changelog' ) );
|
40 |
}
|
41 |
|
@@ -69,10 +68,6 @@ class EDD_SL_Plugin_Updater {
|
|
69 |
*/
|
70 |
function check_update( $_transient_data ) {
|
71 |
|
72 |
-
if ( $this->did_check ) {
|
73 |
-
return $_transient_data;
|
74 |
-
}
|
75 |
-
|
76 |
if( ! is_object( $_transient_data ) ) {
|
77 |
$_transient_data = new stdClass;
|
78 |
}
|
@@ -122,7 +117,7 @@ class EDD_SL_Plugin_Updater {
|
|
122 |
}
|
123 |
|
124 |
// Remove our filter on the site transient
|
125 |
-
remove_filter( '
|
126 |
|
127 |
$update_cache = get_site_transient( 'update_plugins' );
|
128 |
|
@@ -144,7 +139,7 @@ class EDD_SL_Plugin_Updater {
|
|
144 |
}
|
145 |
|
146 |
// Restore our filter
|
147 |
-
add_filter( '
|
148 |
|
149 |
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
150 |
|
@@ -303,7 +298,7 @@ class EDD_SL_Plugin_Updater {
|
|
303 |
}
|
304 |
|
305 |
if( ! current_user_can( 'update_plugins' ) ) {
|
306 |
-
wp_die( __( 'You do not have permission to install plugin updates' ) );
|
307 |
}
|
308 |
|
309 |
$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
|
7 |
* Allows plugins to use their own update API.
|
8 |
*
|
9 |
* @author Pippin Williamson
|
10 |
+
* @version 1.5
|
11 |
*/
|
12 |
class EDD_SL_Plugin_Updater {
|
13 |
private $api_url = '';
|
14 |
private $api_data = array();
|
15 |
private $name = '';
|
16 |
private $slug = '';
|
|
|
17 |
|
18 |
/**
|
19 |
* Class constructor.
|
34 |
$this->version = $_api_data['version'];
|
35 |
|
36 |
// Set up hooks.
|
37 |
+
$this->init();
|
38 |
add_action( 'admin_init', array( $this, 'show_changelog' ) );
|
39 |
}
|
40 |
|
68 |
*/
|
69 |
function check_update( $_transient_data ) {
|
70 |
|
|
|
|
|
|
|
|
|
71 |
if( ! is_object( $_transient_data ) ) {
|
72 |
$_transient_data = new stdClass;
|
73 |
}
|
117 |
}
|
118 |
|
119 |
// Remove our filter on the site transient
|
120 |
+
remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
|
121 |
|
122 |
$update_cache = get_site_transient( 'update_plugins' );
|
123 |
|
139 |
}
|
140 |
|
141 |
// Restore our filter
|
142 |
+
add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
|
143 |
|
144 |
if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
|
145 |
|
298 |
}
|
299 |
|
300 |
if( ! current_user_can( 'update_plugins' ) ) {
|
301 |
+
wp_die( __( 'You do not have permission to install plugin updates' ), __( 'Error', 'edd_sl' ), array( 'response' => 401 ) );
|
302 |
}
|
303 |
|
304 |
$response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
|
includes/shortcodes.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
*
|
5 |
* @since 1.0
|
6 |
*/
|
7 |
-
function wprss_shortcode( $atts ) {
|
8 |
|
9 |
//Enqueue scripts / styles
|
10 |
wp_enqueue_script( 'jquery.colorbox-min', WPRSS_JS . 'jquery.colorbox-min.js', array( 'jquery' ) );
|
@@ -32,3 +32,34 @@
|
|
32 |
// Register shortcodes
|
33 |
add_shortcode( 'wp_rss_aggregator', 'wprss_shortcode');
|
34 |
add_shortcode( 'wp-rss-aggregator', 'wprss_shortcode');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
*
|
5 |
* @since 1.0
|
6 |
*/
|
7 |
+
function wprss_shortcode( $atts = array() ) {
|
8 |
|
9 |
//Enqueue scripts / styles
|
10 |
wp_enqueue_script( 'jquery.colorbox-min', WPRSS_JS . 'jquery.colorbox-min.js', array( 'jquery' ) );
|
32 |
// Register shortcodes
|
33 |
add_shortcode( 'wp_rss_aggregator', 'wprss_shortcode');
|
34 |
add_shortcode( 'wp-rss-aggregator', 'wprss_shortcode');
|
35 |
+
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Handles the shortcode used for single feed items.
|
39 |
+
*
|
40 |
+
* @since 4.6.6
|
41 |
+
*/
|
42 |
+
function wprss_shortcode_single( $atts = array() ) {
|
43 |
+
if ( empty( $atts ) ) return;
|
44 |
+
$id = empty( $atts['id'] ) ? FALSE : $atts['id'];
|
45 |
+
if ( $id === FALSE || get_post_type( $id ) !== 'wprss_feed_item' || ( $item = get_post( $id ) ) === FALSE ) {
|
46 |
+
return '';
|
47 |
+
}
|
48 |
+
//Enqueue scripts / styles
|
49 |
+
wp_enqueue_script( 'jquery.colorbox-min', WPRSS_JS . 'jquery.colorbox-min.js', array( 'jquery' ) );
|
50 |
+
wp_enqueue_script( 'wprss_custom', WPRSS_JS . 'custom.js', array( 'jquery', 'jquery.colorbox-min' ) );
|
51 |
+
|
52 |
+
$general_settings = get_option( 'wprss_settings_general' );
|
53 |
+
|
54 |
+
if( ! $general_settings['styles_disable'] == 1 ) {
|
55 |
+
wp_enqueue_style( 'colorbox', WPRSS_CSS . 'colorbox.css', array(), '1.4.33' );
|
56 |
+
wp_enqueue_style( 'styles', WPRSS_CSS . 'styles.css', array(), '' );
|
57 |
+
}
|
58 |
+
setup_postdata( $item );
|
59 |
+
$output = wprss_render_feed_item( $id );
|
60 |
+
$output = apply_filters( 'wprss_shortcode_single_output', $output );
|
61 |
+
wp_reset_postdata();
|
62 |
+
return $output;
|
63 |
+
}
|
64 |
+
// Register the single feed item shortcode
|
65 |
+
add_shortcode( 'wp-rss-aggregator-feed-item', 'wprss_shortcode_single');
|
js/heartbeat.js
CHANGED
@@ -93,7 +93,7 @@
|
|
93 |
// Update the error icon
|
94 |
var errorsCol = row.find('td.column-errors');
|
95 |
var errorIcon = errorsCol.find('i.fa');
|
96 |
-
errorIcon.toggleClass( 'wprss-show', feed_source['errors'] );
|
97 |
}
|
98 |
|
99 |
};
|
93 |
// Update the error icon
|
94 |
var errorsCol = row.find('td.column-errors');
|
95 |
var errorIcon = errorsCol.find('i.fa');
|
96 |
+
errorIcon.toggleClass( 'wprss-show', feed_source['errors'] !== '' );
|
97 |
}
|
98 |
|
99 |
};
|
readme.txt
CHANGED
@@ -5,7 +5,7 @@ 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: 4.0
|
8 |
-
Stable tag: 4.6.
|
9 |
License: GPLv2 or later
|
10 |
The no.1 RSS feed importer for WordPress. Premium add-ons available for more functionality.
|
11 |
|
@@ -167,6 +167,13 @@ The full documentation section can be found on the [WP RSS Aggregator website](w
|
|
167 |
|
168 |
== Changelog ==
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
= 4.6.5 (2014-11-17) =
|
171 |
* Enhanced: Improved the logging.
|
172 |
* Enhanced: Improved the licensing fields.
|
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: 4.0
|
8 |
+
Stable tag: 4.6.6
|
9 |
License: GPLv2 or later
|
10 |
The no.1 RSS feed importer for WordPress. Premium add-ons available for more functionality.
|
11 |
|
167 |
|
168 |
== Changelog ==
|
169 |
|
170 |
+
= 4.6.6 (2014-12-06) =
|
171 |
+
* Enhanced: Added output layouts for feed sources and feed items.
|
172 |
+
* Enhanced: Updated EDD updater class to version 1.5.
|
173 |
+
* Enhanced: Added time limit extending to prevent script from exhausting its execution time limit while importing.
|
174 |
+
* Fixed bug: The "Delete and Re-import" button was deleting items but not re-importing.
|
175 |
+
* Fixed bug: Non-object errors when a feed source is deleted while importing.
|
176 |
+
|
177 |
= 4.6.5 (2014-11-17) =
|
178 |
* Enhanced: Improved the logging.
|
179 |
* Enhanced: Improved the licensing fields.
|
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.6.
|
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.6.
|
33 |
* @since 1.0
|
34 |
* @author Jean Galea <info@wprssaggregator.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.6.
|
47 |
|
48 |
// Set the database version number of the plugin.
|
49 |
if( !defined( 'WPRSS_DB_VERSION' ) )
|
@@ -98,6 +98,15 @@
|
|
98 |
define( 'WPRSS_TEXT_DOMAIN', 'wprss' );
|
99 |
}
|
100 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
/**
|
102 |
* Load required files.
|
103 |
*/
|
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.6.6
|
7 |
Author: Jean Galea
|
8 |
Author URI: http://www.wprssaggregator.com
|
9 |
License: GPLv2
|
29 |
|
30 |
/**
|
31 |
* @package WPRSSAggregator
|
32 |
+
* @version 4.6.6
|
33 |
* @since 1.0
|
34 |
* @author Jean Galea <info@wprssaggregator.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.6.6', true );
|
47 |
|
48 |
// Set the database version number of the plugin.
|
49 |
if( !defined( 'WPRSS_DB_VERSION' ) )
|
98 |
define( 'WPRSS_TEXT_DOMAIN', 'wprss' );
|
99 |
}
|
100 |
|
101 |
+
// Maximum time for the feed source to be fetched
|
102 |
+
if ( !defined( 'WPRSS_FEED_FETCH_TIME_LIMIT' ) ) {
|
103 |
+
define( 'WPRSS_FEED_FETCH_TIME_LIMIT', 30, TRUE );
|
104 |
+
}
|
105 |
+
// Maximum time for a single feed item to import
|
106 |
+
if ( !defined( 'WPRSS_ITEM_IMPORT_TIME_LIMIT' ) ) {
|
107 |
+
define( 'WPRSS_ITEM_IMPORT_TIME_LIMIT', 15, TRUE );
|
108 |
+
}
|
109 |
+
|
110 |
/**
|
111 |
* Load required files.
|
112 |
*/
|