Version Description
Released: 24 February, 2017 =
New: Support to WooCoomerce 2.7-beta3
Fix: missing argument 2 in yith_wcan_exclude_terms and yith_wcan_include_terms hook
Download this release
Release Info
Developer | yithemes |
Plugin | YITH WooCommerce Ajax Product Filter |
Version | 3.3.0 |
Comparing to | |
See all releases |
Code changes from version 3.2.0 to 3.3.0
- README.txt +6 -1
- assets/css/admin.css +1 -0
- assets/js/yith-wcan-admin.js +1 -1
- includes/functions.yith-wcan.php +3 -3
- init.php +2 -2
- plugin-fw/init.php +1 -1
- plugin-fw/yit-woocommerce-compatibility.php +454 -347
README.txt
CHANGED
@@ -4,7 +4,7 @@ Contributors: yithemes
|
|
4 |
Tags: woocommerce ajax product filter download, woocommerce, widget, ajax, ajax filtered nav, ajax navigation, ajax filtered navigation, woocommerce layered navigation, woocommerce layered nav, product filter, product filters, ajax product filter, woocommerce ajax product filter, woocommerce filters, sidebar filter, sidebar ajax filter, ajax price filter, price filter, product sorting, woocommerce filter, taxonomy filter, attribute filter, attributes filter, woocommerce product sort, ajax sort, woocommerce ajax product filter, advanced product filters, ajax product filters, filters, woocommerce ajax product filters, woocommerce product filters, woocommerce product filters, category filter, attribute filters, woocommerce products filter, woocommerce price filter, yit, yith, yithemes
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.7.2
|
7 |
-
Stable tag: 3.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -159,6 +159,11 @@ If you want to see a demonstration version of the premium plugin, you can see it
|
|
159 |
|
160 |
== Changelog ==
|
161 |
|
|
|
|
|
|
|
|
|
|
|
162 |
= 3.2.0 - Released: 20 February, 2017 =
|
163 |
|
164 |
* Add: Back/Next browser button integration
|
4 |
Tags: woocommerce ajax product filter download, woocommerce, widget, ajax, ajax filtered nav, ajax navigation, ajax filtered navigation, woocommerce layered navigation, woocommerce layered nav, product filter, product filters, ajax product filter, woocommerce ajax product filter, woocommerce filters, sidebar filter, sidebar ajax filter, ajax price filter, price filter, product sorting, woocommerce filter, taxonomy filter, attribute filter, attributes filter, woocommerce product sort, ajax sort, woocommerce ajax product filter, advanced product filters, ajax product filters, filters, woocommerce ajax product filters, woocommerce product filters, woocommerce product filters, category filter, attribute filters, woocommerce products filter, woocommerce price filter, yit, yith, yithemes
|
5 |
Requires at least: 4.0
|
6 |
Tested up to: 4.7.2
|
7 |
+
Stable tag: 3.3.0
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
159 |
|
160 |
== Changelog ==
|
161 |
|
162 |
+
= 3.3.0 - Released: 24 February, 2017 =
|
163 |
+
|
164 |
+
* New: Support to WooCoomerce 2.7-beta3
|
165 |
+
* Fix: missing argument 2 in yith_wcan_exclude_terms and yith_wcan_include_terms hook
|
166 |
+
|
167 |
= 3.2.0 - Released: 20 February, 2017 =
|
168 |
|
169 |
* Add: Back/Next browser button integration
|
assets/css/admin.css
CHANGED
@@ -34,6 +34,7 @@ div.yit-wcan-widget-tag-list.tags{
|
|
34 |
p#yit-wcan-style.yit-wcan-style-color,
|
35 |
p#yit-wcan-style.yit-wcan-style-multicolor,
|
36 |
p#yit-wcan-show-count.yit-wcan-show-count-list,
|
|
|
37 |
p#yit-wcan-show-count.yit-wcan-show-count-brands,
|
38 |
p#yit-wcan-show-count.yit-wcan-show-count-tags{
|
39 |
display: block;
|
34 |
p#yit-wcan-style.yit-wcan-style-color,
|
35 |
p#yit-wcan-style.yit-wcan-style-multicolor,
|
36 |
p#yit-wcan-show-count.yit-wcan-show-count-list,
|
37 |
+
p#yit-wcan-show-count.yit-wcan-show-count-categories,
|
38 |
p#yit-wcan-show-count.yit-wcan-show-count-brands,
|
39 |
p#yit-wcan-show-count.yit-wcan-show-count-tags{
|
40 |
display: block;
|
assets/js/yith-wcan-admin.js
CHANGED
@@ -57,7 +57,7 @@ jQuery(function ($) {
|
|
57 |
style.hide();
|
58 |
}
|
59 |
|
60 |
-
if( data.value == 'list' || data.value == 'tags' || data.value == 'brands' ){
|
61 |
show_count.show();
|
62 |
} else {
|
63 |
show_count.hide();
|
57 |
style.hide();
|
58 |
}
|
59 |
|
60 |
+
if( data.value == 'list' || data.value == 'tags' || data.value == 'brands' || data.value == 'categories' ){
|
61 |
show_count.show();
|
62 |
} else {
|
63 |
show_count.hide();
|
includes/functions.yith-wcan.php
CHANGED
@@ -617,7 +617,7 @@ if( ! function_exists( 'yit_terms_sort' ) ){
|
|
617 |
if( ! function_exists( 'yit_alphabetical_terms_sort' ) ){
|
618 |
|
619 |
function yit_alphabetical_terms_sort( $a, $b ){
|
620 |
-
return strnatcmp ( $a->name, $b->name );
|
621 |
}
|
622 |
}
|
623 |
|
@@ -656,8 +656,8 @@ if( ! function_exists( 'yit_reorder_hierachical_categories' ) ) {
|
|
656 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
657 |
*/
|
658 |
function yit_reorder_hierachical_categories( $parent_term_id, $taxonomy = 'product_cat' ) {
|
659 |
-
$exclude = apply_filters( 'yith_wcan_exclude_terms', array() );
|
660 |
-
$include = apply_filters( 'yith_wcan_include_terms', array() );
|
661 |
|
662 |
$childs = yith_wcan_wp_get_terms(
|
663 |
array(
|
617 |
if( ! function_exists( 'yit_alphabetical_terms_sort' ) ){
|
618 |
|
619 |
function yit_alphabetical_terms_sort( $a, $b ){
|
620 |
+
return strnatcmp ( strtolower( $a->name ), strtolower( $b->name ) );
|
621 |
}
|
622 |
}
|
623 |
|
656 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
657 |
*/
|
658 |
function yit_reorder_hierachical_categories( $parent_term_id, $taxonomy = 'product_cat' ) {
|
659 |
+
$exclude = apply_filters( 'yith_wcan_exclude_terms', array(), array() );
|
660 |
+
$include = apply_filters( 'yith_wcan_include_terms', array(), array() );
|
661 |
|
662 |
$childs = yith_wcan_wp_get_terms(
|
663 |
array(
|
init.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: YITH WooCommerce Ajax Product Filter
|
4 |
* Plugin URI: http://yithemes.com/
|
5 |
* Description: YITH WooCommerce Ajax Product Filter offers the perfect way to filter all the products of your shop.
|
6 |
-
* Version: 3.
|
7 |
* Author: YITHEMES
|
8 |
* Author URI: http://yithemes.com/
|
9 |
* Text Domain: yith-woocommerce-ajax-navigation
|
@@ -64,7 +64,7 @@ load_plugin_textdomain( 'yith-woocommerce-ajax-navigation', false, dirname( plug
|
|
64 |
! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
|
65 |
! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
|
66 |
! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
|
67 |
-
! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '3.
|
68 |
! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
|
69 |
! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
|
70 |
|
3 |
* Plugin Name: YITH WooCommerce Ajax Product Filter
|
4 |
* Plugin URI: http://yithemes.com/
|
5 |
* Description: YITH WooCommerce Ajax Product Filter offers the perfect way to filter all the products of your shop.
|
6 |
+
* Version: 3.3.0
|
7 |
* Author: YITHEMES
|
8 |
* Author URI: http://yithemes.com/
|
9 |
* Text Domain: yith-woocommerce-ajax-navigation
|
64 |
! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
|
65 |
! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
|
66 |
! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
|
67 |
+
! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '3.3.0' );
|
68 |
! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
|
69 |
! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
|
70 |
|
plugin-fw/init.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
-
* Version: 2.9.
|
5 |
* Author: Yithemes
|
6 |
* Text Domain: yith-plugin-fw
|
7 |
* Domain Path: /languages/
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
+
* Version: 2.9.45
|
5 |
* Author: Yithemes
|
6 |
* Text Domain: yith-plugin-fw
|
7 |
* Domain Path: /languages/
|
plugin-fw/yit-woocommerce-compatibility.php
CHANGED
@@ -8,401 +8,508 @@
|
|
8 |
* http://www.gnu.org/licenses/gpl-3.0.txt
|
9 |
*/
|
10 |
|
11 |
-
if ( !
|
12 |
-
|
13 |
} // Exit if accessed directly
|
14 |
|
15 |
$changed_objects = array();
|
16 |
|
17 |
-
if ( !
|
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 |
-
return $getter( $object->id, $key, true );
|
52 |
-
}
|
53 |
-
}
|
54 |
-
}
|
55 |
}
|
56 |
|
57 |
-
if ( !
|
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 |
-
if ( !
|
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 |
-
if ( !
|
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 |
-
if( !
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
178 |
}
|
179 |
|
180 |
-
if( !
|
181 |
-
|
182 |
-
|
183 |
|
184 |
-
|
185 |
|
186 |
-
|
187 |
/**
|
188 |
* @var $object \WC_Data
|
189 |
*/
|
190 |
-
|
191 |
-
$object_reference = $object->get_id();
|
192 |
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
197 |
);
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
|
|
203 |
}
|
204 |
|
205 |
-
if( !
|
206 |
-
|
207 |
-
|
208 |
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
/**
|
213 |
* @var $object \WC_Data
|
214 |
*/
|
215 |
-
$object = $data['
|
216 |
-
|
217 |
-
yit_set_prop( $object, $data['changes'] );
|
218 |
|
219 |
$object->save();
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
}
|
228 |
}
|
229 |
|
230 |
-
if( !
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
}
|
245 |
}
|
246 |
|
247 |
-
if( !
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
}
|
262 |
}
|
263 |
|
264 |
-
if( !
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
}
|
289 |
}
|
290 |
|
291 |
-
if ( !
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
}
|
333 |
|
334 |
-
if( !
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
}
|
350 |
|
351 |
-
if( !
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
|
362 |
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
|
369 |
-
|
370 |
-
|
371 |
}
|
372 |
|
373 |
-
if( !
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
}
|
406 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
407 |
yit_fix_wc_deprecated_filters();
|
408 |
add_action( 'shutdown', 'yit_send_changes_to_db' );
|
8 |
* http://www.gnu.org/licenses/gpl-3.0.txt
|
9 |
*/
|
10 |
|
11 |
+
if ( !defined( 'ABSPATH' ) ) {
|
12 |
+
exit;
|
13 |
} // Exit if accessed directly
|
14 |
|
15 |
$changed_objects = array();
|
16 |
|
17 |
+
if ( !function_exists( 'yit_get_prop' ) ) {
|
18 |
+
/**
|
19 |
+
*
|
20 |
+
*/
|
21 |
+
function yit_get_prop( $object, $key, $single = true, $context = 'view' ) {
|
22 |
+
|
23 |
+
$prop_map = yit_return_new_attribute_map();
|
24 |
+
$is_wc_data = $object instanceof WC_Data;
|
25 |
+
|
26 |
+
if ( $is_wc_data ) {
|
27 |
+
$key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
|
28 |
+
|
29 |
+
if ( ( $getter = "get{$key}" ) && method_exists( $object, $getter ) ) {
|
30 |
+
return $object->$getter( $context );
|
31 |
+
} elseif ( ( $getter = "get_{$key}" ) && method_exists( $object, $getter ) ) {
|
32 |
+
return $object->$getter( $context );
|
33 |
+
} else {
|
34 |
+
return $object->get_meta( $key, $single );
|
35 |
+
}
|
36 |
+
} else {
|
37 |
+
$key = ( in_array( $key, $prop_map ) ) ? array_search( $key, $prop_map ) : $key;
|
38 |
+
|
39 |
+
if ( isset( $object->$key ) ) {
|
40 |
+
return $object->$key;
|
41 |
+
} elseif ( yit_wc_check_post_columns( $key ) ) {
|
42 |
+
return $object->post->$key;
|
43 |
+
} else {
|
44 |
+
$getter = 'get_user_meta';
|
45 |
+
!$object instanceof WC_Customer && $getter = 'get_post_meta';
|
46 |
+
|
47 |
+
return $getter( $object->id, $key, true );
|
48 |
+
}
|
49 |
+
}
|
50 |
+
}
|
|
|
|
|
|
|
|
|
51 |
}
|
52 |
|
53 |
+
if ( !function_exists( 'yit_set_prop' ) ) {
|
54 |
+
/**
|
55 |
+
*
|
56 |
+
*/
|
57 |
+
function yit_set_prop( $object, $arg1, $arg2 = false ) {
|
58 |
+
|
59 |
+
if ( !is_array( $arg1 ) ) {
|
60 |
+
$arg1 = array(
|
61 |
+
$arg1 => $arg2
|
62 |
+
);
|
63 |
+
}
|
64 |
+
|
65 |
+
$prop_map = yit_return_new_attribute_map();
|
66 |
+
$is_wc_data = $object instanceof WC_Data;
|
67 |
+
|
68 |
+
foreach ( $arg1 as $key => $value ) {
|
69 |
+
if ( $is_wc_data ) {
|
70 |
+
$key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
|
71 |
+
|
72 |
+
if ( ( $setter = "set{$key}" ) && method_exists( $object, $setter ) ) {
|
73 |
+
$object->$setter( $value );
|
74 |
+
} elseif ( ( $setter = "set_{$key}" ) && method_exists( $object, $setter ) ) {
|
75 |
+
$object->$setter( $value );
|
76 |
+
} else {
|
77 |
+
$object->update_meta_data( $key, $value );
|
78 |
+
}
|
79 |
+
} else {
|
80 |
+
$key = ( in_array( $key, $prop_map ) ) ? array_search( $key, $prop_map ) : $key;
|
81 |
+
( strpos( $key, '_' ) === 0 ) && $key = substr( $key, 1 );
|
82 |
+
|
83 |
+
if ( yit_wc_check_post_columns( $key ) ) {
|
84 |
+
$object->post->$key = $value;
|
85 |
+
} else {
|
86 |
+
$object->$key = $value;
|
87 |
+
}
|
88 |
+
}
|
89 |
+
}
|
90 |
+
}
|
|
|
|
|
|
|
|
|
91 |
}
|
92 |
|
93 |
+
if ( !function_exists( 'yit_save_prop' ) ) {
|
94 |
+
/**
|
95 |
+
*
|
96 |
+
*/
|
97 |
+
function yit_save_prop( $object, $arg1, $arg2 = false, $force_meta = false ) {
|
98 |
+
if ( !is_array( $arg1 ) ) {
|
99 |
+
$arg1 = array(
|
100 |
+
$arg1 => $arg2
|
101 |
+
);
|
102 |
+
}
|
103 |
+
|
104 |
+
$is_wc_data = $object instanceof WC_Data;
|
105 |
+
|
106 |
+
foreach ( $arg1 as $key => $value ) {
|
107 |
+
yit_set_prop( $object, $key, $value );
|
108 |
+
|
109 |
+
if ( $is_wc_data ) {
|
110 |
+
yit_store_changes( $object, $key, $value );
|
111 |
+
} else {
|
112 |
+
if ( yit_wc_check_post_columns( $key ) ) {
|
113 |
+
yit_store_changes( $object->post, $key, $value );
|
114 |
+
} else {
|
115 |
+
update_post_meta( $object->id, $key, $value );
|
116 |
+
}
|
117 |
+
}
|
118 |
+
}
|
119 |
+
}
|
|
|
|
|
120 |
}
|
121 |
|
122 |
+
if ( !function_exists( 'yit_delete_prop' ) ) {
|
123 |
+
/**
|
124 |
+
*
|
125 |
+
*/
|
126 |
+
function yit_delete_prop( $object, $key, $value = '' ) {
|
127 |
+
$prop_map = yit_return_new_attribute_map();
|
128 |
+
$is_wc_data = $object instanceof WC_Data;
|
129 |
+
|
130 |
+
if ( $is_wc_data ) {
|
131 |
+
$key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
|
132 |
+
|
133 |
+
if ( ( $setter = "set{$key}" ) && ( $getter = "get{$key}" ) && method_exists( $object, $setter ) && ( !$value || $object->$getter == $value ) ) {
|
134 |
+
$object->$setter( '' );
|
135 |
+
} elseif ( ( $setter = "set_{$key}" ) && ( $getter = "get_{$key}" ) && method_exists( $object, $setter ) && ( !$value || $object->$getter == $value ) ) {
|
136 |
+
$object->$setter( '' );
|
137 |
+
} elseif ( ( !$value || $object->get_meta( $key ) == $value ) ) {
|
138 |
+
$object->delete_meta_data( $key, $value );
|
139 |
+
}
|
140 |
+
|
141 |
+
yit_store_changes( $object );
|
142 |
+
} else {
|
143 |
+
if ( yit_wc_check_post_columns( $key ) && ( !$value || $object->post->$key == $value ) ) {
|
144 |
+
yit_store_changes( $object->post, $key, '' );
|
145 |
+
} else {
|
146 |
+
delete_post_meta( $object->id, $key, $value );
|
147 |
+
}
|
148 |
+
}
|
149 |
+
}
|
|
|
|
|
|
|
150 |
}
|
151 |
|
152 |
+
if ( !function_exists( 'yit_return_new_attribute_map' ) ) {
|
153 |
+
function yit_return_new_attribute_map() {
|
154 |
+
return array(
|
155 |
+
'post_parent' => 'parent_id',
|
156 |
+
'post_title' => 'name',
|
157 |
+
'post_status' => 'status',
|
158 |
+
'post_content' => 'description',
|
159 |
+
/* Orders */
|
160 |
+
'paid_date' => 'date_paid',
|
161 |
+
'_paid_date' => '_date_paid',
|
162 |
+
'completed_date' => 'date_completed',
|
163 |
+
'_completed_date' => '_date_completed',
|
164 |
+
'_order_date' => '_date_created',
|
165 |
+
'order_date' => 'date_created',
|
166 |
+
/* Products */
|
167 |
+
'visibility' => 'catalog_visibility',
|
168 |
+
'_visibility' => '_catalog_visibility',
|
169 |
+
'sale_price_dates_from' => 'date_on_sale_from',
|
170 |
+
'_sale_price_dates_from' => '_date_on_sale_from',
|
171 |
+
'sale_price_dates_to' => 'date_on_sale_to',
|
172 |
+
'_sale_price_dates_to' => '_date_on_sale_to',
|
173 |
+
);
|
174 |
+
}
|
175 |
}
|
176 |
|
177 |
+
if ( !function_exists( 'yit_store_changes' ) ) {
|
178 |
+
function yit_store_changes( $object, $key = false, $value = false ) {
|
179 |
+
global $changed_objects;
|
180 |
|
181 |
+
$is_wc_data = $object instanceof WC_Data;
|
182 |
|
183 |
+
if ( $is_wc_data ) {
|
184 |
/**
|
185 |
* @var $object \WC_Data
|
186 |
*/
|
187 |
+
$object_reference = $object->get_id();
|
|
|
188 |
|
189 |
+
$cache_key = is_a( $object, 'WC_Product' ) ? 'product' : 'order';
|
190 |
+
$key = $cache_key . '-' . $object_reference;
|
191 |
+
$group = $cache_key . 's';
|
192 |
+
|
193 |
+
$changed_objects[ $object_reference ] = array(
|
194 |
+
'key' => $key,
|
195 |
+
'group' => $group
|
196 |
);
|
197 |
+
|
198 |
+
wp_cache_set( $key, $object, $group );
|
199 |
+
} else {
|
200 |
+
$changed_objects[ $object->ID ][ $key ] = $value;
|
201 |
+
}
|
202 |
+
}
|
203 |
}
|
204 |
|
205 |
+
if ( !function_exists( 'yit_send_changes_to_db' ) ) {
|
206 |
+
function yit_send_changes_to_db() {
|
207 |
+
global $changed_objects;
|
208 |
|
209 |
+
if ( !empty( $changed_objects ) ) {
|
210 |
+
foreach ( $changed_objects as $id => $data ) {
|
211 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
212 |
/**
|
213 |
* @var $object \WC_Data
|
214 |
*/
|
215 |
+
$object = wp_cache_get( $data[ 'key' ], $data[ 'group' ] );
|
|
|
|
|
216 |
|
217 |
$object->save();
|
218 |
+
} else {
|
219 |
+
$data[ 'ID' ] = $id;
|
220 |
+
wp_update_post( $data );
|
221 |
+
}
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
|
|
225 |
}
|
226 |
|
227 |
+
if ( !function_exists( 'yit_get_orders' ) ) {
|
228 |
+
/**
|
229 |
+
*
|
230 |
+
*/
|
231 |
+
function yit_get_orders( $args ) {
|
232 |
+
if ( version_compare( WC()->version, '2.6', '<' ) ) {
|
233 |
+
$args[ 'fields' ] = 'objects';
|
234 |
+
$posts = get_posts( $args );
|
235 |
+
|
236 |
+
return array_map( 'wc_get_order', $posts );
|
237 |
+
} else {
|
238 |
+
return wc_get_orders( $args );
|
239 |
+
}
|
240 |
+
}
|
|
|
241 |
}
|
242 |
|
243 |
+
if ( !function_exists( 'yit_get_products' ) ) {
|
244 |
+
/**
|
245 |
+
*
|
246 |
+
*/
|
247 |
+
function yit_get_products( $args ) {
|
248 |
+
if ( version_compare( WC()->version, '2.6', '<' ) ) {
|
249 |
+
$args[ 'fields' ] = 'objects';
|
250 |
+
$posts = get_posts( $args );
|
251 |
+
|
252 |
+
return array_map( 'wc_get_product', $posts );
|
253 |
+
} else {
|
254 |
+
return wc_get_products( $args );
|
255 |
+
}
|
256 |
+
}
|
|
|
257 |
}
|
258 |
|
259 |
+
if ( !function_exists( 'yit_update_product_stock' ) ) {
|
260 |
+
/**
|
261 |
+
*
|
262 |
+
*/
|
263 |
+
function yit_update_product_stock( $product, $stock_quantity = 1, $operation = 'set' ) {
|
264 |
+
if ( function_exists( 'wc_update_product_stock' ) ) {
|
265 |
+
$stock = wc_update_product_stock( $product, $stock_quantity, $operation );
|
266 |
+
} else {
|
267 |
+
switch ( $operation ) {
|
268 |
+
case 'increase':
|
269 |
+
$stock = $product->increase_stock( $stock_quantity );
|
270 |
+
break;
|
271 |
+
case 'decrease':
|
272 |
+
$stock = $product->reduce_stock( $stock_quantity );
|
273 |
+
break;
|
274 |
+
case 'set':
|
275 |
+
default:
|
276 |
+
$stock = $product->set_stock( $stock_quantity );
|
277 |
+
break;
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
return $stock;
|
282 |
+
}
|
|
|
283 |
}
|
284 |
|
285 |
+
if ( !function_exists( 'yit_wc_deprecated_filters' ) ) {
|
286 |
+
/**
|
287 |
+
*
|
288 |
+
*/
|
289 |
+
function yit_wc_deprecated_filters() {
|
290 |
+
return apply_filters( 'yit_wc_deprecated_filters', array(
|
291 |
+
'woocommerce_email_order_schema_markup' => 'woocommerce_structured_data_order',
|
292 |
+
'woocommerce_product_width' => 'woocommerce_product_get_width',
|
293 |
+
'woocommerce_product_height' => 'woocommerce_product_get_height',
|
294 |
+
'woocommerce_product_length' => 'woocommerce_product_get_length',
|
295 |
+
'woocommerce_product_weight' => 'woocommerce_product_get_weight',
|
296 |
+
'woocommerce_get_sku' => 'woocommerce_product_get_sku',
|
297 |
+
'woocommerce_get_price' => 'woocommerce_product_get_price',
|
298 |
+
'woocommerce_get_regular_price' => 'woocommerce_product_get_regular_price',
|
299 |
+
'woocommerce_get_sale_price' => 'woocommerce_product_get_sale_price',
|
300 |
+
'woocommerce_product_tax_class' => 'woocommerce_product_get_tax_class',
|
301 |
+
'woocommerce_get_stock_quantity' => 'woocommerce_product_get_stock_quantity',
|
302 |
+
'woocommerce_get_product_attributes' => 'woocommerce_product_get_attributes',
|
303 |
+
'woocommerce_product_gallery_attachment_ids' => 'woocommerce_product_get_gallery_image_ids',
|
304 |
+
'woocommerce_product_review_count' => 'woocommerce_product_get_review_count',
|
305 |
+
'woocommerce_product_files' => 'woocommerce_product_get_downloads',
|
306 |
+
'woocommerce_get_currency' => 'woocommerce_order_get_currency',
|
307 |
+
'woocommerce_order_amount_discount_total' => 'woocommerce_order_get_discount_total',
|
308 |
+
'woocommerce_order_amount_discount_tax' => 'woocommerce_order_get_discount_tax',
|
309 |
+
'woocommerce_order_amount_shipping_total' => 'woocommerce_order_get_shipping_total',
|
310 |
+
'woocommerce_order_amount_shipping_tax' => 'woocommerce_order_get_shipping_tax',
|
311 |
+
'woocommerce_order_amount_cart_tax' => 'woocommerce_order_get_cart_tax',
|
312 |
+
'woocommerce_order_amount_total' => 'woocommerce_order_get_total',
|
313 |
+
'woocommerce_order_amount_total_tax' => 'woocommerce_order_get_total_tax',
|
314 |
+
'woocommerce_order_amount_total_discount' => 'woocommerce_order_get_total_discount',
|
315 |
+
'woocommerce_order_amount_subtotal' => 'woocommerce_order_get_subtotal',
|
316 |
+
'woocommerce_order_tax_totals' => 'woocommerce_order_get_tax_totals',
|
317 |
+
'woocommerce_refund_amount' => 'woocommerce_get_order_refund_get_amount',
|
318 |
+
'woocommerce_refund_reason' => 'woocommerce_get_order_refund_get_reason',
|
319 |
+
'default_checkout_country' => 'default_checkout_billing_country',
|
320 |
+
'default_checkout_state' => 'default_checkout_billing_state',
|
321 |
+
'default_checkout_postcode' => 'default_checkout_billing_postcode',
|
322 |
+
'woocommerce_add_order_item_meta' => 'woocommerce_new_order_item',
|
323 |
+
|
324 |
+
) );
|
325 |
+
}
|
326 |
}
|
327 |
|
328 |
+
if ( !function_exists( 'yit_fix_wc_deprecated_filters' ) ) {
|
329 |
+
/**
|
330 |
+
*
|
331 |
+
*/
|
332 |
+
function yit_fix_wc_deprecated_filters() {
|
333 |
+
|
334 |
+
if ( !version_compare( WC()->version, '2.7.0', '<' ) ) {
|
335 |
+
return;
|
336 |
+
}
|
337 |
+
|
338 |
+
$deprecated_filters = yit_wc_deprecated_filters();
|
339 |
+
foreach ( $deprecated_filters as $old => $new ) {
|
340 |
+
add_filter( $old, 'yit_wc_deprecated_filter_mapping', 10, 100 );
|
341 |
+
}
|
342 |
+
}
|
343 |
}
|
344 |
|
345 |
+
if ( !function_exists( 'yit_wc_deprecated_filter_mapping' ) ) {
|
346 |
+
/**
|
347 |
+
*
|
348 |
+
*/
|
349 |
+
function yit_wc_deprecated_filter_mapping() {
|
350 |
+
$deprecated_filters = yit_wc_deprecated_filters();
|
351 |
|
352 |
+
$filter = current_filter();
|
353 |
+
$args = func_get_args();
|
354 |
+
$data = $args[ 0 ];
|
355 |
|
356 |
|
357 |
+
if ( isset( $deprecated_filters[ $filter ] ) ) {
|
358 |
+
if ( has_filter( $deprecated_filters[ $filter ] ) ) {
|
359 |
+
$data = apply_filters_ref_array( $deprecated_filters[ $filter ], $args );
|
360 |
+
}
|
361 |
+
}
|
362 |
|
363 |
+
return $data;
|
364 |
+
}
|
365 |
}
|
366 |
|
367 |
+
if ( !function_exists( 'yit_wc_check_post_columns' ) ) {
|
368 |
+
/**
|
369 |
+
*
|
370 |
+
*/
|
371 |
+
function yit_wc_check_post_columns( $key ) {
|
372 |
+
$columns = array(
|
373 |
+
'post_author',
|
374 |
+
'post_date',
|
375 |
+
'post_date_gmt',
|
376 |
+
'post_content',
|
377 |
+
'post_title',
|
378 |
+
'post_excerpt',
|
379 |
+
'post_status',
|
380 |
+
'comment_status',
|
381 |
+
'ping_status',
|
382 |
+
'post_password',
|
383 |
+
'post_name',
|
384 |
+
'to_ping',
|
385 |
+
'pinged',
|
386 |
+
'post_modified',
|
387 |
+
'post_modified_gmt',
|
388 |
+
'post_content_filtered',
|
389 |
+
'post_parent',
|
390 |
+
'guid',
|
391 |
+
'menu_order',
|
392 |
+
'post_type',
|
393 |
+
'post_mime_type',
|
394 |
+
'comment_count',
|
395 |
+
);
|
396 |
+
|
397 |
+
return in_array( $key, $columns );
|
398 |
+
}
|
399 |
}
|
400 |
|
401 |
+
|
402 |
+
/* Shortcuts for common functions */
|
403 |
+
|
404 |
+
if ( !function_exists( 'yit_get_order_id' ) ) {
|
405 |
+
/**
|
406 |
+
* Retrieve the order id
|
407 |
+
*
|
408 |
+
* @param WC_Order $order
|
409 |
+
*
|
410 |
+
* @return mixed
|
411 |
+
*/
|
412 |
+
function yit_get_order_id( $order ) {
|
413 |
+
return yit_get_prop( $order, 'id' );
|
414 |
+
}
|
415 |
+
}
|
416 |
+
|
417 |
+
if ( !function_exists( 'yit_get_product_id' ) ) {
|
418 |
+
/**
|
419 |
+
* Retrieve the product id
|
420 |
+
*
|
421 |
+
* @param WC_Product $product
|
422 |
+
*
|
423 |
+
* @return mixed
|
424 |
+
*/
|
425 |
+
function yit_get_product_id( $product ) {
|
426 |
+
return yit_get_prop( $product, 'id' );
|
427 |
+
}
|
428 |
+
}
|
429 |
+
|
430 |
+
if ( !function_exists( 'yit_get_base_product_id' ) ) {
|
431 |
+
/**
|
432 |
+
* New way to retrieve the $product->id as it was before WC 2.7.
|
433 |
+
*
|
434 |
+
* Retrieve the parent product id for WC_Product_Variation instances
|
435 |
+
* or the product id in the other cases.
|
436 |
+
*
|
437 |
+
* @param WC_Product $product
|
438 |
+
*
|
439 |
+
* @return mixed
|
440 |
+
*/
|
441 |
+
function yit_get_base_product_id( $product ) {
|
442 |
+
|
443 |
+
return $product->is_type( 'variation' ) ?
|
444 |
+
yit_get_prop( $product, 'parent_id' ) :
|
445 |
+
yit_get_prop( $product, 'id' );
|
446 |
+
}
|
447 |
+
}
|
448 |
+
|
449 |
+
if ( !function_exists( 'yit_get_display_price' ) ) {
|
450 |
+
/**
|
451 |
+
* @param WC_Product $product
|
452 |
+
* @param string $price
|
453 |
+
* @param int $qty
|
454 |
+
*/
|
455 |
+
function yit_get_display_price( $product, $price = '', $qty = 1 ) {
|
456 |
+
|
457 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
458 |
+
|
459 |
+
$price = wc_get_price_to_display( $product, array( 'qty' => $qty, 'price' => $price ) );
|
460 |
+
} else {
|
461 |
+
|
462 |
+
$price = $product->get_display_price( $price, $qty );
|
463 |
+
}
|
464 |
+
|
465 |
+
return $price;
|
466 |
+
}
|
467 |
+
}
|
468 |
+
|
469 |
+
if ( !function_exists( 'yit_get_price_excluding_tax' ) ) {
|
470 |
+
/**
|
471 |
+
* @param WC_Product $product
|
472 |
+
* @param int $qty
|
473 |
+
* @param string $price
|
474 |
+
*
|
475 |
+
* @return float|string
|
476 |
+
*/
|
477 |
+
function yit_get_price_excluding_tax( $product, $qty = 1, $price = '' ) {
|
478 |
+
|
479 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
480 |
+
|
481 |
+
$price = wc_get_price_excluding_tax( $product, array( 'qty' => $qty, 'price' => $price ) );
|
482 |
+
} else {
|
483 |
+
|
484 |
+
$price = $product->get_price_excluding_tax( $qty, $price );
|
485 |
+
}
|
486 |
+
|
487 |
+
return $price;
|
488 |
+
}
|
489 |
+
}
|
490 |
+
|
491 |
+
if ( !function_exists( 'yit_get_price_including_tax' ) ) {
|
492 |
+
/**
|
493 |
+
* @param WC_Product $product
|
494 |
+
* @param int $qty
|
495 |
+
* @param string $price
|
496 |
+
*
|
497 |
+
* @return float|string
|
498 |
+
*/
|
499 |
+
function yit_get_price_including_tax( $product, $qty = 1, $price = '' ) {
|
500 |
+
|
501 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
502 |
+
|
503 |
+
$price = wc_get_price_including_tax( $product, array( 'qty' => $qty, 'price' => $price ) );
|
504 |
+
} else {
|
505 |
+
|
506 |
+
$price = $product->get_price_including_tax( $qty, $price );
|
507 |
+
}
|
508 |
+
|
509 |
+
return $price;
|
510 |
+
}
|
511 |
+
}
|
512 |
+
|
513 |
+
|
514 |
yit_fix_wc_deprecated_filters();
|
515 |
add_action( 'shutdown', 'yit_send_changes_to_db' );
|