YITH WooCommerce Ajax Search - Version 1.1.3

Version Description

Fixed: Javascript code in external file

Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Search
Version 1.1.3
Comparing to
See all releases

Code changes from version 1.1.2 to 1.1.3

README.txt CHANGED
@@ -3,8 +3,8 @@
3
  Contributors: yithemes
4
  Tags: ajax, search, woocommerce, products, themes, yit, e-commerce, shop
5
  Requires at least: 3.5.1
6
- Tested up to: 4.0
7
- Stable tag: 1.1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -25,10 +25,10 @@ It works just like Google Suggest, but on your website, using your database.
25
 
26
  Working demo is available here:
27
 
28
- **[LIVE DEMO](http://demo.yithemes.com/sistina/)**
29
 
30
 
31
- Full documentation is available [here](http://yithemes.com/docs-plugins/yith_ajax_search/).
32
 
33
 
34
  = Installation =
@@ -41,7 +41,7 @@ YITH WooCommerce Ajax Search will add a new tab called "Ajax Search" below the W
41
 
42
  = Developer =
43
 
44
- Are you a developer? Want to customize the templates or the style of the plugin? Read on the [documentation](http://yithemes.com/docs-plugins/yith_ajax_search/) and discover how to do that.
45
 
46
  = Support =
47
 
@@ -73,6 +73,13 @@ In WooCommerce->Settings->Ajax Search page, you can choose the minumum size of t
73
 
74
  == Changelog ==
75
 
 
 
 
 
 
 
 
76
  = 1.1.2 =
77
 
78
  * Fixed: Prevent undefined title index if the widget is called by the the_widget func
@@ -106,7 +113,7 @@ If you have created your own language pack, or have an update for an existing on
106
 
107
  == Documentation ==
108
 
109
- Full documentation is available [here](http://yithemes.com/docs-plugins/yith_ajax_search/).
110
 
111
  == Upgrade notice ==
112
 
3
  Contributors: yithemes
4
  Tags: ajax, search, woocommerce, products, themes, yit, e-commerce, shop
5
  Requires at least: 3.5.1
6
+ Tested up to: 4.1
7
+ Stable tag: 1.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
25
 
26
  Working demo is available here:
27
 
28
+ **[LIVE DEMO](http://preview.yithemes.com/sistina/)**
29
 
30
 
31
+ Full documentation is available [here](http://yithemes.com/docs-plugins/yith_woocommerce_ajax_search/).
32
 
33
 
34
  = Installation =
41
 
42
  = Developer =
43
 
44
+ Are you a developer? Want to customize the templates or the style of the plugin? Read on the [documentation](http://yithemes.com/docs-plugins/yith_woocommerce_ajax_search/) and discover how to do that.
45
 
46
  = Support =
47
 
73
 
74
  == Changelog ==
75
 
76
+ = 1.2 =
77
+ * Updated: Plugin Core Framework
78
+
79
+ = 1.1.3 =
80
+
81
+ Fixed: Javascript code in external file
82
+
83
  = 1.1.2 =
84
 
85
  * Fixed: Prevent undefined title index if the widget is called by the the_widget func
113
 
114
  == Documentation ==
115
 
116
+ Full documentation is available [here](http://yithemes.com/docs-plugins/yith_woocommerce_ajax_search/).
117
 
118
  == Upgrade notice ==
119
 
assets/js/frontend.js CHANGED
@@ -6,5 +6,26 @@
6
  * @version 1.1.1
7
  */
8
  jQuery(document).ready(function($){
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  });
6
  * @version 1.1.1
7
  */
8
  jQuery(document).ready(function($){
9
+ "use strict";
10
 
11
+ var el = $('#yith-s'),
12
+ loader_icon = el.data('loader-icon') == '' ? woocommerce_params.ajax_loader_url : el.data('loader-icon'),
13
+ min_chars = el.data('min-chars');
14
+
15
+ el.autocomplete({
16
+ minChars: min_chars,
17
+ appendTo: '.yith-ajaxsearchform-container',
18
+ serviceUrl: woocommerce_params.ajax_url + '?action=yith_ajax_search_products',
19
+ onSearchStart: function(){
20
+ $(this).css('background', 'url(' + loader_icon + ') no-repeat right center');
21
+ },
22
+ onSearchComplete: function(){
23
+ $(this).css('background', 'transparent');
24
+ },
25
+ onSelect: function (suggestion) {
26
+ if( suggestion.id != -1 ) {
27
+ window.location.href = suggestion.url;
28
+ }
29
+ }
30
+ });
31
  });
assets/js/frontend.min.js CHANGED
@@ -6,5 +6,26 @@
6
  * @version 1.1.1
7
  */
8
  jQuery(document).ready(function($){
 
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  });
6
  * @version 1.1.1
7
  */
8
  jQuery(document).ready(function($){
9
+ "use strict";
10
 
11
+ var el = $('#yith-s'),
12
+ loader_icon = el.data('loader-icon') == '' ? woocommerce_params.ajax_loader_url : el.data('loader-icon'),
13
+ min_chars = el.data('min-chars');
14
+
15
+ el.autocomplete({
16
+ minChars: min_chars,
17
+ appendTo: '.yith-ajaxsearchform-container',
18
+ serviceUrl: woocommerce_params.ajax_url + '?action=yith_ajax_search_products',
19
+ onSearchStart: function(){
20
+ $(this).css('background', 'url(' + loader_icon + ') no-repeat right center');
21
+ },
22
+ onSearchComplete: function(){
23
+ $(this).css('background', 'transparent');
24
+ },
25
+ onSelect: function (suggestion) {
26
+ if( suggestion.id != -1 ) {
27
+ window.location.href = suggestion.url;
28
+ }
29
+ }
30
+ });
31
  });
class.yith-wcas-frontend.php CHANGED
@@ -48,6 +48,7 @@ if( !class_exists( 'YITH_WCAS_Frontend' ) ) {
48
  public function enqueue_styles_scripts() {
49
  $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
50
  wp_register_script('yith_wcas_jquery-autocomplete', YITH_WCAS_URL . 'assets/js/devbridge-jquery-autocomplete' . $suffix .'.js', array('jquery'), '1.2.7', true);
 
51
 
52
  $css = file_exists( get_stylesheet_directory() . '/woocommerce/yith_ajax_search.css' ) ? get_stylesheet_directory_uri() . '/woocommerce/yith_ajax_search.css' : YITH_WCAS_URL . 'assets/css/yith_wcas_ajax_search.css';
53
  wp_enqueue_style( 'yith_wcas_frontend', $css );
48
  public function enqueue_styles_scripts() {
49
  $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
50
  wp_register_script('yith_wcas_jquery-autocomplete', YITH_WCAS_URL . 'assets/js/devbridge-jquery-autocomplete' . $suffix .'.js', array('jquery'), '1.2.7', true);
51
+ wp_register_script('yith_wcas_frontend', YITH_WCAS_URL . 'assets/js/frontend' . $suffix .'.js', array('jquery'), '1.0', true);
52
 
53
  $css = file_exists( get_stylesheet_directory() . '/woocommerce/yith_ajax_search.css' ) ? get_stylesheet_directory_uri() . '/woocommerce/yith_ajax_search.css' : YITH_WCAS_URL . 'assets/css/yith_wcas_ajax_search.css';
54
  wp_enqueue_style( 'yith_wcas_frontend', $css );
class.yith-wcas.php CHANGED
@@ -22,7 +22,7 @@ if( !class_exists( 'YITH_WCAS' ) ) {
22
  * @var string
23
  * @since 1.0.0
24
  */
25
- public $version = '1.1.2';
26
 
27
  /**
28
  * Plugin object
@@ -104,7 +104,7 @@ if( !class_exists( 'YITH_WCAS' ) ) {
104
  $search_keyword = esc_attr($_REQUEST['query']);
105
 
106
  $ordering_args = $woocommerce->query->get_catalog_ordering_args( 'title', 'asc' );
107
- $products = array();
108
 
109
  $args = array(
110
  's' => apply_filters('yith_wcas_ajax_search_products_search_query', $search_keyword),
@@ -133,34 +133,34 @@ if( !class_exists( 'YITH_WCAS' ) ) {
133
  ));
134
  }
135
 
136
- $products_query = new WP_Query( $args );
137
 
138
- if ( $products_query->have_posts() ) {
139
- while ( $products_query->have_posts() ) {
140
- $products_query->the_post();
141
 
142
- $products[] = array(
143
- 'id' => get_the_ID(),
144
- 'value' => get_the_title(),
145
- 'url' => get_permalink()
146
- );
147
  }
148
  } else {
149
- $products[] = array(
150
  'id' => -1,
151
  'value' => __('No results', 'yit'),
152
- 'url' => ''
153
  );
154
  }
155
  wp_reset_postdata();
156
 
157
 
158
- $products = array(
159
- 'suggestions' => $products
160
  );
161
 
162
 
163
- echo json_encode( $products );
164
  die();
165
  }
166
  }
22
  * @var string
23
  * @since 1.0.0
24
  */
25
+ public $version = '1.1.3';
26
 
27
  /**
28
  * Plugin object
104
  $search_keyword = esc_attr($_REQUEST['query']);
105
 
106
  $ordering_args = $woocommerce->query->get_catalog_ordering_args( 'title', 'asc' );
107
+ $suggestions = array();
108
 
109
  $args = array(
110
  's' => apply_filters('yith_wcas_ajax_search_products_search_query', $search_keyword),
133
  ));
134
  }
135
 
136
+ $products = get_posts( $args );
137
 
138
+ if ( ! empty( $products ) ) {
139
+ foreach ( $products as $post ) {
140
+ $product = wc_get_product( $post );
141
 
142
+ $suggestions[] = apply_filters( 'yith_wcas_suggestion', array(
143
+ 'id' => $product->id,
144
+ 'value' => $product->get_title(),
145
+ 'url' => $product->get_permalink()
146
+ ), $product );
147
  }
148
  } else {
149
+ $suggestions[] = array(
150
  'id' => -1,
151
  'value' => __('No results', 'yit'),
152
+ 'url' => '',
153
  );
154
  }
155
  wp_reset_postdata();
156
 
157
 
158
+ $suggestions = array(
159
+ 'suggestions' => $suggestions
160
  );
161
 
162
 
163
+ echo json_encode( $suggestions );
164
  die();
165
  }
166
  }
init.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: YITH WooCommerce Ajax Search
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
6
- * Version: 1.1.2
7
  * Author: Your Inspiration Themes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
3
  * Plugin Name: YITH WooCommerce Ajax Search
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Search allows your users to search products in real time.
6
+ * Version: 1.1.3
7
  * Author: Your Inspiration Themes
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yit
templates/yith-woocommerce-ajax-search.php CHANGED
@@ -11,38 +11,25 @@ if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
11
 
12
 
13
  wp_enqueue_script('yith_wcas_jquery-autocomplete' );
 
14
 
15
  ?>
16
 
17
  <div class="yith-ajaxsearchform-container">
18
- <form role="search" method="get" id="yith-ajaxsearchform" action="<?php echo esc_url( home_url( '/' ) ) ?>">
19
- <div>
20
- <label class="screen-reader-text" for="yith-s"><?php _e( 'Search for:', 'yit' ) ?></label>
21
- <input type="search" value="<?php echo get_search_query() ?>" name="s" id="yith-s" placeholder="<?php echo get_option('yith_wcas_search_input_label') ?>" />
22
- <input type="submit" id="yith-searchsubmit" value="<?php echo get_option('yith_wcas_search_submit_label') ?>" />
23
- <input type="hidden" name="post_type" value="product" />
24
- </div>
25
- </form>
26
- </div>
27
- <script type="text/javascript">
28
- jQuery(function($){
29
- var search_loader_url = <?php echo apply_filters('yith_wcas_ajax_search_icon', 'woocommerce_params.ajax_loader_url') ?>;
30
 
31
- $('#yith-s').autocomplete({
32
- minChars: <?php echo get_option('yith_wcas_min_chars') * 1; ?>,
33
- appendTo: '.yith-ajaxsearchform-container',
34
- serviceUrl: woocommerce_params.ajax_url + '?action=yith_ajax_search_products',
35
- onSearchStart: function(){
36
- $(this).css('background', 'url('+search_loader_url+') no-repeat right center');
37
- },
38
- onSearchComplete: function(){
39
- $(this).css('background', 'transparent');
40
- },
41
- onSelect: function (suggestion) {
42
- if( suggestion.id != -1 ) {
43
- window.location.href = suggestion.url;
44
- }
45
- }
46
- });
47
- });
48
- </script>
11
 
12
 
13
  wp_enqueue_script('yith_wcas_jquery-autocomplete' );
14
+ wp_enqueue_script('yith_wcas_frontend' );
15
 
16
  ?>
17
 
18
  <div class="yith-ajaxsearchform-container">
19
+ <form role="search" method="get" id="yith-ajaxsearchform" action="<?php echo esc_url( home_url( '/' ) ) ?>">
20
+ <div>
21
+ <label class="screen-reader-text" for="yith-s"><?php _e( 'Search for:', 'yit' ) ?></label>
 
 
 
 
 
 
 
 
 
22
 
23
+ <input type="search"
24
+ value="<?php echo get_search_query() ?>"
25
+ name="s"
26
+ id="yith-s"
27
+ placeholder="<?php echo get_option('yith_wcas_search_input_label') ?>"
28
+ data-loader-icon="<?php echo str_replace( '"', '', apply_filters('yith_wcas_ajax_search_icon', '') ) ?>"
29
+ data-min-chars="<?php echo get_option('yith_wcas_min_chars'); ?>" />
30
+
31
+ <input type="submit" id="yith-searchsubmit" value="<?php echo get_option('yith_wcas_search_submit_label') ?>" />
32
+ <input type="hidden" name="post_type" value="product" />
33
+ </div>
34
+ </form>
35
+ </div>