5, 'display'=>'debug'); $schedules['seconds_30'] = array('interval'=>30, 'display'=>'Bi-minutely'); $schedules['minutes_1'] = array('interval'=>60, 'display'=>'Once every 1 minute'); $schedules['minutes_2'] = array('interval'=>120, 'display'=>'Once every 2 minutes'); return $schedules; } function AGC_activate() { if (!wp_next_scheduled('AGC_cron_hook')) { wp_schedule_event(time(), 'minutes_2', 'AGC_cron_hook'); } AGC_create_mpk_address_table(); AGC_create_payment_table(); AGC_create_carousel_table(); } function AGC_deactivate() { wp_clear_scheduled_hook('AGC_cron_hook'); } function AGC_uninstall() { AGC_drop_mpk_address_table(); AGC_drop_payment_table(); AGC_drop_carousel_table(); } function AGC_add_gateways($methods) { $methods[] = 'AGC_Gateway'; return $methods; } function AGC_drop_mpk_address_table() { global $wpdb; $tableName = $wpdb->prefix . 'agc_electrum_addresses'; $query = "DROP TABLE IF EXISTS `$tableName`"; $wpdb->query($query); } function AGC_drop_payment_table() { global $wpdb; $tableName = $wpdb->prefix . 'agc_payments'; $query = "DROP TABLE IF EXISTS `$tableName`"; $wpdb->query($query); } function AGC_drop_carousel_table() { global $wpdb; $tableName = $wpdb->prefix . 'agc_carousel'; $query = "DROP TABLE IF EXISTS `$tableName`"; $wpdb->query($query); } function AGC_create_mpk_address_table() { global $wpdb; $tableName = $wpdb->prefix . 'agc_electrum_addresses'; $query = "CREATE TABLE IF NOT EXISTS `$tableName` ( `id` bigint(12) unsigned NOT NULL AUTO_INCREMENT, `mpk` char(255) NOT NULL, `mpk_index` bigint(20) NOT NULL DEFAULT '0', `address` char(255) NOT NULL, `cryptocurrency` char(12) NOT NULL, `status` char(24) NOT NULL DEFAULT 'error', `total_received` decimal( 16, 8 ) NOT NULL DEFAULT '0.00000000', `last_checked` bigint(20) NOT NULL DEFAULT '0', `assigned_at` bigint(20) NOT NULL DEFAULT '0', `order_id` bigint(10) NULL, `order_amount` decimal(16, 8) NOT NULL DEFAULT '0.00000000', PRIMARY KEY (`id`), UNIQUE KEY `address` (`address`), KEY `status` (`status`), KEY `mpk_index` (`mpk_index`), KEY `mpk` (`mpk`) );"; $wpdb->query($query); } function AGC_create_payment_table() { global $wpdb; $tableName = $wpdb->prefix . 'agc_payments'; $query = "CREATE TABLE IF NOT EXISTS `$tableName` ( `id` bigint(12) unsigned NOT NULL AUTO_INCREMENT, `address` char(255) NOT NULL, `cryptocurrency` char(12) NOT NULL, `status` char(24) NOT NULL DEFAULT 'error', `ordered_at` bigint(20) NOT NULL DEFAULT '0', `order_id` bigint(10) NOT NULL DEFAULT '0', `order_amount` decimal(32, 18) NOT NULL DEFAULT '0.000000000000000000', `tx_hash` char(255) NULL, PRIMARY KEY (`id`), UNIQUE KEY `unique_payment` (`order_id`, `order_amount`), KEY `status` (`status`) );"; $wpdb->query($query); } function AGC_create_carousel_table() { global $wpdb; $tableName = $wpdb->prefix . 'agc_carousel'; $query = "CREATE TABLE IF NOT EXISTS `$tableName` ( `id` bigint(12) unsigned NOT NULL AUTO_INCREMENT, `cryptocurrency` char(12) NOT NULL, `current_index` bigint(20) NOT NULL DEFAULT '0', `buffer` text NULL, PRIMARY KEY (`id`), UNIQUE KEY `cryptocurrency` (`cryptocurrency`) );"; $wpdb->query($query); require_once( plugin_basename( 'src/AGC_Cryptocurrency.php' ) ); require_once( plugin_basename( 'src/AGC_Carousel_Repo.php' ) ); require_once( plugin_basename( 'src/AGC_Util.php' ) ); require_once( plugin_basename( 'src/AGC_Cryptocurrencies.php' ) ); AGC_Carousel_Repo::init(); $cryptos = AGC_Cryptocurrencies::get(); $settings = get_option('woocommerce_agc_gateway_settings'); // if we find settings here we need to initialize the databases with the admin options for carousels if ($settings) { foreach ($cryptos as $crypto) { if (!$crypto->has_electrum()) { if (array_key_exists($crypto->get_id() . '_carousel_enabled', $settings)) { if ($settings[$crypto->get_id() . '_carousel_enabled'] === 'yes') { $buffer = array(); $buffer[] = $settings[$crypto->get_id() . '_address']; $buffer[] = $settings[$crypto->get_id() . '_address2']; $buffer[] = $settings[$crypto->get_id() . '_address3']; $buffer[] = $settings[$crypto->get_id() . '_address4']; $buffer[] = $settings[$crypto->get_id() . '_address5']; $repo = new AGC_Carousel_Repo(); $repo->set_buffer($crypto->get_id(), $buffer); } } } } } } add_filter('woocommerce_payment_gateways', 'AGC_add_gateways'); ?>