Ok. I'm really stumped on this one.
Basically, I need to call a function for the Wordpress plugin W3 Total Cache as part of a cron job in crontab. I'd like to automatically clear the entire page cache nightly.
Here's the code that works fine within wordpress that I need to call:
if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } I'm currently using the following script:
#!/usr/bin/php <?php define('DOING_AJAX', true); define('WP_USE_THEMES', false); $_SERVER = array( "HTTP_HOST" => "http://example.com", "SERVER_NAME" => "http://example.com", "REQUEST_URI" => "/", "REQUEST_METHOD" => "GET" ); require_once('/path-to-file/wp-load.php'); wp_mail('[email protected]', 'Automatic email', 'Hello, this is an automatically scheduled email from WordPress.'); if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } ?> and the command line:
php -q /path-to-file/flushtest.php I used the wp_mail function to test and make sure I'm getting something.
The script is working fine except that the page cache is never flushed. I get the email and there aren't any errors in the log either.
Any ideas?
Thanks for your help.