• Resolved MarcGuay

    (@marcguay)


    Hello. According to the docs this is possible by using the wpo_purge_cache_hooks filter but I cannot get it to work. In my functions.php file:

    add_filter( 'wpo_purge_cache_hooks', function( $actions ) {
    $actions[] = 'save_post';
    $actions[] = 'wp_trash_post';
    return $actions;
    } );

    Also attempted this:

    add_action( 'registered_taxonomy', 'tr_purge_entire_cache_after_save_delete' );
    function tr_purge_entire_cache_after_save_delete() {
    add_filter( 'wpo_purge_cache_hooks', function( $actions ) {
    $actions[] = 'save_post';
    $actions[] = 'wp_trash_post';
    return $actions;
    } );
    }

    However it never seems to fire early enough. When I dump the $purge_on_action var in the setup_hooks function it never includes my new actions, indicating that the filter is not working. Any ideas?

    • This topic was modified 1 month, 2 weeks ago by MarcGuay.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author David Anderson

    (@davidanderson)

    Hi,

    WP-Optimize runs that filter upon plugin initialisation. Therefore, to make sure you are already hooked by that point, you should put the filter in an mu-plugin, since these run before plugins load. functions.php is much too late.

    David

    Thread Starter MarcGuay

    (@marcguay)

    Working, thank you!

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