WooCommerce Customizer - Version 1.2.1

Version Description

  • Fix missing compatibility class error
Download this release

Release Info

Developer maxrice
Plugin Icon WooCommerce Customizer
Version 1.2.1
Comparing to
See all releases

Code changes from version 1.2 to 1.2.1

includes/class-wc-customizer-compatibility.php ADDED
@@ -0,0 +1,805 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * WooCommerce Plugin Compatibility
4
+ *
5
+ * This source file is subject to the GNU General Public License v3.0
6
+ * that is bundled with this package in the file license.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.html
9
+ * If you did not receive a copy of the license and are unable to
10
+ * obtain it through the world-wide-web, please send an email
11
+ * to license@skyverge.com so we can send you a copy immediately.
12
+ *
13
+ * DISCLAIMER
14
+ *
15
+ * Do not edit or add to this file if you wish to upgrade the plugin to newer
16
+ * versions in the future. If you wish to customize the plugin for your
17
+ * needs please refer to http://www.skyverge.com
18
+ *
19
+ * @author SkyVerge
20
+ * @copyright Copyright (c) 2013, SkyVerge, Inc.
21
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0
22
+ */
23
+
24
+ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
25
+
26
+ if ( ! class_exists( 'WC_Customizer_Compatibility' ) ) :
27
+
28
+ /**
29
+ * WooCommerce Compatibility Utility Class
30
+ *
31
+ * The unfortunate purpose of this class is to provide a single point of
32
+ * compatibility functions for dealing with supporting multiple versions
33
+ * of WooCommerce.
34
+ *
35
+ * The recommended procedure is to rename this file/class, replacing "my plugin"
36
+ * with the particular plugin name, so as to avoid clashes between plugins.
37
+ * Over time we expect to remove methods from this class, using the current
38
+ * ones directly, as support for older versions of WooCommerce is dropped.
39
+ *
40
+ * Current Compatibility: 2.0.x - 2.1
41
+ *
42
+ * @version 1.1
43
+ */
44
+ class WC_Customizer_Compatibility {
45
+
46
+
47
+ /**
48
+ * Compatibility function for outputting a woocommerce attribute label
49
+ *
50
+ * @since 1.0
51
+ * @param string $label the label to display
52
+ * @return string the label to display
53
+ */
54
+ public static function wc_attribute_label( $label ) {
55
+
56
+ if ( self::is_wc_version_gte_2_1() ) {
57
+ return wc_attribute_label( $label );
58
+ } else {
59
+ global $woocommerce;
60
+ return $woocommerce->attribute_label( $label );
61
+ }
62
+ }
63
+
64
+
65
+ /**
66
+ * Compatibility function to add and store a notice
67
+ *
68
+ * @since 1.0
69
+ * @param string $message The text to display in the notice.
70
+ * @param string $notice_type The singular name of the notice type - either error, success or notice. [optional]
71
+ */
72
+ public static function wc_add_notice( $message, $notice_type = 'success' ) {
73
+
74
+ if ( self::is_wc_version_gte_2_1() ) {
75
+ wc_add_notice( $message, $notice_type );
76
+ } else {
77
+ global $woocommerce;
78
+
79
+ if ( 'error' == $notice_type ) {
80
+ $woocommerce->add_error( $message );
81
+ } else {
82
+ $woocommerce->add_message( $message );
83
+ }
84
+ }
85
+ }
86
+
87
+
88
+ /**
89
+ * Prints messages and errors which are stored in the session, then clears them.
90
+ *
91
+ * @since 1.0
92
+ */
93
+ public static function wc_print_notices() {
94
+
95
+ if ( self::is_wc_version_gte_2_1() ) {
96
+ wc_print_notices();
97
+ } else {
98
+ global $woocommerce;
99
+ $woocommerce->show_messages();
100
+ }
101
+ }
102
+
103
+
104
+ /**
105
+ * Compatibility function to queue some JavaScript code to be output in the footer.
106
+ *
107
+ * @since 1.0
108
+ * @param string $code javascript
109
+ */
110
+ public static function wc_enqueue_js( $code ) {
111
+
112
+ if ( self::is_wc_version_gte_2_1() ) {
113
+ wc_enqueue_js( $code );
114
+ } else {
115
+ global $woocommerce;
116
+ $woocommerce->add_inline_js( $code );
117
+ }
118
+ }
119
+
120
+
121
+ /**
122
+ * Forces the provided $content url to https protocol
123
+ *
124
+ * @since 1.0
125
+ * @param string $content the url
126
+ * @return string the url with https protocol
127
+ */
128
+ public static function force_https_url( $content ) {
129
+
130
+ if ( self::is_wc_version_gte_2_1() ) {
131
+ return WC_HTTPS::force_https_url( $content );
132
+ } else {
133
+ global $woocommerce;
134
+ return $woocommerce->force_ssl( $content );
135
+ }
136
+ }
137
+
138
+
139
+ /**
140
+ * Returns true if on the pay page, false otherwise
141
+ *
142
+ * @since 1.0
143
+ * @return boolean true if on the pay page, false otherwise
144
+ */
145
+ public static function is_checkout_pay_page() {
146
+
147
+ if ( self::is_wc_version_gte_2_1() ) {
148
+ return is_checkout_pay_page();
149
+ } else {
150
+ return is_page( woocommerce_get_page_id( 'pay' ) );
151
+ }
152
+ }
153
+
154
+
155
+ /**
156
+ * Returns the order_id if on the checkout pay page
157
+ *
158
+ * @since 1.0
159
+ * @return int order identifier
160
+ */
161
+ public static function get_checkout_pay_page_order_id() {
162
+
163
+ if ( self::is_wc_version_gte_2_1() ) {
164
+ global $wp;
165
+ return isset( $wp->query_vars['order-pay'] ) ? absint( $wp->query_vars['order-pay'] ) : 0;
166
+ } else {
167
+ return isset( $_GET['order'] ) ? absint( $_GET['order'] ) : 0;
168
+ }
169
+ }
170
+
171
+
172
+ /**
173
+ * Returns the total shipping cost for the given order
174
+ *
175
+ * @since 1.0
176
+ * @param WC_Order $order
177
+ * @return float the shipping total
178
+ */
179
+ public static function get_total_shipping( $order ) {
180
+
181
+ if ( self::is_wc_version_gte_2_1() ) {
182
+ return $order->get_total_shipping();
183
+ } else {
184
+ return $order->get_shipping();
185
+ }
186
+ }
187
+
188
+
189
+ /**
190
+ * Returns the value of the custom field named $name, if any. $name should
191
+ * not have a leading underscore
192
+ *
193
+ * @since 1.0
194
+ * @param WC_Order $order WC Order object
195
+ * @param string $name meta key name without a leading underscore
196
+ * @return string|mixed order custom field value for field named $name
197
+ */
198
+ public static function get_order_custom_field( $order, $name ) {
199
+
200
+ if ( self::is_wc_version_gte_2_1() ) {
201
+ return isset( $order->$name ) ? $order->$name : '';
202
+ } else {
203
+ return isset( $order->order_custom_fields[ '_' . $name ][0] ) ? $order->order_custom_fields[ '_' . $name ][0] : '';
204
+ }
205
+ }
206
+
207
+
208
+ /**
209
+ * Sets WooCommerce messages
210
+ *
211
+ * @since 1.0
212
+ */
213
+ public static function set_messages() {
214
+
215
+ if ( self::is_wc_version_gte_2_1() ) {
216
+ // no-op in WC 2.1+
217
+ } else {
218
+ global $woocommerce;
219
+ $woocommerce->set_messages();
220
+ }
221
+ }
222
+
223
+
224
+ /**
225
+ * Returns a new instance of the woocommerce logger
226
+ *
227
+ * @since 1.0
228
+ * @return object logger
229
+ */
230
+ public static function new_wc_logger() {
231
+
232
+ if ( self::is_wc_version_gte_2_1() ) {
233
+ return new WC_Logger();
234
+ } else {
235
+ global $woocommerce;
236
+ return $woocommerce->logger();
237
+ }
238
+ }
239
+
240
+
241
+ /**
242
+ * Returns the admin configuration url for the gateway with class name
243
+ * $gateway_class_name
244
+ *
245
+ * @since 1.0
246
+ * @param string $gateway_class_name the gateway class name
247
+ * @return string admin configuration url for the gateway
248
+ */
249
+ public static function get_payment_gateway_configuration_url( $gateway_class_name ) {
250
+
251
+ if ( self::is_wc_version_gte_2_1() ) {
252
+ return admin_url( 'admin.php?page=wc-settings&tab=checkout&section=' . strtolower( $gateway_class_name ) );
253
+ } else {
254
+ return admin_url( 'admin.php?page=woocommerce_settings&tab=payment_gateways&section=' . $gateway_class_name );
255
+ }
256
+ }
257
+
258
+
259
+ /**
260
+ * Returns true if the current page is the admin configuration page for the
261
+ * gateway with class name $gateway_class_name
262
+ *
263
+ * @since 1.0
264
+ * @param string $gateway_class_name the gateway class name
265
+ * @return boolean true if the current page is the admin configuration page for the gateway
266
+ */
267
+ public static function is_payment_gateway_configuration_page( $gateway_class_name ) {
268
+
269
+ if ( self::is_wc_version_gte_2_1() ) {
270
+ return isset( $_GET['page'] ) && 'wc-settings' == $_GET['page'] &&
271
+ isset( $_GET['tab'] ) && 'checkout' == $_GET['tab'] &&
272
+ isset( $_GET['section'] ) && strtolower( $gateway_class_name ) == $_GET['section'];
273
+ } else {
274
+ return isset( $_GET['page'] ) && 'woocommerce_settings' == $_GET['page'] &&
275
+ isset( $_GET['tab'] ) && 'payment_gateways' == $_GET['tab'] &&
276
+ isset( $_GET['section'] ) && $gateway_class_name == $_GET['section'];
277
+ }
278
+ }
279
+
280
+
281
+ /**
282
+ * Returns the admin configuration url for the shipping method with class name
283
+ * $gateway_class_name
284
+ *
285
+ * @since 1.0
286
+ * @param string $shipping_method_class_name the shipping method class name
287
+ * @return string admin configuration url for the shipping method
288
+ */
289
+ public static function get_shipping_method_configuration_url( $shipping_method_class_name ) {
290
+
291
+ if ( self::is_wc_version_gte_2_1() ) {
292
+ return admin_url( 'admin.php?page=wc-settings&tab=shipping&section=' . strtolower( $shipping_method_class_name ) );
293
+ } else {
294
+ return admin_url( 'admin.php?page=woocommerce_settings&tab=shipping&section=' . $shipping_method_class_name );
295
+ }
296
+ }
297
+
298
+
299
+ /**
300
+ * Returns true if the current page is the admin configuration page for the
301
+ * shipping method with class name $shipping_method_class_name
302
+ *
303
+ * @since 1.0
304
+ * @param string $shipping_method_class_name the shipping method class name
305
+ * @return boolean true if the current page is the admin configuration page for the shipping method
306
+ */
307
+ public static function is_shipping_method_configuration_page( $shipping_method_class_name ) {
308
+
309
+ if ( self::is_wc_version_gte_2_1() ) {
310
+ return isset( $_GET['page'] ) && 'wc-settings' == $_GET['page'] &&
311
+ isset( $_GET['tab'] ) && 'shipping' == $_GET['tab'] &&
312
+ isset( $_GET['section'] ) && strtolower( $shipping_method_class_name ) == $_GET['section'];
313
+ } else {
314
+ return isset( $_GET['page'] ) && 'woocommerce_settings' == $_GET['page'] &&
315
+ isset( $_GET['tab'] ) && 'shipping' == $_GET['tab'] &&
316
+ isset( $_GET['section'] ) && $shipping_method_class_name == $_GET['section'];
317
+ }
318
+ }
319
+
320
+
321
+ /**
322
+ * Format decimal numbers ready for DB storage
323
+ *
324
+ * Sanitize, remove locale formatting, and optionally round + trim off zeros
325
+ *
326
+ * @since 1.0
327
+ * @param float|string $number Expects either a float or a string with a decimal separator only (no thousands)
328
+ * @param mixed $dp number of decimal points to use, blank to use woocommerce_price_num_decimals, or false to avoid all rounding.
329
+ * @param boolean $trim_zeros from end of string
330
+ * @return string
331
+ */
332
+ public static function wc_format_decimal( $number, $dp = false, $trim_zeros = false ) {
333
+
334
+ if ( self::is_wc_version_gte_2_1() ) {
335
+ return wc_format_decimal( $number, $dp, $trim_zeros );
336
+ } else {
337
+ return woocommerce_format_total( $number );
338
+ }
339
+ }
340
+
341
+
342
+ /**
343
+ * Get the count of notices added, either for all notices (default) or for one particular notice type specified
344
+ * by $notice_type.
345
+ *
346
+ * @since 1.0
347
+ * @param string $notice_type The name of the notice type - either error, success or notice. [optional]
348
+ * @return int the notice count
349
+ */
350
+ public static function wc_notice_count( $notice_type = '' ) {
351
+
352
+ if ( self::is_wc_version_gte_2_1() ) {
353
+ return wc_notice_count( $notice_type );
354
+ } else {
355
+ global $woocommerce;
356
+
357
+ if ( 'error' == $notice_type ) {
358
+ return $woocommerce->error_count();
359
+ } else {
360
+ return $woocommerce->message_count();
361
+ }
362
+ }
363
+ }
364
+
365
+
366
+ /**
367
+ * Returns the array of shipping methods chosen during checkout
368
+ *
369
+ * @since 1.0
370
+ * @return array of chosen shipping method ids
371
+ */
372
+ public static function get_chosen_shipping_methods() {
373
+
374
+ if ( self::is_wc_version_gte_2_1() ) {
375
+ $chosen_shipping_methods = self::WC()->session->get( 'chosen_shipping_methods' );
376
+ return $chosen_shipping_methods ? $chosen_shipping_methods : array();
377
+ } else {
378
+ return array( self::WC()->session->get( 'chosen_shipping_method' ) );
379
+ }
380
+ }
381
+
382
+
383
+ /**
384
+ * Returns an array of shipping methods used for the order. This is analogous
385
+ * to but not a precise replacement for WC_Order::get_shipping_methods(), just
386
+ * because there can't be a direct equivalent for pre WC 2.1
387
+ *
388
+ * @since 1.0
389
+ * @return array of shipping method ids for $order
390
+ */
391
+ public static function get_shipping_method_ids( $order ) {
392
+
393
+ if ( self::get_order_custom_field( $order, 'shipping_method' ) ) {
394
+
395
+ // pre WC 2.1 data
396
+ return array( self::get_order_custom_field( $order, 'shipping_method' ) );
397
+
398
+ } elseif ( self::is_wc_version_gte_2_1() ) {
399
+
400
+ $shipping_method_ids = array();
401
+
402
+ foreach ( $order->get_shipping_methods() as $shipping_method ) {
403
+ $shipping_method_ids[] = $shipping_method['method_id'];
404
+ }
405
+
406
+ return $shipping_method_ids;
407
+ }
408
+
409
+ return array();
410
+ }
411
+
412
+
413
+ /**
414
+ * Returns true if the order has the given shipping method
415
+ *
416
+ * @since 1.0
417
+ * @param WC_Order $order
418
+ * @param string $method_id
419
+ * @return boolean true if $order is shipped by $method_id
420
+ */
421
+ public static function has_shipping_method( $order, $method_id ) {
422
+
423
+ if ( self::get_order_custom_field( $order, 'shipping_method' ) ) {
424
+ // pre WC 2.1 data
425
+ return $method_id == self::get_order_custom_field( $order, 'shipping_method' );
426
+ } elseif ( self::is_wc_version_gte_2_1() ) {
427
+ return $order->has_shipping_method( $method_id );
428
+ }
429
+
430
+ // default
431
+ return false;
432
+ }
433
+
434
+
435
+ /**
436
+ * Compatibility function to use the new WC_Admin_Meta_Boxes class for the save_errors() function
437
+ *
438
+ * @since 1.0
439
+ */
440
+ public static function save_errors() {
441
+
442
+ if ( self::is_wc_version_gte_2_1() ) {
443
+ WC_Admin_Meta_Boxes::save_errors();
444
+ } else {
445
+ woocommerce_meta_boxes_save_errors();
446
+ }
447
+ }
448
+
449
+
450
+ /**
451
+ * Get coupon types.
452
+ *
453
+ * @since 1.0
454
+ * @return array of coupon types
455
+ */
456
+ public static function wc_get_coupon_types() {
457
+
458
+ if ( self::is_wc_version_gte_2_1() ) {
459
+ return wc_get_coupon_types();
460
+ } else {
461
+ global $woocommerce;
462
+ return $woocommerce->get_coupon_discount_types();
463
+ }
464
+ }
465
+
466
+
467
+ /**
468
+ * Gets a product meta field value, regardless of product type
469
+ *
470
+ * @since 1.0
471
+ * @param WC_Product $product the product
472
+ * @param string $field_name the field name
473
+ * @return mixed meta value
474
+ */
475
+ public static function get_product_meta( $product, $field_name ) {
476
+
477
+ // even in WC >= 2.0 product variations still use the product_custom_fields array apparently
478
+ if ( $product->variation_id && isset( $product->product_custom_fields[ '_' . $field_name ][0] ) && '' !== $product->product_custom_fields[ '_' . $field_name ][0] ) {
479
+ return $product->product_custom_fields[ '_' . $field_name ][0];
480
+ }
481
+
482
+ // use magic __get
483
+ return $product->$field_name;
484
+ }
485
+
486
+
487
+ /**
488
+ * Format the price with a currency symbol.
489
+ *
490
+ * @since 1.0
491
+ * @param float $price the price
492
+ * @param array $args (default: array())
493
+ * @return string formatted price
494
+ */
495
+ public static function wc_price( $price, $args = array() ) {
496
+
497
+ if ( self::is_wc_version_gte_2_1() ) {
498
+ return wc_price( $price, $args );
499
+ } else {
500
+ return woocommerce_price( $price, $args );
501
+ }
502
+ }
503
+
504
+
505
+ /**
506
+ * WooCommerce Shortcode wrapper
507
+ *
508
+ * @since 1.0
509
+ * @param mixed $function shortcode callback
510
+ * @param array $atts (default: array())
511
+ * @param array $wrapper array of wrapper options (class, before, after)
512
+ * @return string
513
+ */
514
+ public static function shortcode_wrapper(
515
+ $function,
516
+ $atts = array(),
517
+ $wrapper = array(
518
+ 'class' => 'woocommerce',
519
+ 'before' => null,
520
+ 'after' => null
521
+ ) ) {
522
+
523
+ if ( self::is_wc_version_gte_2_1() ) {
524
+ return WC_Shortcodes::shortcode_wrapper( $function, $atts, $wrapper );
525
+ } else {
526
+ global $woocommerce;
527
+ return $woocommerce->shortcode_wrapper( $function, $atts, $wrapper );
528
+ }
529
+ }
530
+
531
+
532
+ /**
533
+ * Compatibility for the woocommerce_get_template() function which is soft-deprecated in 2.1+
534
+ *
535
+ * @since 1.1
536
+ * @param string $template_name
537
+ * @param array $args
538
+ * @param string $template_path
539
+ * @param string $default_path
540
+ */
541
+ public static function wc_get_template( $template_name, $args, $template_path, $default_path ) {
542
+
543
+ if ( self::is_wc_version_gte_2_1() ) {
544
+
545
+ wc_get_template( $template_name, $args, $template_path, $default_path );
546
+
547
+ } else {
548
+
549
+ woocommerce_get_template( $template_name, $args, $template_path, $default_path );
550
+ }
551
+ }
552
+
553
+
554
+ /**
555
+ * Compatibility for the woocommerce_date_format() function which is soft-deprecated in 2.1+
556
+ *
557
+ * @since 1.1
558
+ * @return string date format
559
+ */
560
+ public static function wc_date_format() {
561
+
562
+ return self::is_wc_version_gte_2_1() ? wc_date_format() : woocommerce_date_format();
563
+ }
564
+
565
+
566
+ /**
567
+ * Compatibility for the woocommerce_time_format() function which is soft-deprecated in 2.1+
568
+ *
569
+ * @since 1.1
570
+ * @return string time format
571
+ */
572
+ public static function wc_time_format() {
573
+
574
+ return self::is_wc_version_gte_2_1() ? wc_time_format() : woocommerce_time_format();
575
+ }
576
+
577
+
578
+ /**
579
+ * Compatibility for the wc_timezone_string() function, which only
580
+ * exists in 2.1+
581
+ *
582
+ * @since 1.1
583
+ * @return string a valid PHP timezone string for the site
584
+ */
585
+ public static function wc_timezone_string() {
586
+
587
+ if ( self::is_wc_version_gte_2_1() ) {
588
+
589
+ return wc_timezone_string();
590
+
591
+ } else {
592
+
593
+ // if site timezone string exists, return it
594
+ if ( $timezone = get_option( 'timezone_string' ) ) {
595
+ return $timezone;
596
+ }
597
+
598
+ // get UTC offset, if it isn't set then return UTC
599
+ if ( 0 === ( $utc_offset = get_option( 'gmt_offset', 0 ) ) ) {
600
+ return 'UTC';
601
+ }
602
+
603
+ // adjust UTC offset from hours to seconds
604
+ $utc_offset *= 3600;
605
+
606
+ // attempt to guess the timezone string from the UTC offset
607
+ $timezone = timezone_name_from_abbr( '', $utc_offset );
608
+
609
+ // last try, guess timezone string manually
610
+ if ( false === $timezone ) {
611
+
612
+ $is_dst = date( 'I' );
613
+
614
+ foreach ( timezone_abbreviations_list() as $abbr ) {
615
+ foreach ( $abbr as $city ) {
616
+
617
+ if ( $city['dst'] == $is_dst && $city['offset'] == $utc_offset ) {
618
+ return $city['timezone_id'];
619
+ }
620
+ }
621
+ }
622
+ }
623
+
624
+ // fallback to UTC
625
+ return 'UTC';
626
+ }
627
+ }
628
+
629
+
630
+ /**
631
+ * Compatibility function to load WooCommerec admin functions in the admin,
632
+ * primarily needed for woocommerce_admin_fields() and woocommerce_update_options()
633
+ *
634
+ * Note these functions have been refactored in the WC_Admin_Settings class in 2.1+,
635
+ * so plugins targeting those versions can safely use WC_Admin_Settings::output_fields()
636
+ * and WC_Admin_Settings::save_fields instead
637
+ *
638
+ * @since 1.0
639
+ */
640
+ public static function load_wc_admin_functions() {
641
+
642
+ if ( ! self::is_wc_version_gte_2_1() ) {
643
+
644
+ // woocommerce_admin_fields()
645
+ require_once( self::WC()->plugin_path() . '/admin/woocommerce-admin-settings.php' );
646
+
647
+ // woocommerce_update_options()
648
+ require_once( self::WC()->plugin_path() . '/admin/settings/settings-save.php' );
649
+
650
+ } else {
651
+
652
+ // in 2.1+, wc-admin-functions.php lazy loads the admin settings functions
653
+ }
654
+ }
655
+
656
+
657
+ /**
658
+ * Returns true if the current page is the admin general configuration page
659
+ *
660
+ * @since 1.1
661
+ * @return boolean true if the current page is the admin general configuration page
662
+ */
663
+ public static function is_general_configuration_page() {
664
+
665
+ if ( self::is_wc_version_gte_2_1() ) {
666
+ return isset( $_GET['page'] ) && 'wc-settings' == $_GET['page'] &&
667
+ ( ! isset( $_GET['tab'] ) || 'general' == $_GET['tab'] );
668
+ } else {
669
+ return isset( $_GET['page'] ) && 'woocommerce_settings' == $_GET['page'] &&
670
+ ( ! isset( $_GET['tab'] ) || 'general' == $_GET['tab'] );
671
+ }
672
+ }
673
+
674
+
675
+ /**
676
+ * Returns the admin configuration url for the admin general configuration page
677
+ *
678
+ * @since 1.1
679
+ * @return string admin configuration url for the admin general configuration page
680
+ */
681
+ public static function get_general_configuration_url() {
682
+
683
+ if ( self::is_wc_version_gte_2_1() ) {
684
+ return admin_url( 'admin.php?page=wc-settings&tab=general' );
685
+ } else {
686
+ return admin_url( 'admin.php?page=woocommerce_settings&tab=general' );
687
+ }
688
+ }
689
+
690
+
691
+ /**
692
+ * Returns the order_id if on the checkout order received page
693
+ *
694
+ * Note this must be used in the `wp` or later action, as earlier
695
+ * actions do not yet have access to the query vars
696
+ *
697
+ * @since 1.1
698
+ * @return int order identifier
699
+ */
700
+ public static function get_checkout_order_received_order_id() {
701
+
702
+ if ( self::is_wc_version_gte_2_1() ) {
703
+ global $wp;
704
+ return isset( $wp->query_vars['order-received'] ) ? absint( $wp->query_vars['order-received'] ) : 0;
705
+ } else {
706
+ return isset( $_GET['order'] ) ? absint( $_GET['order'] ) : 0;
707
+ }
708
+ }
709
+
710
+
711
+ /**
712
+ * Generates a URL for the thanks page (order received)
713
+ *
714
+ * @since 1.1
715
+ * @param WC_Order $order
716
+ * @return string url to thanks page
717
+ */
718
+ public static function get_checkout_order_received_url( $order ) {
719
+
720
+ if ( self::is_wc_version_gte_2_1() ) {
721
+ return $order->get_checkout_order_received_url();
722
+ } else {
723
+ return get_permalink( woocommerce_get_page_id( 'thanks' ) );
724
+ }
725
+ }
726
+
727
+
728
+ /**
729
+ * Compatibility function to get the version of the currently installed WooCommerce
730
+ *
731
+ * @since 1.0
732
+ * @return string woocommerce version number or null
733
+ */
734
+ public static function get_wc_version() {
735
+
736
+ // WOOCOMMERCE_VERSION is now WC_VERSION, though WOOCOMMERCE_VERSION is still available for backwards compatibility, we'll disregard it on 2.1+
737
+ if ( defined( 'WC_VERSION' ) && WC_VERSION ) return WC_VERSION;
738
+ if ( defined( 'WOOCOMMERCE_VERSION' ) && WOOCOMMERCE_VERSION ) return WOOCOMMERCE_VERSION;
739
+
740
+ return null;
741
+ }
742
+
743
+
744
+ /**
745
+ * Returns the WooCommerce instance
746
+ *
747
+ * @since 1.0
748
+ * @return WooCommerce woocommerce instance
749
+ */
750
+ public static function WC() {
751
+
752
+ if ( self::is_wc_version_gte_2_1() ) {
753
+ return WC();
754
+ } else {
755
+ global $woocommerce;
756
+ return $woocommerce;
757
+ }
758
+ }
759
+
760
+
761
+ /**
762
+ * Returns true if the WooCommerce plugin is loaded
763
+ *
764
+ * @since 1.0
765
+ * @return boolean true if WooCommerce is loaded
766
+ */
767
+ public static function is_wc_loaded() {
768
+
769
+ if ( self::is_wc_version_gte_2_1() ) {
770
+ return class_exists( 'WooCommerce' );
771
+ } else {
772
+ return class_exists( 'Woocommerce' );
773
+ }
774
+ }
775
+
776
+
777
+ /**
778
+ * Returns true if the installed version of WooCommerce is 2.1 or greater
779
+ *
780
+ * @since 1.0
781
+ * @return boolean true if the installed version of WooCommerce is 2.1 or greater
782
+ */
783
+ public static function is_wc_version_gte_2_1() {
784
+
785
+ // can't use gte 2.1 at the moment because 2.1-BETA < 2.1
786
+ return self::is_wc_version_gt( '2.0.20' );
787
+ }
788
+
789
+
790
+ /**
791
+ * Returns true if the installed version of WooCommerce is greater than $version
792
+ *
793
+ * @since 1.0
794
+ * @param string $version the version to compare
795
+ * @return boolean true if the installed version of WooCommerce is > $version
796
+ */
797
+ public static function is_wc_version_gt( $version ) {
798
+
799
+ return self::get_wc_version() && version_compare( self::get_wc_version(), $version, '>' );
800
+ }
801
+
802
+ }
803
+
804
+
805
+ endif; // Class exists check
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=paypal@s
4
  Tags: woocommerce
5
  Requires at least: 3.5
6
  Tested up to: 3.8.1
7
- Stable tag: 1.2
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -53,8 +53,11 @@ Yes! Fork the plugin on [Github](https://github.com/skyverge/woocommerce-customi
53
 
54
  == Changelog ==
55
 
 
 
 
56
  = 1.2 =
57
- * Fixed issues with add to cart button text customizations in WooCommerce 2.1
58
 
59
  = 1.1.1 =
60
  * WooCommerce 2.1 Compatibility
4
  Tags: woocommerce
5
  Requires at least: 3.5
6
  Tested up to: 3.8.1
7
+ Stable tag: 1.2.1
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
53
 
54
  == Changelog ==
55
 
56
+ = 1.2.1 =
57
+ * Fix missing compatibility class error
58
+
59
  = 1.2 =
60
+ * Fix issues with add to cart button text customizations in WooCommerce 2.1
61
 
62
  = 1.1.1 =
63
  * WooCommerce 2.1 Compatibility
woocommerce-customizer.php CHANGED
@@ -5,7 +5,7 @@
5
  * Description: Customize WooCommerce without code! Easily change add to cart button text and more.
6
  * Author: SkyVerge
7
  * Author URI: http://www.skyverge.com
8
- * Version: 1.2
9
  * Text Domain: wc-customizer
10
  * Domain Path: /languages/
11
  *
@@ -72,7 +72,7 @@ class WC_Customizer {
72
 
73
 
74
  /** plugin version number */
75
- const VERSION = '1.2';
76
 
77
  /** var array the active filters */
78
  public $filters;
5
  * Description: Customize WooCommerce without code! Easily change add to cart button text and more.
6
  * Author: SkyVerge
7
  * Author URI: http://www.skyverge.com
8
+ * Version: 1.2.1
9
  * Text Domain: wc-customizer
10
  * Domain Path: /languages/
11
  *
72
 
73
 
74
  /** plugin version number */
75
+ const VERSION = '1.2.1';
76
 
77
  /** var array the active filters */
78
  public $filters;