-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathshipping-servientrega-wc.php
More file actions
executable file
·195 lines (172 loc) · 6.34 KB
/
Copy pathshipping-servientrega-wc.php
File metadata and controls
executable file
·195 lines (172 loc) · 6.34 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<?php
/**
* Plugin Name: Shipping Servientrega Woocommerce
* Description: Shipping Servientrega Woocommerce is available for Colombia
* Version: 3.0.30
* Author: Saul Morales Pacheco
* Author URI: https://saulmoralespa.com
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
* WC tested up to: 3.5
* WC requires at least: 2.6
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if(!defined('SHIPPING_SERVIENTREGA_WC_SS_VERSION')){
define('SHIPPING_SERVIENTREGA_WC_SS_VERSION', '3.0.30');
}
add_action( 'plugins_loaded', 'shipping_servientrega_wc_ss_init', 1 );
function shipping_servientrega_wc_ss_init()
{
if ( ! shipping_servientrega_wc_ss_requirements() )
return;
shipping_servientrega_wc_ss()->run_servientrega_wc();
}
function shipping_servientrega_wc_ss_notices( $notice ) {
?>
<div class="error notice">
<p><?php echo esc_html( $notice ); ?></p>
</div>
<?php
}
function shipping_servientrega_wc_ss_requirements(){
if ( version_compare( '7.1.0', PHP_VERSION, '>' ) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() {
shipping_servientrega_wc_ss_notices( 'Shipping Servientrega Woocommerce: Requiere la versión de php 7.1 o superior' );
}
);
}
return false;
}
$openssl_warning = 'Shipping Servientrega Woocommerce: Requiere la extensión OpenSSL 1.0.1 o superior se encuentre instalada';
if ( ! defined( 'OPENSSL_VERSION_TEXT' ) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() use ( $openssl_warning ) {
shipping_servientrega_wc_ss_notices($openssl_warning );
}
);
}
return false;
}
preg_match( '/^(?:Libre|Open)SSL ([\d.]+)/', OPENSSL_VERSION_TEXT, $matches );
if ( empty( $matches[1] ) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() use ( $openssl_warning ) {
shipping_servientrega_wc_ss_notices( $openssl_warning );
}
);
}
return false;
}
if ( ! version_compare( $matches[1], '1.0.1', '>=' ) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() use ( $openssl_warning ) {
shipping_servientrega_wc_ss_notices( $openssl_warning );
}
);
}
return false;
}
if ( ! extension_loaded( 'soap' ) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() {
shipping_servientrega_wc_ss_notices( 'Shipping Servientrega Woocommerce: Requiere la extensión soap se encuentre instalada' );
}
);
}
return false;
}
if ( ! extension_loaded( 'xml' ) ){
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() {
shipping_servientrega_wc_ss_notices( 'Shipping Servientrega Woocommerce: Requiere la extensión xml se encuentre instalada' );
}
);
}
return false;
}
if ( ! extension_loaded( 'simplexml' ) ){
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() {
shipping_servientrega_wc_ss_notices( 'Shipping Servientrega Woocommerce: Requiere la extensión simplexml se encuentre instalada' );
}
);
}
return false;
}
if ( !in_array(
'woocommerce/woocommerce.php',
apply_filters( 'active_plugins', get_option( 'active_plugins' ) ),
true
) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() {
shipping_servientrega_wc_ss_notices( 'Shipping Servientrega Woocommerce: Requiere que se encuentre instalado y activo el plugin: Woocommerce' );
}
);
}
return false;
}
if ( ! in_array(
'departamentos-y-ciudades-de-colombia-para-woocommerce/departamentos-y-ciudades-de-colombia-para-woocommerce.php',
apply_filters( 'active_plugins', get_option( 'active_plugins' ) ),
true
) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() {
shipping_servientrega_wc_ss_notices( 'Shipping Servientrega Woocommerce: Requiere que se encuentre instalado y activo el plugin: Departamentos y ciudades de Colombia para Woocommerce' );
}
);
}
return false;
}
$woo_countries = new WC_Countries();
$default_country = $woo_countries->get_base_country();
if ( ! in_array( $default_country, array( 'CO' ), true ) ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
add_action(
'admin_notices',
function() {
$country = 'Shipping Servientrega Woocommerce: Requiere que el país donde se encuentra ubicada la tienda sea Colombia ' .
sprintf(
'%s',
'<a href="' . admin_url() .
'admin.php?page=wc-settings&tab=general#s2id_woocommerce_currency">' .
'Click para establecer</a>' );
shipping_servientrega_wc_ss_notices( $country );
}
);
}
return false;
}
return true;
}
function shipping_servientrega_wc_ss(){
static $plugin;
if (!isset($plugin)){
require_once('includes/class-shipping-servientrega-wc-plugin.php');
$plugin = new Shipping_Servientrega_WC_Plugin(__FILE__, SHIPPING_SERVIENTREGA_WC_SS_VERSION);
}
return $plugin;
}
add_action( 'woocommerce_product_options_shipping', array('Shipping_Servientrega_WC_Plugin', 'add_custom_shipping_option_to_products'));