/** * Method for when plugin deactivated */ static function deactivate() { Scheduler::remove(self::$cron_name); }
/** * Checks that the email supplied is correct and sets/resets the wp_cron event * * @param array $settings_array * @return array $settings_array */ public function validate_basic_options_section($settings_array = array()) { if (empty($settings_array['email_address']) || !is_email($settings_array['email_address'])) { $settings_array['email_address'] = ''; add_settings_error('email_address', 'invalid_email', __('Please enter a valid email address.', 'drafty-in-here'), 'error'); } if (empty($settings_array['drafty_frequency']) || !in_array($settings_array['drafty_frequency'], array('never', 'hourly', 'daily', 'weekly'))) { $settings_array['drafty_frequency'] = ''; add_settings_error('email_address', 'invalid_email', __('Please select how often we send emails.', 'drafty-in-here'), 'error'); } if ($settings_array['drafty_frequency'] != self::$options['drafty_frequency'] || false == Scheduler::next_sheduled(self::$cron_name)) { Scheduler::remove(self::$cron_name); // remove current if ('never' != $settings_array['drafty_frequency']) { Scheduler::add(self::$cron_name, $settings_array['drafty_frequency']); // add new time slot } } if (isset($settings_array['drafty_send_test']) && $settings_array['drafty_send_test'] == 1) { $this->cron_callback(true); } return $settings_array; }