• This is an automatic translation

    I am trying to delete the cache with a script, placed in the WP root. Code:

    ——————————

    <?Php
    
    require_once("wp-load.php");
    
    include_once('wp-admin/includes/plugin.php');
    if ( is_plugin_active( 'w3-total-cache/w3-total-cache.php' ) ) :
    	echo 'Plugin ACTIVE';
    	
    	// Clear all W3 Total Cache
    	$w3_plugin_totalcache->flush_all();
    	echo '<div><p>All <strong>W3 Total Cache</strong> caches successfully emptied.</p></div>';
    
    else :
    	echo 'Plugin DEACTIVATE !!!!!!!!!!!!!!';
    	
    endif;
    
    ?>

    ——————————

    … but I get the error:
    Plugin ACTIVE
    Fatal error: Call to a member function flush_all() on null in /home/zanclus6/public_html/cr_w3tc_clear_cache.php on line 10

    Thank you for the help, Claudio_

Viewing 4 replies - 1 through 4 (of 4 total)
  • Ashok

    (@bappidgreat)

    Hello @k15lmk98

    You can use just a simple function. So just call the function when you need to flush:

    
    w3tc_flush_all();
    

    It is the shortcut for varnish flush. There are some more functions too:

    
    w3tc_flush_post( $post_id );
    w3tc_flush_posts();
    w3tc_flush_url( $url );
    w3tc_pgcache_flush();
    

    You will find more in /wp-content/plugins/w3-total-cache/w3-total-cache-api.php file.

    Have a good day!

    Cheers
    Ash

    Thread Starter K15Lmk98

    (@k15lmk98)

    Thanks 1000+, Ash.

    Topic closed, Claudio_

    Hey guys i m using this plugin and it is working good but i dont know if we use cache then why its not calling the functions.php file of active theme.
    for example people from us can visit the site then they can see some other content and other visitor from rest of countries can see different content as well but due to cache i can not achieve these
    if do you have any idea then please let me know

    @bappidgreat

    Very useful, thank you.

    To flush the W3 Total Cache object cache, you can use this:

    w3tc_objectcache_flush();

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Delete cache via script’ is closed to new replies.