From 5b5bf7fbdcedccff98d93183557b6eeb03fa76b8 Mon Sep 17 00:00:00 2001 From: Peter Molnar Date: Mon, 24 Jun 2013 10:18:49 +0100 Subject: [PATCH] replaced wp-cron adding/removing method, 1.2 beta2 --- wp-ffpc-class.php | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/wp-ffpc-class.php b/wp-ffpc-class.php index a1a664c..f033707 100644 --- a/wp-ffpc-class.php +++ b/wp-ffpc-class.php @@ -185,10 +185,9 @@ if ( ! class_exists( 'WP_FFPC' ) ) { /* add filter for catching canonical redirects */ add_filter('redirect_canonical', 'wp_ffpc_redirect_callback', 10, 2); - if ( !wp_next_scheduled( self::precache_id ) && $this->options['precache_schedule'] != 'null' && $this->scheduled === false ) { - $this->scheduled = wp_schedule_event( time(), $this->options['precache_schedule'] , self::precache_id ); - } - else { + /* clean up schedule if needed */ + if ( !isset( $this->options['precache_schedule'] ) || $this->options['precache_schedule'] == 'null' ) { + $this->log ( 'CRON clearing event' ); wp_clear_scheduled_hook ( self::precache_id ); } @@ -750,6 +749,19 @@ if ( ! class_exists( 'WP_FFPC' ) ) { */ public function plugin_hook_options_save( $activating ) { + /* schedule cron if posted */ + $schedule = wp_get_schedule( self::precache_id ); + if ( $this->options['precache_schedule'] != 'null' ) { + /* clear all other schedules before adding a new in order to replace */ + wp_clear_scheduled_hook ( self::precache_id ); + $this->log ( __( 'Scheduling WP-CRON event', $this->plugin_constant ) ); + $this->scheduled = wp_schedule_event( time(), $this->options['precache_schedule'] , self::precache_id ); + } + elseif ( ( !isset($this->options['precache_schedule']) || $this->options['precache_schedule'] == 'null' ) && !empty( $schedule ) ) { + $this->log ( __('Clearing WP-CRON clearing event ' , $this->plugin_constant ) ); + wp_clear_scheduled_hook ( self::precache_id ); + } + /* flush the cache when news options are saved, not needed on activation */ if ( !$activating ) $this->backend->clear(); @@ -1109,6 +1121,12 @@ if ( ! class_exists( 'WP_FFPC' ) ) { break; } + $baseurl = get_blog_option ( $site, 'siteurl' ); + + if ( !strstr( $permalink, $baseurl ) ) { + $permalink = $baseurl . $permalink; + } + /* collect permalinks */ $links[ $permalink ] = true; @@ -1171,4 +1189,4 @@ if ( ! class_exists( 'WP_FFPC' ) ) { } } -?> \ No newline at end of file +?>