Skip to content

Commit 51c830d

Browse files
authored
Merge pull request #6 from arianoangelo/master
v4.3.3
2 parents 7a4b03c + bb73d17 commit 51c830d

16 files changed

Lines changed: 834 additions & 545 deletions

CryptAPI.php

Lines changed: 52 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
Plugin Name: CryptAPI Payment Gateway for WooCommerce
55
Plugin URI: https://github.com/cryptapi/woocommerce-cryptapi
66
Description: Accept cryptocurrency payments on your WooCommerce website
7-
Version: 4.1
7+
Version: 4.3.3
88
Requires at least: 4.0
9-
Tested up to: 5.9.1
9+
Tested up to: 5.9.3
1010
WC requires at least: 2.4
1111
WC tested up to: 6.2
1212
Requires PHP: 5.5
@@ -17,19 +17,32 @@
1717

1818
require_once 'define.php';
1919

20-
function cryptapi_missing_wc_notice() {
21-
echo '<div class="error"><p><strong>' . sprintf( esc_html__( 'CryptAPI requires WooCommerce to be installed and active. You can download %s here.', 'cryptapi' ), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>' ) . '</strong></p></div>';
20+
function cryptapi_missing_wc_notice()
21+
{
22+
echo '<div class="error"><p><strong>' . sprintf(esc_html__('CryptAPI requires WooCommerce to be installed and active. You can download %s here.', 'cryptapi'), '<a href="https://woocommerce.com/" target="_blank">WooCommerce</a>') . '</strong></p></div>';
23+
}
24+
25+
function cryptapi_missing_bcmath()
26+
{
27+
echo '<div class="error"><p><strong>' . sprintf(esc_html__('CryptAPI requires PHP\'s BCMath extension. You can know more about it %s.', 'cryptapi'), '<a href="https://www.php.net/manual/en/book.bc.php" target="_blank">here</a>') . '</strong></p></div>';
2228
}
2329

2430

25-
function cryptapi_include_gateway($methods) {
31+
function cryptapi_include_gateway($methods)
32+
{
2633
$methods[] = 'WC_CryptAPI_Gateway';
2734
return $methods;
2835
}
2936

30-
function cryptapi_loader() {
31-
if ( ! class_exists( 'WooCommerce' ) ) {
32-
add_action( 'admin_notices', 'cryptapi_missing_wc_notice' );
37+
function cryptapi_loader()
38+
{
39+
if (!class_exists('WooCommerce')) {
40+
add_action('admin_notices', 'cryptapi_missing_wc_notice');
41+
return;
42+
}
43+
44+
if (!extension_loaded('bcmath')) {
45+
add_action('admin_notices', 'cryptapi_missing_bcmath');
3346
return;
3447
}
3548

@@ -41,16 +54,17 @@ function cryptapi_loader() {
4154

4255
cryptapi_include_dirs($dirs);
4356

44-
$mo_file_path = dirname(__FILE__) . '/languages/cryptapi-payment-gateway-for-woocommerce-'. get_locale() . '.mo';
45-
load_textdomain('cryptapi', $mo_file_path );
57+
$mo_file_path = dirname(__FILE__) . '/languages/cryptapi-payment-gateway-for-woocommerce-' . get_locale() . '.mo';
58+
load_textdomain('cryptapi', $mo_file_path);
4659

4760
$cryptapi = new WC_CryptAPI_Gateway();
4861
}
4962

5063
add_action('plugins_loaded', 'cryptapi_loader');
5164
add_filter('woocommerce_payment_gateways', 'cryptapi_include_gateway');
5265

53-
function cryptapi_include_dirs($dirs) {
66+
function cryptapi_include_dirs($dirs)
67+
{
5468

5569
foreach ($dirs as $dir) {
5670
$files = cryptapi_scan_dir($dir);
@@ -62,7 +76,8 @@ function cryptapi_include_dirs($dirs) {
6276
}
6377
}
6478

65-
function cryptapi_include_file($file) {
79+
function cryptapi_include_file($file)
80+
{
6681
if (cryptapi_is_includable($file)) {
6782
require_once $file;
6883
return true;
@@ -71,41 +86,46 @@ function cryptapi_include_file($file) {
7186
return false;
7287
}
7388

74-
function cryptapi_scan_dir($dir) {
75-
if(!is_dir($dir)) return false;
89+
function cryptapi_scan_dir($dir)
90+
{
91+
if (!is_dir($dir)) return false;
7692
$file = scandir($dir);
7793
unset($file[0], $file[1]);
7894

7995
return $file;
8096
}
8197

82-
function cryptapi_is_includable($file) {
98+
function cryptapi_is_includable($file)
99+
{
83100
if (!is_file($file)) return false;
84101
if (!file_exists($file)) return false;
85-
if (strtolower(substr($file,-3,3)) != 'php') return false;
102+
if (strtolower(substr($file, -3, 3)) != 'php') return false;
86103

87104
return true;
88105
}
89106

90-
add_filter( 'cron_schedules', function ( $cryptapi_interval ) {
91-
$cryptapi_interval['cryptapi_interval'] = array(
92-
'interval' => 60,
93-
'display' => esc_html__( 'CryptAPI Interval' ),
94-
);
107+
add_filter('cron_schedules', function ($cryptapi_interval) {
108+
$cryptapi_interval['cryptapi_interval'] = array(
109+
'interval' => 60,
110+
'display' => esc_html__('CryptAPI Interval'),
111+
);
95112

96-
return $cryptapi_interval;
97-
} );
113+
return $cryptapi_interval;
114+
});
98115

99-
register_activation_hook( __FILE__, 'cryptapi_activation' );
116+
register_activation_hook(__FILE__, 'cryptapi_activation');
100117

101-
function cryptapi_activation() {
102-
if (! wp_next_scheduled ( 'cryptapi_cronjob' )) {
103-
wp_schedule_event( time(), 'cryptapi_interval', 'cryptapi_cronjob' );
104-
}
118+
function cryptapi_activation()
119+
{
120+
if (!wp_next_scheduled('cryptapi_cronjob')) {
121+
wp_schedule_event(time(), 'cryptapi_interval', 'cryptapi_cronjob');
122+
}
105123
}
106124

107-
register_deactivation_hook( __FILE__, 'cryptapi_deactivation' );
125+
register_deactivation_hook(__FILE__, 'cryptapi_deactivation');
126+
127+
function cryptapi_deactivation()
128+
{
129+
wp_clear_scheduled_hook('cryptapi_cronjob');
130+
}
108131

109-
function cryptapi_deactivation() {
110-
wp_clear_scheduled_hook( 'cryptapi_cronjob' );
111-
};

README.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,36 @@ The easiest and fastest way is via our live chat on our [website](https://crypta
205205
* Minor fixes
206206
* UI Improvements
207207

208+
#### 4.2
209+
* Improved algorithm
210+
* Minor fixes
211+
* UI Improvements
212+
213+
#### 4.2.1
214+
* Minor fixes
215+
216+
#### 4.2.2
217+
* Minor fixes
218+
219+
#### 4.2.3
220+
* Minor fixes
221+
222+
#### 4.2.4
223+
* Minor fixes
224+
225+
#### 4.3
226+
* Improve calculations
227+
* Minor fixes
228+
229+
#### 4.3.1
230+
* Minor fixes
231+
232+
#### 4.3.2
233+
* Minor fixes
234+
235+
#### 4.3.3
236+
* Minor fixes
237+
208238
### Upgrade Notice
209-
* No breaking changes
239+
#### 4.3
240+
* Please be sure to enable the PHP extension BCMath before upgrading to this version.

0 commit comments

Comments
 (0)