/** * Activate WP Currencies. * * What happens when WP Currencies is activated. * * @since 1.4.0 */ public static function activate() { self::create_tables(); $cron = new Cron(); $cron->schedule_updates(); do_action('wp_currencies_activated'); }
/** * Updated option hook callback. * * @since 1.4.0 * * @param string $old_value * @param string $new_value */ public function updated_option($old_value, $new_value) { wp_clear_scheduled_hook('wp_currencies_update'); // Makes sure there's an API key (won't be able to tell if valid or not at this time). $api_key = isset($new_value['api_key']) ? $new_value['api_key'] : (isset($old_value['api_key']) ? $old_value['api_key'] : ''); if (!empty($api_key)) { $interval = isset($new_value['update_interval']) ? $new_value['update_interval'] : (isset($old_value['update_interval']) ? $old_value['update_interval'] : 'weekly'); $cron = new Cron(); $cron->schedule_updates($api_key, $interval); do_action('wp_currencies_rescheduled_update', time(), esc_attr($interval)); } }