YITH WooCommerce Ajax Product Filter - Version 2.3.1

Version Description

  • Added: Support to YITH Infinite Scrolling plugin
  • Fixed: No pagination container issue after filter applied
  • Fixed: js error yit_wcan not defined
  • Fixed: issue with blank label
Download this release

Release Info

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

Code changes from version 2.3.0 to 2.3.1

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.3
7
- Stable tag: 2.3.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -52,9 +52,9 @@ YITH WooCommerce Ajax Product Filter is available in combination with many other
52
 
53
  YITH WooCommerce Ajax Product Filter has been tested and compatibility is certain with the following WooCommerce plugins that you can add to your site:
54
 
55
- * [YITH WooCommerce Multi Vendor](https://wordpress.org/plugins/yith-woocommerce-product-vendors)
56
- * [YITH WooCommerce Brands Add-On](https://wordpress.org/plugins/yith-woocommerce-brands-add-on)
57
- * [YITH Product Size Charts for WooCommerce](https://wordpress.org/plugins/yith-product-size-charts-for-woocommerce)
58
 
59
  Nevertheless, it could be compatible with many other WooCommerce plugins that have not been tested yet. If you want to inform us about compatibility with other plugins, please, [email to us](mailto:plugins@yithemes.com "Your Inspiration Themes").
60
 
@@ -83,7 +83,6 @@ After renaming the files, you can update/translate the .po file following the cl
83
 
84
  The issue could be related to the fact you are using a non-standard template for a WooCommerce shop page. To solve it, you should ask to the theme's author to use WooCommerce standard HTML classes.
85
  As an alternative:
86
-
87
  **For version prior to 2.2.0:**
88
 
89
  you can use this piece of code in functions.php file of your theme:
@@ -156,6 +155,13 @@ If you want to see a demonstration version of the premium plugin, you can see it
156
 
157
  == Changelog ==
158
 
 
 
 
 
 
 
 
159
  = 2.3.0 =
160
 
161
  * Added: Custom Style Section
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.3
7
+ Stable tag: 2.3.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
52
 
53
  YITH WooCommerce Ajax Product Filter has been tested and compatibility is certain with the following WooCommerce plugins that you can add to your site:
54
 
55
+ * [YITH WooCommerce Multi Vendor](https://wordpress.org/plugins/yith-woocommerce-product-vendors/)
56
+ * [YITH WooCommerce Brands Add-On](https://wordpress.org/plugins/yith-woocommerce-brands-add-on/)
57
+ * [YITH Product Size Charts for WooCommerce](https://wordpress.org/plugins/yith-product-size-charts-for-woocommerce/)
58
 
59
  Nevertheless, it could be compatible with many other WooCommerce plugins that have not been tested yet. If you want to inform us about compatibility with other plugins, please, [email to us](mailto:plugins@yithemes.com "Your Inspiration Themes").
60
 
83
 
84
  The issue could be related to the fact you are using a non-standard template for a WooCommerce shop page. To solve it, you should ask to the theme's author to use WooCommerce standard HTML classes.
85
  As an alternative:
 
86
  **For version prior to 2.2.0:**
87
 
88
  you can use this piece of code in functions.php file of your theme:
155
 
156
  == Changelog ==
157
 
158
+ = 2.3.1 =
159
+
160
+ * Added: Support to YITH Infinite Scrolling plugin
161
+ * Fixed: No pagination container issue after filter applied
162
+ * Fixed: js error yit_wcan not defined
163
+ * Fixed: issue with blank label
164
+
165
  = 2.3.0 =
166
 
167
  * Added: Custom Style Section
assets/js/yith-wcan-frontend.js CHANGED
@@ -161,7 +161,6 @@ jQuery(function ($) {
161
  $('.yit-wcan-container').html($(response).find('.woocommerce-info'));
162
  }
163
 
164
-
165
  //pagination
166
  if ($(response).find(yith_wcan.pagination).length > 0) {
167
  //se non esiste lo creo
@@ -174,6 +173,10 @@ jQuery(function ($) {
174
  .show();
175
  }
176
 
 
 
 
 
177
  //result count
178
  if ($(response).find(yith_wcan.result_count).length > 0) {
179
  $(yith_wcan.result_count).html($(response).find(yith_wcan.result_count).html()).show();
161
  $('.yit-wcan-container').html($(response).find('.woocommerce-info'));
162
  }
163
 
 
164
  //pagination
165
  if ($(response).find(yith_wcan.pagination).length > 0) {
166
  //se non esiste lo creo
173
  .show();
174
  }
175
 
176
+ else {
177
+ $(yith_wcan.pagination).empty();
178
+ }
179
+
180
  //result count
181
  if ($(response).find(yith_wcan.result_count).length > 0) {
182
  $(yith_wcan.result_count).html($(response).find(yith_wcan.result_count).html()).show();
assets/js/yith-wcan-frontend.min.js CHANGED
@@ -1,308 +1,13 @@
1
- /**
2
- * Frontend
3
- *
4
- * @author Your Inspiration Themes
5
- * @package YITH WooCommerce Ajax Navigation
6
- * @version 1.3.2
7
- */
8
- jQuery(function ($) {
9
- /**
10
- Copyright (c) 2010, All Right Reserved, Wong Shek Hei @ shekhei@gmail.com
11
- License: GNU Lesser General Public License (http://www.gnu.org/licenses/lgpl.html)
12
- **/
13
- var expr = /[.#\w].([\S]*)/g, classexpr = /(?!(\[))(\.)[^.#[]*/g, idexpr = /(#)[^.#[]*/, tagexpr = /^[\w]+/, varexpr = /(\w+?)=(['"])([^\2$]*?)\2/, simpleselector = /^[\w]+$/, parseSelector = function (d) {
14
- for (var c = {sel: [], val: []}, a = [], j = !1, h = "", e = [], f = 0, m = d.length; f < m; f++) {
15
- var g = d.charAt(f);
16
- if (j)if ("\\" === g && f + 1 < d.length)e.push(d.charAt(++f)); else if (h === g)h = "", e.push(g); else if (("'" === g || '"' === g) && "" === h)h = g, e.push(g); else if ("]" === g && "" === h)c.val.push(e.join("")), e = [], j = !1; else {
17
- if ("]" !== g || "" !== h)"" === h && "," === g ? (c.val.push(e.join("")),
18
- e = []) : e.push(g)
19
- } else"\\" === g && f + 1 < d.length ? j && e.push(d.charAt(++f)) : "[" === g && "" === h ? j = !0 : " " === g || "+" === g ? (c.sel = c.sel.join(""), a.push(c), "+" === g && a.push({sel: "+", val: ""}), c = {sel: [], val: []}) : " " !== g && "]" !== g && c.sel.push(g)
20
- }
21
- if (0 != c.sel.length || 0 != c.val.length)c.sel = c.sel.join(""), a.push(c);
22
- for (f = 0; f < a.length; f++) {
23
- c = a[f].sel;
24
- if ("+" === c)b.tag = c; else {
25
- var b = [];
26
- b.tag = tagexpr.exec(c);
27
- b.id = idexpr.exec(c);
28
- b.id && $.isArray(b.id) && (b.id = b.id[0].substr(1));
29
- b.tag || (b.tag = "div");
30
- b.vars = [];
31
- for (d = 0; d < a[f].val.length; d++)h =
32
- a[f].val[d].indexOf("="), j = a[f].val[d].substr(0, h), h = a[f].val[d].substr(h + 1), h = h.replace(/^[\s]*[\"\']*|[\"\']*[\s]*$/g, ""), "text" === j ? b.text = h : b.vars.push([j, h]);
33
- c = c.match(classexpr);
34
- j = [];
35
- if (c) {
36
- for (d = 0; d < c.length; d++)j.push(c[d].substr(1));
37
- b.className = j.join(" ")
38
- }
39
- }
40
- a[f] = b
41
- }
42
- return a
43
- }, rmFromParent = function (d) {
44
- var c = d.parentNode, a = d.nextSibling;
45
- c.removeChild(d);
46
- return a ? function () {
47
- c.insertBefore(d, a)
48
- } : function () {
49
- c.appendChild(d)
50
- }
51
- }, nonArrVer = function (d, c) {
52
- var a = [], a = simpleselector.test(d) ? [
53
- {tag: d}
54
- ] : parseSelector(d),
55
- j = [];
56
- "undefined" === typeof c && (c = 1);
57
- for (var h = [], e = [], f = [], m = document.createElement("div"), g = 0, b = 0; b < a.length; b++) {
58
- if ("+" == a[b].tag)e = f.slice(), --g; else {
59
- for (var l = 0; l < c; l++)if ("input" == a[b].tag) {
60
- var k = [];
61
- k.push("<" + a[b].tag);
62
- a[b].id && k.push("id='" + a[b].id + "'");
63
- a[b].className && (k.push("class='" + a[b].className), b + 1 === a.length && k.push(lastClass), k.push("'"));
64
- if (a[b].vars)for (var n = 0; n < a[b].vars.length; n++)k.push(a[b].vars[n][0] + "='" + a[b].vars[n][1] + "'");
65
- a[b].text && k.push("value='" + a[b].text + "'");
66
- k.push("/>");
67
- f[l] = e[l];
68
- e[l] ? (e[l].innerHTML += k.join(" "), e[l] = e[l].lastChild) : (m.innerHTML = k.join(" "), e[l] = m.removeChild(m.firstChild))
69
- } else {
70
- k = document.createElement(a[b].tag);
71
- if (a[b].vars)for (n = 0; n < a[b].vars.length; n++)console.log(a[b].tag, a[b].vars[n]), k.setAttribute(a[b].vars[n][0], a[b].vars[n][1]);
72
- a[b].id && (k.id = a[b].id);
73
- a[b].className && (k.className = a[b].className);
74
- a[b].text && k.appendChild(document.createTextNode(a[b].text));
75
- f[l] = e[l];
76
- e[l] = e[l] ? e[l].appendChild(k) : k
77
- }
78
- g++ || Array.prototype.push.apply(h, e)
79
- }
80
- j =
81
- $.merge(j, e)
82
- }
83
- return $(h)
84
- }, arrVer = function (d, c, a) {
85
- for (var j = d.match(/%[^%]*%/g) || [], h = [], e = 0; e < c.length; e++) {
86
- for (var f = d, m = 0; m < j.length; m++)var g = j[m].substr(1, j[m].length - 2), f = f.replace(j[m], c[e][g]);
87
- h = $.merge(h, nonArrVer(f, a))
88
- }
89
- return $(h)
90
- };
91
- $.jseldom = function (d) {
92
- if (2 == arguments.length && $.isPlainObject(arguments[1]))return arrVer.apply(this, [arguments[0], [arguments[1]]]);
93
- if (1 == arguments.length || 2 == arguments.length && !$.isArray(arguments[1]))return nonArrVer.apply(this, arguments);
94
- if (2 == arguments.length)return arrVer.apply(this, arguments)
95
- };
96
-
97
- $.fn.yith_wcan_ajax_filters = function (e, obj) {
98
- e.preventDefault();
99
- var href = obj.href,
100
- t = $(obj);
101
-
102
- if (typeof href == 'undefined' && t.parents().hasClass('price_slider_wrapper')) {
103
- var form = t.parents('form'),
104
- l = window.location,
105
- shop_uri = l.origin + l.pathname,
106
- is_filtered = shop_uri != l.href,
107
- search = l.search,
108
- min_price = $('.price_slider_amount #min_price').val(),
109
- max_price = $('.price_slider_amount #max_price').val(),
110
- regex_min = new RegExp('^min_price', 'i'),
111
- regex_max = new RegExp('^max_price', 'i');
112
-
113
- href = l.href;
114
-
115
- if (is_filtered == true) {
116
- href = RemoveParameterFromUrl(href, 'min_price');
117
- href = RemoveParameterFromUrl(href, 'max_price');
118
- }
119
-
120
- var concat = shop_uri == href ? '?' : '&';
121
-
122
- href = href + concat + $.param(
123
- {
124
- min_price: min_price,
125
- max_price: max_price
126
- }
127
- );
128
- }
129
-
130
- if (t.data('type') == 'select') {
131
-
132
- t.parents('div.yith-woo-ajax-navigation').find('a.yit-wcan-select-open').removeClass('active');
133
-
134
- t.parent().find('div.yith-wcan-select-wrapper').animate({
135
-
136
- visibility: "hidden",
137
- opacity : 0
138
-
139
- }, 300);
140
- }
141
-
142
- //loading
143
- $(yith_wcan.container).html('').addClass('yith-wcan-loading');
144
-
145
- if (typeof yith_wcan_frontend != 'undefined') {
146
- $(yith_wcan.container).css('backgroundImage', 'url(' + yith_wcan_frontend.loader_url + ')');
147
- }
148
-
149
- $(yith_wcan.pagination).hide();
150
- $(yith_wcan.result_count).hide();
151
-
152
- $.ajax({
153
- url : href,
154
- success: function (response) {
155
- $(yith_wcan.container).removeClass('yith-wcan-loading');
156
-
157
- //container
158
- if ($(response).find(yith_wcan.container).length > 0) {
159
- $('.yit-wcan-container').html($(response).find(yith_wcan.container));
160
- } else {
161
- $('.yit-wcan-container').html($(response).find('.woocommerce-info'));
162
- }
163
-
164
-
165
- //pagination
166
- if ($(response).find(yith_wcan.pagination).length > 0) {
167
- //se non esiste lo creo
168
- if ($(yith_wcan.pagination).length == 0) {
169
- $.jseldom(yith_wcan.pagination).insertAfter($(yith_wcan.container));
170
- }
171
-
172
- $(yith_wcan.pagination)
173
- .html($(response).find(yith_wcan.pagination).html())
174
- .show();
175
- }
176
-
177
- //result count
178
- if ($(response).find(yith_wcan.result_count).length > 0) {
179
- $(yith_wcan.result_count).html($(response).find(yith_wcan.result_count).html()).show();
180
- }
181
-
182
-
183
- var widget_reload = function (t) {
184
- var id = t.attr('id');
185
- t.html($(response).find('#' + id).html());
186
-
187
- if (t.text() == '') {
188
- t.hide();
189
- } else {
190
- t.show();
191
- }
192
- };
193
-
194
- //load new widgets
195
- $('.yith-woo-ajax-navigation').add('.yith-wcan-sort-by').add('.yith-wcan-stock-on-sale').add('.yith-wcan-list-price-filter').each(function () {
196
- var t = $(this);
197
- widget_reload(t)
198
- });
199
-
200
- //update browser history (IE doesn't support it)
201
- if (!navigator.userAgent.match(/msie/i)) {
202
- window.history.pushState({"pageTitle": response.pageTitle}, "", href);
203
- }
204
-
205
- //trigger ready event
206
- $(document).trigger("ready");
207
- $(document).trigger("yith-wcan-ajax-filtered");
208
- }
209
- });
210
- };
211
-
212
- //wrap the container
213
- $(yith_wcan.container).wrap('<div class="yit-wcan-container"></div>');
214
- $('.woocommerce-info').wrap('<div class="yit-wcan-container"></div>');
215
-
216
- $(document).on('click', '.yith-wcan a', function (e) {
217
- $(this).yith_wcan_ajax_filters(e, this);
218
- });
219
-
220
-
221
- /*AJAX NAVIGATION DROPDOWN STYLE*/
222
-
223
- function yit_open_select_dropdown(element) {
224
-
225
- $(element).parent().find('div.yith-wcan-select-wrapper').css("z-index", "1").animate({
226
-
227
- visibility: "visible",
228
- opacity : 1
229
-
230
-
231
- }, 300);
232
-
233
- $(element).parent().find('a.yit-wcan-select-open').addClass('active');
234
- }
235
-
236
- function yit_close_select_dropdown(element) {
237
-
238
- $(element).parent().find('div.yith-wcan-select-wrapper').css("z-index", "-1").animate({
239
-
240
- visibility: "hidden",
241
- opacity : 0
242
-
243
- }, 300);
244
-
245
- $(element).parent().find('a.yit-wcan-select-open').removeClass('active');
246
- }
247
-
248
- var yit_hidden_filters_wrapper = function () {
249
-
250
- $('div.yith-wcan-select-wrapper').animate({
251
-
252
- visibility: "hidden",
253
- opacity : 0
254
-
255
- }, 0);
256
-
257
- $('a.yit-wcan-select-open').removeClass('active');
258
- }
259
-
260
- var yit_active_filter = function () {
261
-
262
- var filter_number = $('div.yith-wcan-select-wrapper ul.yith-wcan-select li.chosen').length;
263
-
264
- yit_hidden_filters_wrapper();
265
-
266
- $('div.yith-wcan-select-wrapper').each(function () {
267
-
268
- var filter_name = "";
269
- var chosen = $(this).find('ul.yith-wcan-select li.chosen').each(function () {
270
- filter_name += $(this).text() + ', ';
271
- });
272
-
273
- filter_name = filter_name.substring(0, filter_name.length - 2);
274
-
275
- if (filter_name != "") {
276
- $(this).parent().find('a.yit-wcan-select-open').text(filter_name);
277
- }
278
- })
279
- }
280
-
281
- $(document).on('click', 'a.yit-wcan-select-open.active', function (e) {
282
- e.preventDefault();
283
- yit_close_select_dropdown(this);
284
- });
285
-
286
- $(document).on('click', 'a.yit-wcan-select-open:not(.active)', function (e) {
287
- e.preventDefault();
288
- yit_open_select_dropdown(this);
289
- });
290
-
291
- $(document).on('ready yith-wcan-ajax-filtered', yit_active_filter);
292
-
293
- $(document).on('ready', yit_hidden_filters_wrapper);
294
-
295
- $('body').on('click', function (e) {
296
-
297
- if (!$(e.target).hasClass('yit-wcan-select-open')) {
298
- yit_hidden_filters_wrapper();
299
- }
300
-
301
- });
302
-
303
- function RemoveParameterFromUrl(url, parameter) {
304
- return url
305
- .replace(new RegExp('[?&]' + parameter + '=[^&#]*(#.*)?$'), '$1')
306
- .replace(new RegExp('([?&])' + parameter + '=[^&]*&'), '$1');
307
- }
308
- });
1
+ jQuery(function(b){function t(b,p){return b.replace(new RegExp("[?&]"+p+"=[^&#]*(#.*)?$"),"$1").replace(new RegExp("([?&])"+p+"=[^&]*&"),"$1")}var w=/(?!(\[))(\.)[^.#[]*/g,x=/(#)[^.#[]*/,y=/^[\w]+/,z=/^[\w]+$/,u=function(h,p){var a=[];if(z.test(h))a=[{tag:h}];else{for(var a=h,d={sel:[],val:[]},f=[],k=!1,g="",l=[],c=0,m=a.length;c<m;c++){var e=a.charAt(c);if(k)if("\\"===e&&c+1<a.length)l.push(a.charAt(++c));else if(g===e)g="",l.push(e);else if(("'"===e||'"'===e)&&""===g)g=e,l.push(e);else if("]"===
2
+ e&&""===g)d.val.push(l.join("")),l=[],k=!1;else{if("]"!==e||""!==g)""===g&&","===e?(d.val.push(l.join("")),l=[]):l.push(e)}else"\\"===e&&c+1<a.length?k&&l.push(a.charAt(++c)):"["===e&&""===g?k=!0:" "===e||"+"===e?(d.sel=d.sel.join(""),f.push(d),"+"===e&&f.push({sel:"+",val:""}),d={sel:[],val:[]}):" "!==e&&"]"!==e&&d.sel.push(e)}if(0!=d.sel.length||0!=d.val.length)d.sel=d.sel.join(""),f.push(d);for(c=0;c<f.length;c++){d=f[c].sel;if("+"===d)n.tag=d;else{var n=[];n.tag=y.exec(d);n.id=x.exec(d);n.id&&
3
+ b.isArray(n.id)&&(n.id=n.id[0].substr(1));n.tag||(n.tag="div");n.vars=[];for(a=0;a<f[c].val.length;a++)g=f[c].val[a].indexOf("="),k=f[c].val[a].substr(0,g),g=f[c].val[a].substr(g+1),g=g.replace(/^[\s]*[\"\']*|[\"\']*[\s]*$/g,""),"text"===k?n.text=g:n.vars.push([k,g]);d=d.match(w);k=[];if(d){for(a=0;a<d.length;a++)k.push(d[a].substr(1));n.className=k.join(" ")}}f[c]=n}a=f}n=[];"undefined"===typeof p&&(p=1);d=[];f=[];k=[];g=document.createElement("div");for(c=l=0;c<a.length;c++){if("+"==a[c].tag)f=
4
+ k.slice(),--l;else{for(m=0;m<p;m++)if("input"==a[c].tag){e=[];e.push("<"+a[c].tag);a[c].id&&e.push("id='"+a[c].id+"'");a[c].className&&(e.push("class='"+a[c].className),c+1===a.length&&e.push(lastClass),e.push("'"));if(a[c].vars)for(var q=0;q<a[c].vars.length;q++)e.push(a[c].vars[q][0]+"='"+a[c].vars[q][1]+"'");a[c].text&&e.push("value='"+a[c].text+"'");e.push("/>");k[m]=f[m];f[m]?(f[m].innerHTML+=e.join(" "),f[m]=f[m].lastChild):(g.innerHTML=e.join(" "),f[m]=g.removeChild(g.firstChild))}else{e=document.createElement(a[c].tag);
5
+ if(a[c].vars)for(q=0;q<a[c].vars.length;q++)console.log(a[c].tag,a[c].vars[q]),e.setAttribute(a[c].vars[q][0],a[c].vars[q][1]);a[c].id&&(e.id=a[c].id);a[c].className&&(e.className=a[c].className);a[c].text&&e.appendChild(document.createTextNode(a[c].text));k[m]=f[m];f[m]=f[m]?f[m].appendChild(e):e}l++||Array.prototype.push.apply(d,f)}n=b.merge(n,f)}return b(d)},v=function(h,p,a){for(var d=h.match(/%[^%]*%/g)||[],f=[],k=0;k<p.length;k++){for(var g=h,l=0;l<d.length;l++)var c=d[l].substr(1,d[l].length-
6
+ 2),g=g.replace(d[l],p[k][c]);f=b.merge(f,u(g,a))}return b(f)};b.jseldom=function(h){if(2==arguments.length&&b.isPlainObject(arguments[1]))return v.apply(this,[arguments[0],[arguments[1]]]);if(1==arguments.length||2==arguments.length&&!b.isArray(arguments[1]))return u.apply(this,arguments);if(2==arguments.length)return v.apply(this,arguments)};b.fn.yith_wcan_ajax_filters=function(h,p){h.preventDefault();var a=p.href,d=b(p);if("undefined"==typeof a&&d.parents().hasClass("price_slider_wrapper")){d.parents("form");
7
+ var f=window.location,k=f.origin+f.pathname,g=k!=f.href,l=b(".price_slider_amount #min_price").val(),c=b(".price_slider_amount #max_price").val(),a=f.href;1==g&&(a=t(a,"min_price"),a=t(a,"max_price"));a=a+(k==a?"?":"&")+b.param({min_price:l,max_price:c})}"select"==d.data("type")&&(d.parents("div.yith-woo-ajax-navigation").find("a.yit-wcan-select-open").removeClass("active"),d.parent().find("div.yith-wcan-select-wrapper").animate({visibility:"hidden",opacity:0},300));b(yith_wcan.container).html("").addClass("yith-wcan-loading");
8
+ "undefined"!=typeof yith_wcan_frontend&&b(yith_wcan.container).css("backgroundImage","url("+yith_wcan_frontend.loader_url+")");b(yith_wcan.pagination).hide();b(yith_wcan.result_count).hide();b.ajax({url:a,success:function(c){b(yith_wcan.container).removeClass("yith-wcan-loading");0<b(c).find(yith_wcan.container).length?b(".yit-wcan-container").html(b(c).find(yith_wcan.container)):b(".yit-wcan-container").html(b(c).find(".woocommerce-info"));0<b(c).find(yith_wcan.pagination).length?(0==b(yith_wcan.pagination).length&&
9
+ b.jseldom(yith_wcan.pagination).insertAfter(b(yith_wcan.container)),b(yith_wcan.pagination).html(b(c).find(yith_wcan.pagination).html()).show()):b(yith_wcan.pagination).empty();0<b(c).find(yith_wcan.result_count).length&&b(yith_wcan.result_count).html(b(c).find(yith_wcan.result_count).html()).show();b(".yith-woo-ajax-navigation").add(".yith-wcan-sort-by").add(".yith-wcan-stock-on-sale").add(".yith-wcan-list-price-filter").each(function(){var a=b(this),d=a.attr("id");a.html(b(c).find("#"+d).html());
10
+ ""==a.text()?a.hide():a.show()});navigator.userAgent.match(/msie/i)||window.history.pushState({pageTitle:c.pageTitle},"",a);b(document).trigger("ready");b(document).trigger("yith-wcan-ajax-filtered")}})};b(yith_wcan.container).wrap('<div class="yit-wcan-container"></div>');b(".woocommerce-info").wrap('<div class="yit-wcan-container"></div>');b(document).on("click",".yith-wcan a",function(h){b(this).yith_wcan_ajax_filters(h,this)});var r=function(){b("div.yith-wcan-select-wrapper").animate({visibility:"hidden",
11
+ opacity:0},0);b("a.yit-wcan-select-open").removeClass("active")};b(document).on("click","a.yit-wcan-select-open.active",function(h){h.preventDefault();b(this).parent().find("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",opacity:0},300);b(this).parent().find("a.yit-wcan-select-open").removeClass("active")});b(document).on("click","a.yit-wcan-select-open:not(.active)",function(h){h.preventDefault();b(this).parent().find("div.yith-wcan-select-wrapper").css("z-index",
12
+ "1").animate({visibility:"visible",opacity:1},300);b(this).parent().find("a.yit-wcan-select-open").addClass("active")});b(document).on("ready yith-wcan-ajax-filtered",function(){b("div.yith-wcan-select-wrapper ul.yith-wcan-select li.chosen");r();b("div.yith-wcan-select-wrapper").each(function(){var h="";b(this).find("ul.yith-wcan-select li.chosen").each(function(){h+=b(this).text()+", "});h=h.substring(0,h.length-2);""!=h&&b(this).parent().find("a.yit-wcan-select-open").text(h)})});b(document).on("ready",
13
+ r);b("body").on("click",function(h){b(h.target).hasClass("yit-wcan-select-open")||r()})});
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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: 2.3.0
7
  * Author: yithemes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith_wc_ajxnav
@@ -65,7 +65,7 @@ if ( defined( 'YITH_WCAN_VERSION' ) ) {
65
  ! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
66
  ! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
67
  ! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
68
- ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '2.3.0' );
69
  ! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
70
  ! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
71
 
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: 2.3.1
7
  * Author: yithemes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith_wc_ajxnav
65
  ! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
66
  ! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
67
  ! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
68
+ ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '2.3.1' );
69
  ! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
70
  ! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
71
 
languages/yith_wc_ajxnav-it_IT.mo CHANGED
Binary file
languages/yith_wc_ajxnav-it_IT.po CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: YITH WooCommerce Ajax Product Filter\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2015-09-11 16:48+0100\n"
6
- "PO-Revision-Date: 2015-09-11 16:48+0100\n"
7
  "Last-Translator: Your Inspiration Themes <plugins@yithemes.com>\n"
8
  "Language-Team: \n"
9
  "Language: it_IT\n"
@@ -26,7 +26,7 @@ msgstr "Front end"
26
 
27
  #: includes/class.yith-wcan-admin.php:143 settings/custom-style-options.php:12
28
  msgid "Custom Style"
29
- msgstr ""
30
 
31
  #: includes/class.yith-wcan-admin.php:144
32
  #: includes/class.yith-wcan-admin.php:216
@@ -131,7 +131,7 @@ msgstr ""
131
 
132
  #: settings/custom-style-options.php:24
133
  msgid "Put here your custom CSS rules:"
134
- msgstr ""
135
 
136
  #: settings/frontend-options.php:12
137
  msgid "General Settings"
2
  msgstr ""
3
  "Project-Id-Version: YITH WooCommerce Ajax Product Filter\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2015-09-17 14:37+0100\n"
6
+ "PO-Revision-Date: 2015-09-17 14:37+0100\n"
7
  "Last-Translator: Your Inspiration Themes <plugins@yithemes.com>\n"
8
  "Language-Team: \n"
9
  "Language: it_IT\n"
26
 
27
  #: includes/class.yith-wcan-admin.php:143 settings/custom-style-options.php:12
28
  msgid "Custom Style"
29
+ msgstr "Modifica stile"
30
 
31
  #: includes/class.yith-wcan-admin.php:144
32
  #: includes/class.yith-wcan-admin.php:216
131
 
132
  #: settings/custom-style-options.php:24
133
  msgid "Put here your custom CSS rules:"
134
+ msgstr "Metti qui le tue modifiche delle regole del CSS"
135
 
136
  #: settings/frontend-options.php:12
137
  msgid "General Settings"
languages/yith_wc_ajxnav-tr_TR.mo CHANGED
Binary file
languages/yith_wc_ajxnav-tr_TR.po CHANGED
@@ -2,8 +2,8 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: YITH WooCommerce Ajax Product filter\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2015-09-11 16:48+0100\n"
6
- "PO-Revision-Date: 2015-09-11 16:48+0100\n"
7
  "Last-Translator: Caner Öncel <caneroncel@gmail.com>\n"
8
  "Language-Team: Caner Öncel <caneroncel@gmail.com>\n"
9
  "Language: tr\n"
@@ -326,7 +326,7 @@ msgstr ""
326
  msgid "Upload multiple files"
327
  msgstr ""
328
 
329
- #: plugin-fw/lib/yit-plugin-panel-wc.php:322
330
  msgid "The changes you have made will be lost if you leave this page."
331
  msgstr ""
332
 
@@ -358,7 +358,7 @@ msgstr ""
358
 
359
  #: plugin-fw/lib/yit-plugin-panel.php:298
360
  #: plugin-fw/lib/yit-plugin-subpanel.php:148
361
- #: plugin-fw/templates/panel/woocommerce/woocommerce-form.php:10
362
  msgid "Are you sure?"
363
  msgstr ""
364
 
@@ -1050,7 +1050,7 @@ msgstr "İtalik"
1050
  msgid "Italic bold"
1051
  msgstr "İtalik kalın"
1052
 
1053
- #: plugin-fw/templates/panel/woocommerce/woocommerce-form.php:10
1054
  msgid "Reset Defaults"
1055
  msgstr ""
1056
 
2
  msgstr ""
3
  "Project-Id-Version: YITH WooCommerce Ajax Product filter\n"
4
  "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2015-09-17 14:37+0100\n"
6
+ "PO-Revision-Date: 2015-09-17 14:37+0100\n"
7
  "Last-Translator: Caner Öncel <caneroncel@gmail.com>\n"
8
  "Language-Team: Caner Öncel <caneroncel@gmail.com>\n"
9
  "Language: tr\n"
326
  msgid "Upload multiple files"
327
  msgstr ""
328
 
329
+ #: plugin-fw/lib/yit-plugin-panel-wc.php:323
330
  msgid "The changes you have made will be lost if you leave this page."
331
  msgstr ""
332
 
358
 
359
  #: plugin-fw/lib/yit-plugin-panel.php:298
360
  #: plugin-fw/lib/yit-plugin-subpanel.php:148
361
+ #: plugin-fw/templates/panel/woocommerce/woocommerce-form.php:11
362
  msgid "Are you sure?"
363
  msgstr ""
364
 
1050
  msgid "Italic bold"
1051
  msgstr "İtalik kalın"
1052
 
1053
+ #: plugin-fw/templates/panel/woocommerce/woocommerce-form.php:11
1054
  msgid "Reset Defaults"
1055
  msgstr ""
1056
 
languages/yith_wc_ajxnav.pot CHANGED
@@ -3,7 +3,7 @@ msgid ""
3
  msgstr ""
4
  "Project-Id-Version: YITH WooCommerce Ajax Product Filter\n"
5
  "Report-Msgid-Bugs-To: \n"
6
- "POT-Creation-Date: 2015-09-11 16:47+0100\n"
7
  "PO-Revision-Date: 2015-06-19 13:59+0100\n"
8
  "Last-Translator: Your Inspiration Themes <plugins@yithemes.com>\n"
9
  "Language-Team: \n"
@@ -329,7 +329,7 @@ msgstr ""
329
  msgid "Upload multiple files"
330
  msgstr ""
331
 
332
- #: plugin-fw/lib/yit-plugin-panel-wc.php:322
333
  msgid "The changes you have made will be lost if you leave this page."
334
  msgstr ""
335
 
@@ -362,7 +362,7 @@ msgstr ""
362
 
363
  #: plugin-fw/lib/yit-plugin-panel.php:298
364
  #: plugin-fw/lib/yit-plugin-subpanel.php:148
365
- #: plugin-fw/templates/panel/woocommerce/woocommerce-form.php:10
366
  msgid "Are you sure?"
367
  msgstr ""
368
 
@@ -1055,7 +1055,7 @@ msgstr ""
1055
  msgid "Italic bold"
1056
  msgstr ""
1057
 
1058
- #: plugin-fw/templates/panel/woocommerce/woocommerce-form.php:10
1059
  msgid "Reset Defaults"
1060
  msgstr ""
1061
 
3
  msgstr ""
4
  "Project-Id-Version: YITH WooCommerce Ajax Product Filter\n"
5
  "Report-Msgid-Bugs-To: \n"
6
+ "POT-Creation-Date: 2015-09-17 14:37+0100\n"
7
  "PO-Revision-Date: 2015-06-19 13:59+0100\n"
8
  "Last-Translator: Your Inspiration Themes <plugins@yithemes.com>\n"
9
  "Language-Team: \n"
329
  msgid "Upload multiple files"
330
  msgstr ""
331
 
332
+ #: plugin-fw/lib/yit-plugin-panel-wc.php:323
333
  msgid "The changes you have made will be lost if you leave this page."
334
  msgstr ""
335
 
362
 
363
  #: plugin-fw/lib/yit-plugin-panel.php:298
364
  #: plugin-fw/lib/yit-plugin-subpanel.php:148
365
+ #: plugin-fw/templates/panel/woocommerce/woocommerce-form.php:11
366
  msgid "Are you sure?"
367
  msgstr ""
368
 
1055
  msgid "Italic bold"
1056
  msgstr ""
1057
 
1058
+ #: plugin-fw/templates/panel/woocommerce/woocommerce-form.php:11
1059
  msgid "Reset Defaults"
1060
  msgstr ""
1061
 
plugin-fw/lib/yit-metabox.php CHANGED
@@ -9,11 +9,11 @@
9
  */
10
 
11
 
12
- if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  } // Exit if accessed directly
15
 
16
- if ( ! class_exists( 'YIT_Metabox' ) ) {
17
  /**
18
  * YIT Metabox
19
  *
@@ -48,8 +48,8 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
48
  * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
49
  *
50
  */
51
-
52
- class YIT_Metabox {
53
 
54
  /**
55
  * @var string the id of metabox
@@ -91,9 +91,10 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
91
  * @since 1.0
92
  * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
93
  */
94
- public static function instance( $id ) {
95
- if ( ! isset( self::$_instance[$id] ) ) {
96
- self::$_instance[$id] = new self( $id );
 
97
  }
98
  return self::$_instance[$id];
99
  }
@@ -107,7 +108,8 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
107
  * @since 1.0
108
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
109
  */
110
- function __construct( $id = '' ) {
 
111
  $this->id = $id;
112
 
113
  }
@@ -124,15 +126,16 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
124
  * @since 1.0
125
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
126
  */
127
- public function init( $options = array() ) {
 
128
 
129
- $this->set_options( $options );
130
  $this->set_tabs();
131
 
132
 
133
- add_action( 'add_meta_boxes', array( $this, 'register_metabox' ) );
134
- add_action( 'save_post', array( $this, 'save_postdata' ) );
135
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ), 15 );
136
 
137
  }
138
 
@@ -145,18 +148,19 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
145
  * @since 1.0
146
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
147
  */
148
- public function enqueue() {
 
149
 
150
  wp_enqueue_media();
151
- wp_enqueue_style( 'wp-color-picker' );
152
- wp_enqueue_style( 'yit-plugin-metaboxes', YIT_CORE_PLUGIN_URL . '/assets/css/metaboxes.css' );
153
- wp_enqueue_style( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css' );
154
- wp_enqueue_script( 'jquery-ui-datepicker' );
155
- wp_enqueue_script( 'yit-spinner', YIT_CORE_PLUGIN_URL . '/assets/js/panel.spinner.js', array( 'jquery' ), '0.0.1', true );
156
- wp_enqueue_script( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array( 'jquery' ), '1.1.0', true );
157
- wp_enqueue_script( 'ajax-chosen', yit_load_js_file( YIT_CORE_PLUGIN_URL . '/assets/js/chosen/ajax-chosen.jquery.js' ), array( 'jquery' ), '1.1.0', true );
158
- wp_enqueue_script( 'yit-metabox', YIT_CORE_PLUGIN_URL . '/assets/js/metabox.js', array( 'jquery', 'wp-color-picker' ), '1.0.0', true );
159
- wp_enqueue_style( 'jquery-ui-overcast', YIT_CORE_PLUGIN_URL . '/assets/css/overcast/jquery-ui-1.8.9.custom.css', false, '1.8.9', 'all' );
160
 
161
 
162
  }
@@ -172,7 +176,8 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
172
  * @since 1.0
173
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
174
  */
175
- public function set_options( $options = array() ) {
 
176
  $this->options = $options;
177
 
178
  }
@@ -188,13 +193,14 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
188
  * @since 1.0
189
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
190
  */
191
- public function set_tabs() {
192
- if ( ! isset( $this->options['tabs'] ) ) {
 
193
  return;
194
  }
195
- $this->tabs = $this->options['tabs'] ;
196
- if( isset($this->tabs['settings']['fields']) ){
197
- $this->tabs['settings']['fields'] = array_filter( $this->tabs['settings']['fields'] );
198
  }
199
  }
200
 
@@ -206,32 +212,31 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
206
  *
207
  * @internal param array $tabs
208
  *
209
- * @param array $tab the new tab to add to the metabox
210
- * @param string $where tell where insert the tab if after or before a $refer
211
- * @param null $refer an existent tab inside metabox
212
  *
213
  * @return void
214
  * @since 1.0
215
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
216
  */
217
- public function add_tab( $tab, $where = 'after', $refer = null ) {
218
- if ( ! is_null( $refer ) ) {
219
- $ref_pos = array_search( $refer, array_keys( $this->tabs ) );
220
- if ( $ref_pos !== false ) {
221
- if ( $where == 'after' ) {
222
- $this->tabs = array_slice( $this->tabs, 0, $ref_pos + 1, true ) +
 
223
  $tab +
224
- array_slice( $this->tabs, $ref_pos + 1, count( $this->tabs ) - 1, true );
225
- }
226
- else {
227
- $this->tabs = array_slice( $this->tabs, 0, $ref_pos, true ) +
228
  $tab +
229
- array_slice( $this->tabs, $ref_pos, count( $this->tabs ), true );
230
  }
231
  }
232
- }
233
- else {
234
- $this->tabs = array_merge( $tab, $this->tabs );
235
  }
236
 
237
  }
@@ -249,9 +254,10 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
249
  * @since 1.0
250
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
251
  */
252
- public function remove_tab( $id_tab ) {
253
- if ( isset( $this->tabs[$id_tab] ) ) {
254
- unset ( $this->tabs[$id_tab] );
 
255
  }
256
  }
257
 
@@ -264,40 +270,40 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
264
  * @internal param array $tabs
265
  *
266
  * @param string $tab_id the id of the tabs where add the field
267
- * @param array $args the field to add
268
- * @param string $where tell where insert the field if after or before a $refer
269
- * @param null $refer an existent field inside tab
270
  *
271
  * @return void
272
  * @since 1.0
273
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
274
  */
275
- public function add_field( $tab_id, $args, $where = 'after', $refer = null ) {
276
- if ( isset( $this->tabs[$tab_id] ) ) {
 
277
 
278
  $cf = $this->tabs[$tab_id]['fields'];
279
- if ( ! is_null( $refer ) ) {
280
- $ref_pos = array_search( $refer, array_keys( $cf ) );
281
- if ( $ref_pos !== false ) {
282
- if ( $where == 'after' ) {
283
- $this->tabs[$tab_id]['fields'] = array_slice( $cf, 0, $ref_pos + 1, true ) +
284
  $args +
285
- array_slice( $cf, $ref_pos, count( $cf ) - 1, true );
286
 
287
- } elseif ( $where == 'before' ) {
288
- $this->tabs[$tab_id]['fields'] = array_slice( $cf, 0, $ref_pos, true ) +
289
  $args +
290
- array_slice( $cf, $ref_pos, count( $cf ), true );
291
 
292
  }
293
  }
294
- }
295
- else {
296
- if ( $where == 'first' ) {
297
  $this->tabs[$tab_id]['fields'] = $args + $cf;
298
 
299
  } else {
300
- $this->tabs[$tab_id]['fields'] = array_merge( $this->tabs[$tab_id]['fields'], $args );
301
  }
302
  }
303
 
@@ -317,10 +323,11 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
317
  * @since 1.0
318
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
319
  */
320
- public function remove_field( $id_field ) {
321
- foreach ( $this->tabs as $tab_name => $tab ) {
322
- if ( isset( $tab['fields'][$id_field] ) ) {
323
- unset ( $this->tabs[$tab_name]['fields'][$id_field] );
 
324
  }
325
  }
326
  }
@@ -336,12 +343,13 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
336
  * @since 1.0
337
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
338
  */
339
- public function reorder_tabs() {
340
- foreach ( $this->tabs as $tab_name => $tab ) {
341
- foreach ( $tab['fields'] as $id_field => $field ) {
342
- $this->tabs[$tab_name]['fields'][$id_field]['private'] = ( isset( $field['private'] ) ) ? $field['private'] : true;
343
- $this->tabs[$tab_name]['fields'][$id_field]['id'] = $this->get_option_metabox_id( $id_field, $this->tabs[$tab_name]['fields'][$id_field]['private'] );
344
- $this->tabs[$tab_name]['fields'][$id_field]['name'] = $this->get_option_metabox_name( $this->tabs[$tab_name]['fields'][$id_field]['id'] );
 
345
  }
346
  }
347
 
@@ -360,11 +368,11 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
360
  * @since 1.0
361
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
362
  */
363
- public function get_option_metabox_id( $id_field, $private = true ) {
364
- if ( $private ) {
 
365
  return '_' . $id_field;
366
- }
367
- else {
368
  return $id_field;
369
  }
370
  }
@@ -381,16 +389,17 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
381
  * @since 1.0
382
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
383
  */
384
- public function get_option_metabox_name( $id_field, $private = true ) {
385
- $db_name = apply_filters( 'yit_metaboxes_option_main_name', 'yit_metaboxes' );
386
- $return = $db_name . '[';
 
387
 
388
- if ( ! strpos( $id_field, '[' ) ) {
389
  return $return . $id_field . ']';
390
  }
391
- $return .= substr( $id_field, 0, strpos( $id_field, '[' ) );
392
  $return .= ']';
393
- $return .= substr( $id_field, strpos( $id_field, '[' ) );
394
 
395
  return $return;
396
  }
@@ -405,9 +414,10 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
405
  * @since 1.0
406
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
407
  */
408
- public function register_metabox( $post_type ) {
409
- if( in_array( $post_type, (array) $this->options['pages'] ) ){
410
- add_meta_box( $this->id, $this->options['label'], array( $this, 'show' ), $post_type, $this->options['context'], $this->options['priority'] );
 
411
  }
412
  }
413
 
@@ -421,10 +431,11 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
421
  * @since 1.0
422
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
423
  */
424
- public function show() {
 
425
  $this->reorder_tabs();
426
 
427
- yit_plugin_get_template( YIT_CORE_PLUGIN_PATH, 'metaboxes/tab.php', array( 'tabs' => $this->tabs ) );
428
  }
429
 
430
  /**
@@ -438,61 +449,62 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
438
  * @since 1.0
439
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
440
  */
441
- public function save_postdata( $post_id ) {
 
442
 
443
 
444
-
445
- if ( ! isset( $_POST['yit_metaboxes_nonce'] ) || ! wp_verify_nonce( $_POST['yit_metaboxes_nonce'], 'metaboxes-fields-nonce' ) ) {
446
  return $post_id;
447
  }
448
 
449
 
450
- if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
451
  return $post_id;
452
  }
453
 
454
- if ( isset( $_POST['post_type'] ) ) {
455
  $post_type = $_POST['post_type'];
456
- }
457
- else {
458
  return $post_id;
459
  }
460
 
461
- if ( 'page' == $post_type ) {
462
- if ( ! current_user_can( 'edit_page', $post_id ) ) {
463
  return $post_id;
464
  }
465
- }
466
- else {
467
- if ( ! current_user_can( 'edit_post', $post_id ) ) {
468
  return $post_id;
469
  }
470
  }
471
 
 
 
 
 
472
  $this->reorder_tabs();
473
 
474
 
475
- foreach ( $this->tabs as $tab ) {
476
 
477
- foreach ( $tab['fields'] as $field ) {
478
 
479
- if ( in_array( $field['type'], array( 'title' ) ) ) {
480
  continue;
481
  }
482
 
483
- if ( isset( $_POST['yit_metaboxes'][$field['id']] ) ) {
484
 
485
- add_post_meta( $post_id, $field['id'], $_POST['yit_metaboxes'][$field['id']], true ) || update_post_meta( $post_id, $field['id'], $_POST['yit_metaboxes'][$field['id']] );
486
- }
487
- elseif ( in_array( $field['type'], array( 'onoff', 'checkbox' ) ) ) {
488
- add_post_meta( $post_id, $field['id'], '0', true ) || update_post_meta( $post_id, $field['id'], '0' );
489
- }
490
- else {
491
- delete_post_meta( $post_id, $field['id'] );
492
  }
493
  }
494
  }
495
 
 
496
  }
497
 
498
  /**
@@ -506,15 +518,16 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
506
  * @since 2.0.0
507
  * @author Andrea Grillo <andrea.grillo@yithemes.com>
508
  */
509
- public function remove_fields( $id_fields ) {
510
- foreach ( $id_fields as $k => $field ) {
511
- $this->remove_field( $field );
 
512
  }
513
  }
514
  }
515
  }
516
 
517
- if ( ! function_exists( 'YIT_Metabox' ) ) {
518
 
519
  /**
520
  * Main instance of plugin
@@ -527,8 +540,9 @@ if ( ! function_exists( 'YIT_Metabox' ) ) {
527
  */
528
 
529
 
530
- function YIT_Metabox( $id ) {
531
- return YIT_Metabox::instance( $id );
 
532
  }
533
  }
534
 
9
  */
10
 
11
 
12
+ if (!defined('ABSPATH')) {
13
  exit;
14
  } // Exit if accessed directly
15
 
16
+ if (!class_exists('YIT_Metabox')) {
17
  /**
18
  * YIT Metabox
19
  *
48
  * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
49
  *
50
  */
51
+ class YIT_Metabox
52
+ {
53
 
54
  /**
55
  * @var string the id of metabox
91
  * @since 1.0
92
  * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
93
  */
94
+ public static function instance($id)
95
+ {
96
+ if (!isset(self::$_instance[$id])) {
97
+ self::$_instance[$id] = new self($id);
98
  }
99
  return self::$_instance[$id];
100
  }
108
  * @since 1.0
109
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
110
  */
111
+ function __construct($id = '')
112
+ {
113
  $this->id = $id;
114
 
115
  }
126
  * @since 1.0
127
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
128
  */
129
+ public function init($options = array())
130
+ {
131
 
132
+ $this->set_options($options);
133
  $this->set_tabs();
134
 
135
 
136
+ add_action('add_meta_boxes', array($this, 'register_metabox'));
137
+ add_action('save_post', array($this, 'save_postdata'));
138
+ add_action('admin_enqueue_scripts', array($this, 'enqueue'), 15);
139
 
140
  }
141
 
148
  * @since 1.0
149
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
150
  */
151
+ public function enqueue()
152
+ {
153
 
154
  wp_enqueue_media();
155
+ wp_enqueue_style('wp-color-picker');
156
+ wp_enqueue_style('yit-plugin-metaboxes', YIT_CORE_PLUGIN_URL . '/assets/css/metaboxes.css');
157
+ wp_enqueue_style('jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css');
158
+ wp_enqueue_script('jquery-ui-datepicker');
159
+ wp_enqueue_script('yit-spinner', YIT_CORE_PLUGIN_URL . '/assets/js/panel.spinner.js', array('jquery'), '0.0.1', true);
160
+ wp_enqueue_script('jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array('jquery'), '1.1.0', true);
161
+ wp_enqueue_script('ajax-chosen', yit_load_js_file(YIT_CORE_PLUGIN_URL . '/assets/js/chosen/ajax-chosen.jquery.js'), array('jquery'), '1.1.0', true);
162
+ wp_enqueue_script('yit-metabox', YIT_CORE_PLUGIN_URL . '/assets/js/metabox.js', array('jquery', 'wp-color-picker'), '1.0.0', true);
163
+ wp_enqueue_style('jquery-ui-overcast', YIT_CORE_PLUGIN_URL . '/assets/css/overcast/jquery-ui-1.8.9.custom.css', false, '1.8.9', 'all');
164
 
165
 
166
  }
176
  * @since 1.0
177
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
178
  */
179
+ public function set_options($options = array())
180
+ {
181
  $this->options = $options;
182
 
183
  }
193
  * @since 1.0
194
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
195
  */
196
+ public function set_tabs()
197
+ {
198
+ if (!isset($this->options['tabs'])) {
199
  return;
200
  }
201
+ $this->tabs = $this->options['tabs'];
202
+ if (isset($this->tabs['settings']['fields'])) {
203
+ $this->tabs['settings']['fields'] = array_filter($this->tabs['settings']['fields']);
204
  }
205
  }
206
 
212
  *
213
  * @internal param array $tabs
214
  *
215
+ * @param array $tab the new tab to add to the metabox
216
+ * @param string $where tell where insert the tab if after or before a $refer
217
+ * @param null $refer an existent tab inside metabox
218
  *
219
  * @return void
220
  * @since 1.0
221
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
222
  */
223
+ public function add_tab($tab, $where = 'after', $refer = null)
224
+ {
225
+ if (!is_null($refer)) {
226
+ $ref_pos = array_search($refer, array_keys($this->tabs));
227
+ if ($ref_pos !== false) {
228
+ if ($where == 'after') {
229
+ $this->tabs = array_slice($this->tabs, 0, $ref_pos + 1, true) +
230
  $tab +
231
+ array_slice($this->tabs, $ref_pos + 1, count($this->tabs) - 1, true);
232
+ } else {
233
+ $this->tabs = array_slice($this->tabs, 0, $ref_pos, true) +
 
234
  $tab +
235
+ array_slice($this->tabs, $ref_pos, count($this->tabs), true);
236
  }
237
  }
238
+ } else {
239
+ $this->tabs = array_merge($tab, $this->tabs);
 
240
  }
241
 
242
  }
254
  * @since 1.0
255
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
256
  */
257
+ public function remove_tab($id_tab)
258
+ {
259
+ if (isset($this->tabs[$id_tab])) {
260
+ unset ($this->tabs[$id_tab]);
261
  }
262
  }
263
 
270
  * @internal param array $tabs
271
  *
272
  * @param string $tab_id the id of the tabs where add the field
273
+ * @param array $args the field to add
274
+ * @param string $where tell where insert the field if after or before a $refer
275
+ * @param null $refer an existent field inside tab
276
  *
277
  * @return void
278
  * @since 1.0
279
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
280
  */
281
+ public function add_field($tab_id, $args, $where = 'after', $refer = null)
282
+ {
283
+ if (isset($this->tabs[$tab_id])) {
284
 
285
  $cf = $this->tabs[$tab_id]['fields'];
286
+ if (!is_null($refer)) {
287
+ $ref_pos = array_search($refer, array_keys($cf));
288
+ if ($ref_pos !== false) {
289
+ if ($where == 'after') {
290
+ $this->tabs[$tab_id]['fields'] = array_slice($cf, 0, $ref_pos + 1, true) +
291
  $args +
292
+ array_slice($cf, $ref_pos, count($cf) - 1, true);
293
 
294
+ } elseif ($where == 'before') {
295
+ $this->tabs[$tab_id]['fields'] = array_slice($cf, 0, $ref_pos, true) +
296
  $args +
297
+ array_slice($cf, $ref_pos, count($cf), true);
298
 
299
  }
300
  }
301
+ } else {
302
+ if ($where == 'first') {
 
303
  $this->tabs[$tab_id]['fields'] = $args + $cf;
304
 
305
  } else {
306
+ $this->tabs[$tab_id]['fields'] = array_merge($this->tabs[$tab_id]['fields'], $args);
307
  }
308
  }
309
 
323
  * @since 1.0
324
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
325
  */
326
+ public function remove_field($id_field)
327
+ {
328
+ foreach ($this->tabs as $tab_name => $tab) {
329
+ if (isset($tab['fields'][$id_field])) {
330
+ unset ($this->tabs[$tab_name]['fields'][$id_field]);
331
  }
332
  }
333
  }
343
  * @since 1.0
344
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
345
  */
346
+ public function reorder_tabs()
347
+ {
348
+ foreach ($this->tabs as $tab_name => $tab) {
349
+ foreach ($tab['fields'] as $id_field => $field) {
350
+ $this->tabs[$tab_name]['fields'][$id_field]['private'] = (isset($field['private'])) ? $field['private'] : true;
351
+ $this->tabs[$tab_name]['fields'][$id_field]['id'] = $this->get_option_metabox_id($id_field, $this->tabs[$tab_name]['fields'][$id_field]['private']);
352
+ $this->tabs[$tab_name]['fields'][$id_field]['name'] = $this->get_option_metabox_name($this->tabs[$tab_name]['fields'][$id_field]['id']);
353
  }
354
  }
355
 
368
  * @since 1.0
369
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
370
  */
371
+ public function get_option_metabox_id($id_field, $private = true)
372
+ {
373
+ if ($private) {
374
  return '_' . $id_field;
375
+ } else {
 
376
  return $id_field;
377
  }
378
  }
389
  * @since 1.0
390
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
391
  */
392
+ public function get_option_metabox_name($id_field, $private = true)
393
+ {
394
+ $db_name = apply_filters('yit_metaboxes_option_main_name', 'yit_metaboxes');
395
+ $return = $db_name . '[';
396
 
397
+ if (!strpos($id_field, '[')) {
398
  return $return . $id_field . ']';
399
  }
400
+ $return .= substr($id_field, 0, strpos($id_field, '['));
401
  $return .= ']';
402
+ $return .= substr($id_field, strpos($id_field, '['));
403
 
404
  return $return;
405
  }
414
  * @since 1.0
415
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
416
  */
417
+ public function register_metabox($post_type)
418
+ {
419
+ if (in_array($post_type, (array)$this->options['pages'])) {
420
+ add_meta_box($this->id, $this->options['label'], array($this, 'show'), $post_type, $this->options['context'], $this->options['priority']);
421
  }
422
  }
423
 
431
  * @since 1.0
432
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
433
  */
434
+ public function show()
435
+ {
436
  $this->reorder_tabs();
437
 
438
+ yit_plugin_get_template(YIT_CORE_PLUGIN_PATH, 'metaboxes/tab.php', array('tabs' => $this->tabs));
439
  }
440
 
441
  /**
449
  * @since 1.0
450
  * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
451
  */
452
+ public function save_postdata($post_id)
453
+ {
454
 
455
 
456
+ if (!isset($_POST['yit_metaboxes_nonce']) || !wp_verify_nonce($_POST['yit_metaboxes_nonce'], 'metaboxes-fields-nonce')) {
 
457
  return $post_id;
458
  }
459
 
460
 
461
+ if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX)) {
462
  return $post_id;
463
  }
464
 
465
+ if (isset($_POST['post_type'])) {
466
  $post_type = $_POST['post_type'];
467
+ } else {
 
468
  return $post_id;
469
  }
470
 
471
+ if ('page' == $post_type) {
472
+ if (!current_user_can('edit_page', $post_id)) {
473
  return $post_id;
474
  }
475
+ } else {
476
+ if (!current_user_can('edit_post', $post_id)) {
 
477
  return $post_id;
478
  }
479
  }
480
 
481
+ if (!in_array($post_type, (array)$this->options['pages'])) {
482
+ return $post_id;
483
+ }
484
+
485
  $this->reorder_tabs();
486
 
487
 
488
+ foreach ($this->tabs as $tab) {
489
 
490
+ foreach ($tab['fields'] as $field) {
491
 
492
+ if (in_array($field['type'], array('title'))) {
493
  continue;
494
  }
495
 
496
+ if (isset($_POST['yit_metaboxes'][$field['id']])) {
497
 
498
+ add_post_meta($post_id, $field['id'], $_POST['yit_metaboxes'][$field['id']], true) || update_post_meta($post_id, $field['id'], $_POST['yit_metaboxes'][$field['id']]);
499
+ } elseif (in_array($field['type'], array('onoff', 'checkbox'))) {
500
+ update_post_meta($post_id, $field['id'], '0');
501
+ } else {
502
+ delete_post_meta($post_id, $field['id']);
 
 
503
  }
504
  }
505
  }
506
 
507
+
508
  }
509
 
510
  /**
518
  * @since 2.0.0
519
  * @author Andrea Grillo <andrea.grillo@yithemes.com>
520
  */
521
+ public function remove_fields($id_fields)
522
+ {
523
+ foreach ($id_fields as $k => $field) {
524
+ $this->remove_field($field);
525
  }
526
  }
527
  }
528
  }
529
 
530
+ if (!function_exists('YIT_Metabox')) {
531
 
532
  /**
533
  * Main instance of plugin
540
  */
541
 
542
 
543
+ function YIT_Metabox($id)
544
+ {
545
+ return YIT_Metabox::instance($id);
546
  }
547
  }
548
 
plugin-fw/lib/yit-plugin-panel-wc.php CHANGED
@@ -282,7 +282,8 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
282
 
283
  do_action( 'yit_panel_wc_after_update' );
284
 
285
- } elseif( isset( $_REQUEST['yit-action'] ) && $_REQUEST['yit-action'] == 'wc-options-reset' ){
 
286
 
287
  $yit_options = $this->get_main_array_options();
288
  $current_tab = $this->get_current_tab();
282
 
283
  do_action( 'yit_panel_wc_after_update' );
284
 
285
+ } elseif( isset( $_REQUEST['yit-action'] ) && $_REQUEST['yit-action'] == 'wc-options-reset'
286
+ && isset( $_POST['yith_wc_reset_options_nonce'] ) && wp_verify_nonce( $_POST['yith_wc_reset_options_nonce'], 'yith_wc_reset_options_'.$this->settings['page'] )){
287
 
288
  $yit_options = $this->get_main_array_options();
289
  $current_tab = $this->get_current_tab();
plugin-fw/templates/panel/woocommerce/woocommerce-form.php CHANGED
@@ -7,6 +7,7 @@
7
  <form id="plugin-fw-wc-reset" method="post">
8
  <?php $warning = __( 'If you continue with this action, you will reset all options in this page.', 'yith-plugin-fw' ) ?>
9
  <input type="hidden" name="yit-action" value="wc-options-reset" />
 
10
  <input type="submit" name="yit-reset" class="button-secondary" value="<?php _e( 'Reset Defaults', 'yith-plugin-fw' ) ?>" onclick="return confirm('<?php echo $warning . '\n' . __( 'Are you sure?', 'yith-plugin-fw' ) ?>');" />
11
  </form>
12
  </div>
7
  <form id="plugin-fw-wc-reset" method="post">
8
  <?php $warning = __( 'If you continue with this action, you will reset all options in this page.', 'yith-plugin-fw' ) ?>
9
  <input type="hidden" name="yit-action" value="wc-options-reset" />
10
+ <?php wp_nonce_field( 'yith_wc_reset_options_'.$this->settings['page'], 'yith_wc_reset_options_nonce' ); ?>
11
  <input type="submit" name="yit-reset" class="button-secondary" value="<?php _e( 'Reset Defaults', 'yith-plugin-fw' ) ?>" onclick="return confirm('<?php echo $warning . '\n' . __( 'Are you sure?', 'yith-plugin-fw' ) ?>');" />
12
  </form>
13
  </div>
widgets/class.yith-wcan-navigation-widget.php CHANGED
@@ -761,7 +761,7 @@ if ( ! class_exists( 'YITH_WCAN_Navigation_Widget' ) ) {
761
 
762
  $term_id = yit_wcan_localize_terms( $term->term_id, $taxonomy );
763
 
764
- if ( $instance['labels'][$term_id] != '' ) {
765
 
766
  echo '<li ' . $class . '>';
767
 
761
 
762
  $term_id = yit_wcan_localize_terms( $term->term_id, $taxonomy );
763
 
764
+ if ( ! empty( $instance['labels'][$term_id] ) ) {
765
 
766
  echo '<li ' . $class . '>';
767