Ok I am really at a standstill on this.
Basically, I need to call a function for the Wordpress W3 Total Cache plugin as part of the cron job in crontab. I would like to automatically clear the entire page cache at night.
Here is the code that works fine in Wordpress, which I need to call:
if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); }
I am 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@example.com ', 'Automatic email', 'Hello, this is an automatically scheduled email from WordPress.'); if (function_exists('w3tc_pgcache_flush')) { w3tc_pgcache_flush(); } ?>
and command line:
php -q /path-to-file/flushtest.php
I used the wp_mail function to check and make sure that I am receiving something.
The script works fine, except that the page cache is never flushed. I receive an email and there are no errors in the log.
Any ideas?
Thank you for your help.
source share