• Resolved wordmax

    (@wordmax)


    We have about 15 feeds that are being updated every 30 minutes. There are many new items in the feeds regularly. When the site is checking/updating new items in feeds, it can take 5+ seconds for the site to load in the browser. Is there any way we can show some temporary pop up notice like, “wait a second while we check for the latest news?” that will show to people while the feeds are being updated and then the notice will go away after the feeds have been updated? Thanks

Viewing 1 replies (of 1 total)
  • Plugin Support Hendra Setiawan

    (@hendcorp)

    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.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.