YITH WooCommerce Ajax Search - Version 1.8.6

Version Description

  • Released on 7 Gen 2021 =
  • Update: Plugin framework
  • Fix: Issue with Plugin framework
Download this release

Release Info

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

Code changes from version 1.8.5 to 1.8.6

README.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: yithemes
4
  Tags: woocommerce search by sku, woocommerce search results, woocommerce search shortcode, woocommerce search page, woocommerce search form, woocommerce search filter, woocommerce search products, woocommerce search content, woocommerce search autocomplete, woocommerce advanced search, woocommerce search category, woocommerce search product attributes, woocommerce search by tag, woocommerce search by brand, woocommerce predictive, woocommerce live search, woocommerce single product search, woocommerce site search, woocommerce search tex, tajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
  Requires at least: 5.3.0
6
  Tested up to: 5.6
7
- Stable tag: 1.8.5
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -138,6 +138,10 @@ If you have created your own language pack for YITH WooCommerce Ajax Search, or
138
  2. YITH WooCommerce Ajax Search in operation displaying WooCommerce search results
139
 
140
  == Changelog ==
 
 
 
 
141
  = 1.8.5 - Released on 31 Dec 2020 =
142
  * New: Support for WooCommerce 4.9
143
  * Update: Plugin framework
4
  Tags: woocommerce search by sku, woocommerce search results, woocommerce search shortcode, woocommerce search page, woocommerce search form, woocommerce search filter, woocommerce search products, woocommerce search content, woocommerce search autocomplete, woocommerce advanced search, woocommerce search category, woocommerce search product attributes, woocommerce search by tag, woocommerce search by brand, woocommerce predictive, woocommerce live search, woocommerce single product search, woocommerce site search, woocommerce search tex, tajax, search, woocommerce, products, themes, yit, e-commerce, shop, yith, ajax search, instant search, premium, yithemes, autocomplete, autosuggest, better search, category search, custom search, highlight terms, Live Search, Predictive Search, product search, relevant search, search highlight, search product, suggest, typeahead, WooCommerce Plugin, woocommerce product search, woocommerce search, wordpress ecommerce
5
  Requires at least: 5.3.0
6
  Tested up to: 5.6
7
+ Stable tag: 1.8.6
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
138
  2. YITH WooCommerce Ajax Search in operation displaying WooCommerce search results
139
 
140
  == Changelog ==
141
+ = 1.8.6 - Released on 7 Gen 2021 =
142
+ * Update: Plugin framework
143
+ * Fix: Issue with Plugin framework
144
+
145
  = 1.8.5 - Released on 31 Dec 2020 =
146
  * New: Support for WooCommerce 4.9
147
  * Update: Plugin framework
init.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: YITH WooCommerce Ajax Search
4
  * Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-ajax-search/
5
  * Description: <code><strong>YITH WooCommerce Ajax Search</strong></code> is the plugin that allows you to search for a specific product by inserting a few characters. Thanks to <strong>Ajax Search</strong>, users can quickly find the contents they are interested in without wasting time among site pages. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
6
- * Version: 1.8.5
7
  * Author: YITH
8
  * Author URI: https://yithemes.com/
9
  * Text Domain: yith-woocommerce-ajax-search
@@ -71,7 +71,7 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
71
  if ( defined( 'YITH_WCAS_VERSION' ) ) {
72
  return;
73
  } else {
74
- define( 'YITH_WCAS_VERSION', '1.8.5' );
75
  }
76
 
77
  if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
3
  * Plugin Name: YITH WooCommerce Ajax Search
4
  * Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-ajax-search/
5
  * Description: <code><strong>YITH WooCommerce Ajax Search</strong></code> is the plugin that allows you to search for a specific product by inserting a few characters. Thanks to <strong>Ajax Search</strong>, users can quickly find the contents they are interested in without wasting time among site pages. <a href="https://yithemes.com/" target="_blank">Get more plugins for your e-commerce shop on <strong>YITH</strong></a>.
6
+ * Version: 1.8.6
7
  * Author: YITH
8
  * Author URI: https://yithemes.com/
9
  * Text Domain: yith-woocommerce-ajax-search
71
  if ( defined( 'YITH_WCAS_VERSION' ) ) {
72
  return;
73
  } else {
74
+ define( 'YITH_WCAS_VERSION', '1.8.6' );
75
  }
76
 
77
  if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
languages/yith-woocommerce-ajax-search.pot CHANGED
@@ -1,15 +1,15 @@
1
- # Copyright (C) 2020 YITH
2
  # This file is distributed under the same license as the YITH WooCommerce Ajax Search package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: YITH WooCommerce Ajax Search 1.8.5\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/yith-woocommerce-ajax-search\n"
8
- "POT-Creation-Date: 2020-12-31 11:35:12+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "PO-Revision-Date: 2020-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
  "X-Generator: grunt-wp-i18n 1.0.3\n"
1
+ # Copyright (C) 2021 YITH
2
  # This file is distributed under the same license as the YITH WooCommerce Ajax Search package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: YITH WooCommerce Ajax Search 1.8.6\n"
6
  "Report-Msgid-Bugs-To: "
7
  "https://wordpress.org/support/plugin/yith-woocommerce-ajax-search\n"
8
+ "POT-Creation-Date: 2021-01-07 08:41:36+00:00\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=utf-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "PO-Revision-Date: 2021-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
  "X-Generator: grunt-wp-i18n 1.0.3\n"
plugin-fw/includes/class-yit-ajax.php CHANGED
@@ -52,24 +52,24 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
52
  /**
53
  * Post Search
54
  *
55
- * @param bool|array $request The request.
56
  */
57
- public function json_search_posts( $request = false ) {
58
  ob_start();
59
 
60
- if ( ! $request ) {
 
 
 
61
  check_ajax_referer( 'search-posts', 'security' );
62
  }
63
 
64
- $request = $request ? $request : $_REQUEST;
65
- $term = isset( $request['term'] ) ? (string) sanitize_text_field( wp_unslash( $request['term'] ) ) : false;
66
-
67
  if ( empty( $term ) ) {
68
  die();
69
  }
70
 
71
  $found_posts = array();
72
-
73
  $args = array(
74
  'post_type' => 'post',
75
  'post_status' => 'publish',
@@ -82,16 +82,18 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
82
  );
83
 
84
  foreach ( $args as $key => $default_value ) {
85
- if ( ! empty( $request[ $key ] ) ) {
86
- $args[ $key ] = $request[ $key ];
87
  }
88
  }
89
 
90
- if ( isset( $request['post_parent'] ) ) {
91
- $args['post_parent'] = $request['post_parent'];
92
  }
93
 
94
- $show_id = isset( $request['show_id'] ) && $request['show_id'];
 
 
95
 
96
  $args['s'] = $term;
97
  $args['fields'] = 'ids';
@@ -107,8 +109,8 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
107
  $found_posts[ $post_id ] = apply_filters( 'yith_plugin_fw_json_search_found_post_title', rawurldecode( $title ), $post_id, $request );
108
  }
109
  }
110
- $found_posts = apply_filters( 'yith_plugin_fw_json_search_found_posts', $found_posts, $request );
111
 
 
112
  wp_send_json( $found_posts );
113
  }
114
 
@@ -118,18 +120,18 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
118
  public function json_search_products() {
119
  check_ajax_referer( 'search-posts', 'security' );
120
 
121
- $term = isset( $_GET['term'] ) ? (string) wc_clean( wp_unslash( $_GET['term'] ) ) : false;
122
  if ( empty( $term ) ) {
123
  die();
124
  }
125
 
126
- $request = $_REQUEST;
127
- $request['post_type'] = 'product';
128
 
129
- $request_include = isset( $request['include'] ) && ! is_array( $request['include'] ) ? explode( ',', $request['include'] ) : array();
 
 
130
 
131
- if ( ! empty( $request['product_type'] ) ) {
132
- $product_type_term = get_term_by( 'slug', $request['product_type'], 'product_type' );
133
  if ( $product_type_term ) {
134
  $posts_in = array_unique( (array) get_objects_in_term( $product_type_term->term_id, 'product_type' ) );
135
  if ( ! ! $request_include ) {
@@ -145,7 +147,6 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
145
  }
146
 
147
  $request = apply_filters( 'yith_plugin_fw_json_search_products_request', $request );
148
-
149
  $this->json_search_posts( $request );
150
  }
151
 
@@ -158,7 +159,7 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
158
 
159
  check_ajax_referer( 'search-posts', 'security' );
160
 
161
- $term = isset( $_REQUEST['term'] ) ? (string) wc_clean( wp_unslash( $_REQUEST['term'] ) ) : false;
162
 
163
  if ( empty( $term ) ) {
164
  die();
@@ -166,11 +167,11 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
166
 
167
  $found_orders = array();
168
  $term = apply_filters( 'yith_plugin_fw_json_search_order_number', $term );
169
- $search = '%' . $term . '%';
170
 
171
  $query_orders = $wpdb->get_results(
172
  $wpdb->prepare(
173
- "SELECT ID, post_title FROM {$wpdb->posts} AS posts WHERE posts.post_type = 'shop_order'AND posts.ID LIKE %s",
174
  $search
175
  )
176
  );
@@ -178,7 +179,7 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
178
  if ( $query_orders ) {
179
  foreach ( $query_orders as $item ) {
180
  $order_number = apply_filters( 'yith_plugin_fw_order_number', '#' . $item->ID, $item->ID );
181
- $found_orders[ $item->ID ] = $order_number . ' &ndash; ' . esc_html( $item->post_title );
182
  }
183
  }
184
 
@@ -199,9 +200,7 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
199
  die();
200
  }
201
 
202
- $request = $_REQUEST;
203
-
204
- $args = array(
205
  'taxonomy' => 'category',
206
  'hide_empty' => false,
207
  'order' => 'ASC',
@@ -214,17 +213,15 @@ if ( ! class_exists( 'YIT_Ajax' ) ) {
214
  'child_of' => 0,
215
  'parent' => '',
216
  'term_field' => 'id',
217
- );
218
-
219
- $args = apply_filters( 'yith_plugin_fw_json_search_terms_default_args', $args, $request );
220
 
221
  foreach ( $args as $key => $default_value ) {
222
- if ( ! empty( $request[ $key ] ) ) {
223
- $args[ $key ] = wp_unslash( $request[ $key ] );
224
  }
225
  }
226
 
227
- $args = apply_filters( 'yith_plugin_fw_json_search_terms_args', $args, $request );
228
 
229
  $args['name__like'] = $term;
230
  $args['fields'] = 'id=>name';
52
  /**
53
  * Post Search
54
  *
55
+ * @param array $request The request.
56
  */
57
+ public function json_search_posts( $request = array() ) {
58
  ob_start();
59
 
60
+ // make sure request is array
61
+ ! is_array( $request ) && $request = array();
62
+
63
+ if ( empty( $request ) ) {
64
  check_ajax_referer( 'search-posts', 'security' );
65
  }
66
 
67
+ $term = isset( $request['term'] ) ? $request['term'] : ( isset( $_REQUEST['term'] ) ? (string) sanitize_text_field( wp_unslash( $_REQUEST['term'] ) ) : '' );
 
 
68
  if ( empty( $term ) ) {
69
  die();
70
  }
71
 
72
  $found_posts = array();
 
73
  $args = array(
74
  'post_type' => 'post',
75
  'post_status' => 'publish',
82
  );
83
 
84
  foreach ( $args as $key => $default_value ) {
85
+ if ( ! empty( $_REQUEST[ $key ] ) ) {
86
+ $args[ $key ] = sanitize_text_field( wp_unslash( $_REQUEST[ $key ] ) );
87
  }
88
  }
89
 
90
+ if ( isset( $_REQUEST['post_parent'] ) ) {
91
+ $args['post_parent'] = intval( $_REQUEST['post_parent'] );
92
  }
93
 
94
+ // merge with passed request data
95
+ $args = array_merge( $args, $request );
96
+ $show_id = ! empty( $_REQUEST['show_id'] );
97
 
98
  $args['s'] = $term;
99
  $args['fields'] = 'ids';
109
  $found_posts[ $post_id ] = apply_filters( 'yith_plugin_fw_json_search_found_post_title', rawurldecode( $title ), $post_id, $request );
110
  }
111
  }
 
112
 
113
+ $found_posts = apply_filters( 'yith_plugin_fw_json_search_found_posts', $found_posts, $request );
114
  wp_send_json( $found_posts );
115
  }
116
 
120
  public function json_search_products() {
121
  check_ajax_referer( 'search-posts', 'security' );
122
 
123
+ $term = isset( $_REQUEST['term'] ) ? (string) wc_clean( wp_unslash( $_REQUEST['term'] ) ) : false;
124
  if ( empty( $term ) ) {
125
  die();
126
  }
127
 
128
+ $request = array( 'post_type' => 'product' );
129
+ $request_include = isset( $_REQUEST['include'] ) && ! is_array( $_REQUEST['include'] ) ? explode( ',', sanitize_text_field( wp_unslash( $_REQUEST['include'] ) ) ) : array();
130
 
131
+ if ( ! empty( $_REQUEST['product_type'] ) ) {
132
+ $product_type = sanitize_text_field( wp_unslash( $_REQUEST['product_type'] ) );
133
+ $product_type_term = get_term_by( 'slug', $product_type, 'product_type' );
134
 
 
 
135
  if ( $product_type_term ) {
136
  $posts_in = array_unique( (array) get_objects_in_term( $product_type_term->term_id, 'product_type' ) );
137
  if ( ! ! $request_include ) {
147
  }
148
 
149
  $request = apply_filters( 'yith_plugin_fw_json_search_products_request', $request );
 
150
  $this->json_search_posts( $request );
151
  }
152
 
159
 
160
  check_ajax_referer( 'search-posts', 'security' );
161
 
162
+ $term = isset( $_REQUEST['term'] ) ? intval( $_REQUEST['term'] ) : false;
163
 
164
  if ( empty( $term ) ) {
165
  die();
167
 
168
  $found_orders = array();
169
  $term = apply_filters( 'yith_plugin_fw_json_search_order_number', $term );
170
+ $search = '%' . intval( $term ) . '%';
171
 
172
  $query_orders = $wpdb->get_results(
173
  $wpdb->prepare(
174
+ "SELECT ID, post_title FROM {$wpdb->posts} AS posts WHERE posts.post_type = 'shop_order' AND posts.ID LIKE %s",
175
  $search
176
  )
177
  );
179
  if ( $query_orders ) {
180
  foreach ( $query_orders as $item ) {
181
  $order_number = apply_filters( 'yith_plugin_fw_order_number', '#' . $item->ID, $item->ID );
182
+ $found_orders[ $item->ID ] = esc_html( $order_number ) . ' &ndash; ' . esc_html( $item->post_title );
183
  }
184
  }
185
 
200
  die();
201
  }
202
 
203
+ $args = apply_filters( 'yith_plugin_fw_json_search_terms_default_args', array(
 
 
204
  'taxonomy' => 'category',
205
  'hide_empty' => false,
206
  'order' => 'ASC',
213
  'child_of' => 0,
214
  'parent' => '',
215
  'term_field' => 'id',
216
+ ) );
 
 
217
 
218
  foreach ( $args as $key => $default_value ) {
219
+ if ( ! empty( $_REQUEST[ $key ] ) ) {
220
+ $args[ $key ] = sanitize_text_field( wp_unslash( $_REQUEST[ $key ] ) );
221
  }
222
  }
223
 
224
+ $args = apply_filters( 'yith_plugin_fw_json_search_terms_args', $args );
225
 
226
  $args['name__like'] = $term;
227
  $args['fields'] = 'id=>name';
plugin-fw/includes/class-yit-metabox.php CHANGED
@@ -317,7 +317,7 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
317
  return $post_id;
318
  }
319
 
320
- $allow_ajax = isset( $_REQUEST['yith_metabox_allow_ajax_saving'] ) && $this->id === $_REQUEST['yith_metabox_allow_ajax_saving'];
321
  if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX && ! $allow_ajax ) ) {
322
  return $post_id;
323
  }
@@ -382,7 +382,7 @@ if ( ! class_exists( 'YIT_Metabox' ) ) {
382
  // phpcs:disable WordPress.Security.NonceVerification.Recommended
383
  $this->reorder_tabs();
384
  $tabs_to_sanitize = $this->tabs;
385
- $allow_ajax = isset( $_REQUEST['yith_metabox_allow_ajax_saving'] ) && $this->id === $_REQUEST['yith_metabox_allow_ajax_saving'];
386
  $ajax_partial_saving_tab = isset( $_REQUEST['yith_metabox_allow_ajax_partial_saving_tab'] ) ? sanitize_key( wp_unslash( $_REQUEST['yith_metabox_allow_ajax_partial_saving_tab'] ) ) : false;
387
 
388
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX && ! $allow_ajax ) {
317
  return $post_id;
318
  }
319
 
320
+ $allow_ajax = isset( $_REQUEST['yith_metabox_allow_ajax_saving'] ) && $this->id === sanitize_key( wp_unslash( $_REQUEST['yith_metabox_allow_ajax_saving'] ) );
321
  if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX && ! $allow_ajax ) ) {
322
  return $post_id;
323
  }
382
  // phpcs:disable WordPress.Security.NonceVerification.Recommended
383
  $this->reorder_tabs();
384
  $tabs_to_sanitize = $this->tabs;
385
+ $allow_ajax = isset( $_REQUEST['yith_metabox_allow_ajax_saving'] ) && $this->id === sanitize_key( wp_unslash( $_REQUEST['yith_metabox_allow_ajax_saving'] ) );
386
  $ajax_partial_saving_tab = isset( $_REQUEST['yith_metabox_allow_ajax_partial_saving_tab'] ) ? sanitize_key( wp_unslash( $_REQUEST['yith_metabox_allow_ajax_partial_saving_tab'] ) ) : false;
387
 
388
  if ( defined( 'DOING_AJAX' ) && DOING_AJAX && ! $allow_ajax ) {
plugin-fw/includes/class-yit-plugin-panel-woocommerce.php CHANGED
@@ -330,7 +330,7 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
330
  do_action( 'yit_panel_wc_after_update' );
331
 
332
  } elseif (
333
- isset( $_REQUEST['yit-action'] ) && 'wc-options-reset' === $_REQUEST['yit-action']
334
  &&
335
  isset( $_POST['yith_wc_reset_options_nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['yith_wc_reset_options_nonce'] ) ), 'yith_wc_reset_options_' . $this->settings['page'] )
336
  ) {
330
  do_action( 'yit_panel_wc_after_update' );
331
 
332
  } elseif (
333
+ isset( $_REQUEST['yit-action'] ) && 'wc-options-reset' === sanitize_key( wp_unslash( $_REQUEST['yit-action'] ) )
334
  &&
335
  isset( $_POST['yith_wc_reset_options_nonce'] ) && wp_verify_nonce( sanitize_key( wp_unslash( $_POST['yith_wc_reset_options_nonce'] ) ), 'yith_wc_reset_options_' . $this->settings['page'] )
336
  ) {
plugin-fw/includes/class-yit-plugin-panel.php CHANGED
@@ -1209,7 +1209,7 @@ if ( ! class_exists( 'YIT_Plugin_Panel' ) ) {
1209
  */
1210
  public function get_options() {
1211
  $options = get_option( 'yit_' . $this->settings['parent'] . '_options' );
1212
- if ( false === $options || ( isset( $_REQUEST['yit-action'] ) && 'reset' === $_REQUEST['yit-action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1213
  $options = $this->get_default_options();
1214
  }
1215
 
1209
  */
1210
  public function get_options() {
1211
  $options = get_option( 'yit_' . $this->settings['parent'] . '_options' );
1212
+ if ( false === $options || ( isset( $_REQUEST['yit-action'] ) && 'reset' === sanitize_key( wp_unslash( $_REQUEST['yit-action'] ) ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1213
  $options = $this->get_default_options();
1214
  }
1215