Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /** Flush all caches of W3TC
- * Weekly basis
- */
- //add weekly shcedule to wp cron
- function dctit_cron_add_weekly( $schedules ) {
- //adds once weekly to the existing schedules.
- $schedules['weekly'] = array(
- 'interval' => 604800,
- 'display' => __( 'Once Weekly' )
- );
- return $schedules;
- }
- add_filter( 'cron_schedules', 'dctit_cron_add_weekly' );
- //flush W3TC Cache - all of them
- function dctit_flush_w3tc_cache() {
- if ( function_exists('w3tc_flush_all') ) {
- w3tc_flush_all();
- }
- }
- add_action( 'dctit_flush_w3tc_cache_hook', 'dctit_flush_w3tc_cache');
- //schedule cron event - weekly
- function dctit_flush_cache_event() {
- if ( ! wp_next_scheduled( 'dctit_flush_w3tc_cache_hook' ) ) {
- wp_schedule_event( time(), 'weekly', 'dctit_flush_w3tc_cache_hook' );
- }
- }
- add_action( 'wp', 'dctit_flush_cache_event' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement