-
Notifications
You must be signed in to change notification settings - Fork 4
/
woo-gateway-tigomoney.php
143 lines (112 loc) · 4.19 KB
/
woo-gateway-tigomoney.php
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
136
137
138
139
140
141
142
143
<?php
/**
* @package WC_Gateway_TigoMoney
* @version 3.2.0
* @category Gateway
* @author Mario César Señoranis Ayala
*/
/**
* Plugin Name: Woo TigoMoney Gateway
* Plugin URI: https://github.com/vevende/woo-gateway-tigomoney
* Description: Payment Gateway for TigoMoney in Woocommerce setup for Bolivia 🇧🇴
* Version: 3.3.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Vevende
* Author URI: https://www.vevende.com/
* Text Domain: woo-tigomoney
* Domain Path: /languages
* License: GPLv2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Copyright 2019 HUMANZILLA SRL <vevende@humanzilla.com>.
*/
defined('ABSPATH') || exit;
defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
class Woo_Gateway_Tigomoney
{
const VERSION = '3.3.0';
protected static $instance = null;
protected function __construct()
{ }
private function __clone()
{ }
private function __wakeup()
{ }
final public static function instance()
{
if (null === static::$instance) {
static::$instance = new static();
}
return static::$instance;
}
public function init()
{
$this->define('WOO_TIGOMONEY_FILE', __FILE__);
$this->define('WOO_TIGOMONEY_ABSPATH', dirname(__FILE__) . DS);
$this->define('WOO_TIGOMONEY_INCLUDE', dirname(__FILE__) . DS . 'includes' . DS);
$this->define('WOO_TIGOMONEY_VERSION', $this::VERSION);
register_activation_hook(WOO_TIGOMONEY_FILE, array($this, 'on_activation'));
register_deactivation_hook(WOO_TIGOMONEY_FILE, array($this, 'on_deactivation'));
add_action('plugins_loaded', array($this, 'on_plugins_loaded'));
}
function on_activation()
{ }
function on_deactivation()
{ }
public function on_plugins_loaded()
{
if (!$this->check_dependencies()) {
add_action('admin_notices', function () {
$wordpress_version = get_bloginfo('version');
$has_valid_wp_version = version_compare($wordpress_version, '5.2.0', '>=');
if ($has_valid_wp_version) {
$message = 'Se requiere una version de WooCommerce 3.6 o superior';
} else {
$message = 'Se requiere una version de Wordpress 5.2 o superior y WooCommerce 3.6 o superior';
}
printf('<div class="error"><p>%s</p></div>', $message);
});
deactivate_plugins(plugin_basename(WOO_TIGOMONEY_FILE));
unset($_GET['activate']);
return;
}
$this->includes();
}
protected function includes()
{
require_once WOO_TIGOMONEY_INCLUDE . 'class-wc-gateway-request.php';
require_once WOO_TIGOMONEY_INCLUDE . 'class-wc-gateway.php';
require_once WOO_TIGOMONEY_INCLUDE . 'hooks.php';
}
protected function hooks()
{ }
protected function check_dependencies()
{
$woocommerce_minimum_met = class_exists('WooCommerce') && version_compare(WC_VERSION, '3.6', '>=');
if (!$woocommerce_minimum_met) {
return false;
}
$wordpress_version = get_bloginfo('version');
return version_compare($wordpress_version, '5.2.0', '>=');
}
protected function define($name, $value)
{
if (!defined($name)) {
define($name, $value);
}
}
}
Woo_Gateway_Tigomoney::instance()->init();