Hi @wordmax
Thanks for reaching out to us!
It’s certainly possible to implement a temporary notification system like the one you described, though it will require some custom development. By leveraging the wprss_fetch_feed_before
and wprss_fetch_feed_after
hooks within the plugin, you can trigger actions before and after feed updates occur. This approach allows you to show a real-time update notification to users while feeds are being refreshed.
While custom development falls outside our standard support scope, I’m happy to provide an example to help you get started.
Here’s a basic example of how you might set up a notification system using AJAX and JavaScript. This code checks the update status and displays a temporary notice on the frontend when feeds are being refreshed. You can customize it to better suit your needs.
// Step 1: Trigger AJAX on feed update start and end
add_action('wprss_fetch_feed_before', function() {
update_option('feed_update_in_progress', true);
});
add_action('wprss_fetch_feed_after', function() {
delete_option('feed_update_in_progress');
});
// Step 2: Register AJAX endpoints for frontend to check feed update status
add_action('wp_ajax_check_feed_update', 'check_feed_update_status');
add_action('wp_ajax_nopriv_check_feed_update', 'check_feed_update_status');
function check_feed_update_status() {
$is_updating = get_option('feed_update_in_progress', false);
wp_send_json_success(['updating' => $is_updating]);
}
On the frontend, you can add this JavaScript to show a notification when feeds are updating:
(function($) {
function checkFeedUpdateStatus() {
$.ajax({
url: '<?php echo admin_url("admin-ajax.php"); ?>',
method: 'POST',
data: { action: 'check_feed_update' },
success: function(response) {
if (response.success && response.data.updating) {
if (!$('#feed-updating-notice').length) {
$('body').append('<div id="feed-updating-notice" style="position: fixed; bottom: 10px; left: 10px; background: yellow; padding: 10px; border: 1px solid black; z-index: 9999;">Feeds are currently updating, please wait...</div>');
}
} else {
$('#feed-updating-notice').remove();
}
}
});
}
// Run check every few seconds
setInterval(checkFeedUpdateStatus, 5000);
})(jQuery);
This code checks every few seconds whether the feed update is in progress and displays a notification accordingly. Feel free to use this as a starting point and tailor it as needed.