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
+ unset( $data['terms'][$key] );
498
+ }
499
 
500
+ // Remove pa_ and sanitize
501
+ $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
502
 
503
+ if ( ! empty( $data['terms'] ) ) {
504
+ $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
505
+ }
506
+
507
+ if ( $data['query_type'] == 'or' ) {
508
+ $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
509
  }
510
  }
511
  }
512
+ }
513
 
514
+ // Min/Max
515
+ if ( isset( $_GET['min_price'] ) ) {
516
+ $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
517
+ }
518
 
519
+ if ( isset( $_GET['max_price'] ) ) {
520
+ $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
521
+ }
522
 
523
+ // Current Filter = this widget
524
+ if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[$taxonomy]['terms'] ) ) {
525
 
526
+ $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
527
 
528
+ // Remove this term is $current_filter has more than 1 term filtered
529
+ if ( sizeof( $current_filter ) > 1 ) {
530
+ $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
531
+ $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
532
+ }
533
 
534
+ }
535
+ else {
536
 
537
+ $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
538
+ $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
539
 
540
+ }
541
 
542
+ // Search Arg
543
+ if ( get_search_query() ) {
544
+ $link = add_query_arg( 's', get_search_query(), $link );
545
+ }
546
 
547
+ // Post Type Arg
548
+ if ( isset( $_GET['post_type'] ) ) {
549
+ $link = add_query_arg( 'post_type', $_GET['post_type'], $link );
550
+ }
551
 
552
+ // Query type Arg
553
+ 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'] ) ) ) {
554
+ $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
555
+ }
556
 
557
+ if ( $instance['colors'][$term->term_id] != '' ) {
558
+ echo '<li ' . $class . '>';
559
 
560
+ 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] . ';" >';
561
 
562
+ echo $term->name;
563
 
564
+ echo ( $count > 0 || $option_is_set ) ? '</a>' : '</span>';
 
565
  }
566
+ }
567
 
568
+ echo "</ul>";
 
 
 
 
569
 
570
+ }
571
+ elseif ( $display_type == 'label' ) {
572
+ // List display
573
+ echo "<ul class='yith-wcan-label yith-wcan yith-wcan-group'>";
574
 
575
+ foreach ( $terms as $term ) {
 
576
 
577
+ // Get count based on current view - uses transients
578
+ $transient_name = 'wc_ln_count_' . md5( sanitize_key( $taxonomy ) . sanitize_key( $term->term_id ) );
579
 
580
+ if ( false === ( $_products_in_term = get_transient( $transient_name ) ) ) {
581
 
582
+ $_products_in_term = get_objects_in_term( $term->term_id, $taxonomy );
 
583
 
584
+ set_transient( $transient_name, $_products_in_term );
585
+ }
586
 
587
+ $option_is_set = ( isset( $_chosen_attributes[$taxonomy] ) && in_array( $term->term_id, $_chosen_attributes[$taxonomy]['terms'] ) );
 
588
 
589
+ // If this is an AND query, only show options with count > 0
590
+ if ( $query_type == 'and' ) {
591
 
592
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->filtered_product_ids ) );
 
 
593
 
594
+ // skip the term for the current archive
595
+ if ( $current_term == $term->term_id ) {
596
+ continue;
597
+ }
598
 
599
+ if ( $count > 0 && $current_term !== $term->term_id ) {
600
+ $found = true;
601
+ }
602
 
603
+ if ( $count == 0 && ! $option_is_set ) {
604
+ continue;
605
+ }
606
 
607
+ // If this is an OR query, show all options so search can be expanded
608
+ }
609
+ else {
610
 
611
+ // skip the term for the current archive
612
+ if ( $current_term == $term->term_id ) {
613
+ continue;
614
+ }
615
 
616
+ $count = sizeof( array_intersect( $_products_in_term, $woocommerce->query->unfiltered_product_ids ) );
 
617
 
618
+ if ( $count > 0 ) {
619
+ $found = true;
620
  }
621
 
622
+ }
623
 
624
+ $arg = 'filter_' . sanitize_title( $instance['attribute'] );
625
 
626
+ $current_filter = ( isset( $_GET[$arg] ) ) ? explode( ',', $_GET[$arg] ) : array();
 
627
 
628
+ if ( ! is_array( $current_filter ) ) {
629
+ $current_filter = array();
630
+ }
631
 
632
+ $current_filter = array_map( 'esc_attr', $current_filter );
 
633
 
634
+ if ( ! in_array( $term->term_id, $current_filter ) ) {
635
+ $current_filter[] = $term->term_id;
636
+ }
 
 
 
 
 
637
 
638
+ // Base Link decided by current page
639
+ if ( defined( 'SHOP_IS_ON_FRONT' ) ) {
640
+ $link = home_url();
641
+ }
642
+ elseif ( is_post_type_archive( 'product' ) || is_page( function_exists( 'wc_get_page_id' ) ? wc_get_page_id( 'shop' ) : woocommerce_get_page_id( 'shop' ) ) ) {
643
+ $link = get_post_type_archive_link( 'product' );
644
+ }
645
+ else {
646
+ $link = get_term_link( get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
647
+ }
648
 
649
+ // All current filters
650
+ if ( $_chosen_attributes ) {
651
+ foreach ( $_chosen_attributes as $name => $data ) {
652
+ if ( $name !== $taxonomy ) {
 
653
 
654
+ // Exclude query arg for current term archive term
655
+ while ( in_array( $current_term, $data['terms'] ) ) {
656
+ $key = array_search( $current_term, $data );
657
+ unset( $data['terms'][$key] );
658
+ }
659
 
660
+ // Remove pa_ and sanitize
661
+ $filter_name = sanitize_title( str_replace( 'pa_', '', $name ) );
662
 
663
+ if ( ! empty( $data['terms'] ) ) {
664
+ $link = add_query_arg( 'filter_' . $filter_name, implode( ',', $data['terms'] ), $link );
665
+ }
666
+
667
+ if ( $data['query_type'] == 'or' ) {
668
+ $link = add_query_arg( 'query_type_' . $filter_name, 'or', $link );
669
  }
670
  }
671
  }
672
+ }
673
 
674
+ // Min/Max
675
+ if ( isset( $_GET['min_price'] ) ) {
676
+ $link = add_query_arg( 'min_price', $_GET['min_price'], $link );
677
+ }
 
 
 
 
 
 
 
678
 
679
+ if ( isset( $_GET['max_price'] ) ) {
680
+ $link = add_query_arg( 'max_price', $_GET['max_price'], $link );
681
+ }
 
 
682
 
683
+ // Current Filter = this widget
684
+ if ( isset( $_chosen_attributes[$taxonomy] ) && is_array( $_chosen_attributes[$taxonomy]['terms'] ) && in_array( $term->term_id, $_chosen_attributes[$taxonomy]['terms'] ) ) {
685
 
686
+ $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_chosen_class} {$is_child_class}'" : "class='{$is_chosen_class}'";
 
687
 
688
+ // Remove this term is $current_filter has more than 1 term filtered
689
+ if ( sizeof( $current_filter ) > 1 ) {
690
+ $current_filter_without_this = array_diff( $current_filter, array( $term->term_id ) );
691
+ $link = add_query_arg( $arg, implode( ',', $current_filter_without_this ), $link );
692
  }
693
 
694
+ }
695
+ else {
 
696
 
697
+ $class = ( $terms_type_list == 'hierarchical' && yit_term_is_child( $term ) ) ? "class='{$is_child_class}'" : '';
698
+ $link = add_query_arg( $arg, implode( ',', $current_filter ), $link );
 
699
 
700
+ }
 
 
701
 
702
+ // Search Arg
703
+ if ( get_search_query() ) {
704
+ $link = add_query_arg( 's', get_search_query(), $link );
705
+ }
706
 
707
+ // Post Type Arg
708
+ if ( isset( $_GET['post_type'] ) ) {
709
+ $link = add_query_arg( 'post_type', $_GET['post_type'], $link );
710
+ }
711
 
712
+ // Query type Arg
713
+ 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'] ) ) ) {
714
+ $link = add_query_arg( 'query_type_' . sanitize_title( $instance['attribute'] ), 'or', $link );
715
+ }
716
 
717
+ if ( $instance['labels'][$term->term_id] != '' ) {
718
 
719
+ echo '<li ' . $class . '>';
 
 
 
720
 
721
+ echo ( $count > 0 || $option_is_set ) ? '<a title="' . $term->name . '" href="' . esc_url( apply_filters( 'woocommerce_layered_nav_link', $link ) ) . '">' : '<span>';
722
 
723
+ echo $instance['labels'][$term->term_id];
724
 
725
+ echo ( $count > 0 || $option_is_set ) ? '</a>' : '</span>';
726
+ }
 
 
 
727
  }
728
+ echo "</ul>";
 
 
729
 
730
+ } // End display type conditional
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
731
 
732
+ echo $after_widget;
 
733
 
734
+ if ( ! $found ) {
735
+ ob_end_clean();
736
+ echo substr( $before_widget, 0, strlen( $before_widget ) - 1 ) . ' style="display:none">' . $after_widget;
737
+ }
738
+ else {
739
+ echo ob_get_clean();
740
+ }
741
  }
742
+ }
743
 
 
 
744
 
745
+ function form( $instance ) {
746
+ global $woocommerce;
747
+
748
+ $defaults = array(
749
+ 'title' => '',
750
+ 'attribute' => '',
751
+ 'query_type' => 'and',
752
+ 'type' => 'list',
753
+ 'colors' => '',
754
+ 'labels' => '',
755
+ 'display' => 'all'
756
+ );
757
+
758
+ $instance = wp_parse_args( (array) $instance, $defaults ); ?>
759
+
760
+ <p>
761
+ <label>
762
+ <strong><?php _e( 'Title', 'yit' ) ?>:</strong><br />
763
+ <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']; ?>" />
764
+ </label>
765
+ </p>
766
+
767
+ <p>
768
+ <label for="<?php echo $this->get_field_id( 'attribute' ); ?>"><strong><?php _e( 'Attribute:', 'yit' ) ?></strong></label>
769
+ <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' ) ); ?>">
770
+ <?php yith_wcan_dropdown_attributes( $instance['attribute'] ); ?>
771
+ </select></p>
772
+
773
+ <p><label for="<?php echo $this->get_field_id( 'query_type' ); ?>"><?php _e( 'Query Type:', 'yit' ) ?></label>
774
+ <select id="<?php echo esc_attr( $this->get_field_id( 'query_type' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'query_type' ) ); ?>">
775
+ <option value="and" <?php selected( $instance['query_type'], 'and' ); ?>><?php _e( 'AND', 'yit' ); ?></option>
776
+ <option value="or" <?php selected( $instance['query_type'], 'or' ); ?>><?php _e( 'OR', 'yit' ); ?></option>
777
+ </select></p>
778
+
779
+ <p><label for="<?php echo $this->get_field_id( 'type' ); ?>"><strong><?php _e( 'Type:', 'yit' ) ?></strong></label>
780
+ <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' ) ); ?>">
781
+ <option value="list" <?php selected( 'list', $instance['type'] ) ?>><?php _e( 'List', 'yit' ) ?></option>
782
+ <option value="color" <?php selected( 'color', $instance['type'] ) ?>><?php _e( 'Color', 'yit' ) ?></option>
783
+ <option value="label" <?php selected( 'label', $instance['type'] ) ?>><?php _e( 'Label', 'yit' ) ?></option>
784
+ <option value="select" <?php selected( 'select', $instance['type'] ) ?>><?php _e( 'Dropdown', 'yit' ) ?></option>
785
+ </select>
786
+ </p>
787
+
788
+ <p id="yit-wcan-display" class="yit-wcan-display-<?php echo $instance['type'] ?>">
789
+ <label for="<?php echo $this->get_field_id( 'display' ); ?>"><strong><?php _e( 'Display (default All):', 'yit' ) ?></strong></label>
790
+ <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' ) ); ?>">
791
+ <option value="all" <?php selected( 'all', $instance['display'] ) ?>> <?php _e( 'All (no hierarchical)', 'yit' ) ?></option>
792
+ <option value="hierarchical" <?php selected( 'hierarchical', $instance['display'] ) ?>> <?php _e( 'All Hierarchical', 'yit' ) ?> </option>
793
+ <option value="parent" <?php selected( 'parent', $instance['display'] ) ?>> <?php _e( 'Only Parent', 'yit' ) ?> </option>
794
+ </select>
795
+ </p>
796
+
797
+ <div class="yith_wcan_placeholder">
798
+ <?php yith_wcan_attributes_table(
799
+ $instance['type'],
800
+ $instance['attribute'],
801
+ 'widget-' . $this->id . '-',
802
+ 'widget-' . $this->id_base . '[' . $this->number . ']',
803
+ $instance['type'] == 'color' ? $instance['colors'] : ( $instance['type'] == 'label' ? $instance['labels'] : array() ),
804
+ $instance['display']
805
+ );
806
+ ?>
807
+ </div>
808
+ <span class="spinner" style="display: none;"></span>
809
+
810
+ <input type="hidden" name="widget_id" value="widget-<?php echo $this->id ?>-" />
811
+ <input type="hidden" name="widget_name" value="widget-<?php echo $this->id_base ?>[<?php echo $this->number ?>]" />
812
+
813
+ <script>jQuery(document).trigger('yith_colorpicker');</script>
814
+ <?php
815
+ }
816
 
817
+ function update( $new_instance, $old_instance ) {
818
+ global $woocommerce;
 
819
 
820
+ $instance = $old_instance;
 
 
 
 
 
 
821
 
822
+ if ( empty( $new_instance['title'] ) ) {
823
+ $new_instance['title'] = function_exists( 'wc_attribute_label' ) ? wc_attribute_label( $new_instance['attribute'] ) : $woocommerce->attribute_label( $new_instance['attribute'] );
824
  }
825
 
826
+ $instance['title'] = strip_tags( $new_instance['title'] );
827
+ $instance['attribute'] = stripslashes( $new_instance['attribute'] );
828
+ $instance['query_type'] = stripslashes( $new_instance['query_type'] );
829
+ $instance['type'] = stripslashes( $new_instance['type'] );
830
+ $instance['colors'] = $new_instance['colors'];
831
+ $instance['labels'] = $new_instance['labels'];
832
+ $instance['display'] = $new_instance['display'];
833
+
834
+ return $instance;
835
  }
836
+
837
+ }
838
  }
widgets/class.yith-wcan-reset-navigation-widget.php CHANGED
@@ -2,112 +2,117 @@
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_Reset_Navigation_Widget extends WP_Widget {
19
 
20
- function __construct() {
21
- $widget_ops = array('classname' => 'yith-woo-ajax-reset-navigation yith-woo-ajax-navigation woocommerce widget_layered_nav', 'description' => __( 'Reset all filters setted by YITH WooCommerce Ajax Navigation', 'yit') );
22
- $control_ops = array('width' => 400, 'height' => 350);
23
- parent::__construct('yith-woo-ajax-reset-navigation', __('YITH WooCommerce Ajax Reset 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( (array) $_attributes_array, array( 'product_cat', 'product_tag' ) ) ) )
33
- return;
34
 
35
- // Price
36
- $min_price = isset( $_GET['min_price'] ) ? esc_attr( $_GET['min_price'] ) : 0;
37
- $max_price = isset( $_GET['max_price'] ) ? esc_attr( $_GET['max_price'] ) : 0;
38
 
39
- ob_start();
 
40
 
41
- if ( count( $_chosen_attributes ) > 0 || $min_price > 0 || $max_price > 0 ) {
42
- $title = isset($instance['title']) ? apply_filters('widget_title', $instance['title'], $instance, $this->id_base) : '';
43
- $label = isset($instance['label']) ? apply_filters('yith-wcan-reset-navigation-label', $instance['label'], $instance, $this->id_base) : '';
44
 
45
- //clean the url
46
- $link = yit_curPageURL();
47
- foreach( (array) $_chosen_attributes as $taxonomy => $data ) {
48
- $taxonomy_filter = str_replace( 'pa_', '', $taxonomy );
49
- $link = remove_query_arg( 'filter_' . $taxonomy_filter, $link );
50
- }
51
- if( isset( $_GET['min_price'] ) ) {
52
- $link = remove_query_arg( 'min_price', $link );
53
- }
54
- if( isset( $_GET['max_price'] ) ) {
55
- $link = remove_query_arg( 'max_price', $link );
56
  }
57
 
58
- echo $before_widget;
59
- if( $title ) {
60
- echo $before_title . $title . $after_title;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
  }
62
-
63
- echo "<div class='yith-wcan'><a class='yith-wcan-reset-navigation button' href='{$link}'>". __( $label, 'yit' ) ."</a></div>";
64
- echo $after_widget;
65
- echo ob_get_clean();
66
- } else {
67
- ob_end_clean();
68
- echo substr($before_widget, 0, strlen($before_widget) - 1) . ' style="display:none">' . $after_widget;
69
  }
70
- }
71
 
72
 
73
- function form( $instance ) {
74
- global $woocommerce;
75
 
76
- $defaults = array(
77
- 'title' => '',
78
- 'label' => __('Reset All Filters', 'yit')
79
- );
80
 
81
- $instance = wp_parse_args( (array) $instance, $defaults ); ?>
82
 
83
- <p>
84
- <label>
85
- <strong><?php _e( 'Title', 'yit' ) ?>:</strong><br />
86
- <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']; ?>" />
87
- </label>
88
- </p>
89
- <p>
90
- <label>
91
- <strong><?php _e( 'Button Label', 'yit' ) ?>:</strong><br />
92
- <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'label' ); ?>" name="<?php echo $this->get_field_name( 'label' ); ?>" value="<?php echo $instance['label']; ?>" />
93
- </label>
94
- </p>
95
 
96
- <?php
97
- }
98
 
99
- function update( $new_instance, $old_instance ) {
100
- global $woocommerce;
101
 
102
- $instance = $old_instance;
103
 
104
- if ( empty( $new_instance['title'] ) )
105
- $new_instance['title'] = function_exists('wc_attribute_label') ? wc_attribute_label( $new_instance['attribute'] ) : $woocommerce->attribute_label( $new_instance['attribute'] );
 
106
 
107
- $instance['label'] = strip_tags($new_instance['label']);
108
 
109
- return $instance;
110
- }
111
 
112
- }
113
  }
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_Reset_Navigation_Widget extends WP_Widget {
21
 
22
+ function __construct() {
23
+ $widget_ops = array( 'classname' => 'yith-woo-ajax-reset-navigation yith-woo-ajax-navigation woocommerce widget_layered_nav', 'description' => __( 'Reset all filters setted by YITH WooCommerce Ajax Navigation', 'yit' ) );
24
+ $control_ops = array( 'width' => 400, 'height' => 350 );
25
+ parent::__construct( 'yith-woo-ajax-reset-navigation', __( 'YITH WooCommerce Ajax Reset 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( (array) $_attributes_array, array( 'product_cat', 'product_tag' ) ) ) ) {
35
+ return;
 
 
 
 
 
 
 
 
 
36
  }
37
 
38
+ // Price
39
+ $min_price = isset( $_GET['min_price'] ) ? esc_attr( $_GET['min_price'] ) : 0;
40
+ $max_price = isset( $_GET['max_price'] ) ? esc_attr( $_GET['max_price'] ) : 0;
41
+
42
+ ob_start();
43
+
44
+ if ( count( $_chosen_attributes ) > 0 || $min_price > 0 || $max_price > 0 ) {
45
+ $title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base ) : '';
46
+ $label = isset( $instance['label'] ) ? apply_filters( 'yith-wcan-reset-navigation-label', $instance['label'], $instance, $this->id_base ) : '';
47
+
48
+ //clean the url
49
+ $link = yit_curPageURL();
50
+ foreach ( (array) $_chosen_attributes as $taxonomy => $data ) {
51
+ $taxonomy_filter = str_replace( 'pa_', '', $taxonomy );
52
+ $link = remove_query_arg( 'filter_' . $taxonomy_filter, $link );
53
+ }
54
+ if ( isset( $_GET['min_price'] ) ) {
55
+ $link = remove_query_arg( 'min_price', $link );
56
+ }
57
+ if ( isset( $_GET['max_price'] ) ) {
58
+ $link = remove_query_arg( 'max_price', $link );
59
+ }
60
+
61
+ echo $before_widget;
62
+ if ( $title ) {
63
+ echo $before_title . $title . $after_title;
64
+ }
65
+
66
+ echo "<div class='yith-wcan'><a class='yith-wcan-reset-navigation button' href='{$link}'>" . __( $label, 'yit' ) . "</a></div>";
67
+ echo $after_widget;
68
+ echo ob_get_clean();
69
+ }
70
+ else {
71
+ ob_end_clean();
72
+ echo substr( $before_widget, 0, strlen( $before_widget ) - 1 ) . ' style="display:none">' . $after_widget;
73
  }
 
 
 
 
 
 
 
74
  }
 
75
 
76
 
77
+ function form( $instance ) {
78
+ global $woocommerce;
79
 
80
+ $defaults = array(
81
+ 'title' => '',
82
+ 'label' => __( 'Reset All Filters', 'yit' )
83
+ );
84
 
85
+ $instance = wp_parse_args( (array) $instance, $defaults ); ?>
86
 
87
+ <p>
88
+ <label>
89
+ <strong><?php _e( 'Title', 'yit' ) ?>:</strong><br />
90
+ <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']; ?>" />
91
+ </label>
92
+ </p>
93
+ <p>
94
+ <label>
95
+ <strong><?php _e( 'Button Label', 'yit' ) ?>:</strong><br />
96
+ <input class="widefat" type="text" id="<?php echo $this->get_field_id( 'label' ); ?>" name="<?php echo $this->get_field_name( 'label' ); ?>" value="<?php echo $instance['label']; ?>" />
97
+ </label>
98
+ </p>
99
 
100
+ <?php
101
+ }
102
 
103
+ function update( $new_instance, $old_instance ) {
104
+ global $woocommerce;
105
 
106
+ $instance = $old_instance;
107
 
108
+ if ( empty( $new_instance['title'] ) ) {
109
+ $new_instance['title'] = function_exists( 'wc_attribute_label' ) ? wc_attribute_label( $new_instance['attribute'] ) : $woocommerce->attribute_label( $new_instance['attribute'] );
110
+ }
111
 
112
+ $instance['label'] = strip_tags( $new_instance['label'] );
113
 
114
+ return $instance;
115
+ }
116
 
117
+ }
118
  }
yit-common/assets/css/yith-panel.css CHANGED
@@ -1,13 +1,15 @@
1
  /* typography */
2
  .typography_container {
3
- padding-bottom:0px;
4
  }
 
5
  .typography_container .option {
6
  width: 100%;
7
  }
 
8
  .typography_container input {
9
- float:left;
10
- margin-right:14px;
11
  }
12
 
13
  .typography_container .select-wrapper {
@@ -16,17 +18,21 @@
16
  margin-right: 10px;
17
  margin-bottom: 0px !important;
18
  }
 
19
  .typography_container .select-wrapper.font-unit {
20
  width: 61px;
21
  }
 
22
  .typography_container .ui-spinner-buttons {
23
  top: 0px !important;
24
  }
 
25
  .typography_container .select-wrapper.font-style {
26
  width: 93px;
27
  }
 
28
  .typography_container .select-wrapper select {
29
- width:100%;
30
  }
31
 
32
  .typography_container .font-preview {
@@ -38,8 +44,9 @@
38
  padding: 20px;
39
  position: relative;
40
  }
 
41
  .typography_container .font-preview .refresh_container {
42
- background: rgba(255,255,255,0.82);
43
  -webkit-border-radius: 10px;
44
  -moz-border-radius: 10px;
45
  border-radius: 10px;
@@ -50,6 +57,7 @@
50
  height: 100%;
51
  z-index: 0;
52
  }
 
53
  .typography_container button.refresh {
54
  /*background: #F2F2F2 url(../images/white-grad.png) repeat-x scroll left top;*/
55
  border: 1px solid #BBB;
@@ -60,11 +68,11 @@
60
  box-sizing: content-box;
61
  color: #464646;
62
  cursor: pointer;
63
- font-size: 12px!important;
64
  line-height: 6px;
65
  margin: -16px 0px 0px -105px;
66
  padding: 3px 19px;
67
- position: absolute;
68
  text-shadow: rgba(255, 255, 255, 1) 0 1px 0;
69
  text-decoration: none;
70
  top: 50%;
@@ -72,6 +80,7 @@
72
  width: auto;
73
  height: 18px;
74
  }
 
75
  .typography_container button.refresh img {
76
  margin-right: 5px;
77
  vertical-align: middle;
1
  /* typography */
2
  .typography_container {
3
+ padding-bottom: 0px;
4
  }
5
+
6
  .typography_container .option {
7
  width: 100%;
8
  }
9
+
10
  .typography_container input {
11
+ float: left;
12
+ margin-right: 14px;
13
  }
14
 
15
  .typography_container .select-wrapper {
18
  margin-right: 10px;
19
  margin-bottom: 0px !important;
20
  }
21
+
22
  .typography_container .select-wrapper.font-unit {
23
  width: 61px;
24
  }
25
+
26
  .typography_container .ui-spinner-buttons {
27
  top: 0px !important;
28
  }
29
+
30
  .typography_container .select-wrapper.font-style {
31
  width: 93px;
32
  }
33
+
34
  .typography_container .select-wrapper select {
35
+ width: 100%;
36
  }
37
 
38
  .typography_container .font-preview {
44
  padding: 20px;
45
  position: relative;
46
  }
47
+
48
  .typography_container .font-preview .refresh_container {
49
+ background: rgba(255, 255, 255, 0.82);
50
  -webkit-border-radius: 10px;
51
  -moz-border-radius: 10px;
52
  border-radius: 10px;
57
  height: 100%;
58
  z-index: 0;
59
  }
60
+
61
  .typography_container button.refresh {
62
  /*background: #F2F2F2 url(../images/white-grad.png) repeat-x scroll left top;*/
63
  border: 1px solid #BBB;
68
  box-sizing: content-box;
69
  color: #464646;
70
  cursor: pointer;
71
+ font-size: 12px !important;
72
  line-height: 6px;
73
  margin: -16px 0px 0px -105px;
74
  padding: 3px 19px;
75
+ position: absolute;
76
  text-shadow: rgba(255, 255, 255, 1) 0 1px 0;
77
  text-decoration: none;
78
  top: 50%;
80
  width: auto;
81
  height: 18px;
82
  }
83
+
84
  .typography_container button.refresh img {
85
  margin-right: 5px;
86
  vertical-align: middle;
yit-common/assets/js/google_fonts.json CHANGED
@@ -1 +1 @@
1
- {"items":["ABeeZee","Abel","Abril Fatface","Aclonica","Acme","Actor","Adamina","Advent Pro","Aguafina Script","Akronim","Aladin","Aldrich","Alef","Alegreya","Alegreya SC","Alex Brush","Alfa Slab One","Alice","Alike","Alike Angular","Allan","Allerta","Allerta Stencil","Allura","Almendra","Almendra Display","Almendra SC","Amarante","Amaranth","Amatic SC","Amethysta","Anaheim","Andada","Andika","Angkor","Annie Use Your Telescope","Anonymous Pro","Antic","Antic Didone","Antic Slab","Anton","Arapey","Arbutus","Arbutus Slab","Architects Daughter","Archivo Black","Archivo Narrow","Arimo","Arizonia","Armata","Artifika","Arvo","Asap","Asset","Astloch","Asul","Atomic Age","Aubrey","Audiowide","Autour One","Average","Average Sans","Averia Gruesa Libre","Averia Libre","Averia Sans Libre","Averia Serif Libre","Bad Script","Balthazar","Bangers","Basic","Battambang","Baumans","Bayon","Belgrano","Belleza","BenchNine","Bentham","Berkshire Swash","Bevan","Bigelow Rules","Bigshot One","Bilbo","Bilbo Swash Caps","Bitter","Black Ops One","Bokor","Bonbon","Boogaloo","Bowlby One","Bowlby One SC","Brawler","Bree Serif","Bubblegum Sans","Bubbler One","Buda:300","Buenard","Butcherman","Butterfly Kids","Cabin","Cabin Condensed","Cabin Sketch","Caesar Dressing","Cagliostro","Calligraffitti","Cambo","Candal","Cantarell","Cantata One","Cantora One","Capriola","Cardo","Carme","Carrois Gothic","Carrois Gothic SC","Carter One","Caudex","Cedarville Cursive","Ceviche One","Changa One","Chango","Chau Philomene One","Chela One","Chelsea Market","Chenla","Cherry Cream Soda","Cherry Swash","Chewy","Chicle","Chivo","Cinzel","Cinzel Decorative","Clicker Script","Coda","Coda Caption:800","Codystar","Combo","Comfortaa","Coming Soon","Concert One","Condiment","Content","Contrail One","Convergence","Cookie","Copse","Corben","Courgette","Cousine","Coustard","Covered By Your Grace","Crafty Girls","Creepster","Crete Round","Crimson Text","Croissant One","Crushed","Cuprum","Cutive","Cutive Mono","Damion","Dancing Script","Dangrek","Dawning of a New Day","Days One","Delius","Delius Swash Caps","Delius Unicase","Della Respira","Denk One","Devonshire","Didact Gothic","Diplomata","Diplomata SC","Domine","Donegal One","Doppio One","Dorsa","Dosis","Dr Sugiyama","Droid Sans","Droid Sans Mono","Droid Serif","Duru Sans","Dynalight","EB Garamond","Eagle Lake","Eater","Economica","Electrolize","Elsie","Elsie Swash Caps","Emblema One","Emilys Candy","Engagement","Englebert","Enriqueta","Erica One","Esteban","Euphoria Script","Ewert","Exo","Expletus Sans","Fanwood Text","Fascinate","Fascinate Inline","Faster One","Fasthand","Federant","Federo","Felipa","Fenix","Finger Paint","Fjalla One","Fjord One","Flamenco","Flavors","Fondamento","Fontdiner Swanky","Forum","Francois One","Freckle Face","Fredericka the Great","Fredoka One","Freehand","Fresca","Frijole","Fruktur","Fugaz One","GFS Didot","GFS Neohellenic","Gabriela","Gafata","Galdeano","Galindo","Gentium Basic","Gentium Book Basic","Geo","Geostar","Geostar Fill","Germania One","Gilda Display","Give You Glory","Glass Antiqua","Glegoo","Gloria Hallelujah","Goblin One","Gochi Hand","Gorditas","Goudy Bookletter 1911","Graduate","Grand Hotel","Gravitas One","Great Vibes","Griffy","Gruppo","Gudea","Habibi","Hammersmith One","Hanalei","Hanalei Fill","Handlee","Hanuman","Happy Monkey","Headland One","Henny Penny","Herr Von Muellerhoff","Holtwood One SC","Homemade Apple","Homenaje","IM Fell DW Pica","IM Fell DW Pica SC","IM Fell Double Pica","IM Fell Double Pica SC","IM Fell English","IM Fell English SC","IM Fell French Canon","IM Fell French Canon SC","IM Fell Great Primer","IM Fell Great Primer SC","Iceberg","Iceland","Imprima","Inconsolata","Inder","Indie Flower","Inika","Irish Grover","Istok Web","Italiana","Italianno","Jacques Francois","Jacques Francois Shadow","Jim Nightshade","Jockey One","Jolly Lodger","Josefin Sans","Josefin Slab","Joti One","Judson","Julee","Julius Sans One","Junge","Jura","Just Another Hand","Just Me Again Down Here","Kameron","Karla","Kaushan Script","Kavoon","Keania One","Kelly Slab","Kenia","Khmer","Kite One","Knewave","Kotta One","Koulen","Kranky","Kreon","Kristi","Krona One","La Belle Aurore","Lancelot","Lato","League Script","Leckerli One","Ledger","Lekton","Lemon","Libre Baskerville","Life Savers","Lilita One","Limelight","Linden Hill","Lobster","Lobster Two","Londrina Outline","Londrina Shadow","Londrina Sketch","Londrina Solid","Lora","Love Ya Like A Sister","Loved by the King","Lovers Quarrel","Luckiest Guy","Lusitana","Lustria","Macondo","Macondo Swash Caps","Magra","Maiden Orange","Mako","Marcellus","Marcellus SC","Marck Script","Margarine","Marko One","Marmelad","Marvel","Mate","Mate SC","Maven Pro","McLaren","Meddon","MedievalSharp","Medula One","Megrim","Meie Script","Merienda","Merienda One","Merriweather","Merriweather Sans","Metal","Metal Mania","Metamorphous","Metrophobic","Michroma","Milonga","Miltonian","Miltonian Tattoo","Miniver","Miss Fajardose","Modern Antiqua","Molengo","Molle:italic","Monda","Monofett","Monoton","Monsieur La Doulaise","Montaga","Montez","Montserrat","Montserrat Alternates","Montserrat Subrayada","Moul","Moulpali","Mountains of Christmas","Mouse Memoirs","Mr Bedfort","Mr Dafoe","Mr De Haviland","Mrs Saint Delafield","Mrs Sheppards","Muli","Mystery Quest","Neucha","Neuton","New Rocker","News Cycle","Niconne","Nixie One","Nobile","Nokora","Norican","Nosifer","Nothing You Could Do","Noticia Text","Noto Sans","Noto Serif","Nova Cut","Nova Flat","Nova Mono","Nova Oval","Nova Round","Nova Script","Nova Slim","Nova Square","Numans","Nunito","Odor Mean Chey","Offside","Old Standard TT","Oldenburg","Oleo Script","Oleo Script Swash Caps","Open Sans","Open Sans Condensed:300","Open Sans Condensed:300italic","Open Sans Condensed:700","Oranienbaum","Orbitron","Oregano","Orienta","Original Surfer","Oswald","Over the Rainbow","Overlock","Overlock SC","Ovo","Oxygen","Oxygen Mono","PT Mono","PT Sans","PT Sans Caption","PT Sans Narrow","PT Serif","PT Serif Caption","Pacifico","Paprika","Parisienne","Passero One","Passion One","Patrick Hand","Patrick Hand SC","Patua One","Paytone One","Peralta","Permanent Marker","Petit Formal Script","Petrona","Philosopher","Piedra","Pinyon Script","Pirata One","Plaster","Play","Playball","Playfair Display","Playfair Display SC","Podkova","Poiret One","Poller One","Poly","Pompiere","Pontano Sans","Port Lligat Sans","Port Lligat Slab","Prata","Preahvihear","Press Start 2P","Princess Sofia","Prociono","Prosto One","Puritan","Purple Purse","Quando","Quantico","Quattrocento","Quattrocento Sans","Questrial","Quicksand","Quintessential","Qwigley","Racing Sans One","Radley","Raleway","Raleway Dots","Rambla","Rammetto One","Ranchers","Rancho","Rationale","Redressed","Reenie Beanie","Revalia","Ribeye","Ribeye Marrow","Righteous","Risque","Roboto","Roboto Condensed","Roboto Slab","Rochester","Rock Salt","Rokkitt","Romanesco","Ropa Sans","Rosario","Rosarivo","Rouge Script","Ruda","Rufina","Ruge Boogie","Ruluko","Rum Raisin","Ruslan Display","Russo One","Ruthie","Rye","Sacramento","Sail","Salsa","Sanchez","Sancreek","Sansita One","Sarina","Satisfy","Scada","Schoolbell","Seaweed Script","Sevillana","Seymour One","Shadows Into Light","Shadows Into Light Two","Shanti","Share","Share Tech","Share Tech Mono","Shojumaru","Short Stack","Siemreap","Sigmar One","Signika","Signika Negative","Simonetta","Sintony","Sirin Stencil","Six Caps","Skranji","Slackey","Smokum","Smythe","Sniglet:800","Snippet","Snowburst One","Sofadi One","Sofia","Sonsie One","Sorts Mill Goudy","Source Code Pro","Source Sans Pro","Special Elite","Spicy Rice","Spinnaker","Spirax","Squada One","Stalemate","Stalinist One","Stardos Stencil","Stint Ultra Condensed","Stint Ultra Expanded","Stoke","Strait","Sue Ellen Francisco","Sunshiney","Supermercado One","Suwannaphum","Swanky and Moo Moo","Syncopate","Tangerine","Taprom","Tauri","Telex","Tenor Sans","Text Me One","The Girl Next Door","Tienne","Tinos","Titan One","Titillium Web","Trade Winds","Trocchi","Trochut","Trykker","Tulpen One","Ubuntu","Ubuntu Condensed","Ubuntu Mono","Ultra","Uncial Antiqua","Underdog","Unica One","UnifrakturCook:700","UnifrakturMaguntia","Unkempt","Unlock","Unna","VT323","Vampiro One","Varela","Varela Round","Vast Shadow","Vibur","Vidaloka","Viga","Voces","Volkhov","Vollkorn","Voltaire","Waiting for the Sunrise","Wallpoet","Walter Turncoat","Warnes","Wellfleet","Wendy One","Wire One","Yanone Kaffeesatz","Yellowtail","Yeseva One","Yesteryear","Zeyada"]}
1
+ {"items": ["ABeeZee", "Abel", "Abril Fatface", "Aclonica", "Acme", "Actor", "Adamina", "Advent Pro", "Aguafina Script", "Akronim", "Aladin", "Aldrich", "Alef", "Alegreya", "Alegreya SC", "Alex Brush", "Alfa Slab One", "Alice", "Alike", "Alike Angular", "Allan", "Allerta", "Allerta Stencil", "Allura", "Almendra", "Almendra Display", "Almendra SC", "Amarante", "Amaranth", "Amatic SC", "Amethysta", "Anaheim", "Andada", "Andika", "Angkor", "Annie Use Your Telescope", "Anonymous Pro", "Antic", "Antic Didone", "Antic Slab", "Anton", "Arapey", "Arbutus", "Arbutus Slab", "Architects Daughter", "Archivo Black", "Archivo Narrow", "Arimo", "Arizonia", "Armata", "Artifika", "Arvo", "Asap", "Asset", "Astloch", "Asul", "Atomic Age", "Aubrey", "Audiowide", "Autour One", "Average", "Average Sans", "Averia Gruesa Libre", "Averia Libre", "Averia Sans Libre", "Averia Serif Libre", "Bad Script", "Balthazar", "Bangers", "Basic", "Battambang", "Baumans", "Bayon", "Belgrano", "Belleza", "BenchNine", "Bentham", "Berkshire Swash", "Bevan", "Bigelow Rules", "Bigshot One", "Bilbo", "Bilbo Swash Caps", "Bitter", "Black Ops One", "Bokor", "Bonbon", "Boogaloo", "Bowlby One", "Bowlby One SC", "Brawler", "Bree Serif", "Bubblegum Sans", "Bubbler One", "Buda:300", "Buenard", "Butcherman", "Butterfly Kids", "Cabin", "Cabin Condensed", "Cabin Sketch", "Caesar Dressing", "Cagliostro", "Calligraffitti", "Cambo", "Candal", "Cantarell", "Cantata One", "Cantora One", "Capriola", "Cardo", "Carme", "Carrois Gothic", "Carrois Gothic SC", "Carter One", "Caudex", "Cedarville Cursive", "Ceviche One", "Changa One", "Chango", "Chau Philomene One", "Chela One", "Chelsea Market", "Chenla", "Cherry Cream Soda", "Cherry Swash", "Chewy", "Chicle", "Chivo", "Cinzel", "Cinzel Decorative", "Clicker Script", "Coda", "Coda Caption:800", "Codystar", "Combo", "Comfortaa", "Coming Soon", "Concert One", "Condiment", "Content", "Contrail One", "Convergence", "Cookie", "Copse", "Corben", "Courgette", "Cousine", "Coustard", "Covered By Your Grace", "Crafty Girls", "Creepster", "Crete Round", "Crimson Text", "Croissant One", "Crushed", "Cuprum", "Cutive", "Cutive Mono", "Damion", "Dancing Script", "Dangrek", "Dawning of a New Day", "Days One", "Delius", "Delius Swash Caps", "Delius Unicase", "Della Respira", "Denk One", "Devonshire", "Didact Gothic", "Diplomata", "Diplomata SC", "Domine", "Donegal One", "Doppio One", "Dorsa", "Dosis", "Dr Sugiyama", "Droid Sans", "Droid Sans Mono", "Droid Serif", "Duru Sans", "Dynalight", "EB Garamond", "Eagle Lake", "Eater", "Economica", "Electrolize", "Elsie", "Elsie Swash Caps", "Emblema One", "Emilys Candy", "Engagement", "Englebert", "Enriqueta", "Erica One", "Esteban", "Euphoria Script", "Ewert", "Exo", "Expletus Sans", "Fanwood Text", "Fascinate", "Fascinate Inline", "Faster One", "Fasthand", "Federant", "Federo", "Felipa", "Fenix", "Finger Paint", "Fjalla One", "Fjord One", "Flamenco", "Flavors", "Fondamento", "Fontdiner Swanky", "Forum", "Francois One", "Freckle Face", "Fredericka the Great", "Fredoka One", "Freehand", "Fresca", "Frijole", "Fruktur", "Fugaz One", "GFS Didot", "GFS Neohellenic", "Gabriela", "Gafata", "Galdeano", "Galindo", "Gentium Basic", "Gentium Book Basic", "Geo", "Geostar", "Geostar Fill", "Germania One", "Gilda Display", "Give You Glory", "Glass Antiqua", "Glegoo", "Gloria Hallelujah", "Goblin One", "Gochi Hand", "Gorditas", "Goudy Bookletter 1911", "Graduate", "Grand Hotel", "Gravitas One", "Great Vibes", "Griffy", "Gruppo", "Gudea", "Habibi", "Hammersmith One", "Hanalei", "Hanalei Fill", "Handlee", "Hanuman", "Happy Monkey", "Headland One", "Henny Penny", "Herr Von Muellerhoff", "Holtwood One SC", "Homemade Apple", "Homenaje", "IM Fell DW Pica", "IM Fell DW Pica SC", "IM Fell Double Pica", "IM Fell Double Pica SC", "IM Fell English", "IM Fell English SC", "IM Fell French Canon", "IM Fell French Canon SC", "IM Fell Great Primer", "IM Fell Great Primer SC", "Iceberg", "Iceland", "Imprima", "Inconsolata", "Inder", "Indie Flower", "Inika", "Irish Grover", "Istok Web", "Italiana", "Italianno", "Jacques Francois", "Jacques Francois Shadow", "Jim Nightshade", "Jockey One", "Jolly Lodger", "Josefin Sans", "Josefin Slab", "Joti One", "Judson", "Julee", "Julius Sans One", "Junge", "Jura", "Just Another Hand", "Just Me Again Down Here", "Kameron", "Karla", "Kaushan Script", "Kavoon", "Keania One", "Kelly Slab", "Kenia", "Khmer", "Kite One", "Knewave", "Kotta One", "Koulen", "Kranky", "Kreon", "Kristi", "Krona One", "La Belle Aurore", "Lancelot", "Lato", "League Script", "Leckerli One", "Ledger", "Lekton", "Lemon", "Libre Baskerville", "Life Savers", "Lilita One", "Limelight", "Linden Hill", "Lobster", "Lobster Two", "Londrina Outline", "Londrina Shadow", "Londrina Sketch", "Londrina Solid", "Lora", "Love Ya Like A Sister", "Loved by the King", "Lovers Quarrel", "Luckiest Guy", "Lusitana", "Lustria", "Macondo", "Macondo Swash Caps", "Magra", "Maiden Orange", "Mako", "Marcellus", "Marcellus SC", "Marck Script", "Margarine", "Marko One", "Marmelad", "Marvel", "Mate", "Mate SC", "Maven Pro", "McLaren", "Meddon", "MedievalSharp", "Medula One", "Megrim", "Meie Script", "Merienda", "Merienda One", "Merriweather", "Merriweather Sans", "Metal", "Metal Mania", "Metamorphous", "Metrophobic", "Michroma", "Milonga", "Miltonian", "Miltonian Tattoo", "Miniver", "Miss Fajardose", "Modern Antiqua", "Molengo", "Molle:italic", "Monda", "Monofett", "Monoton", "Monsieur La Doulaise", "Montaga", "Montez", "Montserrat", "Montserrat Alternates", "Montserrat Subrayada", "Moul", "Moulpali", "Mountains of Christmas", "Mouse Memoirs", "Mr Bedfort", "Mr Dafoe", "Mr De Haviland", "Mrs Saint Delafield", "Mrs Sheppards", "Muli", "Mystery Quest", "Neucha", "Neuton", "New Rocker", "News Cycle", "Niconne", "Nixie One", "Nobile", "Nokora", "Norican", "Nosifer", "Nothing You Could Do", "Noticia Text", "Noto Sans", "Noto Serif", "Nova Cut", "Nova Flat", "Nova Mono", "Nova Oval", "Nova Round", "Nova Script", "Nova Slim", "Nova Square", "Numans", "Nunito", "Odor Mean Chey", "Offside", "Old Standard TT", "Oldenburg", "Oleo Script", "Oleo Script Swash Caps", "Open Sans", "Open Sans Condensed:300", "Open Sans Condensed:300italic", "Open Sans Condensed:700", "Oranienbaum", "Orbitron", "Oregano", "Orienta", "Original Surfer", "Oswald", "Over the Rainbow", "Overlock", "Overlock SC", "Ovo", "Oxygen", "Oxygen Mono", "PT Mono", "PT Sans", "PT Sans Caption", "PT Sans Narrow", "PT Serif", "PT Serif Caption", "Pacifico", "Paprika", "Parisienne", "Passero One", "Passion One", "Patrick Hand", "Patrick Hand SC", "Patua One", "Paytone One", "Peralta", "Permanent Marker", "Petit Formal Script", "Petrona", "Philosopher", "Piedra", "Pinyon Script", "Pirata One", "Plaster", "Play", "Playball", "Playfair Display", "Playfair Display SC", "Podkova", "Poiret One", "Poller One", "Poly", "Pompiere", "Pontano Sans", "Port Lligat Sans", "Port Lligat Slab", "Prata", "Preahvihear", "Press Start 2P", "Princess Sofia", "Prociono", "Prosto One", "Puritan", "Purple Purse", "Quando", "Quantico", "Quattrocento", "Quattrocento Sans", "Questrial", "Quicksand", "Quintessential", "Qwigley", "Racing Sans One", "Radley", "Raleway", "Raleway Dots", "Rambla", "Rammetto One", "Ranchers", "Rancho", "Rationale", "Redressed", "Reenie Beanie", "Revalia", "Ribeye", "Ribeye Marrow", "Righteous", "Risque", "Roboto", "Roboto Condensed", "Roboto Slab", "Rochester", "Rock Salt", "Rokkitt", "Romanesco", "Ropa Sans", "Rosario", "Rosarivo", "Rouge Script", "Ruda", "Rufina", "Ruge Boogie", "Ruluko", "Rum Raisin", "Ruslan Display", "Russo One", "Ruthie", "Rye", "Sacramento", "Sail", "Salsa", "Sanchez", "Sancreek", "Sansita One", "Sarina", "Satisfy", "Scada", "Schoolbell", "Seaweed Script", "Sevillana", "Seymour One", "Shadows Into Light", "Shadows Into Light Two", "Shanti", "Share", "Share Tech", "Share Tech Mono", "Shojumaru", "Short Stack", "Siemreap", "Sigmar One", "Signika", "Signika Negative", "Simonetta", "Sintony", "Sirin Stencil", "Six Caps", "Skranji", "Slackey", "Smokum", "Smythe", "Sniglet:800", "Snippet", "Snowburst One", "Sofadi One", "Sofia", "Sonsie One", "Sorts Mill Goudy", "Source Code Pro", "Source Sans Pro", "Special Elite", "Spicy Rice", "Spinnaker", "Spirax", "Squada One", "Stalemate", "Stalinist One", "Stardos Stencil", "Stint Ultra Condensed", "Stint Ultra Expanded", "Stoke", "Strait", "Sue Ellen Francisco", "Sunshiney", "Supermercado One", "Suwannaphum", "Swanky and Moo Moo", "Syncopate", "Tangerine", "Taprom", "Tauri", "Telex", "Tenor Sans", "Text Me One", "The Girl Next Door", "Tienne", "Tinos", "Titan One", "Titillium Web", "Trade Winds", "Trocchi", "Trochut", "Trykker", "Tulpen One", "Ubuntu", "Ubuntu Condensed", "Ubuntu Mono", "Ultra", "Uncial Antiqua", "Underdog", "Unica One", "UnifrakturCook:700", "UnifrakturMaguntia", "Unkempt", "Unlock", "Unna", "VT323", "Vampiro One", "Varela", "Varela Round", "Vast Shadow", "Vibur", "Vidaloka", "Viga", "Voces", "Volkhov", "Vollkorn", "Voltaire", "Waiting for the Sunrise", "Wallpoet", "Walter Turncoat", "Warnes", "Wellfleet", "Wendy One", "Wire One", "Yanone Kaffeesatz", "Yellowtail", "Yeseva One", "Yesteryear", "Zeyada"]}
yit-common/assets/js/yith-panel.js CHANGED
@@ -1,34 +1,35 @@
1
- jQuery(document).ready(function($){
2
 
3
  //image uploader
4
  var _custom_media = true,
5
  _orig_send_attachment = wp.media.editor.send.attachment;
6
 
7
- $('.uploader .button').click(function(e) {
8
  var send_attachment_bkp = wp.media.editor.send.attachment;
9
  var button = $(this);
10
  var id = button.attr('id').replace('_button', '');
11
  _custom_media = true;
12
- wp.media.editor.send.attachment = function(props, attachment){
13
- if ( _custom_media ) {
14
- $("#"+id).val(attachment.url);
15
  } else {
16
- return _orig_send_attachment.apply( this, [props, attachment] );
17
- };
 
18
  }
19
 
20
  wp.media.editor.open(button);
21
  return false;
22
  });
23
 
24
- $('.add_media').on('click', function(){
25
  _custom_media = false;
26
  });
27
 
28
  //color-picker
29
  $('.panel-colorpicker').wpColorPicker({
30
- change: function(event, ui){
31
- $('#'+event.target.id).parents('.typography_container').find('.font-preview > p').css('color', ui.color.toString());
32
  }
33
  });
34
 
@@ -37,57 +38,57 @@ jQuery(document).ready(function($){
37
 
38
  //datepicker
39
  $('.panel-datepicker').datepicker({
40
- showOtherMonths: true,
41
  selectOtherMonths: true,
42
- numberOfMonths: 2,
43
- minDate: 0
44
  });
45
 
46
  //skin
47
- $('select.skin').on('change', function(){
48
  var img_path = $(this).data('path');
49
- $(this).siblings('.skin-preview').html('<img src="'+ img_path + $(this).val() + '.jpg' +'" alt="preview" />');
50
  }).change();
51
  });
52
 
53
  // typography
54
- (function( window, $, undefined ) {
55
 
56
- $.yit_panel_typography = function( options, element ) {
57
- this.element = $( element );
58
- this._init( options );
59
  };
60
 
61
- $.yit_panel_typography.defaults = {
62
- elements : {
63
- size: '.typography_size',
64
- unit: '.typography_unit',
65
- family: '.typography_family',
66
- style: '.typography_style',
67
- color: '.typography_color',
68
  preview: '.font-preview p',
69
  refresh: '.refresh'
70
  }
71
  };
72
 
73
  $.yit_panel_typography.prototype = {
74
- _init : function( options ) {
75
- this.options = $.extend( true, {}, $.yit_panel_typography.defaults, options );
76
 
77
  //init the options string
78
- if( yit_family_string == '' ) {
79
  //web fonts
80
  var web_fonts = $.parseJSON(yit_web_fonts);
81
- yit_family_string += '<optgroup label="Web Fonts">';
82
- $.each(web_fonts.items, function(i,v){
83
  yit_family_string += '<option>' + v + '</option>';
84
  });
85
  yit_family_string += '</optgroup>';
86
 
87
  //google fonts
88
  var google_fonts = $.parseJSON(yit_google_fonts);
89
- yit_family_string += '<optgroup label="Google Fonts">';
90
- $.each(google_fonts.items, function(i,v){
91
  yit_family_string += '<option>' + v + '</option>';
92
  });
93
  yit_family_string += '</optgroup>';
@@ -97,70 +98,70 @@ jQuery(document).ready(function($){
97
  this._initEvents();
98
  },
99
 
100
- _loadElements : function() {
101
  var elements = this.options.elements;
102
  var container = this.element;
103
 
104
- for( var el in elements) {
105
- elements[el] = container.find( elements[el] );
106
  }
107
  },
108
 
109
- _initEvents : function() {
110
  var elements = this.options.elements;
111
  var self = this;
112
 
113
  //refresh
114
  var refresh = elements.refresh;
115
- refresh.on('click', function(e){
116
  e.preventDefault();
117
 
118
- $(this).parent().fadeOut( 'slow' );
119
 
120
  //Set current value, before trigger change event
121
 
122
  //Color
123
- elements.preview.css( 'color', elements.color.val() );
124
 
125
  //Font size
126
  var size = elements.size.val();
127
  var unit = elements.unit.val();
128
 
129
- elements.preview.css( 'font-size', size + unit );
130
- elements.preview.css( 'line-height', ( unit == 'em' || unit == 'rem' ? Number( size ) + 0.4 : Number ( size ) + 4 ) + unit );
131
 
132
  //Font style
133
  var style = elements.style.val();
134
 
135
- if( style == 'italic' ) {
136
- elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'italic' });
137
- } else if( style == 'bold' ) {
138
- elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'normal' });
139
- } else if( style == 'extra-bold' ) {
140
- elements.preview.css({ 'font-weight' : '800', 'font-style' : 'normal' });
141
- } else if( style == 'bold-italic' ) {
142
- elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'italic' });
143
  } else {
144
- elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'normal' });
145
  }
146
 
147
  //Font Family
148
- var group = elements.family.find( 'option:selected' ).parent().attr( 'label' );
149
 
150
- if( group == 'Web fonts' ) {
151
  //Web font
152
- elements.preview.css( 'font-family', elements.family.val() );
153
  } else {
154
  //Google font
155
  WebFontConfig = {
156
- google: {
157
- families: [ elements.family.find('option:selected' ).text() ] },
158
- fontactive: function( fontFamily, fontDescription ) {
159
- elements.preview.css( 'font-family', fontFamily );
160
  }
161
  };
162
 
163
- (function() {
164
  var wf = document.createElement('script');
165
  wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
166
  '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
@@ -174,59 +175,63 @@ jQuery(document).ready(function($){
174
  });
175
 
176
  //font size, font unit
177
- $([elements.size, elements.unit]).each(function(){
178
- $(this).on('change', function(){
179
- if( elements.refresh.is( ':visible' ) ) { return; }
 
 
180
 
181
  var size = elements.size.val();
182
  var unit = elements.unit.val();
183
 
184
  elements.preview.css({
185
- 'font-size' : size + unit,
186
- 'line-height' : ( unit == 'em' || unit == 'rem' ? Number( size ) + 0.4 : Number ( size ) + 4 ) + unit
187
- }).trigger( 'resize' );
188
  });
189
  });
190
 
191
  //font family
192
  var family = elements.family;
193
- family.on('mousedown', function(e){
194
  var t = $(this);
195
- if(t.data('instance') == false) {
196
  var currentElement = {
197
- 'value' : t.val(),
198
- 'text' : t.find('option:selected').text()
199
  };
200
 
201
  t.html(yit_family_string)
202
  .find('option')
203
- .filter(function(){
204
  return $(this).text() == currentElement.text;
205
  }).attr('selected', true);
206
 
207
  t.data('instance', 'true');
208
  }
209
  });
210
- family.on('change', function(){
211
- if( elements.refresh.is( ':visible' ) ) { return; }
 
 
212
 
213
- var group = $( this ).find( 'option:selected' ).parent().attr( 'label' );
214
 
215
- if( group == 'Web fonts' ) {
216
  //Web font
217
- elements.preview.css( 'font-family', $( this ).val() );
218
  } else {
219
  //Google font
220
  WebFontConfig = {
221
- google: {
222
- families: [ $( this ).val() ]
223
  },
224
- fontactive: function( fontFamily, fontDescription ) {
225
- elements.preview.css( 'font-family', fontFamily );
226
  }
227
  };
228
 
229
- (function() {
230
  var wf = document.createElement('script');
231
  wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
232
  '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
@@ -238,60 +243,62 @@ jQuery(document).ready(function($){
238
  })();
239
  }
240
 
241
- elements.preview.trigger( 'resize' );
242
  });
243
 
244
- elements.style.on('change', function(){
245
- if( elements.refresh.is( ':visible' ) ) { return; }
 
 
246
 
247
- var style = $( this ).val();
248
 
249
- if( style == 'italic' ) {
250
- elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'italic' });
251
- } else if( style == 'bold' ) {
252
- elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'normal' });
253
- } else if( style == 'extra-bold' ) {
254
- elements.preview.css({ 'font-weight' : '800', 'font-style' : 'normal' });
255
- } else if( style == 'bold-italic' ) {
256
- elements.preview.css({ 'font-weight' : 'bold', 'font-style' : 'italic' });
257
  } else {
258
- elements.preview.css({ 'font-weight' : 'normal', 'font-style' : 'normal' });
259
  }
260
 
261
- elements.preview.trigger( 'resize' );
262
  });
263
 
264
  //preview
265
- elements.preview.resize(function(){
266
- var box = $(this).parents('.yit-box');
267
- $(this).parents('form').height( box.height() );
268
  });
269
  }
270
  };
271
 
272
- $.fn.yit_panel_typography = function( options ) {
273
- if ( typeof options === 'string' ) {
274
- var args = Array.prototype.slice.call( arguments, 1 );
275
 
276
- this.each(function() {
277
- var instance = $.data( this, 'yit_panel_typography' );
278
- if ( !instance ) {
279
- console.error( "cannot call methods on yit_checkout prior to initialization; " +
280
- "attempted to call method '" + options + "'" );
281
  return;
282
  }
283
- if ( !$.isFunction( instance[options] ) || options.charAt(0) === "_" ) {
284
- console.error( "no such method '" + options + "' for yit_panel_typography instance" );
285
  return;
286
  }
287
- instance[ options ].apply( instance, args );
288
  });
289
  }
290
  else {
291
- this.each(function() {
292
- var instance = $.data( this, 'yit_panel_typography' );
293
- if ( !instance ) {
294
- $.data( this, 'yit_panel_typography', new $.yit_panel_typography( options, this ) );
295
  }
296
  });
297
  }
@@ -299,4 +306,4 @@ jQuery(document).ready(function($){
299
  };
300
 
301
 
302
- })( window, jQuery );
1
+ jQuery(document).ready(function ($) {
2
 
3
  //image uploader
4
  var _custom_media = true,
5
  _orig_send_attachment = wp.media.editor.send.attachment;
6
 
7
+ $('.uploader .button').click(function (e) {
8
  var send_attachment_bkp = wp.media.editor.send.attachment;
9
  var button = $(this);
10
  var id = button.attr('id').replace('_button', '');
11
  _custom_media = true;
12
+ wp.media.editor.send.attachment = function (props, attachment) {
13
+ if (_custom_media) {
14
+ $("#" + id).val(attachment.url);
15
  } else {
16
+ return _orig_send_attachment.apply(this, [props, attachment]);
17
+ }
18
+ ;
19
  }
20
 
21
  wp.media.editor.open(button);
22
  return false;
23
  });
24
 
25
+ $('.add_media').on('click', function () {
26
  _custom_media = false;
27
  });
28
 
29
  //color-picker
30
  $('.panel-colorpicker').wpColorPicker({
31
+ change: function (event, ui) {
32
+ $('#' + event.target.id).parents('.typography_container').find('.font-preview > p').css('color', ui.color.toString());
33
  }
34
  });
35
 
38
 
39
  //datepicker
40
  $('.panel-datepicker').datepicker({
41
+ showOtherMonths : true,
42
  selectOtherMonths: true,
43
+ numberOfMonths : 2,
44
+ minDate : 0
45
  });
46
 
47
  //skin
48
+ $('select.skin').on('change',function () {
49
  var img_path = $(this).data('path');
50
+ $(this).siblings('.skin-preview').html('<img src="' + img_path + $(this).val() + '.jpg' + '" alt="preview" />');
51
  }).change();
52
  });
53
 
54
  // typography
55
+ (function (window, $, undefined) {
56
 
57
+ $.yit_panel_typography = function (options, element) {
58
+ this.element = $(element);
59
+ this._init(options);
60
  };
61
 
62
+ $.yit_panel_typography.defaults = {
63
+ elements: {
64
+ size : '.typography_size',
65
+ unit : '.typography_unit',
66
+ family : '.typography_family',
67
+ style : '.typography_style',
68
+ color : '.typography_color',
69
  preview: '.font-preview p',
70
  refresh: '.refresh'
71
  }
72
  };
73
 
74
  $.yit_panel_typography.prototype = {
75
+ _init: function (options) {
76
+ this.options = $.extend(true, {}, $.yit_panel_typography.defaults, options);
77
 
78
  //init the options string
79
+ if (yit_family_string == '') {
80
  //web fonts
81
  var web_fonts = $.parseJSON(yit_web_fonts);
82
+ yit_family_string += '<optgroup label="Web Fonts">';
83
+ $.each(web_fonts.items, function (i, v) {
84
  yit_family_string += '<option>' + v + '</option>';
85
  });
86
  yit_family_string += '</optgroup>';
87
 
88
  //google fonts
89
  var google_fonts = $.parseJSON(yit_google_fonts);
90
+ yit_family_string += '<optgroup label="Google Fonts">';
91
+ $.each(google_fonts.items, function (i, v) {
92
  yit_family_string += '<option>' + v + '</option>';
93
  });
94
  yit_family_string += '</optgroup>';
98
  this._initEvents();
99
  },
100
 
101
+ _loadElements: function () {
102
  var elements = this.options.elements;
103
  var container = this.element;
104
 
105
+ for (var el in elements) {
106
+ elements[el] = container.find(elements[el]);
107
  }
108
  },
109
 
110
+ _initEvents: function () {
111
  var elements = this.options.elements;
112
  var self = this;
113
 
114
  //refresh
115
  var refresh = elements.refresh;
116
+ refresh.on('click', function (e) {
117
  e.preventDefault();
118
 
119
+ $(this).parent().fadeOut('slow');
120
 
121
  //Set current value, before trigger change event
122
 
123
  //Color
124
+ elements.preview.css('color', elements.color.val());
125
 
126
  //Font size
127
  var size = elements.size.val();
128
  var unit = elements.unit.val();
129
 
130
+ elements.preview.css('font-size', size + unit);
131
+ elements.preview.css('line-height', ( unit == 'em' || unit == 'rem' ? Number(size) + 0.4 : Number(size) + 4 ) + unit);
132
 
133
  //Font style
134
  var style = elements.style.val();
135
 
136
+ if (style == 'italic') {
137
+ elements.preview.css({ 'font-weight': 'normal', 'font-style': 'italic' });
138
+ } else if (style == 'bold') {
139
+ elements.preview.css({ 'font-weight': 'bold', 'font-style': 'normal' });
140
+ } else if (style == 'extra-bold') {
141
+ elements.preview.css({ 'font-weight': '800', 'font-style': 'normal' });
142
+ } else if (style == 'bold-italic') {
143
+ elements.preview.css({ 'font-weight': 'bold', 'font-style': 'italic' });
144
  } else {
145
+ elements.preview.css({ 'font-weight': 'normal', 'font-style': 'normal' });
146
  }
147
 
148
  //Font Family
149
+ var group = elements.family.find('option:selected').parent().attr('label');
150
 
151
+ if (group == 'Web fonts') {
152
  //Web font
153
+ elements.preview.css('font-family', elements.family.val());
154
  } else {
155
  //Google font
156
  WebFontConfig = {
157
+ google : {
158
+ families: [ elements.family.find('option:selected').text() ] },
159
+ fontactive: function (fontFamily, fontDescription) {
160
+ elements.preview.css('font-family', fontFamily);
161
  }
162
  };
163
 
164
+ (function () {
165
  var wf = document.createElement('script');
166
  wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
167
  '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
175
  });
176
 
177
  //font size, font unit
178
+ $([elements.size, elements.unit]).each(function () {
179
+ $(this).on('change', function () {
180
+ if (elements.refresh.is(':visible')) {
181
+ return;
182
+ }
183
 
184
  var size = elements.size.val();
185
  var unit = elements.unit.val();
186
 
187
  elements.preview.css({
188
+ 'font-size' : size + unit,
189
+ 'line-height': ( unit == 'em' || unit == 'rem' ? Number(size) + 0.4 : Number(size) + 4 ) + unit
190
+ }).trigger('resize');
191
  });
192
  });
193
 
194
  //font family
195
  var family = elements.family;
196
+ family.on('mousedown', function (e) {
197
  var t = $(this);
198
+ if (t.data('instance') == false) {
199
  var currentElement = {
200
+ 'value': t.val(),
201
+ 'text' : t.find('option:selected').text()
202
  };
203
 
204
  t.html(yit_family_string)
205
  .find('option')
206
+ .filter(function () {
207
  return $(this).text() == currentElement.text;
208
  }).attr('selected', true);
209
 
210
  t.data('instance', 'true');
211
  }
212
  });
213
+ family.on('change', function () {
214
+ if (elements.refresh.is(':visible')) {
215
+ return;
216
+ }
217
 
218
+ var group = $(this).find('option:selected').parent().attr('label');
219
 
220
+ if (group == 'Web fonts') {
221
  //Web font
222
+ elements.preview.css('font-family', $(this).val());
223
  } else {
224
  //Google font
225
  WebFontConfig = {
226
+ google : {
227
+ families: [ $(this).val() ]
228
  },
229
+ fontactive: function (fontFamily, fontDescription) {
230
+ elements.preview.css('font-family', fontFamily);
231
  }
232
  };
233
 
234
+ (function () {
235
  var wf = document.createElement('script');
236
  wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
237
  '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
243
  })();
244
  }
245
 
246
+ elements.preview.trigger('resize');
247
  });
248
 
249
+ elements.style.on('change', function () {
250
+ if (elements.refresh.is(':visible')) {
251
+ return;
252
+ }
253
 
254
+ var style = $(this).val();
255
 
256
+ if (style == 'italic') {
257
+ elements.preview.css({ 'font-weight': 'normal', 'font-style': 'italic' });
258
+ } else if (style == 'bold') {
259
+ elements.preview.css({ 'font-weight': 'bold', 'font-style': 'normal' });
260
+ } else if (style == 'extra-bold') {
261
+ elements.preview.css({ 'font-weight': '800', 'font-style': 'normal' });
262
+ } else if (style == 'bold-italic') {
263
+ elements.preview.css({ 'font-weight': 'bold', 'font-style': 'italic' });
264
  } else {
265
+ elements.preview.css({ 'font-weight': 'normal', 'font-style': 'normal' });
266
  }
267
 
268
+ elements.preview.trigger('resize');
269
  });
270
 
271
  //preview
272
+ elements.preview.resize(function () {
273
+ var box = $(this).parents('.yit-box');
274
+ $(this).parents('form').height(box.height());
275
  });
276
  }
277
  };
278
 
279
+ $.fn.yit_panel_typography = function (options) {
280
+ if (typeof options === 'string') {
281
+ var args = Array.prototype.slice.call(arguments, 1);
282
 
283
+ this.each(function () {
284
+ var instance = $.data(this, 'yit_panel_typography');
285
+ if (!instance) {
286
+ console.error("cannot call methods on yit_checkout prior to initialization; " +
287
+ "attempted to call method '" + options + "'");
288
  return;
289
  }
290
+ if (!$.isFunction(instance[options]) || options.charAt(0) === "_") {
291
+ console.error("no such method '" + options + "' for yit_panel_typography instance");
292
  return;
293
  }
294
+ instance[ options ].apply(instance, args);
295
  });
296
  }
297
  else {
298
+ this.each(function () {
299
+ var instance = $.data(this, 'yit_panel_typography');
300
+ if (!instance) {
301
+ $.data(this, 'yit_panel_typography', new $.yit_panel_typography(options, this));
302
  }
303
  });
304
  }
306
  };
307
 
308
 
309
+ })(window, jQuery);
yit-common/google_fonts.php CHANGED
@@ -17,9 +17,11 @@ class Google_Font {
17
  */
18
  public function google_fonts_url() {
19
  $base_url = 'http://fonts.googleapis.com/css?family=';
20
- $fonts = array();
21
 
22
- if ( empty( $this->google_fonts ) ) return;
 
 
23
 
24
  foreach ( $this->google_fonts as $font => $variants ) {
25
  $fonts[] = urlencode( $font . ':' . implode( ',', $variants ) );
@@ -31,15 +33,21 @@ class Google_Font {
31
  /**
32
  * Add a new google font in queue
33
  *
34
- * @param $font The name of google font
35
  * @param array $variants The variatns for the google font to add
36
  */
37
  public function add_google_font( $font, $variants = array() ) {
38
- if ( ! is_array( $variants ) ) $variants = array( $variants );
 
 
39
 
40
  foreach ( $variants as $variant ) {
41
- if ( ! isset( $this->google_fonts[$font] ) ) $this->google_fonts[$font] = array( 300, 400 );
42
- if ( ! in_array( $variant, $this->google_fonts[$font] ) ) $this->google_fonts[$font][] = $variant;
 
 
 
 
43
  }
44
  }
45
  }
@@ -48,7 +56,7 @@ if ( ! function_exists( 'yith_add_google_font' ) ) {
48
  /**
49
  * Add a new google font in queue
50
  *
51
- * @param $font The name of google font
52
  * @param array $variant The variatns for the google font to add
53
  */
54
  function yith_add_google_font( $font, $variant = array() ) {
17
  */
18
  public function google_fonts_url() {
19
  $base_url = 'http://fonts.googleapis.com/css?family=';
20
+ $fonts = array();
21
 
22
+ if ( empty( $this->google_fonts ) ) {
23
+ return;
24
+ }
25
 
26
  foreach ( $this->google_fonts as $font => $variants ) {
27
  $fonts[] = urlencode( $font . ':' . implode( ',', $variants ) );
33
  /**
34
  * Add a new google font in queue
35
  *
36
+ * @param $font The name of google font
37
  * @param array $variants The variatns for the google font to add
38
  */
39
  public function add_google_font( $font, $variants = array() ) {
40
+ if ( ! is_array( $variants ) ) {
41
+ $variants = array( $variants );
42
+ }
43
 
44
  foreach ( $variants as $variant ) {
45
+ if ( ! isset( $this->google_fonts[$font] ) ) {
46
+ $this->google_fonts[$font] = array( 300, 400 );
47
+ }
48
+ if ( ! in_array( $variant, $this->google_fonts[$font] ) ) {
49
+ $this->google_fonts[$font][] = $variant;
50
+ }
51
  }
52
  }
53
  }
56
  /**
57
  * Add a new google font in queue
58
  *
59
+ * @param $font The name of google font
60
  * @param array $variant The variatns for the google font to add
61
  */
62
  function yith_add_google_font( $font, $variant = array() ) {
yit-common/yit-functions.php CHANGED
@@ -2,13 +2,15 @@
2
  /**
3
  * Your Inspiration Themes common functions
4
  *
5
- * @author Your Inspiration Themes
6
  * @version 0.0.1
7
  */
8
 
9
- if( !defined('YITH_FUNCTIONS')) {
10
- define( 'YITH_FUNCTIONS', true);
11
- }
 
 
12
 
13
  if ( ! function_exists( 'yit_is_woocommerce_active' ) ) {
14
  /**
@@ -26,12 +28,13 @@ if ( ! function_exists( 'yit_is_woocommerce_active' ) ) {
26
  }
27
  }
28
 
29
- if( ! function_exists( 'yit_get_plugin_basename_from_slug' ) ) {
30
  /**
31
  * Helper function to extract the file path of the plugin file from the
32
  * plugin slug, if the plugin is installed.
33
  *
34
  * @param string $slug Plugin slug (typically folder name) as provided by the developer
 
35
  * @return string Either file path for plugin if installed, or just the plugin slug
36
  */
37
  function yit_get_plugin_basename_from_slug( $slug ) {
@@ -40,49 +43,52 @@ if( ! function_exists( 'yit_get_plugin_basename_from_slug' ) ) {
40
  $keys = array_keys( get_plugins() );
41
 
42
  foreach ( $keys as $key ) {
43
- if ( preg_match( '|^' . $slug .'|', $key ) )
44
  return $key;
 
45
  }
46
 
47
  return $slug;
48
  }
49
  }
50
 
51
- if( ! function_exists( 'yith_debug') ) {
52
  /**
53
  * Debug helper function. This is a wrapper for var_dump() that adds
54
  * the <pre /> tags, cleans up newlines and indents, and runs
55
  * htmlentities() before output.
56
  *
57
- * @param mixed $var The variable to dump.
58
- * @param mixed $var2 The second variable to dump
59
  * @param ...
 
60
  * @return string
61
  */
62
  function yith_debug() {
63
  $args = func_get_args();
64
- if( !empty( $args ) ) {
65
- foreach( $args as $k=>$arg ) {
66
  // var_dump the variable into a buffer and keep the output
67
  ob_start();
68
- var_dump($arg);
69
  $output = ob_get_clean();
70
 
71
  // neaten the newlines and indents
72
- $output = preg_replace("/\]\=\>\n(\s+)/m", "] => ", $output);
73
 
74
- if(!extension_loaded('xdebug')) {
75
- $output = htmlspecialchars($output, ENT_QUOTES);
76
  }
77
 
78
  $output = '<pre class="yit-debug">'
79
- . '<strong>$param_' . ($k+1) . ": </strong>"
80
  . $output
81
  . '</pre>';
82
  echo $output;
83
  }
84
- } else {
85
- trigger_error("yit_debug() expects at least 1 parameter, 0 given.", E_USER_WARNING);
 
86
  }
87
 
88
  return $args;
@@ -90,23 +96,26 @@ if( ! function_exists( 'yith_debug') ) {
90
  }
91
 
92
 
93
- if( ! function_exists('yit_get_options_from_prefix') ) {
94
  /**
95
  * Returns an array of all options that starts with a prefix
96
  *
97
  * @param string $prefix
 
98
  * @return array
99
  */
100
  function yit_get_options_from_prefix( $prefix ) {
101
- if( !$prefix ) return array();
 
 
102
 
103
  global $wpdb;
104
 
105
- $sql = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '{$prefix}%'";
106
- $options = $wpdb->get_col( $sql );
107
- $return = array();
108
 
109
- foreach( $options as $option ) {
110
  $return[$option] = get_option( $option );
111
  }
112
 
@@ -114,7 +123,7 @@ if( ! function_exists('yit_get_options_from_prefix') ) {
114
  }
115
  }
116
 
117
- if( !function_exists('yit_wp_roles') ) {
118
  /**
119
  * Returns the roles of the site.
120
  *
@@ -124,10 +133,12 @@ if( !function_exists('yit_wp_roles') ) {
124
  function yit_wp_roles() {
125
  global $wp_roles;
126
 
127
- if ( ! isset( $wp_roles ) ) $wp_roles = new WP_Roles();
 
 
128
 
129
  $roles = array();
130
- foreach( $wp_roles->roles as $k=>$role ) {
131
  $roles[$k] = $role['name'];
132
  }
133
 
@@ -135,22 +146,26 @@ if( !function_exists('yit_wp_roles') ) {
135
  }
136
  }
137
 
138
- if( !function_exists('yit_user_roles') ) {
139
  /**
140
  * Returns the roles of the user
141
  *
142
  * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
 
143
  * @return array()
144
  * @since 1.0.0
145
  */
146
  function yit_user_roles( $user_id = null ) {
147
- if ( is_numeric( $user_id ) )
148
  $user = get_userdata( $user_id );
149
- else
 
150
  $user = wp_get_current_user();
 
151
 
152
- if ( empty( $user ) )
153
  return false;
 
154
 
155
  return (array) $user->roles;
156
  }
@@ -158,11 +173,12 @@ if( !function_exists('yit_user_roles') ) {
158
 
159
 
160
  // ADMIN
161
- if( !function_exists('yit_typo_option_to_css') ) {
162
  /**
163
  * Change the typography option saved in database to attributes for css
164
  *
165
  * @param array $option The option as saved in the database
 
166
  * @return string
167
  * @since 1.0.0
168
  */
@@ -208,7 +224,7 @@ if( !function_exists('yit_typo_option_to_css') ) {
208
  }
209
 
210
 
211
- if( !function_exists('yit_curPageURL') ) {
212
  /**
213
  * Retrieve the current complete url
214
  *
@@ -216,15 +232,18 @@ if( !function_exists('yit_curPageURL') ) {
216
  */
217
  function yit_curPageURL() {
218
  $pageURL = 'http';
219
- if ( isset( $_SERVER["HTTPS"] ) AND $_SERVER["HTTPS"] == "on" )
220
  $pageURL .= "s";
 
221
 
222
  $pageURL .= "://";
223
 
224
- if ( isset( $_SERVER["SERVER_PORT"] ) AND $_SERVER["SERVER_PORT"] != "80" )
225
- $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
226
- else
227
- $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
 
 
228
 
229
  return $pageURL;
230
  }
2
  /**
3
  * Your Inspiration Themes common functions
4
  *
5
+ * @author Your Inspiration Themes
6
  * @version 0.0.1
7
  */
8
 
9
+ define( 'YITH_FUNCTIONS', true);
10
+
11
+ /* === Include Common Framework File === */
12
+ require_once( 'google_fonts.php' );
13
+ require_once( 'yith-panel.php' );
14
 
15
  if ( ! function_exists( 'yit_is_woocommerce_active' ) ) {
16
  /**
28
  }
29
  }
30
 
31
+ if ( ! function_exists( 'yit_get_plugin_basename_from_slug' ) ) {
32
  /**
33
  * Helper function to extract the file path of the plugin file from the
34
  * plugin slug, if the plugin is installed.
35
  *
36
  * @param string $slug Plugin slug (typically folder name) as provided by the developer
37
+ *
38
  * @return string Either file path for plugin if installed, or just the plugin slug
39
  */
40
  function yit_get_plugin_basename_from_slug( $slug ) {
43
  $keys = array_keys( get_plugins() );
44
 
45
  foreach ( $keys as $key ) {
46
+ if ( preg_match( '|^' . $slug . '|', $key ) ) {
47
  return $key;
48
+ }
49
  }
50
 
51
  return $slug;
52
  }
53
  }
54
 
55
+ if ( ! function_exists( 'yith_debug' ) ) {
56
  /**
57
  * Debug helper function. This is a wrapper for var_dump() that adds
58
  * the <pre /> tags, cleans up newlines and indents, and runs
59
  * htmlentities() before output.
60
  *
61
+ * @param mixed $var The variable to dump.
62
+ * @param mixed $var2 The second variable to dump
63
  * @param ...
64
+ *
65
  * @return string
66
  */
67
  function yith_debug() {
68
  $args = func_get_args();
69
+ if ( ! empty( $args ) ) {
70
+ foreach ( $args as $k => $arg ) {
71
  // var_dump the variable into a buffer and keep the output
72
  ob_start();
73
+ var_dump( $arg );
74
  $output = ob_get_clean();
75
 
76
  // neaten the newlines and indents
77
+ $output = preg_replace( "/\]\=\>\n(\s+)/m", "] => ", $output );
78
 
79
+ if ( ! extension_loaded( 'xdebug' ) ) {
80
+ $output = htmlspecialchars( $output, ENT_QUOTES );
81
  }
82
 
83
  $output = '<pre class="yit-debug">'
84
+ . '<strong>$param_' . ( $k + 1 ) . ": </strong>"
85
  . $output
86
  . '</pre>';
87
  echo $output;
88
  }
89
+ }
90
+ else {
91
+ trigger_error( "yit_debug() expects at least 1 parameter, 0 given.", E_USER_WARNING );
92
  }
93
 
94
  return $args;
96
  }
97
 
98
 
99
+ if ( ! function_exists( 'yit_get_options_from_prefix' ) ) {
100
  /**
101
  * Returns an array of all options that starts with a prefix
102
  *
103
  * @param string $prefix
104
+ *
105
  * @return array
106
  */
107
  function yit_get_options_from_prefix( $prefix ) {
108
+ if ( ! $prefix ) {
109
+ return array();
110
+ }
111
 
112
  global $wpdb;
113
 
114
+ $sql = "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '{$prefix}%'";
115
+ $options = $wpdb->get_col( $sql );
116
+ $return = array();
117
 
118
+ foreach ( $options as $option ) {
119
  $return[$option] = get_option( $option );
120
  }
121
 
123
  }
124
  }
125
 
126
+ if ( ! function_exists( 'yit_wp_roles' ) ) {
127
  /**
128
  * Returns the roles of the site.
129
  *
133
  function yit_wp_roles() {
134
  global $wp_roles;
135
 
136
+ if ( ! isset( $wp_roles ) ) {
137
+ $wp_roles = new WP_Roles();
138
+ }
139
 
140
  $roles = array();
141
+ foreach ( $wp_roles->roles as $k => $role ) {
142
  $roles[$k] = $role['name'];
143
  }
144
 
146
  }
147
  }
148
 
149
+ if ( ! function_exists( 'yit_user_roles' ) ) {
150
  /**
151
  * Returns the roles of the user
152
  *
153
  * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
154
+ *
155
  * @return array()
156
  * @since 1.0.0
157
  */
158
  function yit_user_roles( $user_id = null ) {
159
+ if ( is_numeric( $user_id ) ) {
160
  $user = get_userdata( $user_id );
161
+ }
162
+ else {
163
  $user = wp_get_current_user();
164
+ }
165
 
166
+ if ( empty( $user ) ) {
167
  return false;
168
+ }
169
 
170
  return (array) $user->roles;
171
  }
173
 
174
 
175
  // ADMIN
176
+ if ( ! function_exists( 'yit_typo_option_to_css' ) ) {
177
  /**
178
  * Change the typography option saved in database to attributes for css
179
  *
180
  * @param array $option The option as saved in the database
181
+ *
182
  * @return string
183
  * @since 1.0.0
184
  */
224
  }
225
 
226
 
227
+ if ( ! function_exists( 'yit_curPageURL' ) ) {
228
  /**
229
  * Retrieve the current complete url
230
  *
232
  */
233
  function yit_curPageURL() {
234
  $pageURL = 'http';
235
+ if ( isset( $_SERVER["HTTPS"] ) AND $_SERVER["HTTPS"] == "on" ) {
236
  $pageURL .= "s";
237
+ }
238
 
239
  $pageURL .= "://";
240
 
241
+ if ( isset( $_SERVER["SERVER_PORT"] ) AND $_SERVER["SERVER_PORT"] != "80" ) {
242
+ $pageURL .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
243
+ }
244
+ else {
245
+ $pageURL .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
246
+ }
247
 
248
  return $pageURL;
249
  }
yit-common/yith-panel.php CHANGED
@@ -2,14 +2,15 @@
2
  /**
3
  * Your Inspiration Themes Panel
4
  *
5
- * @author Your Inspiration Themes
6
  * @version 0.1.0
7
  */
8
 
9
- if( !class_exists('YITH_Panel') ) {
10
  /*
11
  * The class manages the theme options for the Plugin
12
  */
 
13
  class YITH_Panel {
14
 
15
  /**
@@ -23,11 +24,11 @@ if( !class_exists('YITH_Panel') ) {
23
  * Parameters for add_submenu_page
24
  *
25
  * add_submenu_page(
26
- * 'themes.php', // The file name of a standard WordPress admin page
27
- * 'Theme Options', // The text to be displayed in the title tags of the page when the menu is selected
28
- * 'Theme Options', // The text to be used for the menu
29
- * 'administrator', // The capability (or role) required for this menu to be displayed to the user.
30
- * 'theme-options', // The slug name to refer to this menu by (should be unique for this menu).
31
  * 'theme_options_display_page' // The function to be called to output the content for this page.
32
  * );
33
  *
@@ -81,24 +82,24 @@ if( !class_exists('YITH_Panel') ) {
81
  /**
82
  * Constructor
83
  *
84
- * @param array $submenu Parameters for add_submenu_page
85
- * @param array $options Array of plugin options
86
  *
87
  */
88
  public function __construct( $submenu, $options, $banner = array(), $option_group = false, $option_name = false ) {
89
- $this->_submenu = apply_filters('yith_panel_submenu', $submenu);
90
- $this->options = apply_filters('yith_panel_options', $options);
91
 
92
- if( !empty($banner) ) {
93
  $this->banner_url = $banner['url'];
94
  $this->banner_img = $banner['img'];
95
  }
96
 
97
- if( $option_group ) {
98
  $this->option_group = $option_group;
99
  }
100
 
101
- if( $option_name ) {
102
  $this->option_name = $option_name;
103
  }
104
 
@@ -106,9 +107,9 @@ if( !class_exists('YITH_Panel') ) {
106
  //register new settings option group
107
  //include js and css files
108
  //print browser
109
- add_action( 'admin_menu', array( $this, 'add_submenu_page') );
110
- add_action( 'admin_init', array( $this, 'panel_register_setting') );
111
- add_action( 'admin_enqueue_scripts', array( $this, 'panel_enqueue') );
112
 
113
  // add the typography javascript vars
114
  add_action( 'yith_panel_after_panel', array( $this, 'js_typo_vars' ) );
@@ -119,7 +120,7 @@ if( !class_exists('YITH_Panel') ) {
119
  *
120
  * @return void
121
  * @access public
122
- * @link http://codex.wordpress.org/Function_Reference/add_submenu_page
123
  */
124
  public function add_submenu_page() {
125
  $submenu = $this->_submenu;
@@ -129,7 +130,7 @@ if( !class_exists('YITH_Panel') ) {
129
  $submenu[2],
130
  $submenu[3],
131
  $submenu[4],
132
- array( $this, isset($submenu[5]) ? $submenu[5] : 'display_panel_page' )
133
  );
134
  }
135
 
@@ -145,15 +146,15 @@ if( !class_exists('YITH_Panel') ) {
145
  ?>
146
  <div id="icon-themes" class="icon32"><br /></div>
147
  <h2 class="nav-tab-wrapper">
148
- <?php foreach( $this->options as $k=>$tab ): ?>
149
- <a class="nav-tab<?php if( $page == $k ): ?> nav-tab-active<?php endif ?>" href="<?php echo add_query_arg('panel_page', $k) ?>"><?php echo $tab['label'] ?></a>
150
  <?php endforeach ?>
151
- <?php do_action('yith_panel_after_tabs'); ?>
152
  </h2>
153
 
154
  <div class="wrap">
155
  <?php $this->printBanner() ?>
156
- <?php do_action('yith_panel_before_panel'); ?>
157
  <form action="options.php" method="post">
158
 
159
  <?php do_settings_sections( $this->option_name ); ?>
@@ -164,7 +165,7 @@ if( !class_exists('YITH_Panel') ) {
164
  <input class="button-primary" type="submit" name="save_options" value="Save Options" />
165
  </p>
166
  </form>
167
- <?php do_action('yith_panel_after_panel'); ?>
168
  </div>
169
  <?php
170
  }
@@ -174,7 +175,9 @@ if( !class_exists('YITH_Panel') ) {
174
  */
175
  public function js_typo_vars() {
176
  global $yith_panel_if_typography;
177
- if ( ! isset( $yith_panel_if_typography ) || ! $yith_panel_if_typography ) return;
 
 
178
 
179
  $web_fonts = array(
180
  "Arial",
@@ -191,14 +194,14 @@ if( !class_exists('YITH_Panel') ) {
191
  );
192
 
193
  // http://niubbys.altervista.org/google_fonts.php
194
- $google_fonts = file_get_contents( dirname(__FILE__) . '/assets/js/google_fonts.json' );
195
  ?>
196
  <script type="text/javascript">
197
  var yit_google_fonts = '<?php echo $google_fonts ?>',
198
  yit_web_fonts = '{"items":<?php echo json_encode( $web_fonts ) ?>}',
199
  yit_family_string = '';
200
  </script>
201
- <?php
202
  }
203
 
204
  /**
@@ -206,35 +209,35 @@ if( !class_exists('YITH_Panel') ) {
206
  *
207
  * @return void
208
  * @access public
209
- * @link http://codex.wordpress.org/Function_Reference/register_setting
210
- * @link http://codex.wordpress.org/Function_Reference/add_settings_section
211
- * @link http://codex.wordpress.org/Function_Reference/add_settings_field
212
  */
213
  public function panel_register_setting() {
214
  $page = $this->_get_tab();
215
- $tab = isset( $this->options[$page] ) ? $this->options[$page] : array();
216
 
217
- if( !empty($tab['sections']) ) {
218
  //add sections and fields
219
- foreach( $tab['sections'] as $section_name => $section) {
220
  //add the section
221
  add_settings_section(
222
  $section_name,
223
  $section['title'],
224
- array( $this, 'panel_section_content'),
225
  $this->option_name
226
  );
227
 
228
  //add the fields
229
- foreach( $section['fields'] as $option_name => $option ) {
230
- $option['id'] = $option_name;
231
  $option['label_for'] = $option_name;
232
 
233
  //register settings group
234
  register_setting(
235
  $this->option_group,
236
  $option_name,
237
- array( $this, 'panel_sanitize')
238
  );
239
 
240
  add_settings_field(
@@ -258,8 +261,8 @@ if( !class_exists('YITH_Panel') ) {
258
  */
259
  public function panel_section_content( $section ) {
260
  $page = $this->_get_tab();
261
- if( isset( $this->options[$page]['sections'][ $section['id'] ]['description'] )) {
262
- echo "<p class='section-description'>" . $this->options[$page]['sections'][ $section['id'] ]['description'] . "</p>";
263
  }
264
  }
265
 
@@ -267,11 +270,12 @@ if( !class_exists('YITH_Panel') ) {
267
  * Sanitize the option's value
268
  *
269
  * @param array $input
 
270
  * @return array
271
  * @access public
272
  */
273
  public function panel_sanitize( $input ) {
274
- return apply_filters('yith_panel_sanitize', $input);
275
  }
276
 
277
  /**
@@ -282,11 +286,13 @@ if( !class_exists('YITH_Panel') ) {
282
  * @access protected
283
  */
284
  public function _get_tab() {
285
- if( isset($_POST['panel_page']) && $_POST['panel_page'] != '' ) {
286
  return $_POST['panel_page'];
287
- } elseif( isset($_GET['panel_page']) && $_GET['panel_page'] != '' ) {
 
288
  return $_GET['panel_page'];
289
- } else {
 
290
  $tabs = array_keys( $this->options );
291
  return $tabs[0];
292
  }
@@ -301,12 +307,12 @@ if( !class_exists('YITH_Panel') ) {
301
  public function panel_enqueue( $hook ) {
302
  global $pagenow;
303
 
304
- if( $pagenow == $this->_submenu[0] && isset( $_GET['page'] ) && $_GET['page'] == $this->_submenu[4] ) {
305
  wp_enqueue_style( 'wp-color-picker' );
306
  wp_enqueue_style( 'jquery-ui', 'http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css' );
307
  wp_enqueue_script( 'jquery-ui-datepicker' );
308
 
309
- wp_enqueue_style( 'yith-panel-css', plugin_dir_url( __FILE__ ) . 'assets/css/yith-panel.css', array('wp-color-picker'), $this->version );
310
  wp_enqueue_script( 'yith-panel-js', plugin_dir_url( __FILE__ ) . 'assets/js/yith-panel.js', array( 'jquery', 'wp-color-picker' ), $this->version, true );
311
 
312
  wp_enqueue_media();
@@ -323,69 +329,73 @@ if( !class_exists('YITH_Panel') ) {
323
  * @access public
324
  */
325
  public function panel_field_content( $field ) {
326
- $value = get_option( $field['id'], isset($field['std']) ? $field['std'] : '' );
327
- $id = $field['id'];
328
- $name = $field['id'];
329
 
330
  $echo = '';
331
 
332
- switch( $field['type'] ) {
333
  case 'text':
334
- $echo = "<input type='text' id='{$id}' name='{$name}' value='{$value}' class='regular-text code' />";
335
 
336
- if( isset($field['description']) && $field['description'] != '' ) {
337
  $echo .= "<p class='description'>{$field['description']}</p>";
338
  }
339
  break;
340
 
341
- case 'textarea': $echo = "<textarea name='{$name}' id='{$id}' class='large-text code' rows='10' cols='50'>{$value}</textarea>";
342
- if( isset($field['description']) && $field['description'] != '' ) {
 
343
  $echo .= "<p class='description'>{$field['description']}</p>";
344
  }
345
  break;
346
 
347
- case 'checkbox': $echo = "<input type='checkbox' id='{$id}' name='{$name}' value='1' ". checked($value, true, false) ." />";
348
- if( isset($field['description']) && $field['description'] != '' ) {
 
349
  $echo .= " <label for='{$id}'><span class='description'>{$field['description']}</span></label>";
350
  }
351
  break;
352
 
353
- case 'select': $echo = "<select name='{$name}' id='{$id}'>";
354
- foreach( $field['options'] as $v=>$label ) {
355
- $echo .= "<option value='{$v}'". selected($value, $v, false) .">{$label}</option>";
 
356
  }
357
  $echo .= "</select>";
358
- if( isset($field['description']) && $field['description'] != '' ) {
359
  $echo .= "<p class='description'>{$field['description']}</p>";
360
  }
361
  break;
362
 
363
- case 'skin': $echo = "<select name='{$name}' id='{$id}' class='skin' data-path='{$field['path']}'>";
364
- foreach( $field['options'] as $v=>$label ) {
365
- $echo .= "<option value='{$v}'". selected($value, $v, false) .">{$label}</option>";
 
366
  }
367
  $echo .= "</select>";
368
- if( isset($field['description']) && $field['description'] != '' ) {
369
  $echo .= "<p class='description'>{$field['description']}</p><div class='skin-preview'></div>";
370
  }
371
  break;
372
 
373
  case 'number':
374
  $mms = '';
375
- if( isset( $field['min'] ) ) {
376
  $mms .= " min='{$field['min']}'";
377
  }
378
 
379
- if( isset( $field['max'] ) ) {
380
  $mms .= " max='{$field['max']}'";
381
  }
382
 
383
- if( isset( $field['step'] ) ) {
384
  $mms .= " step='{$field['step']}'";
385
  }
386
 
387
  $echo = "<input type='number' id='{$id}' name='{$name}' value='{$value}' class='small-text' {$mms} />";
388
- if( isset($field['description']) && $field['description'] != '' ) {
389
  $echo .= "<p class='description'>{$field['description']}</p>";
390
  }
391
  break;
@@ -394,29 +404,29 @@ if( !class_exists('YITH_Panel') ) {
394
  $std = isset( $field['std'] ) ? $field['std'] : '';
395
 
396
  $echo = "<input type='text' id='{$id}' name='{$name}' value='{$value}' class='medium-text code panel-colorpicker' data-default-color='{$std}' />";
397
- if( isset($field['description']) && $field['description'] != '' ) {
398
  $echo .= "<p class='description'>{$field['description']}</p>";
399
  }
400
  break;
401
 
402
  case 'datepicker':
403
- $std = isset( $field['std'] ) ? $field['std'] : array( 'date' => '', 'hh' => 0, 'mm' => 0, 'ss' => 0 );
404
  $value = ! empty( $value ) ? $value : array( 'date' => '', 'hh' => 0, 'mm' => 0, 'ss' => 0 );
405
 
406
- $echo = "<input type='text' id='{$id}_date' name='{$name}[date]' value='{$value['date']}' class='medium-text code panel-datepicker' colorpicker='" . __( 'Select a date', 'yit' ) . "' /> - ";
407
  $echo .= "<input type='text' id='{$id}_hh' name='{$name}[hh]' value='{$value['hh']}' class='small-text code' colorpicker='" . __( 'Hours', 'yit' ) . "' /> : ";
408
  $echo .= "<input type='text' id='{$id}_mm' name='{$name}[mm]' value='{$value['mm']}' class='small-text code' colorpicker='" . __( 'Minutes', 'yit' ) . "' /> : ";
409
  $echo .= "<input type='text' id='{$id}_ss' name='{$name}[ss]' value='{$value['ss']}' class='small-text code' colorpicker='" . __( 'Minutes', 'yit' ) . "' />";
410
- if( isset($field['description']) && $field['description'] != '' ) {
411
  $echo .= "<p class='description'>{$field['description']}</p>";
412
  }
413
  break;
414
 
415
  case 'upload':
416
- $echo = '<div class="uploader">';
417
- $echo .= " <input type='text' id='{$id}' name='{$name}' value='{$value}' class='regular-text code' /> <input type='button' name='' id='{$id}_button' class='button' value='". __('Upload', 'yit') ."'>";
418
  $echo .= '</div>';
419
- if( isset($field['description']) && $field['description'] != '' ) {
420
  $echo .= "<p class='description'>{$field['description']}</p>";
421
  }
422
  break;
@@ -424,18 +434,26 @@ if( !class_exists('YITH_Panel') ) {
424
  case 'checkboxes':
425
  $echo = '<div class="checkboxes">';
426
  foreach ( $field['options'] as $check_value => $check_label ) {
427
- $echo .= "<label><input type='checkbox' id='{$id}_{$check_value}' name='{$name}[]' value='$check_value' ". checked( in_array( $check_value, $value ), true, false) ." /> {$check_label}</label><br />";
428
  }
429
 
430
  $echo .= " <p class='description'>{$field['description']}</p>";
431
  break;
432
 
433
- case 'typography': $value = wp_parse_args( $value, $field['std'] ); ?>
 
434
  <div class="typography_container typography">
435
  <div class="option">
436
  <!-- Size -->
437
  <div class="spinner_container">
438
- <input class="typography_size number small-text" type="number" name="<?php echo $name ?>[size]" id="<?php echo $id ?>-size" value="<?php echo $value['size'] ?>" data-min="<?php if(isset( $field['min'] )) echo $field['min'] ?>" data-max="<?php if(isset( $field['max'] )) echo $field['max'] ?>" />
 
 
 
 
 
 
 
439
  </div>
440
 
441
  <!-- Unit -->
@@ -451,10 +469,10 @@ if( !class_exists('YITH_Panel') ) {
451
  <!-- Family -->
452
  <div class="select-wrapper font-family">
453
  <select class="typography_family" name="<?php echo $name ?>[family]" id="<?php echo $id ?>-family" data-instance="false">
454
- <?php if( $value['family'] ): ?>
455
  <option value="<?php echo stripslashes( $value['family'] ) ?>"><?php echo $value['family'] ?></option>
456
  <?php else: ?>
457
- <option value=""><?php _e('Select a font family', 'yit') ?></option>
458
  <?php endif ?>
459
  </select>
460
  </div>
@@ -478,16 +496,18 @@ if( !class_exists('YITH_Panel') ) {
478
  <div class="font-preview">
479
  <p>The quick brown fox jumps over the lazy dog</p>
480
  <!-- Refresh -->
481
- <div class="refresh_container"><button class="refresh"><?php _e( 'Click to preview', 'yit' ) ?></button></div>
 
 
482
  </div>
483
  </div>
484
  <?php
485
- global $yith_panel_if_typography;
486
- $yith_panel_if_typography = true;
487
  break;
488
 
489
  default:
490
- do_action('yith_panel_field_' . $field['type']);
491
  break;
492
  }
493
 
@@ -501,7 +521,9 @@ if( !class_exists('YITH_Panel') ) {
501
  * @return void
502
  */
503
  public function printBanner() {
504
- if( !$this->banner_url || !$this->banner_img ) return;
 
 
505
  ?>
506
  <div class="yith_banner">
507
  <a href="<?php echo $this->banner_url ?>" target="_blank">
2
  /**
3
  * Your Inspiration Themes Panel
4
  *
5
+ * @author Your Inspiration Themes
6
  * @version 0.1.0
7
  */
8
 
9
+ if ( ! class_exists( 'YITH_Panel' ) ) {
10
  /*
11
  * The class manages the theme options for the Plugin
12
  */
13
+
14
  class YITH_Panel {
15
 
16
  /**
24
  * Parameters for add_submenu_page
25
  *
26
  * add_submenu_page(
27
+ * 'themes.php', // The file name of a standard WordPress admin page
28
+ * 'Theme Options', // The text to be displayed in the title tags of the page when the menu is selected
29
+ * 'Theme Options', // The text to be used for the menu
30
+ * 'administrator', // The capability (or role) required for this menu to be displayed to the user.
31
+ * 'theme-options', // The slug name to refer to this menu by (should be unique for this menu).
32
  * 'theme_options_display_page' // The function to be called to output the content for this page.
33
  * );
34
  *
82
  /**
83
  * Constructor
84
  *
85
+ * @param array $submenu Parameters for add_submenu_page
86
+ * @param array $options Array of plugin options
87
  *
88
  */
89
  public function __construct( $submenu, $options, $banner = array(), $option_group = false, $option_name = false ) {
90
+ $this->_submenu = apply_filters( 'yith_panel_submenu', $submenu );
91
+ $this->options = apply_filters( 'yith_panel_options', $options );
92
 
93
+ if ( ! empty( $banner ) ) {
94
  $this->banner_url = $banner['url'];
95
  $this->banner_img = $banner['img'];
96
  }
97
 
98
+ if ( $option_group ) {
99
  $this->option_group = $option_group;
100
  }
101
 
102
+ if ( $option_name ) {
103
  $this->option_name = $option_name;
104
  }
105
 
107
  //register new settings option group
108
  //include js and css files
109
  //print browser
110
+ add_action( 'admin_menu', array( $this, 'add_submenu_page' ) );
111
+ add_action( 'admin_init', array( $this, 'panel_register_setting' ) );
112
+ add_action( 'admin_enqueue_scripts', array( $this, 'panel_enqueue' ) );
113
 
114
  // add the typography javascript vars
115
  add_action( 'yith_panel_after_panel', array( $this, 'js_typo_vars' ) );
120
  *
121
  * @return void
122
  * @access public
123
+ * @link http://codex.wordpress.org/Function_Reference/add_submenu_page
124
  */
125
  public function add_submenu_page() {
126
  $submenu = $this->_submenu;
130
  $submenu[2],
131
  $submenu[3],
132
  $submenu[4],
133
+ array( $this, isset( $submenu[5] ) ? $submenu[5] : 'display_panel_page' )
134
  );
135
  }
136
 
146
  ?>
147
  <div id="icon-themes" class="icon32"><br /></div>
148
  <h2 class="nav-tab-wrapper">
149
+ <?php foreach ( $this->options as $k => $tab ): ?>
150
+ <a class="nav-tab<?php if ( $page == $k ): ?> nav-tab-active<?php endif ?>" href="<?php echo add_query_arg( 'panel_page', $k ) ?>"><?php echo $tab['label'] ?></a>
151
  <?php endforeach ?>
152
+ <?php do_action( 'yith_panel_after_tabs' ); ?>
153
  </h2>
154
 
155
  <div class="wrap">
156
  <?php $this->printBanner() ?>
157
+ <?php do_action( 'yith_panel_before_panel' ); ?>
158
  <form action="options.php" method="post">
159
 
160
  <?php do_settings_sections( $this->option_name ); ?>
165
  <input class="button-primary" type="submit" name="save_options" value="Save Options" />
166
  </p>
167
  </form>
168
+ <?php do_action( 'yith_panel_after_panel' ); ?>
169
  </div>
170
  <?php
171
  }
175
  */
176
  public function js_typo_vars() {
177
  global $yith_panel_if_typography;
178
+ if ( ! isset( $yith_panel_if_typography ) || ! $yith_panel_if_typography ) {
179
+ return;
180
+ }
181
 
182
  $web_fonts = array(
183
  "Arial",
194
  );
195
 
196
  // http://niubbys.altervista.org/google_fonts.php
197
+ $google_fonts = file_get_contents( dirname( __FILE__ ) . '/assets/js/google_fonts.json' );
198
  ?>
199
  <script type="text/javascript">
200
  var yit_google_fonts = '<?php echo $google_fonts ?>',
201
  yit_web_fonts = '{"items":<?php echo json_encode( $web_fonts ) ?>}',
202
  yit_family_string = '';
203
  </script>
204
+ <?php
205
  }
206
 
207
  /**
209
  *
210
  * @return void
211
  * @access public
212
+ * @link http://codex.wordpress.org/Function_Reference/register_setting
213
+ * @link http://codex.wordpress.org/Function_Reference/add_settings_section
214
+ * @link http://codex.wordpress.org/Function_Reference/add_settings_field
215
  */
216
  public function panel_register_setting() {
217
  $page = $this->_get_tab();
218
+ $tab = isset( $this->options[$page] ) ? $this->options[$page] : array();
219
 
220
+ if ( ! empty( $tab['sections'] ) ) {
221
  //add sections and fields
222
+ foreach ( $tab['sections'] as $section_name => $section ) {
223
  //add the section
224
  add_settings_section(
225
  $section_name,
226
  $section['title'],
227
+ array( $this, 'panel_section_content' ),
228
  $this->option_name
229
  );
230
 
231
  //add the fields
232
+ foreach ( $section['fields'] as $option_name => $option ) {
233
+ $option['id'] = $option_name;
234
  $option['label_for'] = $option_name;
235
 
236
  //register settings group
237
  register_setting(
238
  $this->option_group,
239
  $option_name,
240
+ array( $this, 'panel_sanitize' )
241
  );
242
 
243
  add_settings_field(
261
  */
262
  public function panel_section_content( $section ) {
263
  $page = $this->_get_tab();
264
+ if ( isset( $this->options[$page]['sections'][$section['id']]['description'] ) ) {
265
+ echo "<p class='section-description'>" . $this->options[$page]['sections'][$section['id']]['description'] . "</p>";
266
  }
267
  }
268
 
270
  * Sanitize the option's value
271
  *
272
  * @param array $input
273
+ *
274
  * @return array
275
  * @access public
276
  */
277
  public function panel_sanitize( $input ) {
278
+ return apply_filters( 'yith_panel_sanitize', $input );
279
  }
280
 
281
  /**
286
  * @access protected
287
  */
288
  public function _get_tab() {
289
+ if ( isset( $_POST['panel_page'] ) && $_POST['panel_page'] != '' ) {
290
  return $_POST['panel_page'];
291
+ }
292
+ elseif ( isset( $_GET['panel_page'] ) && $_GET['panel_page'] != '' ) {
293
  return $_GET['panel_page'];
294
+ }
295
+ else {
296
  $tabs = array_keys( $this->options );
297
  return $tabs[0];
298
  }
307
  public function panel_enqueue( $hook ) {
308
  global $pagenow;
309
 
310
+ if ( $pagenow == $this->_submenu[0] && isset( $_GET['page'] ) && $_GET['page'] == $this->_submenu[4] ) {
311
  wp_enqueue_style( 'wp-color-picker' );
312
  wp_enqueue_style( 'jquery-ui', 'http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css' );
313
  wp_enqueue_script( 'jquery-ui-datepicker' );
314
 
315
+ wp_enqueue_style( 'yith-panel-css', plugin_dir_url( __FILE__ ) . 'assets/css/yith-panel.css', array( 'wp-color-picker' ), $this->version );
316
  wp_enqueue_script( 'yith-panel-js', plugin_dir_url( __FILE__ ) . 'assets/js/yith-panel.js', array( 'jquery', 'wp-color-picker' ), $this->version, true );
317
 
318
  wp_enqueue_media();
329
  * @access public
330
  */
331
  public function panel_field_content( $field ) {
332
+ $value = get_option( $field['id'], isset( $field['std'] ) ? $field['std'] : '' );
333
+ $id = $field['id'];
334
+ $name = $field['id'];
335
 
336
  $echo = '';
337
 
338
+ switch ( $field['type'] ) {
339
  case 'text':
340
+ $echo = "<input type='text' id='{$id}' name='{$name}' value='{$value}' class='regular-text code' />";
341
 
342
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
343
  $echo .= "<p class='description'>{$field['description']}</p>";
344
  }
345
  break;
346
 
347
+ case 'textarea':
348
+ $echo = "<textarea name='{$name}' id='{$id}' class='large-text code' rows='10' cols='50'>{$value}</textarea>";
349
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
350
  $echo .= "<p class='description'>{$field['description']}</p>";
351
  }
352
  break;
353
 
354
+ case 'checkbox':
355
+ $echo = "<input type='checkbox' id='{$id}' name='{$name}' value='1' " . checked( $value, true, false ) . " />";
356
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
357
  $echo .= " <label for='{$id}'><span class='description'>{$field['description']}</span></label>";
358
  }
359
  break;
360
 
361
+ case 'select':
362
+ $echo = "<select name='{$name}' id='{$id}'>";
363
+ foreach ( $field['options'] as $v => $label ) {
364
+ $echo .= "<option value='{$v}'" . selected( $value, $v, false ) . ">{$label}</option>";
365
  }
366
  $echo .= "</select>";
367
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
368
  $echo .= "<p class='description'>{$field['description']}</p>";
369
  }
370
  break;
371
 
372
+ case 'skin':
373
+ $echo = "<select name='{$name}' id='{$id}' class='skin' data-path='{$field['path']}'>";
374
+ foreach ( $field['options'] as $v => $label ) {
375
+ $echo .= "<option value='{$v}'" . selected( $value, $v, false ) . ">{$label}</option>";
376
  }
377
  $echo .= "</select>";
378
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
379
  $echo .= "<p class='description'>{$field['description']}</p><div class='skin-preview'></div>";
380
  }
381
  break;
382
 
383
  case 'number':
384
  $mms = '';
385
+ if ( isset( $field['min'] ) ) {
386
  $mms .= " min='{$field['min']}'";
387
  }
388
 
389
+ if ( isset( $field['max'] ) ) {
390
  $mms .= " max='{$field['max']}'";
391
  }
392
 
393
+ if ( isset( $field['step'] ) ) {
394
  $mms .= " step='{$field['step']}'";
395
  }
396
 
397
  $echo = "<input type='number' id='{$id}' name='{$name}' value='{$value}' class='small-text' {$mms} />";
398
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
399
  $echo .= "<p class='description'>{$field['description']}</p>";
400
  }
401
  break;
404
  $std = isset( $field['std'] ) ? $field['std'] : '';
405
 
406
  $echo = "<input type='text' id='{$id}' name='{$name}' value='{$value}' class='medium-text code panel-colorpicker' data-default-color='{$std}' />";
407
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
408
  $echo .= "<p class='description'>{$field['description']}</p>";
409
  }
410
  break;
411
 
412
  case 'datepicker':
413
+ $std = isset( $field['std'] ) ? $field['std'] : array( 'date' => '', 'hh' => 0, 'mm' => 0, 'ss' => 0 );
414
  $value = ! empty( $value ) ? $value : array( 'date' => '', 'hh' => 0, 'mm' => 0, 'ss' => 0 );
415
 
416
+ $echo = "<input type='text' id='{$id}_date' name='{$name}[date]' value='{$value['date']}' class='medium-text code panel-datepicker' colorpicker='" . __( 'Select a date', 'yit' ) . "' /> - ";
417
  $echo .= "<input type='text' id='{$id}_hh' name='{$name}[hh]' value='{$value['hh']}' class='small-text code' colorpicker='" . __( 'Hours', 'yit' ) . "' /> : ";
418
  $echo .= "<input type='text' id='{$id}_mm' name='{$name}[mm]' value='{$value['mm']}' class='small-text code' colorpicker='" . __( 'Minutes', 'yit' ) . "' /> : ";
419
  $echo .= "<input type='text' id='{$id}_ss' name='{$name}[ss]' value='{$value['ss']}' class='small-text code' colorpicker='" . __( 'Minutes', 'yit' ) . "' />";
420
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
421
  $echo .= "<p class='description'>{$field['description']}</p>";
422
  }
423
  break;
424
 
425
  case 'upload':
426
+ $echo = '<div class="uploader">';
427
+ $echo .= " <input type='text' id='{$id}' name='{$name}' value='{$value}' class='regular-text code' /> <input type='button' name='' id='{$id}_button' class='button' value='" . __( 'Upload', 'yit' ) . "'>";
428
  $echo .= '</div>';
429
+ if ( isset( $field['description'] ) && $field['description'] != '' ) {
430
  $echo .= "<p class='description'>{$field['description']}</p>";
431
  }
432
  break;
434
  case 'checkboxes':
435
  $echo = '<div class="checkboxes">';
436
  foreach ( $field['options'] as $check_value => $check_label ) {
437
+ $echo .= "<label><input type='checkbox' id='{$id}_{$check_value}' name='{$name}[]' value='$check_value' " . checked( in_array( $check_value, $value ), true, false ) . " /> {$check_label}</label><br />";
438
  }
439
 
440
  $echo .= " <p class='description'>{$field['description']}</p>";
441
  break;
442
 
443
+ case 'typography':
444
+ $value = wp_parse_args( $value, $field['std'] ); ?>
445
  <div class="typography_container typography">
446
  <div class="option">
447
  <!-- Size -->
448
  <div class="spinner_container">
449
+ <input class="typography_size number small-text"
450
+ type="number"
451
+ name="<?php echo $name ?>[size]"
452
+ id="<?php echo $id ?>-size"
453
+ value="<?php echo $value['size'] ?>"
454
+ data-min="<?php if ( isset( $field['min'] ) ) echo $field['min']; ?>"
455
+ data-max="<?php if ( isset( $field['max'] ) ) echo $field['max']; ?>"
456
+ />
457
  </div>
458
 
459
  <!-- Unit -->
469
  <!-- Family -->
470
  <div class="select-wrapper font-family">
471
  <select class="typography_family" name="<?php echo $name ?>[family]" id="<?php echo $id ?>-family" data-instance="false">
472
+ <?php if ( $value['family'] ): ?>
473
  <option value="<?php echo stripslashes( $value['family'] ) ?>"><?php echo $value['family'] ?></option>
474
  <?php else: ?>
475
+ <option value=""><?php _e( 'Select a font family', 'yit' ) ?></option>
476
  <?php endif ?>
477
  </select>
478
  </div>
496
  <div class="font-preview">
497
  <p>The quick brown fox jumps over the lazy dog</p>
498
  <!-- Refresh -->
499
+ <div class="refresh_container">
500
+ <button class="refresh"><?php _e( 'Click to preview', 'yit' ) ?></button>
501
+ </div>
502
  </div>
503
  </div>
504
  <?php
505
+ global $yith_panel_if_typography;
506
+ $yith_panel_if_typography = true;
507
  break;
508
 
509
  default:
510
+ do_action( 'yith_panel_field_' . $field['type'] );
511
  break;
512
  }
513
 
521
  * @return void
522
  */
523
  public function printBanner() {
524
+ if ( ! $this->banner_url || ! $this->banner_img ) {
525
+ return;
526
+ }
527
  ?>
528
  <div class="yith_banner">
529
  <a href="<?php echo $this->banner_url ?>" target="_blank">