• Resolved boyska

    (@boyska)


    I’d like to make a plugin of mine “compatible” with w3total cache. What I mean is that, when a certain event occurs (the admin does something), some pages caches need to be regenerated.

    So, I’d like to know if there was an action, a function or something else that I can call to let W3TC know that it has to purge all cache.
    (I know, I could just make the user go to ?page=w3tc_general&flush_all but I do not like much; furthermore, this will only work if the action is done by the admin, but not if the action is done by a visitor).

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter boyska

    (@boyska)

    After doing some research, I’ve seen that in lib/W3/PgCache.php there’s a function called “flush()” that just does what I need.

    However, it’s not “public”, but internal to an object. Plugin integration could be made easy with something like
    add_action('w3_page_flush_all', array( &$this, 'flush' ));

    this way, I could just call do_action('w3_page_flush_all') to have perfect integration with w3totalcache.

    You could now see this topic as a (simple) feature request one. I can (and would like to) provide a working patch for this, if you are willing to accept it.

    I’m not sure if thats what you are looking for, but I needed to clear the cache of a post from a plugin and found the following in the FAQ:

    // Purge the entire page cache:
    if (function_exists('w3tc_pgcache_flush')) {
    w3tc_pgcache_flush();
    }
    //Purge a single post / page by passing it's ID:
    if (function_exists('w3tc_pgcache_flush_post')) {
    w3tc_pgcache_flush_post($post_id);
    }

    Works for me…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Making a plugin compatible with w3total cache’ is closed to new replies.