YITH WooCommerce Ajax Product Filter - Version 1.4.0

Version Description

  • Added: Support to WC 2.2
  • Updated: Plugin Core Framework
  • Fixed: Widget error on empty title
  • Fixed: Ajax load on widget type switching
Download this release

Release Info

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

Code changes from version 1.3.2 to 1.4.0

README.txt CHANGED
@@ -3,13 +3,13 @@
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.9.1
7
- Stable tag: 1.3.2
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
- WooCommerce Compatible up to 2.1.x
13
14
15
== Description ==
@@ -66,6 +66,13 @@ In order to display the widget you need to assign it to the sidebar in the Shop
66
67
== Changelog ==
68
69
= 1.3.2 =
70
71
* Fixed: Wrong enqueue of the main css file
@@ -92,7 +99,7 @@ In order to display the widget you need to assign it to the sidebar in the Shop
92
* Added: Dropdown style
93
* Added: Support to Wordpress 3.8
94
* Fixed: Error with non-latin languages
95
- * Fixed: Improved WPML compatibility
96
97
= 1.1.2 =
98
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: 4.0
7
+ Stable tag: 1.4.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
+ WooCommerce Compatible up to 2.2.x
13
14
15
== Description ==
66
67
== Changelog ==
68
69
+ = 1.4.0 =
70
+
71
+ * Added: Support to WC 2.2
72
+ * Updated: Plugin Core Framework
73
+ * Fixed: Widget error on empty title
74
+ * Fixed: Ajax load on widget type switching
75
+
76
= 1.3.2 =
77
78
* Fixed: Wrong enqueue of the main css file
99
* Added: Dropdown style
100
* Added: Support to Wordpress 3.8
101
* Fixed: Error with non-latin languages
102
+ * Fixed: Improved WPML compatibility
103
104
= 1.1.2 =
105
assets/css/frontend.css CHANGED
@@ -114,28 +114,31 @@
114
padding: 10px 0px;
115
margin-top: -16px;
116
}
117
.widget-area .yith-wcan-select-wrapper {
118
max-width: 260px;
119
}
120
- .yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li
121
- {
122
padding: 5px 8px;
123
border-bottom: 1px solid transparent;
124
border-top: 1px solid transparent;
125
}
126
.yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li:hover,
127
- .woocommerce-page .widget_layered_nav .yith-wcan-select-wrapper ul li.chosen{
128
-webkit-box-shadow: 0px 3px 0px #F2F2F2 inset, 0px -3px 0px #F2F2F2 inset;
129
-moz-box-shadow: 0px 3px 0px #f2f2f2 inset, 0px -3px 0px #f2f2f2 inset;
130
box-shadow: 0px 3px 0px #F2F2F2 inset, 0px -3px 0px #F2F2F2 inset;
131
border-bottom: 1px solid #cecece;
132
border-top: 1px solid #cecece;
133
}
134
.yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li a, .widget .yit-wcan-select-open {
135
width: 100%;
136
color: #838383;
137
box-sizing: border-box;
138
- -moz-box-sizing:border-box; /* Firefox */
139
}
140
141
.yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li a, .widget .yit-wcan-select-open {
@@ -147,7 +150,7 @@
147
color: #838383;
148
}
149
150
- .woocommerce-page .widget_layered_nav .yith-wcan-select-wrapper ul li.chosen a, .woocommerce-page .widget_layered_nav .yith-wcan-select-wrapper ul li.chosen a{
151
background: transparent url(../images/cross.png) bottom 6px left no-repeat;
152
border: none;
153
}
114
padding: 10px 0px;
115
margin-top: -16px;
116
}
117
+
118
.widget-area .yith-wcan-select-wrapper {
119
max-width: 260px;
120
}
121
+
122
+ .yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li {
123
padding: 5px 8px;
124
border-bottom: 1px solid transparent;
125
border-top: 1px solid transparent;
126
}
127
+
128
.yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li:hover,
129
+ .woocommerce-page .widget_layered_nav .yith-wcan-select-wrapper ul li.chosen {
130
-webkit-box-shadow: 0px 3px 0px #F2F2F2 inset, 0px -3px 0px #F2F2F2 inset;
131
-moz-box-shadow: 0px 3px 0px #f2f2f2 inset, 0px -3px 0px #f2f2f2 inset;
132
box-shadow: 0px 3px 0px #F2F2F2 inset, 0px -3px 0px #F2F2F2 inset;
133
border-bottom: 1px solid #cecece;
134
border-top: 1px solid #cecece;
135
}
136
+
137
.yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li a, .widget .yit-wcan-select-open {
138
width: 100%;
139
color: #838383;
140
box-sizing: border-box;
141
+ -moz-box-sizing: border-box; /* Firefox */
142
}
143
144
.yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li a, .widget .yit-wcan-select-open {
150
color: #838383;
151
}
152
153
+ .woocommerce-page .widget_layered_nav .yith-wcan-select-wrapper ul li.chosen a, .woocommerce-page .widget_layered_nav .yith-wcan-select-wrapper ul li.chosen a {
154
background: transparent url(../images/cross.png) bottom 6px left no-repeat;
155
border: none;
156
}
assets/js/yith-wcan-admin.js CHANGED
@@ -5,42 +5,41 @@
5
* @package YITH WooCommerce Ajax Navigation
6
* @version 1.3.2
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
16
-
17
var display = $(this).parents('.widget-content').find('#yit-wcan-display');
18
19
var data = {
20
- action: 'yith_wcan_select_type',
21
- id: $('input[name=widget_id]', $(t).parents('.widget-content')).val(),
22
- name: $('input[name=widget_name]', $(t).parents('.widget-content')).val(),
23
attribute: $('.yith_wcan_attributes', $(t).parents('.widget-content')).val(),
24
- value: $('.yith_wcan_type', $(t).parents('.widget-content')).val(),
25
};
26
27
/* Hierarchical hide/show */
28
- if( data.value == 'list' || data.value == 'select' ) {
29
display.show();
30
- }else if( data.value == 'label' || data.value == 'color' ){ console.log(data.value);
31
display.hide();
32
}
33
34
- $.post(ajaxurl, data, function(response) {
35
spinner.hide();
36
- container.html( response.content );
37
$(document).trigger('yith_colorpicker');
38
}, 'json');
39
});
40
41
//color-picker
42
- $(document).on('yith_colorpicker', function(){
43
- $('.yith-colorpicker').each(function(){
44
$(this).wpColorPicker();
45
});
46
}).trigger('yith_colorpicker');
5
* @package YITH WooCommerce Ajax Navigation
6
* @version 1.3.2
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
16
var display = $(this).parents('.widget-content').find('#yit-wcan-display');
17
18
var data = {
19
+ action : 'yith_wcan_select_type',
20
+ id : $('input[name=widget_id]', $(t).parents('.widget-content')).val(),
21
+ name : $('input[name=widget_name]', $(t).parents('.widget-content')).val(),
22
attribute: $('.yith_wcan_attributes', $(t).parents('.widget-content')).val(),
23
+ value : $('.yith_wcan_type', $(t).parents('.widget-content')).val(),
24
};
25
26
/* Hierarchical hide/show */
27
+ if (data.value == 'list' || data.value == 'select') {
28
display.show();
29
+ } else if (data.value == 'label' || data.value == 'color') {
30
display.hide();
31
}
32
33
+ $.post(ajaxurl, data, function (response) {
34
spinner.hide();
35
+ container.html(response.content);
36
$(document).trigger('yith_colorpicker');
37
}, 'json');
38
});
39
40
//color-picker
41
+ $(document).on('yith_colorpicker',function () {
42
+ $('.yith-colorpicker').each(function () {
43
$(this).wpColorPicker();
44
});
45
}).trigger('yith_colorpicker');
class.yith-wcan-admin.php CHANGED
@@ -93,7 +93,7 @@ if( !class_exists( 'YITH_WCAN_Admin' ) ) {
93
$attribute,
94
$_POST['id'],
95
$_POST['name'],
96
- json_decode($_POST['type']),
97
false
98
);
99
93
$attribute,
94
$_POST['id'],
95
$_POST['name'],
96
+ json_decode($_POST['value']),
97
false
98
);
99
class.yith-wcan-frontend.php CHANGED
@@ -2,17 +2,19 @@
2
/**
3
* Frontend class
4
*
5
- * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
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
*/
@@ -24,71 +26,71 @@ if( !class_exists( 'YITH_WCAN_Frontend' ) ) {
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_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
-
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
@@ -97,9 +99,10 @@ if( !class_exists( 'YITH_WCAN_Frontend' ) ) {
97
$_chosen_attributes = $_attributes_array = array();
98
99
/* FIX TO WOOCOMMERCE 2.1 */
100
- if( function_exists( 'wc_get_attribute_taxonomies' ) ){
101
$attribute_taxonomies = wc_get_attribute_taxonomies();
102
- } else {
103
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
104
}
105
@@ -111,8 +114,9 @@ if( !class_exists( 'YITH_WCAN_Frontend' ) ) {
111
112
/* FIX TO WOOCOMMERCE 2.1 */
113
if ( function_exists( 'wc_attribute_taxonomy_name' ) ) {
114
- $taxonomy = wc_attribute_taxonomy_name($attribute);
115
- } else {
116
$taxonomy = $woocommerce->attribute_taxonomy_name( $attribute );
117
}
118
@@ -120,26 +124,29 @@ if( !class_exists( 'YITH_WCAN_Frontend' ) ) {
120
// create an array of product attribute taxonomies
121
$_attributes_array[] = $taxonomy;
122
123
- $name = 'filter_' . $attribute;
124
$query_type_name = 'query_type_' . $attribute;
125
126
- if ( ! empty( $_GET[ $name ] ) && taxonomy_exists( $taxonomy ) ) {
127
128
- $_chosen_attributes[ $taxonomy ]['terms'] = explode( ',', $_GET[ $name ] );
129
130
- if ( empty( $_GET[ $query_type_name ] ) || ! in_array( strtolower( $_GET[ $query_type_name ] ), array( 'and', 'or' ) ) )
131
- $_chosen_attributes[ $taxonomy ]['query_type'] = apply_filters( 'woocommerce_layered_nav_default_query_type', 'and' );
132
- else
133
- $_chosen_attributes[ $taxonomy ]['query_type'] = strtolower( $_GET[ $query_type_name ] );
134
135
}
136
}
137
}
138
139
- if( version_compare( preg_replace( '/-beta-([0-9]+)/', '', $woocommerce->version ), '2.1', '<' ) ) {
140
- add_filter('loop_shop_post_in', 'woocommerce_layered_nav_query' );
141
- } else {
142
- add_filter('loop_shop_post_in', array( WC()->query, 'layered_nav_query' ));
143
}
144
145
@@ -147,6 +154,5 @@ if( !class_exists( 'YITH_WCAN_Frontend' ) ) {
147
}
148
149
150
-
151
}
152
}
2
/**
3
* Frontend class
4
*
5
+ * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
8
*/
9
10
+ if ( ! defined( 'YITH_WCAN' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
14
+ if ( ! class_exists( 'YITH_WCAN_Frontend' ) ) {
15
/**
16
* Frontend class.
17
+ * The class manage all the frontend behaviors.
18
*
19
* @since 1.0.0
20
*/
26
* @since 1.0.0
27
*/
28
public $version;
29
+
30
+ /**
31
+ * Constructor
32
+ *
33
+ * @access public
34
+ * @since 1.0.0
35
+ */
36
+ public function __construct( $version ) {
37
$this->version = $version;
38
39
+ //Actions
40
+ add_action( 'init', array( $this, 'init' ) );
41
add_action( 'init', array( $this, 'woocommerce_layered_nav_init' ), 99 );
42
43
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles_scripts' ) );
44
45
// YITH WCAN Loaded
46
do_action( 'yith_wcan_loaded' );
47
+ }
48
+
49
+
50
+ /**
51
+ * Init method:
52
+ * - default options
53
+ *
54
+ * @access public
55
+ * @since 1.0.0
56
+ */
57
+ public function init() {
58
59
}
60
+
61
+
62
+ /**
63
+ * Enqueue frontend styles and scripts
64
+ *
65
+ * @access public
66
+ * @return void
67
+ * @since 1.0.0
68
+ */
69
+ public function enqueue_styles_scripts() {
70
+ if ( yith_wcan_can_be_displayed() ) {
71
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
72
73
wp_enqueue_style( 'yith_wcan_admin', YITH_WCAN_URL . 'assets/css/frontend.css', false, $this->version );
74
+ wp_enqueue_script( 'yith_wcan_frontend', YITH_WCAN_URL . 'assets/js/yith-wcan-frontend' . $suffix . '.js', array( 'jquery' ), $this->version, true );
75
76
$args = array(
77
+ 'container' => '.products',
78
+ 'pagination' => 'nav.woocommerce-pagination',
79
'result_count' => '.woocommerce-result-count'
80
);
81
wp_localize_script( 'yith_wcan_frontend', 'yith_wcan', apply_filters( 'yith-wcan-frontend-args', $args ) );
82
}
83
+ }
84
85
86
/**
87
* Layered Nav Init
88
*
89
+ * @package WooCommerce/Widgets
90
+ * @access public
91
* @return void
92
*/
93
+ public function woocommerce_layered_nav_init() {
94
95
if ( is_active_widget( false, false, 'yith-woo-ajax-navigation', true ) && ! is_admin() ) {
96
99
$_chosen_attributes = $_attributes_array = array();
100
101
/* FIX TO WOOCOMMERCE 2.1 */
102
+ if ( function_exists( 'wc_get_attribute_taxonomies' ) ) {
103
$attribute_taxonomies = wc_get_attribute_taxonomies();
104
+ }
105
+ else {
106
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
107
}
108
114
115
/* FIX TO WOOCOMMERCE 2.1 */
116
if ( function_exists( 'wc_attribute_taxonomy_name' ) ) {
117
+ $taxonomy = wc_attribute_taxonomy_name( $attribute );
118
+ }
119
+ else {
120
$taxonomy = $woocommerce->attribute_taxonomy_name( $attribute );
121
}
122
124
// create an array of product attribute taxonomies
125
$_attributes_array[] = $taxonomy;
126
127
+ $name = 'filter_' . $attribute;
128
$query_type_name = 'query_type_' . $attribute;
129
130
+ if ( ! empty( $_GET[$name] ) && taxonomy_exists( $taxonomy ) ) {
131
132
+ $_chosen_attributes[$taxonomy]['terms'] = explode( ',', $_GET[$name] );
133
134
+ if ( empty( $_GET[$query_type_name] ) || ! in_array( strtolower( $_GET[$query_type_name] ), array( 'and', 'or' ) ) ) {
135
+ $_chosen_attributes[$taxonomy]['query_type'] = apply_filters( 'woocommerce_layered_nav_default_query_type', 'and' );
136
+ }
137
+ else {
138
+ $_chosen_attributes[$taxonomy]['query_type'] = strtolower( $_GET[$query_type_name] );
139
+ }
140
141
}
142
}
143
}
144
145
+ if ( version_compare( preg_replace( '/-beta-([0-9]+)/', '', $woocommerce->version ), '2.1', '<' ) ) {
146
+ add_filter( 'loop_shop_post_in', 'woocommerce_layered_nav_query' );
147
+ }
148
+ else {
149
+ add_filter( 'loop_shop_post_in', array( WC()->query, 'layered_nav_query' ) );
150
}
151
152
154
}
155
156
157
}
158
}
class.yith-wcan-helper.php CHANGED
@@ -2,14 +2,16 @@
2
/**
3
* Main class
4
*
5
- * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
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
*
@@ -26,22 +28,28 @@ if( !class_exists( 'YITH_WCAN_Helper' ) ) {
26
public static function attribute_taxonomies() {
27
global $woocommerce;
28
29
- if ( ! isset( $woocommerce ) ) return array();
30
31
$attributes = array();
32
if ( function_exists( 'wc_get_attribute_taxonomies' ) ) {
33
$attribute_taxonomies = wc_get_attribute_taxonomies();
34
- } else {
35
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
36
}
37
38
- if( empty( $attribute_taxonomies ) ) return array();
39
- foreach( $attribute_taxonomies as $attribute ) {
40
41
/* FIX TO WOOCOMMERCE 2.1 */
42
if ( function_exists( 'wc_attribute_taxonomy_name' ) ) {
43
- $taxonomy = wc_attribute_taxonomy_name($attribute->attribute_name);
44
- } else {
45
$taxonomy = $woocommerce->attribute_taxonomy_name( $attribute->attribute_name );
46
}
47
2
/**
3
* Main class
4
*
5
+ * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
8
*/
9
10
+ if ( ! defined( 'YITH_WCAN' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
14
+ if ( ! class_exists( 'YITH_WCAN_Helper' ) ) {
15
/**
16
* YITH WooCommerce Ajax Navigation Helper
17
*
28
public static function attribute_taxonomies() {
29
global $woocommerce;
30
31
+ if ( ! isset( $woocommerce ) ) {
32
+ return array();
33
+ }
34
35
$attributes = array();
36
if ( function_exists( 'wc_get_attribute_taxonomies' ) ) {
37
$attribute_taxonomies = wc_get_attribute_taxonomies();
38
+ }
39
+ else {
40
$attribute_taxonomies = $woocommerce->get_attribute_taxonomies();
41
}
42
43
+ if ( empty( $attribute_taxonomies ) ) {
44
+ return array();
45
+ }
46
+ foreach ( $attribute_taxonomies as $attribute ) {
47
48
/* FIX TO WOOCOMMERCE 2.1 */
49
if ( function_exists( 'wc_attribute_taxonomy_name' ) ) {
50
+ $taxonomy = wc_attribute_taxonomy_name( $attribute->attribute_name );
51
+ }
52
+ else {
53
$taxonomy = $woocommerce->attribute_taxonomy_name( $attribute->attribute_name );
54
}
55
class.yith-wcan.php CHANGED
@@ -2,14 +2,16 @@
2
/**
3
* Main class
4
*
5
- * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
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
*
@@ -22,7 +24,7 @@ if( !class_exists( 'YITH_WCAN' ) ) {
22
* @var string
23
* @since 1.0.0
24
*/
25
- public $version = '1.3.2';
26
27
/**
28
* Plugin object
@@ -45,9 +47,10 @@ if( !class_exists( 'YITH_WCAN' ) ) {
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
@@ -59,16 +62,17 @@ if( !class_exists( 'YITH_WCAN' ) ) {
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' );
2
/**
3
* Main class
4
*
5
+ * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
8
*/
9
10
+ if ( ! defined( 'YITH_WCAN' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
14
+ if ( ! class_exists( 'YITH_WCAN' ) ) {
15
/**
16
* YITH WooCommerce Ajax Navigation
17
*
24
* @var string
25
* @since 1.0.0
26
*/
27
+ public $version = '1.4.0';
28
29
/**
30
* Plugin object
47
add_action( 'widgets_init', array( $this, 'registerWidgets' ) );
48
49
50
+ if ( is_admin() ) {
51
$this->obj = new YITH_WCAN_Admin( $this->version );
52
+ }
53
+ else {
54
$this->obj = new YITH_WCAN_Frontend( $this->version );
55
}
56
62
* Init method
63
*
64
* @access public
65
+ * @since 1.0.0
66
*/
67
+ public function init() {
68
+ }
69
70
71
/**
72
* Load and register widgets
73
*
74
* @access public
75
+ * @since 1.0.0
76
*/
77
public function registerWidgets() {
78
register_widget( 'YITH_WCAN_Navigation_Widget' );
functions.yith-wcan.php CHANGED
@@ -2,12 +2,14 @@
2
/**
3
* Functions
4
*
5
- * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
8
*/
9
10
- if ( !defined( 'YITH_WCAN' ) ) { exit; } // Exit if accessed directly
11
12
13
/**
@@ -15,15 +17,16 @@ if ( !defined( 'YITH_WCAN' ) ) { exit; } // Exit if accessed directly
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
}
@@ -32,48 +35,50 @@ function yith_wcan_dropdown_attributes( $selected, $echo = true ) {
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' /></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
@@ -90,18 +95,19 @@ 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
}
102
103
104
- if( !function_exists('yit_curPageURL') ) {
105
/**
106
* Retrieve the current complete url
107
*
@@ -109,81 +115,88 @@ if( !function_exists('yit_curPageURL') ) {
109
*/
110
function yit_curPageURL() {
111
$pageURL = 'http';
112
- if ( isset( $_SERVER["HTTPS"] ) AND $_SERVER["HTTPS"] == "on" )
113
$pageURL .= "s";
114
115
$pageURL .= "://";
116
117
- if ( isset( $_SERVER["SERVER_PORT"] ) AND $_SERVER["SERVER_PORT"] != "80" )
118
- $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
119
- else
120
- $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
121
122
return $pageURL;
123
}
124
}
125
126
- if( !function_exists('yit_reorder_terms_by_parent') ) {
127
/**
128
* Sort the array of terms associating the child to the parent terms
129
*
130
* @param $terms mixed|array
131
* @return mixed!array
132
* @since 1.3.1
133
*/
134
function yit_reorder_terms_by_parent( $terms ) {
135
136
- /* Extract Child Terms */
137
$child_terms = array();
138
$terms_count = 0;
139
140
- foreach( $terms as $array_key => $term ) {
141
142
- if( $term->parent != 0 ) {
143
144
- if( isset( $child_terms[ $term->parent ] ) && $child_terms[ $term->parent ] != null ) {
145
- $child_terms[ $term->parent ] = array_merge( $child_terms[ $term->parent ], array( $term ) );
146
- }else {
147
- $child_terms[ $term->parent ] = array( $term );
148
}
149
150
- } else {
151
- $parent_terms[ $terms_count ] = $term;
152
}
153
- $terms_count++;
154
}
155
156
/* Reorder Therms */
157
$terms_count = 0;
158
- $terms = array();
159
160
- foreach( $parent_terms as $term ) {
161
162
- $terms[ $terms_count ] = $term;
163
164
/* The term as child */
165
- if( array_key_exists( $term->term_id, $child_terms ) ){
166
167
- foreach ( $child_terms[ $term->term_id ] as $child_term ) {
168
- $terms_count++;
169
- $terms[ $terms_count ] = $child_term;
170
}
171
}
172
- $terms_count++;
173
}
174
175
return $terms;
176
}
177
}
178
179
- if( !function_exists('yit_get_terms') ) {
180
/**
181
* Get the array of objects terms
182
*
183
* @param $type A type of term to display
184
* @return $terms mixed|array
185
*
186
- * @since 1.3.1
187
*/
188
function yit_get_terms( $case, $taxonomy ) {
189
@@ -191,32 +204,33 @@ if( !function_exists('yit_get_terms') ) {
191
192
switch ( $case ) {
193
194
- case 'all':
195
- $terms = get_terms( $taxonomy, array( 'hide_empty' => true, 'exclude' => $exclude ) );
196
- break;
197
198
- case 'hierarchical':
199
- $terms = yit_reorder_terms_by_parent( get_terms( $taxonomy, array( 'hide_empty' => true, 'exclude' => $exclude ) ) );
200
- break;
201
202
- case 'parent' :
203
- $terms = get_terms( $taxonomy, array( 'hide_empty' => true, 'parent' => false, 'exclude' => $exclude ) );
204
- break;
205
206
- default:
207
- $terms = get_terms( $taxonomy, array( 'hide_empty' => true, 'exclude' => $exclude ) );
208
- break;
209
- }
210
211
return $terms;
212
}
213
}
214
215
- if( !function_exists('yit_term_is_child') ) {
216
/**
217
* Return true if the term is a child, false otherwise
218
*
219
* @param $term The term object
220
* @return bool
221
*
222
* @since 1.3.1
@@ -227,11 +241,12 @@ if( !function_exists('yit_term_is_child') ) {
227
}
228
}
229
230
- if( !function_exists('yit_term_is_parent') ) {
231
/**
232
* Return true if the term is a parent, false otherwise
233
*
234
* @param $term The term object
235
* @return bool
236
*
237
* @since 1.3.1
@@ -242,12 +257,13 @@ if( !function_exists('yit_term_is_parent') ) {
242
}
243
}
244
245
- if( !function_exists('yit_term_has_child') ) {
246
/**
247
* Return true if the term has a child, false otherwise
248
*
249
- * @param $term The term object
250
* @param $taxonomy the taxonomy to search
251
* @return bool
252
*
253
* @since 1.3.1
@@ -255,7 +271,7 @@ if( !function_exists('yit_term_has_child') ) {
255
function yit_term_has_child( $term, $taxonomy ) {
256
global $woocommerce;
257
258
- $count = 0;
259
$child_terms = get_terms( $taxonomy, array( 'child_of' => $term->term_id ) );
260
foreach ( $child_terms as $term ) {
261
$_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
2
/**
3
* Functions
4
*
5
+ * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
8
*/
9
10
+ if ( ! defined( 'YITH_WCAN' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
14
15
/**
17
*/
18
function yith_wcan_dropdown_attributes( $selected, $echo = true ) {
19
$attributes = YITH_WCAN_Helper::attribute_taxonomies();
20
+ $options = "";
21
22
+ foreach ( $attributes as $attribute ) {
23
+ $options .= "<option name='{$attribute}'" . selected( $attribute, $selected, false ) . ">{$attribute}</option>";
24
}
25
26
+ if ( $echo ) {
27
echo $options;
28
+ }
29
+ else {
30
return $options;
31
}
32
}
35
/**
36
* Print the widgets options already filled
37
*
38
+ * @param $type string list|colors|label
39
* @param $attribute woocommerce taxonomy
40
+ * @param $id id used in the <input />
41
+ * @param $name base name used in the <input />
42
+ * @param $values array of values (could be empty if this is an ajax call)
43
+ *
44
* @return string
45
*/
46
function yith_wcan_attributes_table( $type, $attribute, $id, $name, $values = array(), $echo = true ) {
47
$return = '';
48
49
+ $terms = get_terms( 'pa_' . $attribute, array( 'hide_empty' => '0' ) );
50
51
+ if ( 'list' == $type ) {
52
+ $return = '<input type="hidden" name="' . $name . '[colors]" value="" /><input type="hidden" name="' . $name . '[labels]" value="" />';
53
+ }
54
+ elseif ( 'color' == $type ) {
55
+ if ( ! empty( $terms ) ) {
56
+ $return = sprintf( '<table><tr><th>%s</th><th>%s</th></tr>', __( 'Term', 'yit' ), __( 'Color', 'yit' ) );
57
58
+ foreach ( $terms as $term ) {
59
+ $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>";
60
}
61
62
$return .= '</table>';
63
}
64
65
+ $return .= '<input type="hidden" name="' . $name . '[labels]" value="" />';
66
+ }
67
+ elseif ( 'label' == $type ) {
68
+ if ( ! empty( $terms ) ) {
69
+ $return = sprintf( '<table><tr><th>%s</th><th>%s</th></tr>', __( 'Term', 'yit' ), __( 'Labels', 'yit' ) );
70
71
+ foreach ( $terms as $term ) {
72
+ $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' /></td></tr>";
73
}
74
75
$return .= '</table>';
76
}
77
78
+ $return .= '<input type="hidden" name="' . $name . '[colors]" value="" />';
79
}
80
81
+ if ( $echo ) {
82
echo $return;
83
}
84
95
global $woocommerce, $_attributes_array;
96
97
98
+ /* if ( ! is_post_type_archive( 'product' ) && ! is_tax( array_merge( $_attributes_array, array( 'product_cat', 'product_tag' ) ) ) )
99
+ return false;*/
100
101
if ( is_active_widget( false, false, 'yith-woo-ajax-navigation', true ) ) {
102
return true;
103
+ }
104
+ else {
105
return false;
106
}
107
}
108
109
110
+ if ( ! function_exists( 'yit_curPageURL' ) ) {
111
/**
112
* Retrieve the current complete url
113
*
115
*/
116
function yit_curPageURL() {
117
$pageURL = 'http';
118
+ if ( isset( $_SERVER["HTTPS"] ) AND $_SERVER["HTTPS"] == "on" ) {
119
$pageURL .= "s";
120
+ }
121
122
$pageURL .= "://";
123
124
+ if ( isset( $_SERVER["SERVER_PORT"] ) AND $_SERVER["SERVER_PORT"] != "80" ) {
125
+ $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
126
+ }
127
+ else {
128
+ $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
129
+ }
130
131
return $pageURL;
132
}
133
}
134
135
+ if ( ! function_exists( 'yit_reorder_terms_by_parent' ) ) {
136
/**
137
* Sort the array of terms associating the child to the parent terms
138
*
139
* @param $terms mixed|array
140
+ *
141
* @return mixed!array
142
* @since 1.3.1
143
*/
144
function yit_reorder_terms_by_parent( $terms ) {
145
146
+ /* Extract Child Terms */
147
$child_terms = array();
148
$terms_count = 0;
149
150
+ foreach ( $terms as $array_key => $term ) {
151
152
+ if ( $term->parent != 0 ) {
153
154
+ if ( isset( $child_terms[$term->parent] ) && $child_terms[$term->parent] != null ) {
155
+ $child_terms[$term->parent] = array_merge( $child_terms[$term->parent], array( $term ) );
156
+ }
157
+ else {
158
+ $child_terms[$term->parent] = array( $term );
159
}
160
161
}
162
+ else {
163
+ $parent_terms[$terms_count] = $term;
164
+ }
165
+ $terms_count ++;
166
}
167
168
/* Reorder Therms */
169
$terms_count = 0;
170
+ $terms = array();
171
172
+ foreach ( $parent_terms as $term ) {
173
174
+ $terms[$terms_count] = $term;
175
176
/* The term as child */
177
+ if ( array_key_exists( $term->term_id, $child_terms ) ) {
178
179
+ foreach ( $child_terms[$term->term_id] as $child_term ) {
180
+ $terms_count ++;
181
+ $terms[$terms_count] = $child_term;
182
}
183
}
184
+ $terms_count ++;
185
}
186
187
return $terms;
188
}
189
}
190
191
+ if ( ! function_exists( 'yit_get_terms' ) ) {
192
/**
193
* Get the array of objects terms
194
*
195
* @param $type A type of term to display
196
+ *
197
* @return $terms mixed|array
198
*
199
+ * @since 1.3.1
200
*/
201
function yit_get_terms( $case, $taxonomy ) {
202
204
205
switch ( $case ) {
206
207
+ case 'all':
208
+ $terms = get_terms( $taxonomy, array( 'hide_empty' => true, 'exclude' => $exclude ) );
209
+ break;
210
211
+ case 'hierarchical':
212
+ $terms = yit_reorder_terms_by_parent( get_terms( $taxonomy, array( 'hide_empty' => true, 'exclude' => $exclude ) ) );
213
+ break;
214
215
+ case 'parent' :
216
+ $terms = get_terms( $taxonomy, array( 'hide_empty' => true, 'parent' => false, 'exclude' => $exclude ) );
217
+ break;
218
219
+ default:
220
+ $terms = get_terms( $taxonomy, array( 'hide_empty' => true, 'exclude' => $exclude ) );
221
+ break;
222
+ }
223
224
return $terms;
225
}
226
}
227
228
+ if ( ! function_exists( 'yit_term_is_child' ) ) {
229
/**
230
* Return true if the term is a child, false otherwise
231
*
232
* @param $term The term object
233
+ *
234
* @return bool
235
*
236
* @since 1.3.1
241
}
242
}
243
244
+ if ( ! function_exists( 'yit_term_is_parent' ) ) {
245
/**
246
* Return true if the term is a parent, false otherwise
247
*
248
* @param $term The term object
249
+ *
250
* @return bool
251
*
252
* @since 1.3.1
257
}
258
}
259
260
+ if ( ! function_exists( 'yit_term_has_child' ) ) {
261
/**
262
* Return true if the term has a child, false otherwise
263
*
264
+ * @param $term The term object
265
* @param $taxonomy the taxonomy to search
266
+ *
267
* @return bool
268
*
269
* @since 1.3.1
271
function yit_term_has_child( $term, $taxonomy ) {
272
global $woocommerce;
273
274
+ $count = 0;
275
$child_terms = get_terms( $taxonomy, array( 'child_of' => $term->term_id ) );
276
foreach ( $child_terms as $term ) {
277
$_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
init.php CHANGED
@@ -3,13 +3,13 @@
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.3.2
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.3.2
15
*/
@@ -28,20 +28,24 @@
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
40
function yith_wcan_constructor() {
41
global $woocommerce;
42
- if ( ! isset( $woocommerce ) ) return;
43
44
- load_plugin_textdomain( 'yit', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
45
46
define( 'YITH_WCAN', true );
47
define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
@@ -49,16 +53,17 @@ function yith_wcan_constructor() {
49
define( 'YITH_WCAN_VERSION', '1.3.2' );
50
51
// Load required classes and functions
52
- require_once('functions.yith-wcan.php');
53
- require_once('class.yith-wcan-admin.php');
54
- require_once('class.yith-wcan-frontend.php');
55
- require_once('class.yith-wcan-helper.php');
56
- require_once('widgets/class.yith-wcan-navigation-widget.php');
57
- require_once('widgets/class.yith-wcan-reset-navigation-widget.php');
58
- require_once('class.yith-wcan.php');
59
60
// Let's start the game!
61
global $yith_wcan;
62
$yith_wcan = new YITH_WCAN();
63
}
64
add_action( 'plugins_loaded', 'yith_wcan_constructor' );
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.4.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.3.2
15
*/
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' ) ) {
32
+ exit;
33
+ } // Exit if accessed directly
34
35
/**
36
* Required functions
37
*/
38
+ if ( ! defined( 'YITH_FUNCTIONS' ) ) {
39
require_once( 'yit-common/yit-functions.php' );
40
}
41
42
function yith_wcan_constructor() {
43
global $woocommerce;
44
+ if ( ! isset( $woocommerce ) ) {
45
+ return;
46
+ }
47
48
+ load_plugin_textdomain( 'yit', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
49
50
define( 'YITH_WCAN', true );
51
define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
53
define( 'YITH_WCAN_VERSION', '1.3.2' );
54
55
// Load required classes and functions
56
+ require_once( 'functions.yith-wcan.php' );
57
+ require_once( 'class.yith-wcan-admin.php' );
58
+ require_once( 'class.yith-wcan-frontend.php' );
59
+ require_once( 'class.yith-wcan-helper.php' );
60
+ require_once( 'widgets/class.yith-wcan-navigation-widget.php' );
61
+ require_once( 'widgets/class.yith-wcan-reset-navigation-widget.php' );
62
+ require_once( 'class.yith-wcan.php' );
63
64
// Let's start the game!
65
global $yith_wcan;
66
$yith_wcan = new YITH_WCAN();
67
}
68
+
69
add_action( 'plugins_loaded', 'yith_wcan_constructor' );
languages/yit-tr_TR.mo ADDED
Binary file
languages/yit-tr_TR.po ADDED
@@ -0,0 +1,205 @@
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: YITH WooCommerce Ajax Navigation v1.3.1\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2014-03-03 12:55+0100\n"
6
+ "PO-Revision-Date: 2014-07-21 23:43+0200\n"
7
+ "Last-Translator: Caner Öncel <caneroncel@gmail.com>\n"
8
+ "Language-Team: Caner Öncel <caneroncel@gmail.com>\n"
9
+ "Language: tr\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "Plural-Forms: nplurals=2; plural=n != 1;\n"
14
+ "X-Generator: Poedit 1.6.6\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;"
17
+ "_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-Textdomain-Support: yes\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 "Terim"
26
+
27
+ # @ yit
28
+ #: functions.yith-wcan.php:52
29
+ #: widgets/class.yith-wcan-navigation-widget.php:702
30
+ msgid "Color"
31
+ msgstr "Renk"
32
+
33
+ # @ yit
34
+ #: functions.yith-wcan.php:64
35
+ msgid "Labels"
36
+ msgstr "Etiketler"
37
+
38
+ # @ yit
39
+ #: widgets/class.yith-wcan-navigation-widget.php:21
40
+ msgid "Narrow down the products list without reloading the page"
41
+ msgstr "Sayfayı yenilemeden ürün listesini daralt"
42
+
43
+ # @ yit
44
+ #: widgets/class.yith-wcan-navigation-widget.php:23
45
+ msgid "YITH WooCommerce Ajax Navigation"
46
+ msgstr "YITH WooCommerce Ajax Navigation"
47
+
48
+ #: widgets/class.yith-wcan-navigation-widget.php:220
49
+ msgid "Filters List:"
50
+ msgstr "Filtre Listesi:"
51
+
52
+ # @ yit
53
+ #: widgets/class.yith-wcan-navigation-widget.php:683
54
+ #: widgets/class.yith-wcan-reset-navigation-widget.php:85
55
+ msgid "Title"
56
+ msgstr "Başlık"
57
+
58
+ # @ yit
59
+ #: widgets/class.yith-wcan-navigation-widget.php:688
60
+ msgid "Attribute:"
61
+ msgstr "Özellikler:"
62
+
63
+ # @ yit
64
+ #: widgets/class.yith-wcan-navigation-widget.php:693
65
+ msgid "Query Type:"
66
+ msgstr "Sorgu Tipi:"
67
+
68
+ # @ yit
69
+ #: widgets/class.yith-wcan-navigation-widget.php:695
70
+ msgid "AND"
71
+ msgstr "VE"
72
+
73
+ # @ yit
74
+ #: widgets/class.yith-wcan-navigation-widget.php:696
75
+ msgid "OR"
76
+ msgstr "VEYA"
77
+
78
+ # @ yit
79
+ #: widgets/class.yith-wcan-navigation-widget.php:699
80
+ msgid "Type:"
81
+ msgstr "Tür:"
82
+
83
+ # @ yit
84
+ #: widgets/class.yith-wcan-navigation-widget.php:701
85
+ msgid "List"
86
+ msgstr "Liste"
87
+
88
+ # @ yit
89
+ #: widgets/class.yith-wcan-navigation-widget.php:703
90
+ msgid "Label"
91
+ msgstr "Etiket"
92
+
93
+ #: widgets/class.yith-wcan-navigation-widget.php:704
94
+ msgid "Dropdown"
95
+ msgstr "Açılır Menü"
96
+
97
+ #: widgets/class.yith-wcan-navigation-widget.php:709
98
+ msgid "Display (default All):"
99
+ msgstr "Görüntüleme (Varsayılan tümü):"
100
+
101
+ #: widgets/class.yith-wcan-navigation-widget.php:711
102
+ msgid "All (no hierarchical)"
103
+ msgstr "Tümü"
104
+
105
+ #: widgets/class.yith-wcan-navigation-widget.php:712
106
+ msgid "All Hierarchical"
107
+ msgstr "Tüm Hiyerarşik"
108
+
109
+ #: widgets/class.yith-wcan-navigation-widget.php:713
110
+ msgid "Only Parent"
111
+ msgstr "Sadece Ebeveyn"
112
+
113
+ # @ yit
114
+ #: widgets/class.yith-wcan-reset-navigation-widget.php:21
115
+ msgid "Reset all filters setted by YITH WooCommerce Ajax Navigation"
116
+ msgstr ""
117
+ "YITH WooCommerce Ajax Navigation için ayarlanmış tüm filtreleri sıfırlayın"
118
+
119
+ # @ yit
120
+ #: widgets/class.yith-wcan-reset-navigation-widget.php:23
121
+ msgid "YITH WooCommerce Ajax Reset Navigation"
122
+ msgstr "YITH WooCommerce Ajax Reset Navigation"
123
+
124
+ #: widgets/class.yith-wcan-reset-navigation-widget.php:78
125
+ msgid "Reset All Filters"
126
+ msgstr "Tüm Filtreleri Sıfırla"
127
+
128
+ #: widgets/class.yith-wcan-reset-navigation-widget.php:91
129
+ msgid "Button Label"
130
+ msgstr "Buton Metni"
131
+
132
+ # @ yit
133
+ #: yit-common/yith-panel.php:406
134
+ msgid "Select a date"
135
+ msgstr "Bir tarih seçin"
136
+
137
+ # @ yit
138
+ #: yit-common/yith-panel.php:407
139
+ msgid "Hours"
140
+ msgstr "Saat"
141
+
142
+ # @ yit
143
+ #: yit-common/yith-panel.php:408 yit-common/yith-panel.php:409
144
+ msgid "Minutes"
145
+ msgstr "Dakika"
146
+
147
+ # @ yit
148
+ #: yit-common/yith-panel.php:417
149
+ msgid "Upload"
150
+ msgstr "Yükle"
151
+
152
+ # @ yit
153
+ #: yit-common/yith-panel.php:444
154
+ msgid "px"
155
+ msgstr "px"
156
+
157
+ # @ yit
158
+ #: yit-common/yith-panel.php:445
159
+ msgid "em"
160
+ msgstr "em"
161
+
162
+ # @ yit
163
+ #: yit-common/yith-panel.php:446
164
+ msgid "pt"
165
+ msgstr "pt"
166
+
167
+ # @ yit
168
+ #: yit-common/yith-panel.php:447
169
+ msgid "rem"
170
+ msgstr "rem"
171
+
172
+ # @ yit
173
+ #: yit-common/yith-panel.php:457
174
+ msgid "Select a font family"
175
+ msgstr "Bir font ailesi seçin"
176
+
177
+ # @ yit
178
+ #: yit-common/yith-panel.php:465
179
+ msgid "Regular"
180
+ msgstr "Normal"
181
+
182
+ # @ yit
183
+ #: yit-common/yith-panel.php:466
184
+ msgid "Bold"
185
+ msgstr "Kalın"
186
+
187
+ # @ yit
188
+ #: yit-common/yith-panel.php:467
189
+ msgid "Extra bold"
190
+ msgstr "Ekstra kalın"
191
+
192
+ # @ yit
193
+ #: yit-common/yith-panel.php:468
194
+ msgid "Italic"
195
+ msgstr "İtalik"
196
+
197
+ # @ yit
198
+ #: yit-common/yith-panel.php:469
199
+ msgid "Italic bold"
200
+ msgstr "İtalik kalın"
201
+
202
+ # @ yit
203
+ #: yit-common/yith-panel.php:481
204
+ msgid "Click to preview"
205
+ msgstr "Önizleme için tıklayın"
widgets/class.yith-wcan-navigation-widget.php CHANGED
@@ -2,221 +2,246 @@
2
/**
3
* Main class
4
*
5
- * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
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
- $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
38
- $query_type = isset( $instance['query_type'] ) ? $instance['query_type'] : 'and';
39
- $display_type = isset( $instance['type'] ) ? $instance['type'] : 'list';
40
- $is_child_class = 'yit-wcan-child-terms';
41
- $is_chosen_class = 'chosen';
42
- $terms_type_list = ( isset( $instance['display'] ) && ( $display_type == 'list' || $display_type == 'select' ) ) ? $instance['display'] : 'all';
43
44
- /* FIX TO WOOCOMMERCE 2.1 */
45
- if ( function_exists( 'wc_attribute_taxonomy_name' ) ) {
46
- $taxonomy = wc_attribute_taxonomy_name($instance['attribute']);
47
- } else {
48
- $taxonomy = $woocommerce->attribute_taxonomy_name($instance['attribute'] );
49
- }
50
51
- if ( ! taxonomy_exists( $taxonomy ) )
52
- return;
53
54
- $terms = yit_get_terms( $terms_type_list, $taxonomy );
55
56
- if ( count( $terms ) > 0 ) {
57
58
- ob_start();
59
60
- $found = false;
61
62
- echo $before_widget . $before_title . $title . $after_title;
63
64
- // Force found when option is selected - do not force found on taxonomy attributes
65
- if ( ! $_attributes_array || ! is_tax( $_attributes_array ) )
66
- if ( is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) )
67
- $found = true;
68
69
- if ( $display_type == 'list' ) {
70
- // List display
71
- echo "<ul class='yith-wcan-list yith-wcan'>";
72
73
- foreach ( $terms as $term ) {
74
75
- // Get count based on current view - uses transients
76
- $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
77
78
- if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
79
80
- $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
81
82
- set_transient( $transient_name, $_products_in_term );
83
- }
84
85
- $option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );
86
87
- // If this is an AND query, only show options with count > 0
88
- if ( $query_type == 'and' ) {
89
90
- $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
91
92
- // skip the term for the current archive
93
- if ( $current_term == $term->term_id )
94
- continue;
95
96
- if ( $count > 0 && $current_term !== $term->term_id )
97
- $found = true;
98
99
- if ( ( $terms_type_list != 'hierarchical' || ! yit_term_has_child($term, $taxonomy) ) && $count == 0 && ! $option_is_set ){
100
- continue;
101
- }
102
103
// If this is an OR query, show all options so search can be expanded
104
- } else {
105
-
106
- // skip the term for the current archive
107
- if ( $current_term == $term->term_id )
108
- continue;
109
110
- $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
111
112
- if ( $count > 0 )
113
- $found = true;
114
115
}
116
117
- $arg = 'filter_' . sanitize_title( $instance['attribute'] );
118
119
- $current_filter = ( isset( $_GET[ $arg ] ) ) ? explode( ',', $_GET[ $arg ] ) : array();
120
121
- if ( ! is_array( $current_filter ) )
122
- $current_filter = array();
123
124
- $current_filter = array_map( 'esc_attr', $current_filter );
125
126
- if ( ! in_array( $term->term_id, $current_filter ) )
127
- $current_filter[] = $term->term_id;
128
129
- // Base Link decided by current page
130
- if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
131
- $link = home_url();
132
- } elseif ( is_post_type_archive( 'product' ) || is_page( function_exists( 'wc_get_page_id' ) ? wc_get_page_id('shop') : woocommerce_get_page_id('shop') ) ) {
133
- $link = get_post_type_archive_link( 'product' );
134
- } else {
135
- $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
136
- }
137
138
- // All current filters
139
- if ( $_chosen_attributes ) {
140
- foreach ( $_chosen_attributes as $name => $data ) {
141
- if ( $name !== $taxonomy ) {
142
143
- // Exclude query arg for current term archive term
144
- while ( in_array( $current_term, $data['terms'] ) ) {
145
- $key = array_search( $current_term, $data );
146
- unset( $data['terms'][$key] );
147
- }
148
149
- // Remove pa_ and sanitize
150
- $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
151
152
- if ( ! empty( $data['terms'] ) )
153
- $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
154
155
- if ( $data['query_type'] == 'or' )
156
- $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
157
}
158
}
159
}
160
161
- // Min/Max
162
- if ( isset( $_GET['min_price'] ) )
163
- $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
164
-
165
- if ( isset( $_GET['max_price'] ) )
166
- $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
167
-
168
- // Current Filter = this widget
169
- if ( isset( $_chosen_attributes[ $taxonomy ] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) {
170
171
- $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
172
173
- // Remove this term is $current_filter has more than 1 term filtered
174
- if ( sizeof( $current_filter ) > 1 ) {
175
- $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
176
- $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
177
- }
178
179
- } else {
180
181
- $class = ($terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
182
183
- $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
184
185
- }
186
187
- // Search Arg
188
- if ( get_search_query() )
189
- $link = add_query_arg( 's', get_search_query(), $link );
190
191
- // Post Type Arg
192
- if ( isset( $_GET['post_type'] ) )
193
- $link = add_query_arg( 'post_type', $_GET['post_type'], $link );
194
195
- // Query type Arg
196
- 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'] ) ) )
197
- $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
198
199
200
201
- echo '<li ' . $class . '>';
202
203
- echo ( $count > 0 || $option_is_set ) ? '<a href="' . esc_url( apply_filters( 'woocommerce_layered_nav_link', $link ) ) . '">' : '<span>';
204
205
- echo $term->name;
206
207
- echo ( $count > 0 || $option_is_set ) ? '</a>' : '</span>';
208
209
- if( $count != 0 ) {
210
- echo ' <small class="count">' . $count . '</small><div class="clear"></div></li>';
211
- }
212
213
}
214
215
- echo "</ul>";
216
217
- }elseif ( $display_type == 'select' ){ ?>
218
219
- <a class="yit-wcan-select-open" href="#"><?php _e('Filters List:', 'yit') ?></a>
220
221
<?php
222
// Select display
@@ -236,7 +261,7 @@ if( !class_exists( 'YITH_WCAN' ) ) {
236
set_transient( $transient_name, $_products_in_term );
237
}
238
239
- $option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );
240
241
// If this is an AND query, only show options with count > 0
242
if ( $query_type == 'and' ) {
@@ -244,49 +269,58 @@ if( !class_exists( 'YITH_WCAN' ) ) {
244
$count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
245
246
// skip the term for the current archive
247
- if ( $current_term == $term->term_id )
248
continue;
249
250
- if ( $count > 0 && $current_term !== $term->term_id )
251
$found = true;
252
253
- if ( ( $terms_type_list != 'hierarchical' || ! yit_term_has_child($term, $taxonomy) ) && $count == 0 && ! $option_is_set ){
254
- continue;
255
- }
256
257
// If this is an OR query, show all options so search can be expanded
258
- } else {
259
260
// skip the term for the current archive
261
- if ( $current_term == $term->term_id )
262
continue;
263
264
$count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
265
266
- if ( $count > 0 )
267
$found = true;
268
269
}
270
271
$arg = 'filter_' . urldecode( sanitize_title( $instance['attribute'] ) );
272
273
- $current_filter = ( isset( $_GET[ $arg ] ) ) ? explode( ',', $_GET[ $arg ] ) : array();
274
275
- if ( ! is_array( $current_filter ) )
276
$current_filter = array();
277
278
$current_filter = array_map( 'esc_attr', $current_filter );
279
280
- if ( ! in_array( $term->term_id, $current_filter ) )
281
$current_filter[] = $term->term_id;
282
283
// Base Link decided by current page
284
if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
285
$link = home_url();
286
- } elseif ( is_post_type_archive( 'product' ) || is_page( woocommerce_get_page_id('shop') ) ) {
287
$link = get_post_type_archive_link( 'product' );
288
- } else {
289
- $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
290
}
291
292
// All current filters
@@ -303,51 +337,59 @@ if( !class_exists( 'YITH_WCAN' ) ) {
303
// Remove pa_ and sanitize
304
$filter_name = urldecode( sanitize_title( str_replace( 'pa_', '', $name ) ) );
305
306
- if ( ! empty( $data['terms'] ) )
307
$link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
308
309
- if ( $data['query_type'] == 'or' )
310
$link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
311
}
312
}
313
}
314
315
// Min/Max
316
- if ( isset( $_GET['min_price'] ) )
317
$link = add_query_arg( 'min_price', $_GET['min_price'], $link );
318
319
- if ( isset( $_GET['max_price'] ) )
320
$link = add_query_arg( 'max_price', $_GET['max_price'], $link );
321
322
// Current Filter = this widget
323
- if ( isset( $_chosen_attributes[ $taxonomy ] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) {
324
325
$class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
326
327
// Remove this term is $current_filter has more than 1 term filtered
328
if ( sizeof( $current_filter ) > 1 ) {
329
$current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
330
- $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
331
}
332
333
- } else {
334
335
- $class = ($terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
336
- $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
337
338
}
339
340
// Search Arg
341
- if ( get_search_query() )
342
$link = add_query_arg( 's', get_search_query(), $link );
343
344
// Post Type Arg
345
- if ( isset( $_GET['post_type'] ) )
346
$link = add_query_arg( 'post_type', $_GET['post_type'], $link );
347
348
// Query type Arg
349
- 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'] ) ) )
350
$link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
351
352
echo '<li ' . $class . '>';
353
@@ -365,392 +407,432 @@ if( !class_exists( 'YITH_WCAN' ) ) {
365
366
echo "</div>";
367
368
- } elseif ( $display_type == 'color' ) {
369
- // List display
370
- echo "<ul class='yith-wcan-color yith-wcan yith-wcan-group'>";
371
-
372
- foreach ( $terms as $term ) {
373
374
- // Get count based on current view - uses transients
375
- $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
376
377
- if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
378
379
- $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
380
381
- set_transient( $transient_name, $_products_in_term );
382
- }
383
384
- $option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );
385
386
- // If this is an AND query, only show options with count > 0
387
- if ( $query_type == 'and' ) {
388
389
- $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
390
391
- // skip the term for the current archive
392
- if ( $current_term == $term->term_id )
393
- continue;
394
395
- if ( $count > 0 && $current_term !== $term->term_id )
396
- $found = true;
397
398
- if ( $count == 0 && ! $option_is_set )
399
- continue;
400
401
- // If this is an OR query, show all options so search can be expanded
402
- } else {
403
404
- // skip the term for the current archive
405
- if ( $current_term == $term->term_id )
406
- continue;
407
408
- $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
409
410
- if ( $count > 0 )
411
- $found = true;
412
413
}
414
415
- $arg = 'filter_' . sanitize_title( $instance['attribute'] );
416
417
- $current_filter = ( isset( $_GET[ $arg ] ) ) ? explode( ',', $_GET[ $arg ] ) : array();
418
419
- if ( ! is_array( $current_filter ) )
420
- $current_filter = array();
421
422
- $current_filter = array_map( 'esc_attr', $current_filter );
423
424
- if ( ! in_array( $term->term_id, $current_filter ) )
425
- $current_filter[] = $term->term_id;
426
427
- // Base Link decided by current page
428
- if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
429
- $link = home_url();
430
- } elseif ( is_post_type_archive( 'product' ) || is_page( function_exists( 'wc_get_page_id' ) ? wc_get_page_id('shop') : woocommerce_get_page_id('shop') ) ) {
431
- $link = get_post_type_archive_link( 'product' );
432
- } else {
433
- $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
434
- }
435
436
- // All current filters
437
- if ( $_chosen_attributes ) {
438
- foreach ( $_chosen_attributes as $name => $data ) {
439
- if ( $name !== $taxonomy ) {
440
441
- // Exclude query arg for current term archive term
442
- while ( in_array( $current_term, $data['terms'] ) ) {
443
- $key = array_search( $current_term, $data );
444
- unset( $data['terms'][$key] );
445
- }
446
447
- // Remove pa_ and sanitize
448
- $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
449
450
- if ( ! empty( $data['terms'] ) )
451
- $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
452
453
- if ( $data['query_type'] == 'or' )
454
- $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
455
}
456
}
457
}
458
459
- // Min/Max
460
- if ( isset( $_GET['min_price'] ) )
461
- $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
462
463
- if ( isset( $_GET['max_price'] ) )
464
- $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
465
466
- // Current Filter = this widget
467
- if ( isset( $_chosen_attributes[ $taxonomy ] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) {
468
469
- $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
470
471
- // Remove this term is $current_filter has more than 1 term filtered
472
- if ( sizeof( $current_filter ) > 1 ) {
473
- $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
474
- $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
475
- }
476
477
- } else {
478
479
- $class = ($terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
480
- $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
481
482
- }
483
484
- // Search Arg
485
- if ( get_search_query() )
486
- $link = add_query_arg( 's', get_search_query(), $link );
487
488
- // Post Type Arg
489
- if ( isset( $_GET['post_type'] ) )
490
- $link = add_query_arg( 'post_type', $_GET['post_type'], $link );
491
492
- // Query type Arg
493
- 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'] ) ) )
494
- $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
495
496
- if( $instance['colors'][$term->term_id] != '' ) {
497
- echo '<li ' . $class . '>';
498
499
- 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 ) ) . '" title="' . $term->name . '" >' : '<span style="background-color:' . $instance['colors'][$term->term_id] . ';" >';
500
501
- echo $term->name;
502
503
- echo ( $count > 0 || $option_is_set ) ? '</a>' : '</span>';
504
- }
505
}
506
507
- echo "</ul>";
508
-
509
- } elseif ( $display_type == 'label' ) {
510
- // List display
511
- echo "<ul class='yith-wcan-label yith-wcan yith-wcan-group'>";
512
513
- foreach ( $terms as $term ) {
514
515
- // Get count based on current view - uses transients
516
- $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
517
518
- if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
519
520
- $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
521
522
- set_transient( $transient_name, $_products_in_term );
523
- }
524
525
- $option_is_set = ( isset( $_chosen_attributes[ $taxonomy ] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) );
526
527
- // If this is an AND query, only show options with count > 0
528
- if ( $query_type == 'and' ) {
529
530
- $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
531
532
- // skip the term for the current archive
533
- if ( $current_term == $term->term_id )
534
- continue;
535
536
- if ( $count > 0 && $current_term !== $term->term_id )
537
- $found = true;
538
539
- if ( $count == 0 && ! $option_is_set )
540
- continue;
541
542
- // If this is an OR query, show all options so search can be expanded
543
- } else {
544
545
- // skip the term for the current archive
546
- if ( $current_term == $term->term_id )
547
- continue;
548
549
- $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
550
551
- if ( $count > 0 )
552
- $found = true;
553
554
}
555
556
- $arg = 'filter_' . sanitize_title( $instance['attribute'] );
557
558
- $current_filter = ( isset( $_GET[ $arg ] ) ) ? explode( ',', $_GET[ $arg ] ) : array();
559
560
- if ( ! is_array( $current_filter ) )
561
- $current_filter = array();
562
563
- $current_filter = array_map( 'esc_attr', $current_filter );
564
565
- if ( ! in_array( $term->term_id, $current_filter ) )
566
- $current_filter[] = $term->term_id;
567
568
- // Base Link decided by current page
569
- if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
570
- $link = home_url();
571
- } elseif ( is_post_type_archive( 'product' ) || is_page( function_exists( 'wc_get_page_id' ) ? wc_get_page_id('shop') : woocommerce_get_page_id('shop') ) ) {
572
- $link = get_post_type_archive_link( 'product' );
573
- } else {
574
- $link = get_term_link( get_query_var('term'), get_query_var('taxonomy') );
575
- }
576
577
- // All current filters
578
- if ( $_chosen_attributes ) {
579
- foreach ( $_chosen_attributes as $name => $data ) {
580
- if ( $name !== $taxonomy ) {
581
582
- // Exclude query arg for current term archive term
583
- while ( in_array( $current_term, $data['terms'] ) ) {
584
- $key = array_search( $current_term, $data );
585
- unset( $data['terms'][$key] );
586
- }
587
588
- // Remove pa_ and sanitize
589
- $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
590
591
- if ( ! empty( $data['terms'] ) )
592
- $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
593
594
- if ( $data['query_type'] == 'or' )
595
- $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
596
}
597
}
598
}
599
600
- // Min/Max
601
- if ( isset( $_GET['min_price'] ) )
602
- $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
603
-
604
- if ( isset( $_GET['max_price'] ) )
605
- $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
606
-
607
- // Current Filter = this widget
608
- if ( isset( $_chosen_attributes[ $taxonomy ] ) && is_array( $_chosen_attributes[ $taxonomy ]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[ $taxonomy ]['terms'] ) ) {
609
-
610
- $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
611
612
- // Remove this term is $current_filter has more than 1 term filtered
613
- if ( sizeof( $current_filter ) > 1 ) {
614
- $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
615
- $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
616
- }
617
618
- } else {
619
620
- $class = ($terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
621
- $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
622
623
}
624
625
- // Search Arg
626
- if ( get_search_query() )
627
- $link = add_query_arg( 's', get_search_query(), $link );
628
629
- // Post Type Arg
630
- if ( isset( $_GET['post_type'] ) )
631
- $link = add_query_arg( 'post_type', $_GET['post_type'], $link );
632
633
- // Query type Arg
634
- 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'] ) ) )
635
- $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
636
637
- if($instance['labels'][$term->term_id] != '' ){
638
639
- echo '<li ' . $class . '>';
640
641
- echo ( $count > 0 || $option_is_set ) ? '<a title="' . $term->name . '" href="' . esc_url( apply_filters( 'woocommerce_layered_nav_link', $link ) ) . '">' : '<span>';
642
643
- echo $instance['labels'][$term->term_id];
644
645
- echo ( $count > 0 || $option_is_set ) ? '</a>' : '</span>';
646
- }
647
- }
648
- echo "</ul>";
649
650
- } // End display type conditional
651
652
- echo $after_widget;
653
654
- if ( ! $found ) {
655
- ob_end_clean();
656
- echo substr($before_widget, 0, strlen($before_widget) - 1) . ' style="display:none">' . $after_widget;
657
- } else {
658
- echo ob_get_clean();
659
}
660
- }
661
- }
662
-
663
664
- function form( $instance ) {
665
- global $woocommerce;
666
-
667
- $defaults = array(
668
- 'title' => '',
669
- 'attribute' => '',
670
- 'query_type' => 'and',
671
- 'type' => 'list',
672
- 'colors' => '',
673
- 'labels' => '',
674
- 'display' => 'all'
675
- );
676
-
677
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
678
-
679
- <p>
680
- <label>
681
- <strong><?php _e( 'Title', 'yit' ) ?>:</strong><br />
682
- <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" />
683
- </label>
684
- </p>
685
-
686
- <p><label for="<?php echo $this->get_field_id('attribute'); ?>"><strong><?php _e('Attribute:', 'yit') ?></strong></label>
687
- <select class="yith_wcan_attributes widefat" id="<?php echo esc_attr( $this->get_field_id('attribute') ); ?>" name="<?php echo esc_attr( $this->get_field_name('attribute') ); ?>">
688
- <?php yith_wcan_dropdown_attributes( $instance['attribute'] ); ?>
689
- </select></p>
690
-
691
- <p><label for="<?php echo $this->get_field_id( 'query_type' ); ?>"><?php _e( 'Query Type:', 'yit' ) ?></label>
692
- <select id="<?php echo esc_attr( $this->get_field_id( 'query_type' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'query_type' ) ); ?>">
693
- <option value="and" <?php selected( $instance['query_type'], 'and' ); ?>><?php _e( 'AND', 'yit' ); ?></option>
694
- <option value="or" <?php selected( $instance['query_type'], 'or' ); ?>><?php _e( 'OR', 'yit' ); ?></option>
695
- </select></p>
696
-
697
- <p><label for="<?php echo $this->get_field_id('type'); ?>"><strong><?php _e('Type:', 'yit') ?></strong></label>
698
- <select class="yith_wcan_type widefat" id="<?php echo esc_attr( $this->get_field_id('type') ); ?>" name="<?php echo esc_attr( $this->get_field_name('type') ); ?>">
699
- <option value="list" <?php selected( 'list', $instance['type'] ) ?>><?php _e( 'List', 'yit' ) ?></option>
700
- <option value="color" <?php selected( 'color', $instance['type'] ) ?>><?php _e( 'Color', 'yit' ) ?></option>
701
- <option value="label" <?php selected( 'label', $instance['type'] ) ?>><?php _e( 'Label', 'yit' ) ?></option>
702
- <option value="select" <?php selected( 'select', $instance['type'] ) ?>><?php _e( 'Dropdown', 'yit' ) ?></option>
703
- </select>
704
- </p>
705
-
706
- <p id="yit-wcan-display" class="yit-wcan-display-<?php echo $instance['type'] ?>">
707
- <label for="<?php echo $this->get_field_id('display'); ?>"><strong><?php _e('Display (default All):', 'yit') ?></strong></label>
708
- <select class="yith_wcan_type widefat" id="<?php echo esc_attr( $this->get_field_id('display') ); ?>" name="<?php echo esc_attr( $this->get_field_name('display') ); ?>">
709
- <option value="all" <?php selected( 'all', $instance['display'] ) ?>> <?php _e( 'All (no hierarchical)', 'yit' ) ?></option>
710
- <option value="hierarchical" <?php selected( 'hierarchical', $instance['display'] ) ?>> <?php _e( 'All Hierarchical', 'yit' ) ?> </option>
711
- <option value="parent" <?php selected( 'parent', $instance['display'] ) ?>> <?php _e( 'Only Parent', 'yit' ) ?> </option>
712
- </select>
713
- </p>
714
-
715
- <div class="yith_wcan_placeholder">
716
- <?php yith_wcan_attributes_table(
717
- $instance['type'],
718
- $instance['attribute'],
719
- 'widget-' . $this->id . '-',
720
- 'widget-' . $this->id_base . '[' . $this->number . ']',
721
- $instance['type'] == 'color' ? $instance['colors'] : ( $instance['type'] == 'label' ? $instance['labels'] : array() ),
722
- $instance['display']
723
- );
724
- ?>
725
- </div>
726
- <span class="spinner" style="display: none;"></span>
727
728
- <input type="hidden" name="widget_id" value="widget-<?php echo $this->id ?>-" />
729
- <input type="hidden" name="widget_name" value="widget-<?php echo $this->id_base ?>[<?php echo $this->number ?>]" />
730
731
- <script>jQuery(document).trigger('yith_colorpicker');</script>
732
- <?php
733
}
734
735
- function update( $new_instance, $old_instance ) {
736
- global $woocommerce;
737
738
- $instance = $old_instance;
739
740
- if ( empty( $new_instance['title'] ) ) {
741
- $new_instance['title'] = function_exists('wc_attribute_label') ? wc_attribute_label( $new_instance['attribute'] ) : $woocommerce->attribute_label( $new_instance['attribute'] );
742
- }
743
744
- $instance['title'] = strip_tags( $new_instance['title'] );
745
- $instance['attribute'] = stripslashes( $new_instance['attribute'] );
746
- $instance['query_type'] = stripslashes( $new_instance['query_type'] );
747
- $instance['type'] = stripslashes( $new_instance['type'] );
748
- $instance['colors'] = $new_instance['colors'];
749
- $instance['labels'] = $new_instance['labels'];
750
- $instance['display'] = $new_instance['display'];
751
752
- return $instance;
753
}
754
755
}
756
}
2
/**
3
* Main class
4
*
5
+ * @author Your Inspiration Themes
6
* @package YITH WooCommerce Ajax Navigation
7
* @version 1.3.2
8
*/
9
10
+ if ( ! defined( 'YITH_WCAN' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
14
+ if ( ! class_exists( 'YITH_WCAN' ) ) {
15
/**
16
* YITH WooCommerce Ajax Navigation Widget
17
*
18
* @since 1.0.0
19
*/
20
+ class YITH_WCAN_Navigation_Widget extends WP_Widget {
21
22
+ function __construct() {
23
+ $widget_ops = array( 'classname' => 'yith-woo-ajax-navigation woocommerce widget_layered_nav', 'description' => __( 'Narrow down the products list without reloading the page', 'yit' ) );
24
+ $control_ops = array( 'width' => 400, 'height' => 350 );
25
+ parent::__construct( 'yith-woo-ajax-navigation', __( 'YITH WooCommerce Ajax Navigation', 'yit' ), $widget_ops, $control_ops );
26
+ }
27
28
29
+ function widget( $args, $instance ) {
30
+ global $_chosen_attributes, $woocommerce, $_attributes_array;
31
32
+ extract( $args );
33
34
+ if ( ! is_post_type_archive( 'product' ) && ! is_tax( array_merge( $_attributes_array, array( 'product_cat', 'product_tag' ) ) ) ) {
35
+ return;
36
+ }
37
38
+ $current_term = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->term_id : '';
39
+ $current_tax = $_attributes_array && is_tax( $_attributes_array ) ? get_queried_object()->taxonomy : '';
40
+ $title = apply_filters( 'widget_title', ( isset( $instance['title'] ) ? $instance['title'] : ''), $instance, $this->id_base );
41
+ $query_type = isset( $instance['query_type'] ) ? $instance['query_type'] : 'and';
42
+ $display_type = isset( $instance['type'] ) ? $instance['type'] : 'list';
43
+ $is_child_class = 'yit-wcan-child-terms';
44
+ $is_chosen_class = 'chosen';
45
+ $terms_type_list = ( isset( $instance['display'] ) && ( $display_type == 'list' || $display_type == 'select' ) ) ? $instance['display'] : 'all';
46
+
47
+ /* FIX TO WOOCOMMERCE 2.1 */
48
+ if ( function_exists( 'wc_attribute_taxonomy_name' ) ) {
49
+ $taxonomy = wc_attribute_taxonomy_name( $instance['attribute'] );
50
+ }
51
+ else {
52
+ $taxonomy = $woocommerce->attribute_taxonomy_name( $instance['attribute'] );
53
+ }
54
55
+ if ( ! taxonomy_exists( $taxonomy ) ) {
56
+ return;
57
+ }
58
59
+ $terms = yit_get_terms( $terms_type_list, $taxonomy );
60
61
+ if ( count( $terms ) > 0 ) {
62
63
+ ob_start();
64
65
+ $found = false;
66
67
+ echo $before_widget . $before_title . $title . $after_title;
68
69
+ // Force found when option is selected - do not force found on taxonomy attributes
70
+ if ( ! $_attributes_array || ! is_tax( $_attributes_array ) ) {
71
+ if ( is_array( $_chosen_attributes ) && array_key_exists( $taxonomy, $_chosen_attributes ) ) {
72
+ $found = true;
73
+ }
74
+ }
75
76
+ if ( $display_type == 'list' ) {
77
+ // List display
78
+ echo "<ul class='yith-wcan-list yith-wcan'>";
79
80
+ foreach ( $terms as $term ) {
81
82
+ // Get count based on current view - uses transients
83
+ $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
84
85
+ if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
86
87
+ $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
88
89
+ set_transient( $transient_name, $_products_in_term );
90
+ }
91
92
+ $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && in_array( $term->term_id, $_chosen_attributes[$taxonomy]['terms'] ) );
93
94
+ // If this is an AND query, only show options with count > 0
95
+ if ( $query_type == 'and' ) {
96
97
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
98
99
+ // skip the term for the current archive
100
+ if ( $current_term == $term->term_id ) {
101
+ continue;
102
+ }
103
104
+ if ( $count > 0 && $current_term !== $term->term_id ) {
105
+ $found = true;
106
+ }
107
108
+ if ( ( $terms_type_list != 'hierarchical' || ! yit_term_has_child( $term, $taxonomy ) ) && $count == 0 && ! $option_is_set ) {
109
+ continue;
110
+ }
111
112
// If this is an OR query, show all options so search can be expanded
113
+ }
114
+ else {
115
116
+ // skip the term for the current archive
117
+ if ( $current_term == $term->term_id ) {
118
+ continue;
119
+ }
120
121
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
122
123
+ if ( $count > 0 ) {
124
+ $found = true;
125
}
126
127
+ }
128
+
129
+ $arg = 'filter_' . sanitize_title( $instance['attribute'] );
130
131
+ $current_filter = ( isset( $_GET[$arg] ) ) ? explode( ',', $_GET[$arg] ) : array();
132
133
+ if ( ! is_array( $current_filter ) ) {
134
+ $current_filter = array();
135
+ }
136
137
+ $current_filter = array_map( 'esc_attr', $current_filter );
138
139
+ if ( ! in_array( $term->term_id, $current_filter ) ) {
140
+ $current_filter[] = $term->term_id;
141
+ }
142
143
+ // Base Link decided by current page
144
+ if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
145
+ $link = home_url();
146
+ }
147
+ elseif ( is_post_type_archive( 'product' ) || is_page( function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' ) ) ) {
148
+ $link = get_post_type_archive_link( 'product' );
149
+ }
150
+ else {
151
+ $link = get_term_link( get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
152
+ }
153
154
+ // All current filters
155
+ if ( $_chosen_attributes ) {
156
+ foreach ( $_chosen_attributes as $name => $data ) {
157
+ if ( $name !== $taxonomy ) {
158
159
+ // Exclude query arg for current term archive term
160
+ while ( in_array( $current_term, $data['terms'] ) ) {
161
+ $key = array_search( $current_term, $data );
162
+ unset( $data['terms'][$key] );
163
+ }
164
165
+ // Remove pa_ and sanitize
166
+ $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
167
168
+ if ( ! empty( $data['terms'] ) ) {
169
+ $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
170
+ }
171
172
+ if ( $data['query_type'] == 'or' ) {
173
+ $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
174
}
175
}
176
}
177
+ }
178
179
+ // Min/Max
180
+ if ( isset( $_GET['min_price'] ) ) {
181
+ $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
182
+ }
183
184
+ if ( isset( $_GET['max_price'] ) ) {
185
+ $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
186
+ }
187
188
+ // Current Filter = this widget
189
+ if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[$taxonomy]['terms'] ) ) {
190
191
+ $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
192
193
+ // Remove this term is $current_filter has more than 1 term filtered
194
+ if ( sizeof( $current_filter ) > 1 ) {
195
+ $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
196
+ $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
197
+ }
198
199
+ }
200
+ else {
201
202
+ $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
203
204
+ $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
205
206
+ }
207
208
+ // Search Arg
209
+ if ( get_search_query() ) {
210
+ $link = add_query_arg( 's', get_search_query(), $link );
211
+ }
212
213
+ // Post Type Arg
214
+ if ( isset( $_GET['post_type'] ) ) {
215
+ $link = add_query_arg( 'post_type', $_GET['post_type'], $link );
216
+ }
217
218
+ // Query type Arg
219
+ 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'] ) ) ) {
220
+ $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
221
+ }
222
223
224
+ echo '<li ' . $class . '>';
225
226
+ echo ( $count > 0 || $option_is_set ) ? '<a href="' . esc_url( apply_filters( 'woocommerce_layered_nav_link', $link ) ) . '">' : '<span>';
227
228
+ echo $term->name;
229
230
+ echo ( $count > 0 || $option_is_set ) ? '</a>' : '</span>';
231
232
+ if ( $count != 0 ) {
233
+ echo ' <small class="count">' . $count . '</small><div class="clear"></div></li>';
234
}
235
236
+ }
237
238
+ echo "</ul>";
239
+
240
+ }
241
+ elseif ( $display_type == 'select' ) {
242
+ ?>
243
244
+ <a class="yit-wcan-select-open" href="#"><?php _e( 'Filters List:', 'yit' ) ?></a>
245
246
<?php
247
// Select display
261
set_transient( $transient_name, $_products_in_term );
262
}
263
264
+ $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && in_array( $term->term_id, $_chosen_attributes[$taxonomy]['terms'] ) );
265
266
// If this is an AND query, only show options with count > 0
267
if ( $query_type == 'and' ) {
269
$count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
270
271
// skip the term for the current archive
272
+ if ( $current_term == $term->term_id ) {
273
continue;
274
+ }
275
276
+ if ( $count > 0 && $current_term !== $term->term_id ) {
277
$found = true;
278
+ }
279
280
+ if ( ( $terms_type_list != 'hierarchical' || ! yit_term_has_child( $term, $taxonomy ) ) && $count == 0 && ! $option_is_set ) {
281
+ continue;
282
+ }
283
284
// If this is an OR query, show all options so search can be expanded
285
+ }
286
+ else {
287
288
// skip the term for the current archive
289
+ if ( $current_term == $term->term_id ) {
290
continue;
291
+ }
292
293
$count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
294
295
+ if ( $count > 0 ) {
296
$found = true;
297
+ }
298
299
}
300
301
$arg = 'filter_' . urldecode( sanitize_title( $instance['attribute'] ) );
302
303
+ $current_filter = ( isset( $_GET[$arg] ) ) ? explode( ',', $_GET[$arg] ) : array();
304
305
+ if ( ! is_array( $current_filter ) ) {
306
$current_filter = array();
307
+ }
308
309
$current_filter = array_map( 'esc_attr', $current_filter );
310
311
+ if ( ! in_array( $term->term_id, $current_filter ) ) {
312
$current_filter[] = $term->term_id;
313
+ }
314
315
// Base Link decided by current page
316
if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
317
$link = home_url();
318
+ }
319
+ elseif ( is_post_type_archive( 'product' ) || is_page( woocommerce_get_page_id( 'shop' ) ) ) {
320
$link = get_post_type_archive_link( 'product' );
321
+ }
322
+ else {
323
+ $link = get_term_link( get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
324
}
325
326
// All current filters
337
// Remove pa_ and sanitize
338
$filter_name = urldecode( sanitize_title( str_replace( 'pa_', '', $name ) ) );
339
340
+ if ( ! empty( $data['terms'] ) ) {
341
$link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
342
+ }
343
344
+ if ( $data['query_type'] == 'or' ) {
345
$link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
346
+ }
347
}
348
}
349
}
350
351
// Min/Max
352
+ if ( isset( $_GET['min_price'] ) ) {
353
$link = add_query_arg( 'min_price', $_GET['min_price'], $link );
354
+ }
355
356
+ if ( isset( $_GET['max_price'] ) ) {
357
$link = add_query_arg( 'max_price', $_GET['max_price'], $link );
358
+ }
359
360
// Current Filter = this widget
361
+ if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[$taxonomy]['terms'] ) ) {
362
363
$class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
364
365
// Remove this term is $current_filter has more than 1 term filtered
366
if ( sizeof( $current_filter ) > 1 ) {
367
$current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
368
+ $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
369
}
370
371
+ }
372
+ else {
373
374
+ $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
375
+ $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
376
377
}
378
379
// Search Arg
380
+ if ( get_search_query() ) {
381
$link = add_query_arg( 's', get_search_query(), $link );
382
+ }
383
384
// Post Type Arg
385
+ if ( isset( $_GET['post_type'] ) ) {
386
$link = add_query_arg( 'post_type', $_GET['post_type'], $link );
387
+ }
388
389
// Query type Arg
390
+ 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'] ) ) ) {
391
$link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
392
+ }
393
394
echo '<li ' . $class . '>';
395
407
408
echo "</div>";
409
410
+ }
411
+ elseif ( $display_type == 'color' ) {
412
+ // List display
413
+ echo "<ul class='yith-wcan-color yith-wcan yith-wcan-group'>";
414
415
+ foreach ( $terms as $term ) {
416
417
+ // Get count based on current view - uses transients
418
+ $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
419
420
+ if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
421
422
+ $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
423
424
+ set_transient( $transient_name, $_products_in_term );
425
+ }
426
427
+ $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && in_array( $term->term_id, $_chosen_attributes[$taxonomy]['terms'] ) );
428
429
+ // If this is an AND query, only show options with count > 0
430
+ if ( $query_type == 'and' ) {
431
432
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
433
434
+ // skip the term for the current archive
435
+ if ( $current_term == $term->term_id ) {
436
+ continue;
437
+ }
438
439
+ if ( $count > 0 && $current_term !== $term->term_id ) {
440
+ $found = true;
441
+ }
442
443
+ if ( $count == 0 && ! $option_is_set ) {
444
+ continue;
445
+ }
446
447
+ // If this is an OR query, show all options so search can be expanded
448
+ }
449
+ else {
450
451
+ // skip the term for the current archive
452
+ if ( $current_term == $term->term_id ) {
453
+ continue;
454
+ }
455
456
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
457
458
+ if ( $count > 0 ) {
459
+ $found = true;
460
}
461
462
+ }
463
464
+ $arg = 'filter_' . sanitize_title( $instance['attribute'] );
465
466
+ $current_filter = ( isset( $_GET[$arg] ) ) ? explode( ',', $_GET[$arg] ) : array();
467
468
+ if ( ! is_array( $current_filter ) ) {
469
+ $current_filter = array();
470
+ }
471
472
+ $current_filter = array_map( 'esc_attr', $current_filter );
473
474
+ if ( ! in_array( $term->term_id, $current_filter ) ) {
475
+ $current_filter[] = $term->term_id;
476
+ }
477
478
+ // Base Link decided by current page
479
+ if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
480
+ $link = home_url();
481
+ }
482
+ elseif ( is_post_type_archive( 'product' ) || is_page( function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' ) ) ) {
483
+ $link = get_post_type_archive_link( 'product' );
484
+ }
485
+ else {
486
+ $link = get_term_link( get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
487
+ }
488
489
+ // All current filters
490
+ if ( $_chosen_attributes ) {
491
+ foreach ( $_chosen_attributes as $name => $data ) {
492
+ if ( $name !== $taxonomy ) {
493
494
+ // Exclude query arg for current term archive term
495
+ while ( in_array( $current_term, $data['terms'] ) ) {
496
+ $key = array_search( $current_term, $data );
497
+