YITH WooCommerce Ajax Product Filter - Version 3.3.1

Version Description

  • Released: 20 MArch, 2017 =

  • Fix: Filter by color lost current filter

Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Product Filter
Version 3.3.1
Comparing to
See all releases

Code changes from version 3.3.0 to 3.3.1

README.txt CHANGED
@@ -3,8 +3,8 @@
3
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.3.0
8
License: GPLv2 or later
9
License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
@@ -159,6 +159,10 @@ If you want to see a demonstration version of the premium plugin, you can see it
159
160
== Changelog ==
161
162
= 3.3.0 - Released: 24 February, 2017 =
163
164
* New: Support to WooCoomerce 2.7-beta3
3
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.3
7
+ Stable tag: 3.3.1
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.1 - Released: 20 MArch, 2017 =
163
+
164
+ * Fix: Filter by color lost current filter
165
+
166
= 3.3.0 - Released: 24 February, 2017 =
167
168
* New: Support to WooCoomerce 2.7-beta3
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.3.0
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.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
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.1
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.1' );
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.45
5
* Author: Yithemes
6
* Text Domain: yith-plugin-fw
7
* Domain Path: /languages/
@@ -54,3 +54,5 @@ if ( ! function_exists ( 'yit_maybe_plugin_fw_loader' ) ) {
54
}
55
}
56
}
1
<?php
2
/**
3
* Framework Name: YIT Plugin Framework
4
+ * Version: 2.9.57
5
* Author: Yithemes
6
* Text Domain: yith-plugin-fw
7
* Domain Path: /languages/
54
}
55
}
56
}
57
+
58
+
plugin-fw/lib/yit-upgrade.php CHANGED
@@ -33,7 +33,7 @@ if ( ! class_exists( 'YIT_Upgrade' ) ) {
33
/**
34
* @var string api server url
35
*/
36
- protected $_package_url = 'http://www.yithemes.com';
37
38
/**
39
* @var array The registered plugins
33
/**
34
* @var string api server url
35
*/
36
+ protected $_package_url = 'https://yithemes.com';
37
38
/**
39
* @var array The registered plugins
plugin-fw/licence/lib/yit-licence.php CHANGED
@@ -48,7 +48,7 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
48
* @var string The yithemes api uri
49
* @since 1.0
50
*/
51
- protected $_api_uri = 'http://yithemes.com';
52
53
/**
54
* @var string The yithemes api uri query args
@@ -143,7 +143,7 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
143
$home_url = str_replace( $scheme, '', $home_url );
144
}
145
146
- return $home_url;
147
}
148
149
/**
@@ -692,7 +692,7 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
692
* @author Andrea Grillo <andrea.grillo@yithemes.com>
693
*/
694
public function display_product_name( $product_name ){
695
- return str_replace( array( 'for WooCommerce', 'YITH', 'WooCommerce', 'Premium', 'Theme' ), '', $product_name );
696
}
697
698
public function get_number_of_membership_products(){
48
* @var string The yithemes api uri
49
* @since 1.0
50
*/
51
+ protected $_api_uri = 'https://yithemes.com';
52
53
/**
54
* @var string The yithemes api uri query args
143
$home_url = str_replace( $scheme, '', $home_url );
144
}
145
146
+ return apply_filters('yit_licence_get_home_url', $home_url );
147
}
148
149
/**
692
* @author Andrea Grillo <andrea.grillo@yithemes.com>
693
*/
694
public function display_product_name( $product_name ){
695
+ return str_replace( array( 'for WooCommerce', 'YITH', 'WooCommerce', 'Premium', 'Theme', 'WordPress' ), '', $product_name );
696
}
697
698
public function get_number_of_membership_products(){
plugin-fw/licence/lib/yit-plugin-licence.php CHANGED
@@ -71,9 +71,9 @@ if ( !class_exists( 'YIT_Plugin_Licence' ) ) {
71
);
72
73
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
74
- add_action( "wp_ajax_activate-{$this->_product_type}", array( $this, 'activate' ) );
75
- add_action( "wp_ajax_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
76
- add_action( "wp_ajax_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
77
add_action( 'yit_licence_after_check', array( $this, 'licence_after_check' ) );
78
}
79
71
);
72
73
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
74
+ add_action( "wp_ajax_yith_activate-{$this->_product_type}", array( $this, 'activate' ) );
75
+ add_action( "wp_ajax_yith_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
76
+ add_action( "wp_ajax_yith_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
77
add_action( 'yit_licence_after_check', array( $this, 'licence_after_check' ) );
78
}
79
plugin-fw/licence/lib/yit-theme-licence.php CHANGED
@@ -73,9 +73,9 @@ if ( !class_exists( 'YIT_Theme_Licence' ) ) {
73
);
74
75
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
76
- add_action( "wp_ajax_activate-{$this->_product_type}", array( $this, 'activate' ) );
77
- add_action( "wp_ajax_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
78
- add_action( "wp_ajax_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
79
}
80
81
/**
73
);
74
75
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
76
+ add_action( "wp_ajax_yith_activate-{$this->_product_type}", array( $this, 'activate' ) );
77
+ add_action( "wp_ajax_yith_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
78
+ add_action( "wp_ajax_yith_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
79
}
80
81
/**
plugin-fw/licence/templates/panel/activation/activation-panel.php CHANGED
@@ -25,7 +25,7 @@ $num_members_products_activate = $this->get_number_of_membership_products();
25
<div class="licence-check-section">
26
<form method="post" id="licence-check-update" action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
27
<span class="licence-label" style="display: block;"><?php _e( 'Have you updated your licenses? Have you asked for an extension? Update information concerning your products.', 'yith-plugin-fw' ); ?></span>
28
- <input type="hidden" name="action" value="update_licence_information-<?php echo $this->get_product_type(); ?>" />
29
<input type="submit" name="submit" value="<?php _e( 'Update license information', 'yith-plugin-fw' ) ?>" class="button-licence licence-check" />
30
<div class="spinner"></div>
31
</form>
@@ -61,7 +61,7 @@ $num_members_products_activate = $this->get_number_of_membership_products();
61
<input type="submit" name="submit" value="<?php _e( 'Activate', 'yith-plugin-fw' )?>" class="button-licence licence-activation" data-formid="<?php echo $info['product_id'] ?>"/>
62
</td>
63
</tr>
64
- <input type="hidden" name="action" value="activate-<?php echo $this->get_product_type(); ?>" />
65
<input type="hidden" name="product_init" value="<?php echo $init ?>" />
66
</tbody>
67
</table>
@@ -138,7 +138,7 @@ $num_members_products_activate = $this->get_number_of_membership_products();
138
data-licence-email="<?php echo $info['licence']['email'] ?>"
139
data-licence-key="<?php echo $info['licence']['licence_key'] ?>"
140
data-product-init="<?php echo $init ?>"
141
- data-action="deactivate-<?php echo $this->get_product_type(); ?>">
142
<?php _e( 'Deactivate', 'yith-plugin-fw' ) ?>
143
</a>
144
25
<div class="licence-check-section">
26
<form method="post" id="licence-check-update" action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
27
<span class="licence-label" style="display: block;"><?php _e( 'Have you updated your licenses? Have you asked for an extension? Update information concerning your products.', 'yith-plugin-fw' ); ?></span>
28
+ <input type="hidden" name="action" value="yith_update_licence_information-<?php echo $this->get_product_type(); ?>" />
29
<input type="submit" name="submit" value="<?php _e( 'Update license information', 'yith-plugin-fw' ) ?>" class="button-licence licence-check" />
30
<div class="spinner"></div>
31
</form>
61
<input type="submit" name="submit" value="<?php _e( 'Activate', 'yith-plugin-fw' )?>" class="button-licence licence-activation" data-formid="<?php echo $info['product_id'] ?>"/>
62
</td>
63
</tr>
64
+ <input type="hidden" name="action" value="yith_activate-<?php echo $this->get_product_type(); ?>" />
65
<input type="hidden" name="product_init" value="<?php echo $init ?>" />
66
</tbody>
67
</table>
138
data-licence-email="<?php echo $info['licence']['email'] ?>"
139
data-licence-key="<?php echo $info['licence']['licence_key'] ?>"
140
data-product-init="<?php echo $init ?>"
141
+ data-action="yith_deactivate-<?php echo $this->get_product_type(); ?>">
142
<?php _e( 'Deactivate', 'yith-plugin-fw' ) ?>
143
</a>
144
plugin-fw/yit-plugin.php CHANGED
@@ -41,3 +41,39 @@ load_textdomain( 'yith-plugin-fw', get_template_directory() . '/core/plugin-fw/y
41
42
// ...or from plugin folder
43
|| load_textdomain( 'yith-plugin-fw', dirname(__FILE__) . '/languages/yith-plugin-fw-' . apply_filters( 'plugin_locale', get_locale(), 'yith-plugin-fw' ) . '.mo' );
41
42
// ...or from plugin folder
43
|| load_textdomain( 'yith-plugin-fw', dirname(__FILE__) . '/languages/yith-plugin-fw-' . apply_filters( 'plugin_locale', get_locale(), 'yith-plugin-fw' ) . '.mo' );
44
+
45
+ if( apply_filters( 'yit_fw_wc_update_message_hook', true )
46
+ &&
47
+ ( function_exists( 'WC' ) && ! version_compare( WC()->version, '2.7', '>=' ) )
48
+ && ! isset( $_COOKIE['yith_wc_2_7_notice'] )
49
+ ){
50
+ add_action( 'admin_notices', 'yit_fw_wc_update_message', 15 );
51
+
52
+ if( ! function_exists( 'yit_fw_wc_update_message' ) ){
53
+ function yit_fw_wc_update_message(){
54
+ ?>
55
+ <div id="yith-notice-is-dismissable" class="yith-wc-update-message notice notice-error is-dismissible">
56
+ <?php $message = 'the new WooCommerce version 2.7 will be soon released. <strong>Before</strong> proceeding with the update, please verify the plugins you are using are already compatible. You can check the compatibility status of YITH products'; ?>
57
+ <?php $url = 'https://support.yithemes.com/hc/en-us/articles/215945378-Theme-and-Plugin-compatibility-with-WordPress-and-WooCommerce'; ?>
58
+ <p><?php printf( '<strong>%s</strong> - %s <a href="%s" target="_blank">HERE</a>.', 'Please note', $message, $url ); ?></p>
59
+ </div>
60
+ <?php
61
+ }
62
+ }
63
+
64
+ add_action( 'admin_enqueue_scripts', 'yit_plugin_fw_dismissable_notice', 20 );
65
+
66
+ if( ! function_exists( 'yit_plugin_fw_dismissable_notice' ) ){
67
+ function yit_plugin_fw_dismissable_notice(){
68
+ $assets_path = str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/';
69
+ wp_enqueue_script( 'jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie.min.js', array( 'jquery' ), '1.4.1', true);
70
+ $js = "jQuery( document ).ready( function(){
71
+ jQuery( '#yith-notice-is-dismissable' ).find('.notice-dismiss').on( 'click', function(){
72
+ jQuery.cookie('yith_wc_2_7_notice', 'dismiss', { path: '/' });
73
+ } );
74
+ } ); ";
75
+
76
+ wp_add_inline_script( 'jquery-cookie', $js );
77
+ }
78
+ }
79
+ }
plugin-fw/yit-woocommerce-compatibility.php CHANGED
@@ -12,6 +12,10 @@ if ( !defined( 'ABSPATH' ) ) {
12
exit;
13
} // Exit if accessed directly
14
15
$changed_objects = array();
16
17
if ( !function_exists( 'yit_get_prop' ) ) {
@@ -44,7 +48,9 @@ if ( !function_exists( 'yit_get_prop' ) ) {
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
}
@@ -94,7 +100,7 @@ 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
@@ -107,12 +113,18 @@ if ( !function_exists( 'yit_save_prop' ) ) {
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
}
@@ -138,12 +150,14 @@ if ( !function_exists( 'yit_delete_prop' ) ) {
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
}
@@ -156,6 +170,7 @@ if ( !function_exists( 'yit_return_new_attribute_map' ) ) {
156
'post_title' => 'name',
157
'post_status' => 'status',
158
'post_content' => 'description',
159
/* Orders */
160
'paid_date' => 'date_paid',
161
'_paid_date' => '_date_paid',
@@ -163,6 +178,7 @@ if ( !function_exists( 'yit_return_new_attribute_map' ) ) {
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',
@@ -175,7 +191,7 @@ if ( !function_exists( 'yit_return_new_attribute_map' ) ) {
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;
@@ -186,16 +202,15 @@ if ( !function_exists( 'yit_store_changes' ) ) {
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
}
@@ -212,8 +227,9 @@ if ( !function_exists( 'yit_send_changes_to_db' ) ) {
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;
@@ -319,7 +335,6 @@ if ( !function_exists( 'yit_wc_deprecated_filters' ) ) {
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
}
@@ -440,7 +455,7 @@ if ( !function_exists( 'yit_get_base_product_id' ) ) {
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
}
@@ -510,6 +525,170 @@ if ( !function_exists( 'yit_get_price_including_tax' ) ) {
510
}
511
}
512
513
514
yit_fix_wc_deprecated_filters();
515
add_action( 'shutdown', 'yit_send_changes_to_db' );
12
exit;
13
} // Exit if accessed directly
14
15
+ if ( !function_exists( 'WC' ) ) {
16
+ return;
17
+ }
18
+
19
$changed_objects = array();
20
21
if ( !function_exists( 'yit_get_prop' ) ) {
48
$getter = 'get_user_meta';
49
!$object instanceof WC_Customer && $getter = 'get_post_meta';
50
51
+ $object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id;
52
+
53
+ return $getter( $object_id, $key, true );
54
}
55
}
56
}
100
/**
101
*
102
*/
103
+ function yit_save_prop( $object, $arg1, $arg2 = false, $force_update = false ) {
104
if ( !is_array( $arg1 ) ) {
105
$arg1 = array(
106
$arg1 => $arg2
113
yit_set_prop( $object, $key, $value );
114
115
if ( $is_wc_data ) {
116
+ if ( $force_update ) {
117
+ $object->save();
118
+ } else {
119
+ yit_store_changes( $object, $key, $value );
120
+ }
121
} else {
122
if ( yit_wc_check_post_columns( $key ) ) {
123
yit_store_changes( $object->post, $key, $value );
124
} else {
125
+ $object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id;
126
+
127
+ update_post_meta( $object_id, $key, $value );
128
}
129
}
130
}
150
$object->delete_meta_data( $key, $value );
151
}
152
153
+ yit_store_changes( $object, $key );
154
} else {
155
if ( yit_wc_check_post_columns( $key ) && ( !$value || $object->post->$key == $value ) ) {
156
yit_store_changes( $object->post, $key, '' );
157
} else {
158
+ $object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id;
159
+
160
+ delete_post_meta( $object_id, $key, $value );
161
}
162
}
163
}
170
'post_title' => 'name',
171
'post_status' => 'status',
172
'post_content' => 'description',
173
+ 'post_excerpt' => 'short_description',
174
/* Orders */
175
'paid_date' => 'date_paid',
176
'_paid_date' => '_date_paid',
178
'_completed_date' => '_date_completed',
179
'_order_date' => '_date_created',
180
'order_date' => 'date_created',
181
+ 'order_total' => 'total',
182
/* Products */
183
'visibility' => 'catalog_visibility',
184
'_visibility' => '_catalog_visibility',
191
}
192
193
if ( !function_exists( 'yit_store_changes' ) ) {
194
+ function yit_store_changes( $object, $key, $value = false ) {
195
global $changed_objects;
196
197
$is_wc_data = $object instanceof WC_Data;
202
*/
203
$object_reference = $object->get_id();
204
205
+ $cache_type = is_a( $object, 'WC_Product' ) ? 'product' : 'order';
206
+ $cache_key = $cache_type . '-' . $object_reference;
207
+ $cache_group = $cache_type . 's';
208
209
+ $changed_objects[ $object_reference ][ 'object' ] = $object;
210
+ $changed_objects[ $object_reference ][ 'changes' ][ $key ] = $value;
211
212
+
213
+ wp_cache_set( $cache_key, $object, $cache_group );
214
} else {
215
$changed_objects[ $object->ID ][ $key ] = $value;
216
}
227
/**
228
* @var $object \WC_Data
229
*/
230
+ $object = is_a( $data[ 'object' ], 'WC_Product' ) ? wc_get_product( $id ) : wc_get_order( $id );
231
232
+ yit_set_prop( $object, $data[ 'changes' ] );
233
$object->save();
234
} else {
235
$data[ 'ID' ] = $id;
335
'default_checkout_country' => 'default_checkout_billing_country',
336
'default_checkout_state' => 'default_checkout_billing_state',
337
'default_checkout_postcode' => 'default_checkout_billing_postcode',
338
339
) );
340
}
455
*/
456
function yit_get_base_product_id( $product ) {
457
458
+ return $product instanceof WC_Data && $product->is_type( 'variation' ) ?
459
yit_get_prop( $product, 'parent_id' ) :
460
yit_get_prop( $product, 'id' );
461
}
525
}
526
}
527
528
+ if ( !function_exists( 'yit_get_product_image_id' ) ) {
529
+ /**
530
+ * get the attach image id
531
+ *
532
+ * @param WC_Product $product
533
+ * @param string $context ( view/edit )
534
+ */
535
+ function yit_get_product_image_id( $product, $context = 'view' ) {
536
+
537
+ if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
538
+
539
+ $image_id = $product->get_image_id( $context );
540
+ } else {
541
+
542
+ $image_id = $product->get_image_id();
543
+ }
544
+
545
+ return $image_id;
546
+ }
547
+ }
548
+
549
+ if ( !function_exists( 'yit_get_refund_amount' ) ) {
550
+ /**
551
+ * @param $refund \WC_Order_Refund
552
+ * @param $context string
553
+ *
554
+ * @return float
555
+ */
556
+ function yit_get_refund_amount( $refund, $context = 'view' ) {
557
+ $is_wc_data = $refund instanceof WC_Data;
558
+
559
+ if ( $is_wc_data ) {
560
+ return $refund->get_amount( $context );
561
+ } else {
562
+ return $refund->get_refund_amount();
563
+ }
564
+ }
565
+ }
566
+
567
+ if ( !function_exists( 'yit_add_select2_fields' ) ) {
568
+ /**
569
+ * Add select 2
570
+ *
571
+ * @param array $args
572
+ */
573
+ function yit_add_select2_fields( $args = array() ) {
574
+ $default = array(
575
+ 'type' => 'hidden',
576
+ 'class' => '',
577
+ 'id' => '',
578
+ 'name' => '',
579
+ 'data-placeholder' => '',
580
+ 'data-allow_clear' => false,
581
+ 'data-selected' => '',
582
+ 'data-multiple' => false,
583
+ 'data-action' => '',
584
+ 'value' => '',
585
+ 'style' => '',
586
+ 'custom-attributes' => array()
587
+ );
588
+
589
+ $args = wp_parse_args( $args, $default );
590
+
591
+ $custom_attributes = array();
592
+ foreach ( $args[ 'custom-attributes' ] as $attribute => $attribute_value ) {
593
+ $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
594
+ }
595
+ $custom_attributes = implode( ' ', $custom_attributes );
596
+
597
+ if ( version_compare( WC()->version, '2.7.0', '>=' ) ) :
598
+ if ( $args[ 'data-multiple' ] === true && substr( $args[ 'name' ], -2 ) != '[]' ) {
599
+ $args[ 'name' ] = $args[ 'name' ] . '[]';
600
+ }
601
+ ?>
602
+
603
+ <select
604
+ id="<?php echo $args[ 'id' ] ?>"
605
+ class="<?php echo $args[ 'class' ] ?>"
606
+ name="<?php echo $args[ 'name' ] ?>"
607
+ data-placeholder="<?php echo $args[ 'data-placeholder' ] ?>"
608
+ data-allow_clear="<?php echo $args[ 'data-allow_clear' ] ?>"
609
+ <?php echo !empty( $args[ 'data-action' ] ) ? 'data-action="' . $args[ 'data-action' ] . '"' : ''; ?>
610
+ <?php echo !empty( $args[ 'data-multiple' ] ) ? 'multiple="multiple"' : ''; ?>
611
+ style="<?php echo $args[ 'style' ] ?>"
612
+ <?php echo $custom_attributes ?>
613
+ >
614
+
615
+ <?php if ( !empty( $args[ 'value' ] ) ) {
616
+ $values = $args[ 'value' ];
617
+
618
+ if ( !is_array( $values ) ) {
619
+ $values = explode( ',', $values );
620
+ }
621
+
622
+ foreach ( $values as $value ): ?>
623
+ <option value="<?php echo $value; ?>" <?php selected( true, true, true ) ?> >
624
+ <?php echo $args[ 'data-selected' ][ $value ]; ?>
625
+ </option>
626
+ <?php endforeach;
627
+ }
628
+ ?>
629
+ </select>
630
+ <?php
631
+ else :
632
+ if ( $args[ 'data-multiple' ] === false && is_array( $args[ 'data-selected' ] ) ) {
633
+ $args[ 'data-selected' ] = current($args[ 'data-selected' ]);
634
+ }
635
+
636
+ ?>
637
+ <input
638
+ type="hidden"
639
+ id="<?php echo $args[ 'id' ] ?>"
640
+ class="<?php echo $args[ 'class' ] ?>"
641
+ name="<?php echo $args[ 'name' ] ?>"
642
+ data-placeholder="<?php echo $args[ 'data-placeholder' ] ?>"
643
+ data-allow_clear="<?php echo $args[ 'data-allow_clear' ] ?>"
644
+ data-selected="<?php echo is_array( $args[ 'data-selected' ] ) ? esc_attr( json_encode( $args[ 'data-selected' ] ) ) : esc_attr( $args[ 'data-selected' ] ) ?>"
645
+ data-multiple="<?php echo $args[ 'data-multiple' ] === true ? 'true' : 'false' ?>"
646
+ <?php echo( !empty( $args[ 'data-action' ] ) ? 'data-action="' . $args[ 'data-action' ] . '"' : '' ) ?>
647
+ value="<?php echo $args[ 'value' ] ?>"
648
+ style="<?php echo $args[ 'style' ] ?>"
649
+ <?php echo $custom_attributes ?>
650
+ />
651
+ <?php
652
+ endif;
653
+ }
654
+ }
655
+
656
+ if ( !function_exists( 'yit_product_visibility_meta' ) ) {
657
+ function yit_product_visibility_meta( $args ) {
658
+ if ( version_compare( WC()->version, '2.7.0', '<' ) ) {
659
+ $args[ 'meta_query' ] = isset( $args[ 'meta_query' ] ) ? $args[ 'meta_query' ] : array();
660
+ $args[ 'meta_query' ][] = WC()->query->visibility_meta_query();
661
+ } else {
662
+ $product_visibility_term_ids = wc_get_product_visibility_term_ids();
663
+ $args[ 'tax_query' ] = isset( $args[ 'tax_query' ] ) ? $args[ 'tax_query' ] : array();
664
+ $args[ 'tax_query' ][] = array(
665
+ 'taxonomy' => 'product_visibility',
666
+ 'field' => 'term_taxonomy_id',
667
+ 'terms' => is_search() ? $product_visibility_term_ids[ 'exclude-from-search' ] : $product_visibility_term_ids[ 'exclude-from-catalog' ],
668
+ 'operator' => 'NOT IN',
669
+ );
670
+ }
671
+
672
+ return $args;
673
+ }
674
+ }
675
+
676
+ if ( !function_exists( 'yit_datetime_to_timestamp' ) ) {
677
+
678
+ /**
679
+ *
680
+ */
681
+ function yit_datetime_to_timestamp( $date ) {
682
+
683
+ if ( version_compare( WC()->version, '2.7.0', '<' ) ) {
684
+ $date = strtotime( $date );
685
+ }
686
+
687
+ return $date;
688
+ }
689
+
690
+ }
691
+
692
693
yit_fix_wc_deprecated_filters();
694
add_action( 'shutdown', 'yit_send_changes_to_db' );
widgets/class.yith-wcan-navigation-widget.php CHANGED
@@ -432,7 +432,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
432
if ( $name !== $taxonomy ) {
433
434
// Exclude query arg for current term archive term
435
- while ( $in_array_function( $current_term, $data['terms'] ) ) {
436
$key = array_search( $current_term, $data );
437
unset( $data['terms'][$key] );
438
}
432
if ( $name !== $taxonomy ) {
433
434
// Exclude query arg for current term archive term
435
+ while ( $in_array_function( $term->slug, $data['terms'] ) ) {
436
$key = array_search( $current_term, $data );
437
unset( $data['terms'][$key] );
438
}