• Hello everyone,

    It’s so important that the plugin offers a callback when the count finishes, so we can do something on the front-end like redirect or even show/hide some element on the page.

    A great idea is to provide that option only for devs by explaining the way to use on the documentation for example and become available on the dashboard somehow after plugin updates.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Leandro Berg

    (@leandroberg)

    Follow here my solution for this problem using the circular countdown (just remove the “type circular” option on PHP hook to apply the solution to all type of counters:

    PHP HOOK (functions.php)

    add_action('cbfccountdown_after_display', function($attr, $index){
    
        if($attr['type'] != 'circular') return;
        if($index != 1) return;
    
        wp_enqueue_script('countdown-after-finish', get_template_directory_uri() . '/js/countdown-after-finish.js', [], false, true);
    
    }, 99, 2);

    JS CODE (countdown-after-finish.js)

    (() => {
    
        let d = document;
        let el = d.querySelector("#cbfc-circular-countdown1");
    
        const observer = new MutationObserver(() => {
    
            let finished = true;
    
            el.querySelectorAll(".cbfc-circular-val").forEach(el => {
    
                if(el.innerHTML != 0) finished = false;
    
            });
    
            if(!finished) return;
    
            // do something here
    
        });
    
        observer.observe(el, {subtree: true, childList: true});
    
    })();
    • This reply was modified 3 years, 11 months ago by Leandro Berg.
    • This reply was modified 3 years, 11 months ago by Leandro Berg.
    • This reply was modified 3 years, 11 months ago by Leandro Berg.
    • This reply was modified 3 years, 11 months ago by Leandro Berg.
    Plugin Author Sabuj Kundu

    (@manchumahara)

    Hi,

    We will think about this. we know better way to this integration, like php hooks in wordpress it’s possible to implement js hooks which we implemented in few other plugin before. will try to add such in this plugin in next release.

    Thread Starter Leandro Berg

    (@leandroberg)

    Hey Sabuj hello,

    okay, until you do release that feature, maybe people can use my simple solution to achieve that.

    Best.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Callback on finish’ is closed to new replies.