YITH WooCommerce Ajax Product Filter - Version 1.0.0

Version Description

  • Initial release

=

Download this release

Release Info

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

Version 1.0.0

README.txt ADDED
@@ -0,0 +1,92 @@
1
+ === YITH WooCommerce Ajax Navigation ===
2
+
3
+ Contributors: yithemes
4
+ Tags: woocommerce, widget, ajax, ajax filtered nav, ajax navigation, ajax filtered navigation
5
+ Requires at least: 3.5.1
6
+ Tested up to: 3.5.1
7
+ Stable tag: 1.0.0
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ YITH WooCommerce Ajax Navigation allows you to filter the products in the Shop page without reloading the page.
12
+
13
+
14
+ == Description ==
15
+
16
+ YITH WooCommerce Ajax Navigation allows you to filter the products in the Shop page without reloading the page. The plugin also includes two new types of Product Attributes visualizations: Color and Label.
17
+ With Color display type you're able to assign a color (selected from a Color Picker) to each Product Attributes. With Label Color display you're able to assign a label (3 chars max) to your Product Attributes.
18
+
19
+ Working demos are available here:
20
+ **[LIVE DEMO 1](http://demo.yithemes.com/room09/shop/)** - **[LIVE DEMO 2](http://demo.yithemes.com/bazar/shop/)**
21
+
22
+ Full documentation is available [here](http://yithemes.com/docs-plugins/yith_ajax_navigation/).
23
+
24
+
25
+ = Installation =
26
+
27
+ Once you have installed the plugin, you just need to activate the plugin in order to enable it.
28
+
29
+ = Configuration =
30
+
31
+ The widget works with Product Attributes. This means you need to create the Attributes and to assign them to your products. Once you have customized your products with Product Attributes you're able to use the Widget.
32
+
33
+ = Developer =
34
+
35
+ Are you a developer? Want to customize the templates or the style of the plugin? Read on the [documentation](http://yithemes.com/docs-plugins/yith_ajax_navigation/) and discover how to do that.
36
+
37
+ = Support =
38
+
39
+ Hi there, we have good news here: all our plugins are released for free. Wow!
40
+ Already knew it, right?! Great, but maybe you do not know that: if you're looking for how to install the plugins or how to use them within your Wordpress installations, which is the right way to ask support?
41
+ That's the way:
42
+
43
+ * Register on http://yithemes.com
44
+ * Go to Support > Get Support
45
+
46
+ Here we provide support, not on wordpress.org were, usually we do not read topics. It's better to follow us or write on our forum!
47
+
48
+ == Installation ==
49
+
50
+ 1. Unzip the downloaded zip file.
51
+ 2. Upload the plugin folder into the `wp-content/plugins/` directory of your WordPress site.
52
+ 3. Activate `YITH WooCommerce Ajax Navigation` from Plugins page
53
+
54
+ == Frequently Asked Questions ==
55
+
56
+ = The widget is not displayed in my sidebar. Why? =
57
+ In order to display the widget you need to assign it to the sidebar in the Shop page and you need to add Product Attributes to your product. Read the Getting Started section to learn how to add them.
58
+
59
+ == Screenshots ==
60
+
61
+ 1. The widget in action with "Color" type selected
62
+ 2. The widget in action with "Label" type selected
63
+ 3. The final result
64
+
65
+ == Changelog ==
66
+
67
+ = 1.0.0 =
68
+
69
+ * Initial release
70
+
71
+ == Suggestions ==
72
+
73
+ If you have suggestions about how to improve YITH WooCommerce Ajax Navigation, you can [write us](mailto:plugins@yithemes.com "Your Inspiration Themes") so we can bundle them into YITH WooCommerce Ajax Navigation.
74
+
75
+ == Translators ==
76
+
77
+ = Available Languages =
78
+ * English (Default)
79
+ * Italiano
80
+
81
+ If you have created your own language pack, or have an update for an existing one, you can send [gettext PO and MO file](http://codex.wordpress.org/Translating_WordPress "Translating WordPress")
82
+ [use](http://yithemes.com/contact/ "Your Inspiration Themes") so we can bundle it into YITH WooCommerce Ajax Navigation Languages.
83
+
84
+ == Documentation ==
85
+
86
+ Full documentation is available [here](http://yithemes.com/docs-plugins/yith_ajax_navigation/).
87
+
88
+ == Upgrade notice ==
89
+
90
+ = 1.0.0 =
91
+
92
+ Initial release
assets/css/admin.css ADDED
@@ -0,0 +1,26 @@
1
+ /* widget area */
2
+ .yith_wcan_placeholder + .spinner {
3
+ background-position: center;
4
+ float: left;
5
+ margin: 10px 0;
6
+ width: 100%;
7
+ }
8
+
9
+ .yith_wcan_placeholder table {
10
+ width: 100%;
11
+ }
12
+
13
+ .yith_wcan_placeholder th {
14
+ text-align: left;
15
+ }
16
+
17
+ .yith_wcan_placeholder td {
18
+ vertical-align: top;
19
+ }
20
+
21
+ /*
22
+ .yith_wcan_placeholder .wp-color-result:after,
23
+ .yith_wcan_placeholder .wp-color-result.wp-picker-open:after{
24
+ content: "";
25
+ }
26
+ */
assets/css/frontend.css ADDED
@@ -0,0 +1,84 @@
1
+ .yith-wcan-group:after {
2
+ content: "";
3
+ display: table;
4
+ clear: both;
5
+ }
6
+
7
+ .yith-wcan-loading {
8
+ background: url('../images/ajax-loader.gif') no-repeat center;
9
+ height: 100px;
10
+ }
11
+
12
+ .woocommerce .widget_layered_nav ul.yith-wcan li span,
13
+ .woocommerce-page .widget_layered_nav ul.yith-wcan li span {
14
+ cursor: not-allowed;
15
+ }
16
+
17
+ /* Colors Type */
18
+ .yith-wcan-color li {
19
+ float: left;
20
+ }
21
+
22
+ .woocommerce .widget_layered_nav ul.yith-wcan-color li a,
23
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-color li a,
24
+ .woocommerce .widget_layered_nav ul.yith-wcan-color li span,
25
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-color li span {
26
+ border: 1px solid #ddd;
27
+ display: block;
28
+ height: 20px;
29
+ margin: 5px 5px 5px 0;
30
+ padding: 0;
31
+ width: 20px;
32
+ overflow: hidden;
33
+ text-indent: 100%;
34
+ white-space: nowrap;
35
+ }
36
+
37
+ .woocommerce .widget_layered_nav ul.yith-wcan-color li a:hover,
38
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-color li a:hover,
39
+ .woocommerce .widget_layered_nav ul.yith-wcan-color li.chosen a,
40
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-color li.chosen a,
41
+ .woocommerce .widget_layered_nav ul.yith-wcan-color li span:hover,
42
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-color li span:hover,
43
+ .woocommerce .widget_layered_nav ul.yith-wcan-color li.chosen span,
44
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-color li.chosen span {
45
+ border: 1px solid #444;
46
+ background-image: none;
47
+
48
+ -webkit-border-radius: 0;
49
+ -moz-border-radius: 0;
50
+ border-radius: 0;
51
+ }
52
+
53
+ /* Labels Type */
54
+ .yith-wcan-label li {
55
+ float: left;
56
+ }
57
+
58
+ .woocommerce .widget_layered_nav ul.yith-wcan-label li a,
59
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-label li a,
60
+ .woocommerce .widget_layered_nav ul.yith-wcan-label li span,
61
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-label li span {
62
+ background: #efefef;
63
+ border: 1px solid #ddd;
64
+ display: block;
65
+ margin: 5px 5px 5px 0;
66
+ padding: 2px;
67
+ overflow: hidden;
68
+ text-decoration: none;
69
+ }
70
+
71
+ .woocommerce .widget_layered_nav ul.yith-wcan-label li a:hover,
72
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-label li a:hover,
73
+ .woocommerce .widget_layered_nav ul.yith-wcan-label li.chosen a,
74
+ .woocommerce-page .widget_layered_nav ul.yith-wcan-label li.chosen a {
75
+ border: 1px solid #444;
76
+ background-image: none;
77
+ background-color: #ad74a2;
78
+ color: #fff;
79
+
80
+ -webkit-border-radius: 0;
81
+ -moz-border-radius: 0;
82
+ border-radius: 0;
83
+ }
84
+
assets/images/ajax-loader.gif ADDED
Binary file
assets/js/yith-wcan-admin.js ADDED
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Admin
3
+ *
4
+ * @author Your Inspiration Themes
5
+ * @package YITH WooCommerce Ajax Navigation
6
+ * @version 1.0.0
7
+ */
8
+ jQuery(function($){
9
+
10
+ $(document).on('change', '.yith_wcan_type, .yith_wcan_attributes', function(e){
11
+ var t = this,
12
+ container = $(this).parents('.widget-content').find('.yith_wcan_placeholder').html(''),
13
+ spinner = container.next('.spinner').show();
14
+
15
+ var data = {
16
+ action: 'yith_wcan_select_type',
17
+ id: $('input[name=widget_id]', $(t).parents('.widget-content')).val(),
18
+ name: $('input[name=widget_name]', $(t).parents('.widget-content')).val(),
19
+ attribute: $('.yith_wcan_attributes', $(t).parents('.widget-content')).val(),
20
+ value: $('.yith_wcan_type', $(t).parents('.widget-content')).val()
21
+ };
22
+
23
+
24
+ $.post(ajaxurl, data, function(response) {
25
+ spinner.hide();
26
+
27
+ container.html( response.content );
28
+ $(document).trigger('yith_colorpicker');
29
+ }, 'json');
30
+ });
31
+
32
+ //color-picker
33
+ $(document).on('yith_colorpicker', function(){
34
+ $('.yith-colorpicker').each(function(){
35
+ $(this).wpColorPicker();
36
+ });
37
+ }).trigger('yith_colorpicker');
38
+ });
assets/js/yith-wcan-frontend.js ADDED
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Frontend
3
+ *
4
+ * @author Your Inspiration Themes
5
+ * @package YITH WooCommerce Ajax Navigation
6
+ * @version 1.0.0
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]+#x2F;,parseSelector=function(d){for(var c={sel:[],val:[]},a=[],j=!1,h="",e=[],f=0,m=d.length;f<m;f++){var g=d.charAt(f);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{if("]"!==g||""!==h)""===h&&","===g?(c.val.push(e.join("")),
14
+ e=[]):e.push(g)}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)}if(0!=c.sel.length||0!=c.val.length)c.sel=c.sel.join(""),a.push(c);for(f=0;f<a.length;f++){c=a[f].sel;if("+"===c)b.tag=c;else{var b=[];b.tag=tagexpr.exec(c);b.id=idexpr.exec(c);b.id&&$.isArray(b.id)&&(b.id=b.id[0].substr(1));b.tag||(b.tag="div");b.vars=[];for(d=0;d<a[f].val.length;d++)h=
15
+ 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]*#x2F;g,""),"text"===j?b.text=h:b.vars.push([j,h]);c=c.match(classexpr);j=[];if(c){for(d=0;d<c.length;d++)j.push(c[d].substr(1));b.className=j.join(" ")}}a[f]=b}return a},rmFromParent=function(d){var c=d.parentNode,a=d.nextSibling;c.removeChild(d);return a?function(){c.insertBefore(d,a)}:function(){c.appendChild(d)}},nonArrVer=function(d,c){var a=[],a=simpleselector.test(d)?[{tag:d}]:parseSelector(d),
16
+ j=[];"undefined"===typeof c&&(c=1);for(var h=[],e=[],f=[],m=document.createElement("div"),g=0,b=0;b<a.length;b++){if("+"==a[b].tag)e=f.slice(),--g;else{for(var l=0;l<c;l++)if("input"==a[b].tag){var k=[];k.push("<"+a[b].tag);a[b].id&&k.push("id='"+a[b].id+"'");a[b].className&&(k.push("class='"+a[b].className),b+1===a.length&&k.push(lastClass),k.push("'"));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]+"'");a[b].text&&k.push("value='"+a[b].text+"'");k.push("/>");
17
+ f[l]=e[l];e[l]?(e[l].innerHTML+=k.join(" "),e[l]=e[l].lastChild):(m.innerHTML=k.join(" "),e[l]=m.removeChild(m.firstChild))}else{k=document.createElement(a[b].tag);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]);a[b].id&&(k.id=a[b].id);a[b].className&&(k.className=a[b].className);a[b].text&&k.appendChild(document.createTextNode(a[b].text));f[l]=e[l];e[l]=e[l]?e[l].appendChild(k):k}g++||Array.prototype.push.apply(h,e)}j=
18
+ $.merge(j,e)}return $(h)},arrVer=function(d,c,a){for(var j=d.match(/%[^%]*%/g)||[],h=[],e=0;e<c.length;e++){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]);h=$.merge(h,nonArrVer(f,a))}return $(h)};
19
+ $.jseldom=function(d){if(2==arguments.length&&$.isPlainObject(arguments[1]))return arrVer.apply(this,[arguments[0],[arguments[1]]]);if(1==arguments.length||2==arguments.length&&!$.isArray(arguments[1]))return nonArrVer.apply(this,arguments);if(2==arguments.length)return arrVer.apply(this,arguments)};
20
+
21
+
22
+ //wrap the container
23
+ $(yith_wcan.container).wrap('<div class="yit-wcan-container"></div>');
24
+ $('.woocommerce-info').wrap('<div class="yit-wcan-container"></div>');
25
+
26
+ $(document).on('click', '.yith-wcan a', function(e){
27
+ e.preventDefault();
28
+ var href = this.href;
29
+
30
+ //loading
31
+ $(yith_wcan.container).html('').addClass('yith-wcan-loading');
32
+ $(yith_wcan.pagination).hide();
33
+ $(yith_wcan.result_count).hide();
34
+
35
+ $.ajax({
36
+ url: href,
37
+ success: function( response ){
38
+ $(yith_wcan.container).removeClass('yith-wcan-loading');
39
+
40
+ //container
41
+ if( $(response).find(yith_wcan.container).length > 0 ) {
42
+ $('.yit-wcan-container').html( $(response).find(yith_wcan.container) );
43
+ } else {
44
+ $('.yit-wcan-container').html( $(response).find('.woocommerce-info') );
45
+ }
46
+
47
+
48
+ //pagination
49
+ if( $(response).find(yith_wcan.pagination).length > 0 ) {
50
+ //se non esiste lo creo
51
+ if( $(yith_wcan.pagination).length == 0 ) {
52
+ $.jseldom( yith_wcan.pagination ).insertAfter( $(yith_wcan.container) );
53
+ }
54
+
55
+ $(yith_wcan.pagination)
56
+ .html( $(response).find(yith_wcan.pagination).html())
57
+ .show();
58
+ }
59
+
60
+ //result count
61
+ if( $(response).find(yith_wcan.result_count).length > 0 ) {
62
+ $(yith_wcan.result_count).html( $(response).find(yith_wcan.result_count).html()).show();
63
+ }
64
+
65
+
66
+ //load new widgets
67
+ $('.yith-woo-ajax-navigation').each(function(){
68
+ var id = $(this).attr('id');
69
+ $(this).html( $(response).find('#'+id).html() );
70
+
71
+ if( $(this).text() == '' ) {
72
+ $(this).hide();
73
+ } else {
74
+ $(this).show();
75
+ }
76
+ });
77
+
78
+ //update browser history (IE doesn't support it)
79
+ if ( !navigator.userAgent.match(/msie/i) ) {
80
+ window.history.pushState({"pageTitle":response.pageTitle},"", href);
81
+ }
82
+
83
+ //trigger ready event
84
+ $(document).trigger("ready");
85
+ $(document).trigger("yith-wcan-ajax-filtered");
86
+ }
87
+ });
88
+ });
89
+ });
assets/js/yith-wcan-frontend.min.js ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Frontend
3
+ *
4
+ * @author Your Inspiration Themes
5
+ * @package YITH WooCommerce Ajax Navigation
6
+ * @version 1.0.0
7
+ */
8
+ jQuery(function(c){var s=/(?!(\[))(\.)[^.#[]*/g,t=/(#)[^.#[]*/,u=/^[\w]+/,v=/^[\w]+#x2F;,q=function(n,p){var a=[];if(v.test(n))a=[{tag:n}];else{for(var a=n,e={sel:[],val:[]},f=[],h=!1,g="",j=[],b=0,k=a.length;b<k;b++){var d=a.charAt(b);if(h)if("\\"===d&&b+1<a.length)j.push(a.charAt(++b));else if(g===d)g="",j.push(d);else if(("'"===d||'"'===d)&&""===g)g=d,j.push(d);else if("]"===d&&""===g)e.val.push(j.join("")),j=[],h=!1;else{if("]"!==d||""!==g)""===g&&","===d?(e.val.push(j.join("")),j=[]):j.push(d)}else"\\"===
9
+ d&&b+1<a.length?h&&j.push(a.charAt(++b)):"["===d&&""===g?h=!0:" "===d||"+"===d?(e.sel=e.sel.join(""),f.push(e),"+"===d&&f.push({sel:"+",val:""}),e={sel:[],val:[]}):" "!==d&&"]"!==d&&e.sel.push(d)}if(0!=e.sel.length||0!=e.val.length)e.sel=e.sel.join(""),f.push(e);for(b=0;b<f.length;b++){e=f[b].sel;if("+"===e)l.tag=e;else{var l=[];l.tag=u.exec(e);l.id=t.exec(e);l.id&&c.isArray(l.id)&&(l.id=l.id[0].substr(1));l.tag||(l.tag="div");l.vars=[];for(a=0;a<f[b].val.length;a++)g=f[b].val[a].indexOf("="),h=f[b].val[a].substr(0,
10
+ g),g=f[b].val[a].substr(g+1),g=g.replace(/^[\s]*[\"\']*|[\"\']*[\s]*#x2F;g,""),"text"===h?l.text=g:l.vars.push([h,g]);e=e.match(s);h=[];if(e){for(a=0;a<e.length;a++)h.push(e[a].substr(1));l.className=h.join(" ")}}f[b]=l}a=f}l=[];"undefined"===typeof p&&(p=1);e=[];f=[];h=[];g=document.createElement("div");for(b=j=0;b<a.length;b++){if("+"==a[b].tag)f=h.slice(),--j;else{for(k=0;k<p;k++)if("input"==a[b].tag){d=[];d.push("<"+a[b].tag);a[b].id&&d.push("id='"+a[b].id+"'");a[b].className&&(d.push("class='"+
11
+ a[b].className),b+1===a.length&&d.push(lastClass),d.push("'"));if(a[b].vars)for(var m=0;m<a[b].vars.length;m++)d.push(a[b].vars[m][0]+"='"+a[b].vars[m][1]+"'");a[b].text&&d.push("value='"+a[b].text+"'");d.push("/>");h[k]=f[k];f[k]?(f[k].innerHTML+=d.join(" "),f[k]=f[k].lastChild):(g.innerHTML=d.join(" "),f[k]=g.removeChild(g.firstChild))}else{d=document.createElement(a[b].tag);if(a[b].vars)for(m=0;m<a[b].vars.length;m++)console.log(a[b].tag,a[b].vars[m]),d.setAttribute(a[b].vars[m][0],a[b].vars[m][1]);
12
+ a[b].id&&(d.id=a[b].id);a[b].className&&(d.className=a[b].className);a[b].text&&d.appendChild(document.createTextNode(a[b].text));h[k]=f[k];f[k]=f[k]?f[k].appendChild(d):d}j++||Array.prototype.push.apply(e,f)}l=c.merge(l,f)}return c(e)},r=function(n,p,a){for(var e=n.match(/%[^%]*%/g)||[],f=[],h=0;h<p.length;h++){for(var g=n,j=0;j<e.length;j++)var b=e[j].substr(1,e[j].length-2),g=g.replace(e[j],p[h][b]);f=c.merge(f,q(g,a))}return c(f)};c.jseldom=function(n){if(2==arguments.length&&c.isPlainObject(arguments[1]))return r.apply(this,
13
+ [arguments[0],[arguments[1]]]);if(1==arguments.length||2==arguments.length&&!c.isArray(arguments[1]))return q.apply(this,arguments);if(2==arguments.length)return r.apply(this,arguments)};c(yith_wcan.container).wrap('<div class="yit-wcan-container"></div>');c(".woocommerce-info").wrap('<div class="yit-wcan-container"></div>');c(document).on("click",".yith-wcan a",function(n){n.preventDefault();var p=this.href;c(yith_wcan.container).html("").addClass("yith-wcan-loading");c(yith_wcan.pagination).hide();
14
+ c(yith_wcan.result_count).hide();c.ajax({url:p,success:function(a){c(yith_wcan.container).removeClass("yith-wcan-loading");0<c(a).find(yith_wcan.container).length?c(".yit-wcan-container").html(c(a).find(yith_wcan.container)):c(".yit-wcan-container").html(c(a).find(".woocommerce-info"));0<c(a).find(yith_wcan.pagination).length&&(0==c(yith_wcan.pagination).length&&c.jseldom(yith_wcan.pagination).insertAfter(c(yith_wcan.container)),c(yith_wcan.pagination).html(c(a).find(yith_wcan.pagination).html()).show());
15
+ 0<c(a).find(yith_wcan.result_count).length&&c(yith_wcan.result_count).html(c(a).find(yith_wcan.result_count).html()).show();c(".yith-woo-ajax-navigation").each(function(){var e=c(this).attr("id");c(this).html(c(a).find("#"+e).html());""==c(this).text()?c(this).hide():c(this).show()});navigator.userAgent.match(/msie/i)||window.history.pushState({pageTitle:a.pageTitle},"",p);c(document).trigger("ready");c(document).trigger("yith-wcan-ajax-filtered")}})})});
class.yith-wcan-admin.php ADDED
@@ -0,0 +1,106 @@
1
+ <?php
2
+ /**
3
+ * Admin class
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Navigation
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAN' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAN_Admin' ) ) {
13
+ /**
14
+ * Admin class.
15
+ * The class manage all the admin behaviors.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+ class YITH_WCAN_Admin {
20
+ /**
21
+ * Plugin version
22
+ *
23
+ * @var string
24
+ * @since 1.0.0
25
+ */
26
+ public $version;
27
+
28
+ /**
29
+ * Constructor
30
+ *
31
+ * @access public
32
+ * @since 1.0.0
33
+ */
34
+ public function __construct( $version ) {
35
+ $this->version = $version;
36
+
37
+ //Actions
38
+ add_action( 'init', array( $this, 'init' ) );
39
+ add_action('wp_ajax_yith_wcan_select_type', array( $this, 'ajax_print_terms') );
40
+
41
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
42
+
43
+ // YITH WCAN Loaded
44
+ do_action( 'yith_wcan_loaded' );
45
+ }
46
+
47
+
48
+ /**
49
+ * Init method:
50
+ * - default options
51
+ *
52
+ * @access public
53
+ * @since 1.0.0
54
+ */
55
+ public function init() {}
56
+
57
+
58
+ /**
59
+ * Enqueue admin styles and scripts
60
+ *
61
+ * @access public
62
+ * @return void
63
+ * @since 1.0.0
64
+ */
65
+ public function enqueue_styles_scripts() {
66
+ global $pagenow;
67
+
68
+ if( 'widgets.php' == $pagenow ) {
69
+ wp_enqueue_style( 'wp-color-picker' );
70
+ wp_enqueue_style( 'yith_wcan_admin', YITH_WCAN_URL . 'assets/css/admin.css', false, $this->version );
71
+
72
+ wp_enqueue_script( 'wp-color-picker' );
73
+ wp_enqueue_script( 'yith_wcan_admin', YITH_WCAN_URL . 'assets/js/yith-wcan-admin.js', array('jquery', 'wp-color-picker'), $this->version, true );
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Print terms for the element selected
79
+ *
80
+ * @access public
81
+ * @return void
82
+ * @since 1.0.0
83
+ */
84
+ public function ajax_print_terms() {
85
+ $type = $_POST['value'];
86
+ $attribute = $_POST['attribute'];
87
+ $return = array('message' => '', 'content' => $_POST);
88
+
89
+ $terms = get_terms( 'pa_' . $attribute, array('hide_empty'=>'0') );
90
+
91
+
92
+ $return['content'] = yith_wcan_attributes_table(
93
+ $type,
94
+ $attribute,
95
+ $_POST['id'],
96
+ $_POST['name'],
97
+ array(),
98
+ false
99
+ );
100
+
101
+ echo json_encode($return);
102
+ die();
103
+ }
104
+
105
+ }
106
+ }
class.yith-wcan-frontend.php ADDED
@@ -0,0 +1,130 @@
1
+ <?php
2
+ /**
3
+ * Frontend class
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Navigation
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAN' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAN_Frontend' ) ) {
13
+ /**
14
+ * Frontend class.
15
+ * The class manage all the frontend behaviors.
16
+ *
17
+ * @since 1.0.0
18
+ */
19
+ class YITH_WCAN_Frontend {
20
+ /**
21
+ * Plugin version
22
+ *
23
+ * @var string
24
+ * @since 1.0.0
25
+ */
26
+ public $version;
27
+
28
+ /**
29
+ * Constructor
30
+ *
31
+ * @access public
32
+ * @since 1.0.0
33
+ */
34
+ public function __construct( $version ) {
35
+ $this->version = $version;
36
+
37
+ //Actions
38
+ add_action( 'init', array( $this, 'init' ) );
39
+ add_action( 'init', array( $this, 'woocommerce_layered_nav_init' ), 99 );
40
+
41
+ add_action( 'wp_head', array( $this, 'enqueue_styles_scripts' ) );
42
+
43
+ // YITH WCAN Loaded
44
+ do_action( 'yith_wcan_loaded' );
45
+ }
46
+
47
+
48
+ /**
49
+ * Init method:
50
+ * - default options
51
+ *
52
+ * @access public
53
+ * @since 1.0.0
54
+ */
55
+ public function init() {
56
+
57
+ }
58
+
59
+
60
+ /**
61
+ * Enqueue frontend styles and scripts
62
+ *
63
+ * @access public
64
+ * @return void
65
+ * @since 1.0.0
66
+ */
67
+ public function enqueue_styles_scripts() {
68
+ if( yith_wcan_can_be_displayed() ) {
69
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
70
+
71
+ wp_enqueue_style( 'yith_wcan_admin', YITH_WCAN_URL . 'assets/css/frontend.css', false, $this->version );
72
+ wp_enqueue_script( 'yith_wcan_frontend', YITH_WCAN_URL . 'assets/js/yith-wcan-frontend' . $suffix .'.js', array('jquery'), $this->version, true );
73
+
74
+ $args = array(
75
+ 'container' => '.products',
76
+ 'pagination' => 'nav.woocommerce-pagination',
77
+ 'result_count' => '.woocommerce-result-count'
78
+ );
79
+ wp_localize_script( 'yith_wcan_frontend', 'yith_wcan', apply_filters( 'yith-wcan-frontend-args', $args ) );
80
+ }
81
+ }
82
+
83
+
84
+ /**
85
+ * Layered Nav Init
86
+ *
87
+ * @package WooCommerce/Widgets
88
+ * @access public
89
+ * @return void
90
+ */
91
+ public function woocommerce_layered_nav_init( ) {
92
+
93
+ if ( is_active_widget( false, false, 'yith-woo-ajax-navigation', true ) && ! is_admin() ) {
94
+
95
+ global $_chosen_attributes, $woocommerce, $_attributes_array;
96
+
97
+ $_chosen_attributes = $_attributes_array = array();
98
+
99
+ $attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
100
+ if ( $attribute_taxonomies ) {
101
+ foreach ( $attribute_taxonomies as $tax ) {
102
+
103
+ $attribute = sanitize_title( $tax->attribute_name );
104
+ $taxonomy = $woocommerce->attribute_taxonomy_name( $attribute );
105
+
106
+ // create an array of product attribute taxonomies
107
+ $_attributes_array[] = $taxonomy;
108
+
109
+ $name = 'filter_' . $attribute;
110
+ $query_type_name = 'query_type_' . $attribute;
111
+
112
+ if ( ! empty( $_GET[ $name ] ) && taxonomy_exists( $taxonomy ) ) {
113
+
114
+ $_chosen_attributes[ $taxonomy ]['terms'] = explode( ',', $_GET[ $name ] );
115
+
116
+ if ( empty( $_GET[ $query_type_name ] ) || ! in_array( strtolower( $_GET[ $query_type_name ] ), array( 'and', 'or' ) ) )
117
+ $_chosen_attributes[ $taxonomy ]['query_type'] = apply_filters( 'woocommerce_layered_nav_default_query_type', 'and' );
118
+ else
119
+ $_chosen_attributes[ $taxonomy ]['query_type'] = strtolower( $_GET[ $query_type_name ] );
120
+
121
+ }
122
+ }
123
+ }
124
+
125
+ add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query');
126
+ }
127
+ }
128
+
129
+ }
130
+ }
class.yith-wcan-helper.php ADDED
@@ -0,0 +1,45 @@
1
+ <?php
2
+ /**
3
+ * Main class
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Navigation
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAN' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAN_Helper' ) ) {
13
+ /**
14
+ * YITH WooCommerce Ajax Navigation Helper
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ class YITH_WCAN_Helper {
19
+
20
+ /*
21
+ * Get Woocommerce Attribute Taxonomies
22
+ *
23
+ * @since 1.0.0
24
+ * @access public
25
+ */
26
+ public static function attribute_taxonomies() {
27
+ global $woocommerce;
28
+
29
+ if ( ! isset( $woocommerce ) ) return array();
30
+
31
+ $attributes = array();
32
+ $attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
33
+
34
+ if( empty( $attribute_taxonomies ) ) return array();
35
+ foreach( $attribute_taxonomies as $attribute ) {
36
+ if ( taxonomy_exists( $woocommerce->attribute_taxonomy_name( $attribute->attribute_name ) ) ) {
37
+ $attributes[] = $attribute->attribute_name;
38
+ }
39
+ }
40
+
41
+ return $attributes;
42
+ }
43
+
44
+ }
45
+ }
class.yith-wcan.php ADDED
@@ -0,0 +1,79 @@
1
+ <?php
2
+ /**
3
+ * Main class
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Navigation
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAN' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAN' ) ) {
13
+ /**
14
+ * YITH WooCommerce Ajax Navigation
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ class YITH_WCAN {
19
+ /**
20
+ * Plugin version
21
+ *
22
+ * @var string
23
+ * @since 1.0.0
24
+ */
25
+ public $version = '1.0.0';
26
+
27
+ /**
28
+ * Plugin object
29
+ *
30
+ * @var string
31
+ * @since 1.0.0
32
+ */
33
+ public $obj = null;
34
+
35
+ /**
36
+ * Constructor
37
+ *
38
+ * @return mixed|YITH_WCAN_Admin|YITH_WCAN_Frontend
39
+ * @since 1.0.0
40
+ */
41
+ public function __construct() {
42
+
43
+ // actions
44
+ add_action( 'init', array( $this, 'init' ) );
45
+ add_action( 'widgets_init', array( $this, 'registerWidgets' ) );
46
+
47
+
48
+ if( is_admin() ) {
49
+ $this->obj = new YITH_WCAN_Admin( $this->version );
50
+ } else {
51
+ $this->obj = new YITH_WCAN_Frontend( $this->version );
52
+ }
53
+
54
+ return $this->obj;
55
+ }
56
+
57
+
58
+ /**
59
+ * Init method
60
+ *
61
+ * @access public
62
+ * @since 1.0.0
63
+ */
64
+ public function init() {}
65
+
66
+
67
+ /**
68
+ * Load and register widgets
69
+ *
70
+ * @access public
71
+ * @since 1.0.0
72
+ */
73
+ public function registerWidgets() {
74
+ register_widget( 'YITH_WCAN_Navigation_Widget' );
75
+
76
+ }
77
+
78
+ }
79
+ }
functions.yith-wcan.php ADDED
@@ -0,0 +1,101 @@
1
+ <?php
2
+ /**
3
+ * Functions
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Navigation
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAN' ) ) { exit; } // Exit if accessed directly
11
+
12
+
13
+ /**
14
+ * Return a dropdown with Woocommerce attributes
15
+ */
16
+ function yith_wcan_dropdown_attributes( $selected, $echo = true ) {
17
+ $attributes = YITH_WCAN_Helper::attribute_taxonomies();
18
+ $options = "";
19
+
20
+ foreach( $attributes as $attribute ) {
21
+ $options .= "<option name='{$attribute}'". selected( $attribute, $selected, false ) .">{$attribute}</option>";
22
+ }
23
+
24
+ if( $echo ) {
25
+ echo $options;
26
+ } else {
27
+ return $options;
28
+ }
29
+ }
30
+
31
+
32
+ /**
33
+ * Print the widgets options already filled
34
+ *
35
+ * @param $type string list|colors|label
36
+ * @param $attribute woocommerce taxonomy
37
+ * @param $id id used in the <input />
38
+ * @param $name base name used in the <input />
39
+ * @param $values array of values (could be empty if this is an ajax call)
40
+ *
41
+ * @return string
42
+ */
43
+ function yith_wcan_attributes_table( $type, $attribute, $id, $name, $values = array(), $echo = true ) {
44
+ $return = '';
45
+
46
+ $terms = get_terms( 'pa_' . $attribute, array('hide_empty'=>'0') );
47
+
48
+ if( 'list' == $type ) {
49
+ $return = '<input type="hidden" name="'. $name .'[colors]" value="" /><input type="hidden" name="'. $name .'[labels]" value="" />';
50
+ } elseif( 'color' == $type ) {
51
+ if( !empty($terms) ) {
52
+ $return = sprintf('<table><tr><th>%s</th><th>%s</th></tr>', __('Term', 'yit'), __('Color', 'yit'));
53
+
54
+ foreach( $terms as $term ) {
55
+ $return .= "<tr><td><label for='{$id}{$term->term_id}'>{$term->name}</label></td><td><input type='text' id='{$id}{$term->term_id}' name='{$name}[colors][{$term->term_id}]' value='" . (isset( $values[$term->term_id] ) ? $values[$term->term_id] : '') . "' size='3' class='yith-colorpicker' /></td></tr>";
56
+ }
57
+
58
+ $return .= '</table>';
59
+ }
60
+
61
+ $return .= '<input type="hidden" name="'. $name .'[labels]" value="" />';
62
+ } elseif( 'label' == $type ) {
63
+ if( !empty($terms) ) {
64
+ $return = sprintf('<table><tr><th>%s</th><th>%s</th></tr>', __('Term', 'yit'), __('Labels', 'yit'));
65
+
66
+ foreach( $terms as $term ) {
67
+ $return .= "<tr><td><label for='{$id}{$term->term_id}'>{$term->name}</label></td><td><input type='text' id='{$id}{$term->term_id}' name='{$name}[labels][{$term->term_id}]' value='" . (isset( $values[$term->term_id] ) ? $values[$term->term_id] : '') . "' size='3' maxlength='3' /></td></tr>";
68
+ }
69
+
70
+ $return .= '</table>';
71
+ }
72
+
73
+ $return .= '<input type="hidden" name="'. $name .'[colors]" value="" />';
74
+ }
75
+
76
+ if( $echo ) {
77
+ echo $return;
78
+ }
79
+
80
+ return $return;
81
+ }
82
+
83
+
84
+ /**
85
+ * Can the widget be displayed?
86
+ *
87
+ * @return bool
88
+ */
89
+ function yith_wcan_can_be_displayed() {
90
+ global $woocommerce, $_attributes_array;
91
+
92
+
93
+ /* if ( ! is_post_type_archive( 'product' ) && ! is_tax( array_merge( $_attributes_array, array( 'product_cat', 'product_tag' ) ) ) )
94
+ return false;*/
95
+
96
+ if ( is_active_widget( false, false, 'yith-woo-ajax-navigation', true ) ) {
97
+ return true;
98
+ } else {
99
+ return false;
100
+ }
101
+ }
init.php ADDED
@@ -0,0 +1,57 @@
1
+ <?php
2
+ /**
3
+ * Plugin Name: YITH WooCommerce Ajax Navigation
4
+ * Plugin URI: http://yithemes.com/
5
+ * Description: YITH WooCommerce Ajax Navigation allows user to filter products in Shop page without reloading the page.
6
+ * Version: 1.0.0
7
+ * Author: Your Inspiration Themes
8
+ * Author URI: http://yithemes.com/
9
+ * Text Domain: yit
10
+ * Domain Path: /languages/
11
+ *
12
+ * @author Your Inspiration Themes
13
+ * @package YITH WooCommerce Ajax Navigation
14
+ * @version 1.0.0
15
+ */
16
+ /* Copyright 2013 Your Inspiration Themes (email : plugins@yithemes.com)
17
+
18
+ This program is free software; you can redistribute it and/or modify
19
+ it under the terms of the GNU General Public License, version 2, as
20
+ published by the Free Software Foundation.
21
+
22
+ This program is distributed in the hope that it will be useful,
23
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
24
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
+ GNU General Public License for more details.
26
+
27
+ You should have received a copy of the GNU General Public License
28
+ along with this program; if not, write to the Free Software
29
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
+ */
31
+ if ( !defined( 'ABSPATH' ) ) { exit; } // Exit if accessed directly
32
+
33
+ /**
34
+ * Required functions
35
+ */
36
+ if( !defined('YITH_FUNCTIONS') ) {
37
+ require_once( 'yit-common/yit-functions.php' );
38
+ }
39
+ if ( ! yit_is_woocommerce_active() ) return;
40
+
41
+ load_plugin_textdomain( 'yit', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
42
+
43
+ define( 'YITH_WCAN', true );
44
+ define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
45
+ define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
46
+
47
+ // Load required classes and functions
48
+ require_once('functions.yith-wcan.php');
49
+ require_once('class.yith-wcan-admin.php');
50
+ require_once('class.yith-wcan-frontend.php');
51
+ require_once('class.yith-wcan-helper.php');
52
+ require_once('widgets/class.yith-wcan-navigation-widget.php');
53
+ require_once('class.yith-wcan.php');
54
+
55
+ // Let's start the game!
56
+ global $yith_wcan;
57
+ $yith_wcan = new YITH_WCAN();
languages/default.po ADDED
@@ -0,0 +1,192 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: YITH WooCommerce Ajax Navigation v1.0.0\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2013-06-17 12:59:26+0000\n"
7
+ "Last-Translator: Your Inspiration Themes <plugins@yithemes.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: CSL v1.x\n"
14
+ "X-Poedit-Language: English\n"
15
+ "X-Poedit-Country: UNITED STATES\n"
16
+ "X-Poedit-SourceCharset: utf-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
18
+ "X-Poedit-Basepath: ../\n"
19
+ "X-Poedit-Bookmarks: \n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Textdomain-Support: yes"
22
+
23
+ #: functions.yith-wcan.php:52
24
+ #: functions.yith-wcan.php:64
25
+ #@ yit
26
+ msgid "Term"
27
+ msgstr ""
28
+
29
+ #: functions.yith-wcan.php:52
30
+ #: widgets/class.yith-wcan-navigation-widget.php:535
31
+ #@ yit
32
+ msgid "Color"
33
+ msgstr ""
34
+
35
+ #: functions.yith-wcan.php:64
36
+ #@ yit
37
+ msgid "Labels"
38
+ msgstr ""
39
+
40
+ #. translators: plugin header field 'Name'
41
+ #: init.php:0
42
+ #: widgets/class.yith-wcan-navigation-widget.php:23
43
+ #@ yit
44
+ msgid "YITH WooCommerce Ajax Navigation"
45
+ msgstr ""
46
+
47
+ #. translators: plugin header field 'PluginURI'
48
+ #. translators: plugin header field 'AuthorURI'
49
+ #: init.php:0
50
+ #@ yit
51
+ msgid "http://yithemes.com/"
52
+ msgstr ""
53
+
54
+ #. translators: plugin header field 'Description'
55
+ #: init.php:0
56
+ #@ yit
57
+ msgid "YITH WooCommerce Ajax Navigation allows user to filter products in Shop page without reloading the page."
58
+ msgstr ""
59
+
60
+ #. translators: plugin header field 'Author'
61
+ #: init.php:0
62
+ #@ yit
63
+ msgid "Your Inspiration Themes"
64
+ msgstr ""
65
+
66
+ #. translators: plugin header field 'Version'
67
+ #: init.php:0
68
+ #@ yit
69
+ msgid "1.0.0"
70
+ msgstr ""
71
+
72
+ #: widgets/class.yith-wcan-navigation-widget.php:21
73
+ #@ yit
74
+ msgid "Narrow down the products list without reloading the page"
75
+ msgstr ""
76
+
77
+ #: widgets/class.yith-wcan-navigation-widget.php:516
78
+ #@ yit
79
+ msgid "Title"
80
+ msgstr ""
81
+
82
+ #: widgets/class.yith-wcan-navigation-widget.php:521
83
+ #@ yit
84
+ msgid "Attribute:"
85
+ msgstr ""
86
+
87
+ #: widgets/class.yith-wcan-navigation-widget.php:526
88
+ #@ yit
89
+ msgid "Query Type:"
90
+ msgstr ""
91
+
92
+ #: widgets/class.yith-wcan-navigation-widget.php:528
93
+ #@ yit
94
+ msgid "AND"
95
+ msgstr ""
96
+
97
+ #: widgets/class.yith-wcan-navigation-widget.php:529
98
+ #@ yit
99
+ msgid "OR"
100
+ msgstr ""
101
+
102
+ #: widgets/class.yith-wcan-navigation-widget.php:532
103
+ #@ yit
104
+ msgid "Type:"
105
+ msgstr ""
106
+
107
+ #: widgets/class.yith-wcan-navigation-widget.php:534
108
+ #@ yit
109
+ msgid "List"
110
+ msgstr ""
111
+
112
+ #: widgets/class.yith-wcan-navigation-widget.php:536
113
+ #@ yit
114
+ msgid "Label"
115
+ msgstr ""
116
+
117
+ #: yit-common/yith-panel.php:396
118
+ #@ yit
119
+ msgid "Select a date"
120
+ msgstr ""
121
+
122
+ #: yit-common/yith-panel.php:397
123
+ #@ yit
124
+ msgid "Hours"
125
+ msgstr ""
126
+
127
+ #: yit-common/yith-panel.php:398
128
+ #: yit-common/yith-panel.php:399
129
+ #@ yit
130
+ msgid "Minutes"
131
+ msgstr ""
132
+
133
+ #: yit-common/yith-panel.php:407
134
+ #@ yit
135
+ msgid "Upload"
136
+ msgstr ""
137
+
138
+ #: yit-common/yith-panel.php:434
139
+ #@ yit
140
+ msgid "px"
141
+ msgstr ""
142
+
143
+ #: yit-common/yith-panel.php:435
144
+ #@ yit
145
+ msgid "em"
146
+ msgstr ""
147
+
148
+ #: yit-common/yith-panel.php:436
149
+ #@ yit
150
+ msgid "pt"
151
+ msgstr ""
152
+
153
+ #: yit-common/yith-panel.php:437
154
+ #@ yit
155
+ msgid "rem"
156
+ msgstr ""
157
+
158
+ #: yit-common/yith-panel.php:447
159
+ #@ yit
160
+ msgid "Select a font family"
161
+ msgstr ""
162
+
163
+ #: yit-common/yith-panel.php:455
164
+ #@ yit
165
+ msgid "Regular"
166
+ msgstr ""
167
+
168
+ #: yit-common/yith-panel.php:456
169
+ #@ yit
170
+ msgid "Bold"
171
+ msgstr ""
172
+
173
+ #: yit-common/yith-panel.php:457
174
+ #@ yit
175
+ msgid "Extra bold"
176
+ msgstr ""
177
+
178
+ #: yit-common/yith-panel.php:458
179
+ #@ yit
180
+ msgid "Italic"
181
+ msgstr ""
182
+
183
+ #: yit-common/yith-panel.php:459
184
+ #@ yit
185
+ msgid "Italic bold"
186
+ msgstr ""
187
+
188
+ #: yit-common/yith-panel.php:471
189
+ #@ yit
190
+ msgid "Click to preview"
191
+ msgstr ""
192
+
languages/yit-it_IT.mo ADDED
Binary file
languages/yit-it_IT.po ADDED
@@ -0,0 +1,191 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: YITH WooCommerce Ajax Navigation v1.0.0\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2013-06-17 15:07+0100\n"
7
+ "Last-Translator: Your Inspiration Themes <plugins@yithemes.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: Poedit 1.5.5\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
16
+ "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
+ "X-Poedit-Basepath: ../\n"
18
+ "X-Textdomain-Support: yes\n"
19
+ "Language: it_IT\n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+
22
+ # @ yit
23
+ #: functions.yith-wcan.php:52 functions.yith-wcan.php:64
24
+ msgid "Term"
25
+ msgstr "Proprietà"
26
+
27
+ # @ yit
28
+ #: functions.yith-wcan.php:52
29
+ #: widgets/class.yith-wcan-navigation-widget.php:535
30
+ msgid "Color"
31
+ msgstr "Colore"
32
+
33
+ # @ yit
34
+ #: functions.yith-wcan.php:64
35
+ msgid "Labels"
36
+ msgstr "Label"
37
+
38
+ # @ yit
39
+ #. translators: plugin header field 'Name'
40
+ #: init.php:0 widgets/class.yith-wcan-navigation-widget.php:23
41
+ msgid "YITH WooCommerce Ajax Navigation"
42
+ msgstr "YITH WooCommerce Ajax Navigation"
43
+
44
+ # @ yit
45
+ #. translators: plugin header field 'PluginURI'
46
+ #. translators: plugin header field 'AuthorURI'
47
+ #: init.php:0
48
+ msgid "http://yithemes.com/"
49
+ msgstr "http://yithemes.com/"
50
+
51
+ # @ yit
52
+ #. translators: plugin header field 'Description'
53
+ #: init.php:0
54
+ msgid ""
55
+ "YITH WooCommerce Ajax Navigation allows user to filter products in Shop page "
56
+ "without reloading the page."
57
+ msgstr ""
58
+ "YITH WooCommerce Ajax Navigation consente all'utente di filtrare i prodotti "
59
+ "contenuti nella pagina Shop senza ricaricare la pagina."
60
+
61
+ # @ yit
62
+ #. translators: plugin header field 'Author'
63
+ #: init.php:0
64
+ msgid "Your Inspiration Themes"
65
+ msgstr "Your Inspiration Themes"
66
+
67
+ # @ yit
68
+ #. translators: plugin header field 'Version'
69
+ #: init.php:0
70
+ msgid "1.0.0"
71
+ msgstr "1.0.0"
72
+
73
+ # @ yit
74
+ #: widgets/class.yith-wcan-navigation-widget.php:21
75
+ msgid "Narrow down the products list without reloading the page"
76
+ msgstr "Filtra la lista dei prodotti senza ricaricare la pagina"
77
+
78
+ # @ yit
79
+ #: widgets/class.yith-wcan-navigation-widget.php:516
80
+ msgid "Title"
81
+ msgstr "Titolo"
82
+
83
+ # @ yit
84
+ #: widgets/class.yith-wcan-navigation-widget.php:521
85
+ msgid "Attribute:"
86
+ msgstr "Attributo:"
87
+
88
+ # @ yit
89
+ #: widgets/class.yith-wcan-navigation-widget.php:526
90
+ msgid "Query Type:"
91
+ msgstr "Tipo Query:"
92
+
93
+ # @ yit
94
+ #: widgets/class.yith-wcan-navigation-widget.php:528
95
+ msgid "AND"
96
+ msgstr "AND"
97
+
98
+ # @ yit
99
+ #: widgets/class.yith-wcan-navigation-widget.php:529
100
+ msgid "OR"
101
+ msgstr "OR"
102
+
103
+ # @ yit
104
+ #: widgets/class.yith-wcan-navigation-widget.php:532
105
+ msgid "Type:"
106
+ msgstr "Tipo:"
107
+
108
+ # @ yit
109
+ #: widgets/class.yith-wcan-navigation-widget.php:534
110
+ msgid "List"
111
+ msgstr "Lista"
112
+
113
+ # @ yit
114
+ #: widgets/class.yith-wcan-navigation-widget.php:536
115
+ msgid "Label"
116
+ msgstr "Label"
117
+
118
+ # @ yit
119
+ #: yit-common/yith-panel.php:396
120
+ msgid "Select a date"
121
+ msgstr "Seleziona una data"
122
+
123
+ # @ yit
124
+ #: yit-common/yith-panel.php:397
125
+ msgid "Hours"
126
+ msgstr "Ore"
127
+
128
+ # @ yit
129
+ #: yit-common/yith-panel.php:398 yit-common/yith-panel.php:399
130
+ msgid "Minutes"
131
+ msgstr "Minuti"
132
+
133
+ # @ yit
134
+ #: yit-common/yith-panel.php:407
135
+ msgid "Upload"
136
+ msgstr "Upload"
137
+
138
+ # @ yit
139
+ #: yit-common/yith-panel.php:434
140
+ msgid "px"
141
+ msgstr "px"
142
+
143
+ # @ yit
144
+ #: yit-common/yith-panel.php:435
145
+ msgid "em"
146
+ msgstr "em"
147
+
148
+ # @ yit
149
+ #: yit-common/yith-panel.php:436
150
+ msgid "pt"
151
+ msgstr "pt"
152
+
153
+ # @ yit
154
+ #: yit-common/yith-panel.php:437
155
+ msgid "rem"
156
+ msgstr "rem"
157
+
158
+ # @ yit
159
+ #: yit-common/yith-panel.php:447
160
+ msgid "Select a font family"
161
+ msgstr "Seleziona un font"
162
+
163
+ # @ yit
164
+ #: yit-common/yith-panel.php:455
165
+ msgid "Regular"
166
+ msgstr "Regular"
167
+
168
+ # @ yit
169
+ #: yit-common/yith-panel.php:456
170
+ msgid "Bold"
171
+ msgstr "Bold"
172
+
173
+ # @ yit
174
+ #: yit-common/yith-panel.php:457
175
+ msgid "Extra bold"
176
+ msgstr "Extra bold"
177
+
178
+ # @ yit
179
+ #: yit-common/yith-panel.php:458
180
+ msgid "Italic"
181
+ msgstr "Italic"
182
+
183
+ # @ yit
184
+ #: yit-common/yith-panel.php:459
185
+ msgid "Italic bold"
186
+ msgstr "Italic bold"
187
+
188
+ # @ yit
189
+ #: yit-common/yith-panel.php:471
190
+ msgid "Click to preview"
191
+ msgstr "Clicca per anteprima"
languages/yit.pot ADDED
@@ -0,0 +1,187 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: YITH WooCommerce Ajax Navigation v1.0.0\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2013-06-17 15:02+0100\n"
7
+ "Last-Translator: Your Inspiration Themes <plugins@yithemes.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
13
+ "X-Generator: Poedit 1.5.5\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
16
+ "_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2\n"
17
+ "X-Textdomain-Support: yes\n"
18
+ "Language: en_US\n"
19
+
20
+ # @ yit
21
+ #: functions.yith-wcan.php:52 functions.yith-wcan.php:64
22
+ msgid "Term"
23
+ msgstr ""
24
+
25
+ # @ yit
26
+ #: functions.yith-wcan.php:52
27
+ #: widgets/class.yith-wcan-navigation-widget.php:535
28
+ msgid "Color"
29
+ msgstr ""
30
+
31
+ # @ yit
32
+ #: functions.yith-wcan.php:64
33
+ msgid "Labels"
34
+ msgstr ""
35
+
36
+ # @ yit
37
+ #. translators: plugin header field 'Name'
38
+ #: init.php:0 widgets/class.yith-wcan-navigation-widget.php:23
39
+ msgid "YITH WooCommerce Ajax Navigation"
40
+ msgstr ""
41
+
42
+ # @ yit
43
+ #. translators: plugin header field 'PluginURI'
44
+ #. translators: plugin header field 'AuthorURI'
45
+ #: init.php:0
46
+ msgid "http://yithemes.com/"
47
+ msgstr ""
48
+
49
+ # @ yit
50
+ #. translators: plugin header field 'Description'
51
+ #: init.php:0
52
+ msgid ""
53
+ "YITH WooCommerce Ajax Navigation allows user to filter products in Shop page "
54
+ "without reloading the page."
55
+ msgstr ""
56
+
57
+ # @ yit
58
+ #. translators: plugin header field 'Author'
59
+ #: init.php:0
60
+ msgid "Your Inspiration Themes"
61
+ msgstr ""
62
+
63
+ # @ yit
64
+ #. translators: plugin header field 'Version'
65
+ #: init.php:0
66
+ msgid "1.0.0"
67
+ msgstr ""
68
+
69
+ # @ yit
70
+ #: widgets/class.yith-wcan-navigation-widget.php:21
71
+ msgid "Narrow down the products list without reloading the page"
72
+ msgstr ""
73
+
74
+ # @ yit
75
+ #: widgets/class.yith-wcan-navigation-widget.php:516
76
+ msgid "Title"
77
+ msgstr ""
78
+
79
+ # @ yit
80
+ #: widgets/class.yith-wcan-navigation-widget.php:521
81
+ msgid "Attribute:"
82
+ msgstr ""
83
+
84
+ # @ yit
85
+ #: widgets/class.yith-wcan-navigation-widget.php:526
86
+ msgid "Query Type:"
87
+ msgstr ""
88
+
89
+ # @ yit
90
+ #: widgets/class.yith-wcan-navigation-widget.php:528
91
+ msgid "AND"
92
+ msgstr ""
93
+
94
+ # @ yit
95
+ #: widgets/class.yith-wcan-navigation-widget.php:529
96
+ msgid "OR"
97
+ msgstr ""
98
+
99
+ # @ yit
100
+ #: widgets/class.yith-wcan-navigation-widget.php:532
101
+ msgid "Type:"
102
+ msgstr ""
103
+
104
+ # @ yit
105
+ #: widgets/class.yith-wcan-navigation-widget.php:534
106
+ msgid "List"
107
+ msgstr ""
108
+
109
+ # @ yit
110
+ #: widgets/class.yith-wcan-navigation-widget.php:536
111
+ msgid "Label"
112
+ msgstr ""
113
+
114
+ # @ yit
115
+ #: yit-common/yith-panel.php:396
116
+ msgid "Select a date"
117
+ msgstr ""
118
+
119
+ # @ yit
120
+ #: yit-common/yith-panel.php:397
121
+ msgid "Hours"
122
+ msgstr ""
123
+
124
+ # @ yit
125
+ #: yit-common/yith-panel.php:398 yit-common/yith-panel.php:399
126
+ msgid "Minutes"
127
+ msgstr ""
128
+
129
+ # @ yit
130
+ #: yit-common/yith-panel.php:407
131
+ msgid "Upload"
132
+ msgstr ""
133
+
134
+ # @ yit
135
+ #: yit-common/yith-panel.php:434
136
+ msgid "px"
137
+ msgstr ""
138
+
139
+ # @ yit
140
+ #: yit-common/yith-panel.php:435
141
+ msgid "em"
142
+ msgstr ""
143
+
144
+ # @ yit
145
+ #: yit-common/yith-panel.php:436
146
+ msgid "pt"
147
+ msgstr ""
148
+
149
+ # @ yit
150
+ #: yit-common/yith-panel.php:437
151
+ msgid "rem"
152
+ msgstr ""
153
+
154
+ # @ yit
155
+ #: yit-common/yith-panel.php:447
156
+ msgid "Select a font family"
157
+ msgstr ""
158
+
159
+ # @ yit
160
+ #: yit-common/yith-panel.php:455
161
+ msgid "Regular"
162
+ msgstr ""
163
+
164
+ # @ yit
165
+ #: yit-common/yith-panel.php:456
166
+ msgid "Bold"
167
+ msgstr ""
168
+
169
+ # @ yit
170
+ #: yit-common/yith-panel.php:457
171
+ msgid "Extra bold"
172
+ msgstr ""
173
+
174
+ # @ yit
175
+ #: yit-common/yith-panel.php:458
176
+ msgid "Italic"
177
+ msgstr ""
178
+
179
+ # @ yit
180
+ #: yit-common/yith-panel.php:459
181
+ msgid "Italic bold"
182
+ msgstr ""
183
+
184
+ # @ yit
185
+ #: yit-common/yith-panel.php:471
186
+ msgid "Click to preview"
187
+ msgstr ""
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.png ADDED
Binary file
widgets/class.yith-wcan-navigation-widget.php ADDED
@@ -0,0 +1,577 @@
1
+ <?php
2
+ /**
3
+ * Main class
4
+ *
5
+ * @author Your Inspiration Themes
6
+ * @package YITH WooCommerce Ajax Navigation
7
+ * @version 1.0.0
8
+ */
9
+
10
+ if ( !defined( 'YITH_WCAN' ) ) { exit; } // Exit if accessed directly
11
+
12
+ if( !class_exists( 'YITH_WCAN' ) ) {
13
+ /**
14
+ * YITH WooCommerce Ajax Navigation Widget
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ class YITH_WCAN_Navigation_Widget extends WP_Widget {
19
+
20
+ function __construct() {
21
+ $widget_ops = array('classname' => 'yith-woo-ajax-navigation woocommerce widget_layered_nav', 'description' => __( 'Narrow down the products list without reloading the page', 'yit') );
22
+ $control_ops = array('width' => 400, 'height' => 350);
23
+ parent::__construct('yith-woo-ajax-navigation', __('YITH WooCommerce Ajax Navigation', 'yit'), $widget_ops, $control_ops);
24
+ }
25
+
26
+
27
+ function widget( $args, $instance ) {
28
+ global $_chosen_attributes, $woocommerce, $_attributes_array;
29
+
30
+ extract( $args );
31
+
32
+ if ( ! is_post_type_archive( 'product' ) && ! is_tax( array_merge( $_attributes_array, array( 'product_cat', 'product_tag' ) ) ) )
33
+ return;
34
+
35
+ $current_term = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->term_id : '';
36
+ $current_tax = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->taxonomy : '';
37
+
38
+ $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
39
+ $taxonomy = $woocommerce->attribute_taxonomy_name($instance['attribute']);
40
+ $query_type = isset( $instance['query_type'] ) ? $instance['query_type'] : 'and';
41
+ $display_type = isset( $instance['type'] ) ? $instance['type'] : 'list';
42
+
43
+ if ( ! taxonomy_exists( $taxonomy ) )
44
+ return;
45
+
46
+ $terms = get_terms( $taxonomy, array( 'hide_empty' => '1' ) );
47
+
48
+ if ( count( $terms ) > 0 ) {
49
+
50
+ ob_start();
51
+
52
+ $found = false;
53
+
54
+ echo $before_widget . $before_title . $title . $after_title;
55
+
56
+ // Force found when option is selected - do not force found on taxonomy attributes
57
+ if ( ! $_attributes_array || ! is_tax( $_attributes_array ) )
58
+ if ( is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) )
59
+ $found = true;
60
+
61
+ if ( $display_type == 'list' ) {
62
+ // List display
63
+ echo "<ul class='yith-wcan-list yith-wcan'>";
64
+
65
+ foreach ( $terms as $term ) {
66
+
67
+ // Get count based on current view - uses transients
68
+ $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
69
+
70
+ if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
71
+
72
+ $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
73
+
74
+ set_transient( $transient_name, $_products_in_term );
75
+ }
76
+
77
+ $option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );
78
+
79
+ // If this is an AND query, only show options with count > 0
80
+ if ( $query_type == 'and' ) {
81
+
82
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
83
+
84
+ // skip the term for the current archive
85
+ if ( $current_term == $term->term_id )
86
+ continue;
87
+
88
+ if ( $count > 0 && $current_term !== $term->term_id )
89
+ $found = true;
90
+
91
+ if ( $count == 0 && ! $option_is_set )
92
+ continue;
93
+
94
+ // If this is an OR query, show all options so search can be expanded
95
+ } else {
96
+
97
+ // skip the term for the current archive
98
+ if ( $current_term == $term->term_id )
99
+ continue;
100
+
101
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
102
+
103
+ if ( $count > 0 )
104
+ $found = true;
105
+
106
+ }
107
+
108
+ $arg = 'filter_' . sanitize_title( $instance['attribute'] );
109
+
110
+ $current_filter = ( isset( $_GET[ $arg ] ) ) ? explode( ',', $_GET[ $arg ] ) : array();
111
+
112
+ if ( ! is_array( $current_filter ) )
113
+ $current_filter = array();
114
+
115
+ $current_filter = array_map( 'esc_attr', $current_filter );
116
+
117
+ if ( ! in_array( $term->term_id, $current_filter ) )
118
+ $current_filter[] = $term->term_id;
119
+
120
+ // Base Link decided by current page
121
+ if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
122
+ $link = home_url();
123
+ } elseif ( is_post_type_archive( 'product' ) || is_page( woocommerce_get_page_id('shop') ) ) {
124
+ $link = get_post_type_archive_link( 'product' );
125
+ } else {
126
+ $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
127
+ }
128
+
129
+ // All current filters
130
+ if ( $_chosen_attributes ) {
131
+ foreach ( $_chosen_attributes as $name => $data ) {
132
+ if ( $name !== $taxonomy ) {
133
+
134
+ // Exclude query arg for current term archive term
135
+ while ( in_array( $current_term, $data['terms'] ) ) {
136
+ $key = array_search( $current_term, $data );
137
+ unset( $data['terms'][$key] );
138
+ }
139
+
140
+ // Remove pa_ and sanitize
141
+ $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
142
+
143
+ if ( ! empty( $data['terms'] ) )
144
+ $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
145
+
146
+ if ( $data['query_type'] == 'or' )
147
+ $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
148
+ }
149
+ }
150
+ }
151
+
152
+ // Min/Max
153
+ if ( isset( $_GET['min_price'] ) )
154
+ $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
155
+
156
+ if ( isset( $_GET['max_price'] ) )
157
+ $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
158
+
159
+ // Current Filter = this widget
160
+ if ( isset( $_chosen_attributes[ $taxonomy ] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) {
161
+
162
+ $class = 'class="chosen"';
163
+
164
+ // Remove this term is $current_filter has more than 1 term filtered
165
+ if ( sizeof( $current_filter ) > 1 ) {
166
+ $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
167
+ $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
168
+ }
169
+
170
+ } else {
171
+
172
+ $class = '';
173
+ $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
174
+
175
+ }
176
+
177
+ // Search Arg
178
+ if ( get_search_query() )
179
+ $link = add_query_arg( 's', get_search_query(), $link );
180
+
181
+ // Post Type Arg
182
+ if ( isset( $_GET['post_type'] ) )
183
+ $link = add_query_arg( 'post_type', $_GET['post_type'], $link );
184
+
185
+ // Query type Arg
186
+ if ( $query_type == 'or' && ! ( sizeof( $current_filter ) == 1 && isset( $_chosen_attributes[ $taxonomy ]['terms'] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) )
187
+ $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
188
+
189
+ echo '<li ' . $class . '>';
190
+
191
+ echo ( $count > 0 || $option_is_set ) ? '<a href="' . esc_url( apply_filters( 'woocommerce_layered_nav_link', $link ) ) . '">' : '<span>';
192
+
193
+ echo $term->name;
194
+
195
+ echo ( $count > 0 || $option_is_set ) ? '</a>' : '</span>';
196
+
197
+ echo ' <small class="count">' . $count . '</small></li>';
198
+
199
+ }
200
+
201
+ echo "</ul>";
202
+
203
+ } elseif ( $display_type == 'color' ) {
204
+ // List display
205
+ echo "<ul class='yith-wcan-color yith-wcan yith-wcan-group'>";
206
+
207
+ foreach ( $terms as $term ) {
208
+
209
+ // Get count based on current view - uses transients
210
+ $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
211
+
212
+ if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
213
+
214
+ $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
215
+
216
+ set_transient( $transient_name, $_products_in_term );
217
+ }
218
+
219
+ $option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );
220
+
221
+ // If this is an AND query, only show options with count > 0
222
+ if ( $query_type == 'and' ) {
223
+
224
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
225
+
226
+ // skip the term for the current archive
227
+ if ( $current_term == $term->term_id )
228
+ continue;
229
+
230
+ if ( $count > 0 && $current_term !== $term->term_id )
231
+ $found = true;
232
+
233
+ if ( $count == 0 && ! $option_is_set )
234
+ continue;
235
+
236
+ // If this is an OR query, show all options so search can be expanded
237
+ } else {
238
+
239
+ // skip the term for the current archive
240
+ if ( $current_term == $term->term_id )
241
+ continue;
242
+
243
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
244
+
245
+ if ( $count > 0 )
246
+ $found = true;
247
+
248
+ }
249
+
250
+ $arg = 'filter_' . sanitize_title( $instance['attribute'] );
251
+
252
+ $current_filter = ( isset( $_GET[ $arg ] ) ) ? explode( ',', $_GET[ $arg ] ) : array();
253
+
254
+ if ( ! is_array( $current_filter ) )
255
+ $current_filter = array();
256
+
257
+ $current_filter = array_map( 'esc_attr', $current_filter );
258
+
259
+ if ( ! in_array( $term->term_id, $current_filter ) )
260
+ $current_filter[] = $term->term_id;
261
+
262
+ // Base Link decided by current page
263
+ if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
264
+ $link = home_url();
265
+ } elseif ( is_post_type_archive( 'product' ) || is_page( woocommerce_get_page_id('shop') ) ) {
266
+ $link = get_post_type_archive_link( 'product' );
267
+ } else {
268
+ $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
269
+ }
270
+
271
+ // All current filters
272
+ if ( $_chosen_attributes ) {
273
+ foreach ( $_chosen_attributes as $name => $data ) {
274
+ if ( $name !== $taxonomy ) {
275
+
276
+ // Exclude query arg for current term archive term
277
+ while ( in_array( $current_term, $data['terms'] ) ) {
278
+ $key = array_search( $current_term, $data );
279
+ unset( $data['terms'][$key] );
280
+ }
281
+
282
+ // Remove pa_ and sanitize
283
+ $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
284
+
285
+ if ( ! empty( $data['terms'] ) )
286
+ $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
287
+
288
+ if ( $data['query_type'] == 'or' )
289
+ $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
290
+ }
291
+ }
292
+ }
293
+
294
+ // Min/Max
295
+ if ( isset( $_GET['min_price'] ) )
296
+ $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
297
+
298
+ if ( isset( $_GET['max_price'] ) )
299
+ $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
300
+
301
+ // Current Filter = this widget
302
+ if ( isset( $_chosen_attributes[ $taxonomy ] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) {
303
+
304
+ $class = 'class="chosen"';
305
+
306
+ // Remove this term is $current_filter has more than 1 term filtered
307
+ if ( sizeof( $current_filter ) > 1 ) {
308
+ $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
309
+ $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
310
+ }
311
+
312
+ } else {
313
+
314
+ $class = '';
315
+ $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
316
+
317
+ }
318
+
319
+ // Search Arg
320
+ if ( get_search_query() )
321
+ $link = add_query_arg( 's', get_search_query(), $link );
322
+
323
+ // Post Type Arg
324
+ if ( isset( $_GET['post_type'] ) )
325
+ $link = add_query_arg( 'post_type', $_GET['post_type'], $link );
326
+
327
+ // Query type Arg
328
+ if ( $query_type == 'or' && ! ( sizeof( $current_filter ) == 1 && isset( $_chosen_attributes[ $taxonomy ]['terms'] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) )
329
+ $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
330
+
331
+ echo '<li ' . $class . '>';
332
+
333
+ echo ( $count > 0 || $option_is_set ) ? '<a style="background-color:' . $instance['colors'][$term->term_id] . ';" href="' . esc_url( apply_filters( 'woocommerce_layered_nav_link', $link ) ) . '">' : '<span style="background-color:' . $instance['colors'][$term->term_id] . ';" >';
334
+
335
+ echo $term->name;
336
+
337
+ echo ( $count > 0 || $option_is_set ) ? '</a>' : '</span>';
338
+
339
+ //echo ' <small class="count">' . $count . '</small></li>';
340
+
341
+ }
342
+
343
+ echo "</ul>";
344
+
345
+ } elseif ( $display_type == 'label' ) {
346
+ // List display
347
+ echo "<ul class='yith-wcan-label yith-wcan yith-wcan-group'>";
348
+
349
+ foreach ( $terms as $term ) {
350
+
351
+ // Get count based on current view - uses transients
352
+ $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
353
+
354
+ if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
355
+
356
+ $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
357
+
358
+ set_transient( $transient_name, $_products_in_term );
359
+ }
360
+
361
+ $option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );
362
+
363
+ // If this is an AND query, only show options with count > 0
364
+ if ( $query_type == 'and' ) {
365
+
366
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
367
+
368
+ // skip the term for the current archive
369
+ if ( $current_term == $term->term_id )
370
+ continue;
371
+
372
+ if ( $count > 0 && $current_term !== $term->term_id )
373
+ $found = true;
374
+
375
+ if ( $count == 0 && ! $option_is_set )
376
+ continue;
377
+
378
+ // If this is an OR query, show all options so search can be expanded
379
+ } else {
380
+
381
+ // skip the term for the current archive
382
+ if ( $current_term == $term->term_id )
383
+ continue;
384
+
385
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
386
+
387
+ if ( $count > 0 )
388
+ $found = true;
389
+
390
+ }
391
+
392
+ $arg = 'filter_' . sanitize_title( $instance['attribute'] );
393
+
394
+ $current_filter = ( isset( $_GET[ $arg ] ) ) ? explode( ',', $_GET[ $arg ] ) : array();
395
+
396
+ if ( ! is_array( $current_filter ) )
397
+ $current_filter = array();
398
+
399
+ $current_filter = array_map( 'esc_attr', $current_filter );
400
+
401
+ if ( ! in_array( $term->term_id, $current_filter ) )
402
+ $current_filter[] = $term->term_id;
403
+
404
+ // Base Link decided by current page
405
+ if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
406
+ $link = home_url();
407
+ } elseif ( is_post_type_archive( 'product' ) || is_page( woocommerce_get_page_id('shop') ) ) {
408
+ $link = get_post_type_archive_link( 'product' );
409
+ } else {
410
+ $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
411
+ }
412
+
413
+ // All current filters
414
+ if ( $_chosen_attributes ) {
415
+ foreach ( $_chosen_attributes as $name => $data ) {
416
+ if ( $name !== $taxonomy ) {
417
+
418
+ // Exclude query arg for current term archive term
419
+ while ( in_array( $current_term, $data['terms'] ) ) {
420
+ $key = array_search( $current_term, $data );
421
+ unset( $data['terms'][$key] );
422
+ }
423
+
424
+ // Remove pa_ and sanitize
425
+ $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
426
+
427
+ if ( ! empty( $data['terms'] ) )
428
+ $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
429
+
430
+ if ( $data['query_type'] == 'or' )
431
+ $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
432
+ }
433
+ }
434
+ }
435
+
436
+ // Min/Max
437
+ if ( isset( $_GET['min_price'] ) )
438
+ $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
439
+
440
+ if ( isset( $_GET['max_price'] ) )
441
+ $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
442
+
443
+ // Current Filter = this widget
444
+ if ( isset( $_chosen_attributes[ $taxonomy ] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) {
445
+
446
+ $class = 'class="chosen"';
447
+
448
+ // Remove this term is $current_filter has more than 1 term filtered
449
+ if ( sizeof( $current_filter ) > 1 ) {
450
+ $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
451
+ $link = add_query_arg( $arg, implode( ',', $current_fi