forked from recrypto/woocommerce-steem
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.php
More file actions
135 lines (110 loc) · 4.17 KB
/
Copy pathplugin.php
File metadata and controls
135 lines (110 loc) · 4.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
/**
* Plugin Name: WooCommerce Steem Payment Method
* Plugin URI: https://github.com/sagescrub/woocommerce-steem-payment-method
* Description: Accept Steem payments directly to your shop (Currencies: STEEM, SBD).
* Version: 1.1.6
* Author: <a href="https://steemit.com/@sagescrub">sagescrub</a>, <a href="https://steemit.com/@recrypto">ReCrypto</a>
* Requires at least: 4.1
* Tested up to: 5.2.2
*
* WC requires at least: 3.1
* WC tested up to: 3.6.5
*
* Text Domain: wc-steem-payment-method
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
define('WC_STEEM_VERSION', '1.1.6');
define('WC_STEEM_DIR_PATH', trailingslashit(plugin_dir_path(__FILE__)));
define('WC_STEEM_DIR_URL', trailingslashit(plugin_dir_url(__FILE__)));
register_activation_hook(__FILE__, 'wc_steem_activate');
register_deactivation_hook(__FILE__, 'wc_steem_deactivate');
/**
* Plugin activation
*
* @since 1.0.0
*/
function wc_steem_activate() {
do_action('wc_steem_activated');
$settings = get_option('woocommerce_wc_steem_settings', array());
if ( ! isset($settings['accepted_currencies'])) {
$settings['accepted_currencies'] = array(
'STEEM',
'SBD',
);
}
update_option('woocommerce_wc_steem_settings', $settings);
}
/**
* Plugin deactivation
*
* @since 1.0.0
*/
function wc_steem_deactivate() {
do_action('wc_steem_deactivated');
// Remove the options from the database
delete_option('wc_steem_fiat_to_fiat_exchange_rates');
delete_option('wc_steem_fiat_to_fiat_exchange_rates_last_successful_query_time');
delete_option('wc_steem_fiat_to_steem_exchange_rates');
delete_option('wc_steem_exchange_poloniex_USD_SBD');
delete_option('wc_steem_exchange_poloniex_USD_STEEM');
delete_option('wc_steem_exchange_bittrex_USD_SBD');
delete_option('wc_steem_exchange_bittrex_USD_STEEM');
delete_option('wc_steem_exchange_binance_USD_SBD');
delete_option('wc_steem_exchange_binance_USD_STEEM');
delete_option('wc_steem_exchange_binance_last_successful_query_time');
delete_option('wc_steem_exchange_bittrex_last_successful_query_time');
delete_option('wc_steem_exchange_poloniex_last_successful_query_time');
// Remove legacy rates option from pre 1.1.0 version of this plugin.
delete_option('wc_steem_rates');
}
/**
* Plugin init
*
* @since 1.0.0
*/
function wc_steem_init() {
/**
* Fires before including the files
*
* @since 1.0.0
*/
do_action('wc_steem_pre_init');
require_once(WC_STEEM_DIR_PATH . 'libraries/wordpress.php');
require_once(WC_STEEM_DIR_PATH . 'libraries/woocommerce.php');
require_once(WC_STEEM_DIR_PATH . 'includes/wc-steem-functions.php');
require_once(WC_STEEM_DIR_PATH . 'includes/class-wc-steem.php');
require_once(WC_STEEM_DIR_PATH . 'includes/class-wc-steem-transaction-transfer.php');
require_once(WC_STEEM_DIR_PATH . 'includes/class-wc-gateway-steem.php');
require_once(WC_STEEM_DIR_PATH . 'includes/wc-steem-handler.php');
require_once(WC_STEEM_DIR_PATH . 'includes/wc-steem-cart-handler.php');
require_once(WC_STEEM_DIR_PATH . 'includes/wc-steem-checkout-handler.php');
require_once(WC_STEEM_DIR_PATH . 'includes/wc-steem-order-handler.php');
require_once(WC_STEEM_DIR_PATH . 'includes/wc-steem-product-handler.php');
require_once(WC_STEEM_DIR_PATH . 'includes/wc-steem-rates-handler.php');
require_once(WC_STEEM_DIR_PATH . 'includes/exchanges/wc-steem-exchange.php');
require_once(WC_STEEM_DIR_PATH . 'includes/exchanges/wc-steem-exchange-poloniex.php');
require_once(WC_STEEM_DIR_PATH . 'includes/exchanges/wc-steem-exchange-bittrex.php');
require_once(WC_STEEM_DIR_PATH . 'includes/exchanges/wc-steem-exchange-binance.php');
/**
* Fires after including the files
*
* @since 1.0.0
*/
do_action('wc_steem_init');
}
add_action('plugins_loaded', 'wc_steem_init');
/**
* Register "WooCommerce Steem" as payment gateway in WooCommerce
*
* @since 1.0.0
*
* @param array $gateways
* @return array $gateways
*/
function wc_steem_register_gateway($gateways) {
$gateways[] = 'WC_Gateway_Steem';
return $gateways;
}
add_filter('woocommerce_payment_gateways', 'wc_steem_register_gateway');