YITH WooCommerce Ajax Search - Version 1.5.0

Version Description

  • Released: Mar 06, 2017 = New: Support to WooCommerce 2.7 RC 1 Update: Plugin Core Update: Languages files
Download this release

Release Info

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

Code changes from version 1.4.1 to 1.5.0

README.txt CHANGED
@@ -2,9 +2,9 @@
2
 
3
  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: 3.5.1
6
  Tested up to: 4.6.1
7
- Stable tag: 1.4.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -138,6 +138,11 @@ 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.4.1 - Released: Oct 17, 2016 =
142
  * Added: Option to save the autocomplete results in a transient
143
  * Updated: Plugin Framework
2
 
3
  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: 4.0.0
6
  Tested up to: 4.6.1
7
+ Stable tag: 1.5.0
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.5.0 - Released: Mar 06, 2017 =
142
+ New: Support to WooCommerce 2.7 RC 1
143
+ Update: Plugin Core
144
+ Update: Languages files
145
+
146
  = 1.4.1 - Released: Oct 17, 2016 =
147
  * Added: Option to save the autocomplete results in a transient
148
  * Updated: Plugin Framework
class.yith-wcas.php CHANGED
@@ -55,7 +55,7 @@ if ( !class_exists( 'YITH_WCAS' ) ) {
55
  $this->obj = new YITH_WCAS_Frontend( $this->version );
56
  }
57
  }
58
-
59
  // actions
60
  add_action( 'widgets_init', array( $this, 'registerWidgets' ) );
61
 
@@ -170,7 +170,7 @@ if ( !class_exists( 'YITH_WCAS' ) ) {
170
  $product = wc_get_product( $post );
171
 
172
  $suggestions[] = apply_filters( 'yith_wcas_suggestion', array(
173
- 'id' => $product->id,
174
  'value' => strip_tags( $product->get_title() ),
175
  'url' => $product->get_permalink()
176
  ), $product );
55
  $this->obj = new YITH_WCAS_Frontend( $this->version );
56
  }
57
  }
58
+ include_once( YITH_WCAS_DIR.'plugin-fw/yit-woocommerce-compatibility.php' );
59
  // actions
60
  add_action( 'widgets_init', array( $this, 'registerWidgets' ) );
61
 
170
  $product = wc_get_product( $post );
171
 
172
  $suggestions[] = apply_filters( 'yith_wcas_suggestion', array(
173
+ 'id' => $product->get_id(),
174
  'value' => strip_tags( $product->get_title() ),
175
  'url' => $product->get_permalink()
176
  ), $product );
functions.yith-wcas.php CHANGED
@@ -7,8 +7,11 @@
7
  * @version 1.1.1
8
  */
9
 
10
- if ( !defined( 'YITH_WCAS' ) ) { exit; } // Exit if accessed directly
11
- function getmicrotime(){
12
- list($usec, $sec) = explode(" ",microtime());
13
- return ((float)$usec + (float)$sec);
 
 
 
14
  }
7
  * @version 1.1.1
8
  */
9
 
10
+ if ( ! defined( 'YITH_WCAS' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
+ function getmicrotime() {
14
+ list( $usec, $sec ) = explode( " ", microtime() );
15
+
16
+ return ( (float) $usec + (float) $sec );
17
  }
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.4.1
7
  * Author: YITHEMES
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith-woocommerce-ajax-search
@@ -65,7 +65,7 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
65
  if ( defined( 'YITH_WCAS_VERSION' ) ){
66
  return;
67
  }else{
68
- define( 'YITH_WCAS_VERSION', '1.4.1' );
69
  }
70
 
71
  if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
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.5.0
7
  * Author: YITHEMES
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith-woocommerce-ajax-search
65
  if ( defined( 'YITH_WCAS_VERSION' ) ){
66
  return;
67
  }else{
68
+ define( 'YITH_WCAS_VERSION', '1.5.0' );
69
  }
70
 
71
  if ( ! defined( 'YITH_WCAS_FREE_INIT' ) ) {
languages/yith-woocommerce-ajax-search-it_IT.mo CHANGED
Binary file
languages/yith-woocommerce-ajax-search-it_IT.po CHANGED
@@ -1,8 +1,8 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: YITH WooCommerce Ajax Search Premium\n"
4
- "POT-Creation-Date: 2016-10-17 12:45+0200\n"
5
- "PO-Revision-Date: 2016-10-17 12:45+0200\n"
6
  "Last-Translator: \n"
7
  "Language-Team: Yithemes <plugins@yithemes.com>\n"
8
  "Language: it_IT\n"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: YITH WooCommerce Ajax Search Premium\n"
4
+ "POT-Creation-Date: 2017-03-06 14:56+0100\n"
5
+ "PO-Revision-Date: 2017-03-06 14:56+0100\n"
6
  "Last-Translator: \n"
7
  "Language-Team: Yithemes <plugins@yithemes.com>\n"
8
  "Language: it_IT\n"
languages/yith-woocommerce-ajax-search.pot CHANGED
@@ -2,7 +2,7 @@
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: YITH WooCommerce Ajax Search Free\n"
5
- "POT-Creation-Date: 2016-10-17 12:45+0200\n"
6
  "PO-Revision-Date: 2015-07-17 09:42+0100\n"
7
  "Last-Translator: \n"
8
  "Language-Team: Yithemes <plugins@yithemes.com>\n"
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: YITH WooCommerce Ajax Search Free\n"
5
+ "POT-Creation-Date: 2017-03-06 14:56+0100\n"
6
  "PO-Revision-Date: 2015-07-17 09:42+0100\n"
7
  "Last-Translator: \n"
8
  "Language-Team: Yithemes <plugins@yithemes.com>\n"
plugin-fw/init.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Framework Name: YIT Plugin Framework
4
- * Version: 2.9.38
5
  * Author: Yithemes
6
  * Text Domain: yith-plugin-fw
7
  * Domain Path: /languages/
@@ -19,8 +19,6 @@
19
  * http://www.gnu.org/licenses/gpl-3.0.txt
20
  */
21
 
22
- // test
23
-
24
  if ( ! defined ( 'ABSPATH' ) ) {
25
  exit;
26
  } // Exit if accessed directly
@@ -56,3 +54,5 @@ if ( ! function_exists ( 'yit_maybe_plugin_fw_loader' ) ) {
56
  }
57
  }
58
  }
 
 
1
  <?php
2
  /**
3
  * Framework Name: YIT Plugin Framework
4
+ * Version: 2.9.51
5
  * Author: Yithemes
6
  * Text Domain: yith-plugin-fw
7
  * Domain Path: /languages/
19
  * http://www.gnu.org/licenses/gpl-3.0.txt
20
  */
21
 
 
 
22
  if ( ! defined ( 'ABSPATH' ) ) {
23
  exit;
24
  } // Exit if accessed directly
54
  }
55
  }
56
  }
57
+
58
+
plugin-fw/lib/yit-cpt-unlimited.php CHANGED
@@ -138,8 +138,8 @@ class YIT_CPT_Unlimited {
138
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ) );
139
 
140
  // metaboxes
141
- add_action( 'after_setup_theme', array( $this, 'add_metabox_cptu' ), 2 );
142
- add_action( 'after_setup_theme', array( $this, 'add_metabox_item_fields' ), 2 );
143
 
144
  // multiuploader
145
  if ( $this->_args['add_multiuploader'] ) {
138
  add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ) );
139
 
140
  // metaboxes
141
+ add_action( 'add_meta_boxes', array( $this, 'add_metabox_cptu' ), 2 );
142
+ add_action( 'add_meta_boxes', array( $this, 'add_metabox_item_fields' ), 2 );
143
 
144
  // multiuploader
145
  if ( $this->_args['add_multiuploader'] ) {
plugin-fw/lib/yit-metabox.php CHANGED
@@ -133,7 +133,7 @@ if (!class_exists('YIT_Metabox')) {
133
  $this->set_tabs();
134
 
135
 
136
- add_action('add_meta_boxes', array($this, 'register_metabox'));
137
  add_action('save_post', array($this, 'save_postdata'));
138
  add_action('admin_enqueue_scripts', array($this, 'enqueue'), 15);
139
 
@@ -414,6 +414,7 @@ if (!class_exists('YIT_Metabox')) {
414
  */
415
  public function register_metabox($post_type)
416
  {
 
417
  if (in_array($post_type, (array)$this->options['pages'])) {
418
  add_meta_box($this->id, $this->options['label'], array($this, 'show'), $post_type, $this->options['context'], $this->options['priority']);
419
  }
@@ -476,12 +477,31 @@ if (!class_exists('YIT_Metabox')) {
476
  }
477
  }
478
 
479
- if (!in_array($post_type, (array)$this->options['pages'])) {
480
  return $post_id;
481
- }
482
 
483
  $this->reorder_tabs();
484
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
485
 
486
  foreach ($this->tabs as $tab) {
487
 
@@ -501,8 +521,7 @@ if (!class_exists('YIT_Metabox')) {
501
  }
502
  }
503
  }
504
-
505
-
506
  }
507
 
508
  /**
133
  $this->set_tabs();
134
 
135
 
136
+ add_action('add_meta_boxes', array($this, 'register_metabox'),99);
137
  add_action('save_post', array($this, 'save_postdata'));
138
  add_action('admin_enqueue_scripts', array($this, 'enqueue'), 15);
139
 
414
  */
415
  public function register_metabox($post_type)
416
  {
417
+
418
  if (in_array($post_type, (array)$this->options['pages'])) {
419
  add_meta_box($this->id, $this->options['label'], array($this, 'show'), $post_type, $this->options['context'], $this->options['priority']);
420
  }
477
  }
478
  }
479
 
480
+ /*if (!in_array($post_type, (array)$this->options['pages'])) {
481
  return $post_id;
482
+ }*/
483
 
484
  $this->reorder_tabs();
485
 
486
+ if(isset($_POST['yit_metaboxes'])) {
487
+ $yit_metabox_data = $_POST['yit_metaboxes'];
488
+
489
+ if(is_array($yit_metabox_data)) {
490
+
491
+ foreach ($yit_metabox_data as $field_name => $field_value) {
492
+
493
+ if(! add_post_meta($post_id, $field_name, $field_value, true) )
494
+ {
495
+ update_post_meta($post_id, $field_name, $field_value);
496
+ }
497
+
498
+
499
+ }
500
+
501
+ }
502
+
503
+
504
+ }
505
 
506
  foreach ($this->tabs as $tab) {
507
 
521
  }
522
  }
523
  }
524
+
 
525
  }
526
 
527
  /**
plugin-fw/lib/yit-plugin-panel-wc.php CHANGED
@@ -369,7 +369,7 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
369
  wp_enqueue_script( 'woocommerce_settings', $woocommerce->plugin_url() . '/assets/js/admin/settings.min.js', $woocommerce_settings_deps, $woocommerce_version, true );
370
 
371
  wp_register_script( 'colorbox', YIT_CORE_PLUGIN_URL . '/assets/js/jquery.colorbox.js', array( 'jquery' ), '1.6.3', true );
372
- wp_register_script( 'yit-plugin-panel', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel.min.js', array( 'jquery', 'jquery-chosen','wp-color-picker' ), $this->version, true );
373
  wp_localize_script( 'woocommerce_settings', 'woocommerce_settings_params', array(
374
  'i18n_nav_warning' => __( 'The changes you have made will be lost if you leave this page.', 'yith-plugin-fw' )
375
  ) );
369
  wp_enqueue_script( 'woocommerce_settings', $woocommerce->plugin_url() . '/assets/js/admin/settings.min.js', $woocommerce_settings_deps, $woocommerce_version, true );
370
 
371
  wp_register_script( 'colorbox', YIT_CORE_PLUGIN_URL . '/assets/js/jquery.colorbox.js', array( 'jquery' ), '1.6.3', true );
372
+ wp_register_script( 'yit-plugin-panel', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel.min.js', array( 'jquery', 'jquery-chosen','wp-color-picker', 'jquery-ui-dialog' ), $this->version, true );
373
  wp_localize_script( 'woocommerce_settings', 'woocommerce_settings_params', array(
374
  'i18n_nav_warning' => __( 'The changes you have made will be lost if you leave this page.', 'yith-plugin-fw' )
375
  ) );
plugin-fw/lib/yit-plugin-panel.php CHANGED
@@ -114,7 +114,7 @@ if ( ! class_exists( 'YIT_Plugin_Panel' ) ) {
114
  if( ! isset( $admin_page_hooks['yit_plugin_panel'] ) ){
115
  $position = apply_filters( 'yit_plugins_menu_item_position', '62.32' );
116
  // YITH Plugins text must not be translated
117
- add_menu_page( 'yit_plugin_panel', 'YITH Plugins', 'manage_options', 'yit_plugin_panel', NULL, YIT_CORE_PLUGIN_URL . '/assets/images/yithemes-icon.png', $position );
118
  }
119
  }
120
 
@@ -324,7 +324,7 @@ if ( ! class_exists( 'YIT_Plugin_Panel' ) ) {
324
  }
325
  ?>
326
  <div id="icon-themes" class="icon32"><br /></div>
327
- <h2 class="nav-tab-wrapper">
328
  <?php echo $tabs ?>
329
  </h2>
330
  <?php
114
  if( ! isset( $admin_page_hooks['yit_plugin_panel'] ) ){
115
  $position = apply_filters( 'yit_plugins_menu_item_position', '62.32' );
116
  // YITH Plugins text must not be translated
117
+ current_user_can( 'manage_options' ) && add_menu_page( 'yit_plugin_panel', 'YITH Plugins', 'manage_options', 'yit_plugin_panel', NULL, YIT_CORE_PLUGIN_URL . '/assets/images/yithemes-icon.png', $position );
118
  }
119
  }
120
 
324
  }
325
  ?>
326
  <div id="icon-themes" class="icon32"><br /></div>
327
+ <h2 class="yith nav-tab-wrapper">
328
  <?php echo $tabs ?>
329
  </h2>
330
  <?php
plugin-fw/licence/lib/yit-licence.php CHANGED
@@ -95,8 +95,9 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
95
  }
96
 
97
  /* Update Licence Information */
98
- add_action( 'core_upgrade_preamble', array( $this, 'check_all' ) );
99
- add_action( 'wp_maybe_auto_update', array( $this, 'check_all' ) );
 
100
 
101
  }
102
 
@@ -142,7 +143,7 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
142
  $home_url = str_replace( $scheme, '', $home_url );
143
  }
144
 
145
- return $home_url;
146
  }
147
 
148
  /**
95
  }
96
 
97
  /* Update Licence Information */
98
+ //@TODO: Removed for performance
99
+ // add_action( 'core_upgrade_preamble', array( $this, 'check_all' ) );
100
+ // add_action( 'wp_maybe_auto_update', array( $this, 'check_all' ) );
101
 
102
  }
103
 
143
  $home_url = str_replace( $scheme, '', $home_url );
144
  }
145
 
146
+ return apply_filters('yit_licence_get_home_url', $home_url );
147
  }
148
 
149
  /**
plugin-fw/yit-plugin.php CHANGED
@@ -19,6 +19,7 @@ if ( ! defined( 'ABSPATH' ) ) {
19
  ! defined( 'YIT_CORE_PLUGIN_TEMPLATE_PATH' ) && define( 'YIT_CORE_PLUGIN_TEMPLATE_PATH', YIT_CORE_PLUGIN_PATH . '/templates' );
20
 
21
  include_once( 'yit-functions.php' );
 
22
  include_once( 'yit-plugin-registration-hook.php' );
23
  include_once( 'lib/yit-metabox.php' );
24
  include_once( 'lib/yit-plugin-panel.php' );
@@ -40,3 +41,18 @@ load_textdomain( 'yith-plugin-fw', get_template_directory() . '/core/plugin-fw/y
40
 
41
  // ...or from plugin folder
42
  || load_textdomain( 'yith-plugin-fw', dirname(__FILE__) . '/languages/yith-plugin-fw-' . apply_filters( 'plugin_locale', get_locale(), 'yith-plugin-fw' ) . '.mo' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  ! defined( 'YIT_CORE_PLUGIN_TEMPLATE_PATH' ) && define( 'YIT_CORE_PLUGIN_TEMPLATE_PATH', YIT_CORE_PLUGIN_PATH . '/templates' );
20
 
21
  include_once( 'yit-functions.php' );
22
+ include_once( 'yit-woocommerce-compatibility.php' );
23
  include_once( 'yit-plugin-registration-hook.php' );
24
  include_once( 'lib/yit-metabox.php' );
25
  include_once( 'lib/yit-plugin-panel.php' );
41
 
42
  // ...or from plugin folder
43
  || load_textdomain( 'yith-plugin-fw', dirname(__FILE__) . '/languages/yith-plugin-fw-' . apply_filters( 'plugin_locale', get_locale(), 'yith-plugin-fw' ) . '.mo' );
44
+
45
+ if( apply_filters( 'yit_fw_wc_update_message_hook', true ) || ( function_exists( 'WC' ) && ! version_compare( WC()->version, '2.7', '>=' ) ) ){
46
+ add_action( 'admin_notices', 'yit_fw_wc_update_message', 15 );
47
+
48
+ if( ! function_exists( 'yit_fw_wc_update_message' ) ){
49
+ function yit_fw_wc_update_message(){ ?>
50
+ <div class="notice notice-error is-dismissible">
51
+ <?php $message = 'the new WooCommerce version 2.7 will be soon released. <strong>Before</strong> proceeding with the update, please verify the plugins you are using are already compatible. You can check the compatibility status of YITH products'; ?>
52
+ <?php $url = 'https://support.yithemes.com/hc/en-us/articles/215945378-Theme-and-Plugin-compatibility-with-WordPress-and-WooCommerce'; ?>
53
+ <p><?php printf( '<strong>%s</strong> - %s <a href="%s" target="_blank">HERE</a>.', 'Please note', $message, $url ); ?></p>
54
+ </div>
55
+ <?php
56
+ }
57
+ }
58
+ }
plugin-fw/yit-woocommerce-compatibility.php ADDED
@@ -0,0 +1,688 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( ! function_exists( 'WC' ) ) {
16
+ return;
17
+ }
18
+
19
+ $changed_objects = array();
20
+
21
+ if ( ! function_exists( 'yit_get_prop' ) ) {
22
+ /**
23
+ *
24
+ */
25
+ function yit_get_prop( $object, $key, $single = true, $context = 'view' ) {
26
+
27
+ $prop_map = yit_return_new_attribute_map();
28
+ $is_wc_data = $object instanceof WC_Data;
29
+
30
+ if ( $is_wc_data ) {
31
+ $key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
32
+
33
+ if ( ( $getter = "get{$key}" ) && method_exists( $object, $getter ) ) {
34
+ return $object->$getter( $context );
35
+ } elseif ( ( $getter = "get_{$key}" ) && method_exists( $object, $getter ) ) {
36
+ return $object->$getter( $context );
37
+ } else {
38
+ return $object->get_meta( $key, $single );
39
+ }
40
+ } else {
41
+ $key = ( in_array( $key, $prop_map ) ) ? array_search( $key, $prop_map ) : $key;
42
+
43
+ if ( isset( $object->$key ) ) {
44
+ return $object->$key;
45
+ } elseif ( yit_wc_check_post_columns( $key ) ) {
46
+ return $object->post->$key;
47
+ } else {
48
+ $getter = 'get_user_meta';
49
+ ! $object instanceof WC_Customer && $getter = 'get_post_meta';
50
+
51
+ $object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id;
52
+
53
+ return $getter( $object_id, $key, true );
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+ if ( ! function_exists( 'yit_set_prop' ) ) {
60
+ /**
61
+ *
62
+ */
63
+ function yit_set_prop( $object, $arg1, $arg2 = false ) {
64
+
65
+ if ( ! is_array( $arg1 ) ) {
66
+ $arg1 = array(
67
+ $arg1 => $arg2
68
+ );
69
+ }
70
+
71
+ $prop_map = yit_return_new_attribute_map();
72
+ $is_wc_data = $object instanceof WC_Data;
73
+
74
+ foreach ( $arg1 as $key => $value ) {
75
+ if ( $is_wc_data ) {
76
+ $key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
77
+
78
+ if ( ( $setter = "set{$key}" ) && method_exists( $object, $setter ) ) {
79
+ $object->$setter( $value );
80
+ } elseif ( ( $setter = "set_{$key}" ) && method_exists( $object, $setter ) ) {
81
+ $object->$setter( $value );
82
+ } else {
83
+ $object->update_meta_data( $key, $value );
84
+ }
85
+ } else {
86
+ $key = ( in_array( $key, $prop_map ) ) ? array_search( $key, $prop_map ) : $key;
87
+ ( strpos( $key, '_' ) === 0 ) && $key = substr( $key, 1 );
88
+
89
+ if ( yit_wc_check_post_columns( $key ) ) {
90
+ $object->post->$key = $value;
91
+ } else {
92
+ $object->$key = $value;
93
+ }
94
+ }
95
+ }
96
+ }
97
+ }
98
+
99
+ if ( ! function_exists( 'yit_save_prop' ) ) {
100
+ /**
101
+ *
102
+ */
103
+ function yit_save_prop( $object, $arg1, $arg2 = false, $force_update = false ) {
104
+ if ( ! is_array( $arg1 ) ) {
105
+ $arg1 = array(
106
+ $arg1 => $arg2
107
+ );
108
+ }
109
+
110
+ $is_wc_data = $object instanceof WC_Data;
111
+
112
+ foreach ( $arg1 as $key => $value ) {
113
+ yit_set_prop( $object, $key, $value );
114
+
115
+ if ( $is_wc_data ) {
116
+ if( $force_update ){
117
+ $object->save();
118
+ }
119
+ else {
120
+ yit_store_changes( $object, $key, $value );
121
+ }
122
+ } else {
123
+ if ( yit_wc_check_post_columns( $key ) ) {
124
+ yit_store_changes( $object->post, $key, $value );
125
+ } else {
126
+ $object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id;
127
+
128
+ update_post_meta( $object_id, $key, $value );
129
+ }
130
+ }
131
+ }
132
+ }
133
+ }
134
+
135
+ if ( ! function_exists( 'yit_delete_prop' ) ) {
136
+ /**
137
+ *
138
+ */
139
+ function yit_delete_prop( $object, $key, $value = '' ) {
140
+ $prop_map = yit_return_new_attribute_map();
141
+ $is_wc_data = $object instanceof WC_Data;
142
+
143
+ if ( $is_wc_data ) {
144
+ $key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
145
+
146
+ if ( ( $setter = "set{$key}" ) && ( $getter = "get{$key}" ) && method_exists( $object, $setter ) && ( ! $value || $object->$getter == $value ) ) {
147
+ $object->$setter( '' );
148
+ } elseif ( ( $setter = "set_{$key}" ) && ( $getter = "get_{$key}" ) && method_exists( $object, $setter ) && ( ! $value || $object->$getter == $value ) ) {
149
+ $object->$setter( '' );
150
+ } elseif ( ( ! $value || $object->get_meta( $key ) == $value ) ) {
151
+ $object->delete_meta_data( $key, $value );
152
+ }
153
+
154
+ yit_store_changes( $object );
155
+ } else {
156
+ if ( yit_wc_check_post_columns( $key ) && ( ! $value || $object->post->$key == $value ) ) {
157
+ yit_store_changes( $object->post, $key, '' );
158
+ } else {
159
+ $object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id;
160
+
161
+ delete_post_meta( $object_id, $key, $value );
162
+ }
163
+ }
164
+ }
165
+ }
166
+
167
+ if ( ! function_exists( 'yit_return_new_attribute_map' ) ) {
168
+ function yit_return_new_attribute_map() {
169
+ return array(
170
+ 'post_parent' => 'parent_id',
171
+ 'post_title' => 'name',
172
+ 'post_status' => 'status',
173
+ 'post_content' => 'description',
174
+ /* Orders */
175
+ 'paid_date' => 'date_paid',
176
+ '_paid_date' => '_date_paid',
177
+ 'completed_date' => 'date_completed',
178
+ '_completed_date' => '_date_completed',
179
+ '_order_date' => '_date_created',
180
+ 'order_date' => 'date_created',
181
+ 'order_total' => 'total',
182
+ /* Products */
183
+ 'visibility' => 'catalog_visibility',
184
+ '_visibility' => '_catalog_visibility',
185
+ 'sale_price_dates_from' => 'date_on_sale_from',
186
+ '_sale_price_dates_from' => '_date_on_sale_from',
187
+ 'sale_price_dates_to' => 'date_on_sale_to',
188
+ '_sale_price_dates_to' => '_date_on_sale_to',
189
+ );
190
+ }
191
+ }
192
+
193
+ if ( ! function_exists( 'yit_store_changes' ) ) {
194
+ function yit_store_changes( $object, $key = false, $value = false ) {
195
+ global $changed_objects;
196
+
197
+ $is_wc_data = $object instanceof WC_Data;
198
+
199
+ if ( $is_wc_data ) {
200
+ /**
201
+ * @var $object \WC_Data
202
+ */
203
+ $object_reference = $object->get_id();
204
+
205
+ $cache_type = is_a( $object, 'WC_Product' ) ? 'product' : 'order';
206
+ $cache_key = $cache_type . '-' . $object_reference;
207
+ $cache_group = $cache_type . 's';
208
+
209
+ $changed_objects[ $object_reference ]['object'] = $object;
210
+ $changed_objects[ $object_reference ]['changes'][ $key ] = $value;
211
+
212
+
213
+ wp_cache_set( $cache_key, $object, $cache_group );
214
+ } else {
215
+ $changed_objects[ $object->ID ][ $key ] = $value;
216
+ }
217
+ }
218
+ }
219
+
220
+ if ( ! function_exists( 'yit_send_changes_to_db' ) ) {
221
+ function yit_send_changes_to_db() {
222
+ global $changed_objects;
223
+
224
+ if ( ! empty( $changed_objects ) ) {
225
+ foreach ( $changed_objects as $id => $data ) {
226
+ if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
227
+ /**
228
+ * @var $object \WC_Data
229
+ */
230
+ $object = is_a( $data['object'], 'WC_Product' ) ? wc_get_product( $id ) : wc_get_order( $id );
231
+
232
+ yit_set_prop( $object, $data['changes'] );
233
+ $object->save();
234
+ } else {
235
+ $data['ID'] = $id;
236
+ wp_update_post( $data );
237
+ }
238
+ }
239
+ }
240
+ }
241
+ }
242
+
243
+ if ( ! function_exists( 'yit_get_orders' ) ) {
244
+ /**
245
+ *
246
+ */
247
+ function yit_get_orders( $args ) {
248
+ if ( version_compare( WC()->version, '2.6', '<' ) ) {
249
+ $args['fields'] = 'objects';
250
+ $posts = get_posts( $args );
251
+
252
+ return array_map( 'wc_get_order', $posts );
253
+ } else {
254
+ return wc_get_orders( $args );
255
+ }
256
+ }
257
+ }
258
+
259
+ if ( ! function_exists( 'yit_get_products' ) ) {
260
+ /**
261
+ *
262
+ */
263
+ function yit_get_products( $args ) {
264
+ if ( version_compare( WC()->version, '2.6', '<' ) ) {
265
+ $args['fields'] = 'objects';
266
+ $posts = get_posts( $args );
267
+
268
+ return array_map( 'wc_get_product', $posts );
269
+ } else {
270
+ return wc_get_products( $args );
271
+ }
272
+ }
273
+ }
274
+
275
+ if ( ! function_exists( 'yit_update_product_stock' ) ) {
276
+ /**
277
+ *
278
+ */
279
+ function yit_update_product_stock( $product, $stock_quantity = 1, $operation = 'set' ) {
280
+ if ( function_exists( 'wc_update_product_stock' ) ) {
281
+ $stock = wc_update_product_stock( $product, $stock_quantity, $operation );
282
+ } else {
283
+ switch ( $operation ) {
284
+ case 'increase':
285
+ $stock = $product->increase_stock( $stock_quantity );
286
+ break;
287
+ case 'decrease':
288
+ $stock = $product->reduce_stock( $stock_quantity );
289
+ break;
290
+ case 'set':
291
+ default:
292
+ $stock = $product->set_stock( $stock_quantity );
293
+ break;
294
+ }
295
+ }
296
+
297
+ return $stock;
298
+ }
299
+ }
300
+
301
+ if ( ! function_exists( 'yit_wc_deprecated_filters' ) ) {
302
+ /**
303
+ *
304
+ */
305
+ function yit_wc_deprecated_filters() {
306
+ return apply_filters( 'yit_wc_deprecated_filters', array(
307
+ 'woocommerce_email_order_schema_markup' => 'woocommerce_structured_data_order',
308
+ 'woocommerce_product_width' => 'woocommerce_product_get_width',
309
+ 'woocommerce_product_height' => 'woocommerce_product_get_height',
310
+ 'woocommerce_product_length' => 'woocommerce_product_get_length',
311
+ 'woocommerce_product_weight' => 'woocommerce_product_get_weight',
312
+ 'woocommerce_get_sku' => 'woocommerce_product_get_sku',
313
+ 'woocommerce_get_price' => 'woocommerce_product_get_price',
314
+ 'woocommerce_get_regular_price' => 'woocommerce_product_get_regular_price',
315
+ 'woocommerce_get_sale_price' => 'woocommerce_product_get_sale_price',
316
+ 'woocommerce_product_tax_class' => 'woocommerce_product_get_tax_class',
317
+ 'woocommerce_get_stock_quantity' => 'woocommerce_product_get_stock_quantity',
318
+ 'woocommerce_get_product_attributes' => 'woocommerce_product_get_attributes',
319
+ 'woocommerce_product_gallery_attachment_ids' => 'woocommerce_product_get_gallery_image_ids',
320
+ 'woocommerce_product_review_count' => 'woocommerce_product_get_review_count',
321
+ 'woocommerce_product_files' => 'woocommerce_product_get_downloads',
322
+ 'woocommerce_get_currency' => 'woocommerce_order_get_currency',
323
+ 'woocommerce_order_amount_discount_total' => 'woocommerce_order_get_discount_total',
324
+ 'woocommerce_order_amount_discount_tax' => 'woocommerce_order_get_discount_tax',
325
+ 'woocommerce_order_amount_shipping_total' => 'woocommerce_order_get_shipping_total',
326
+ 'woocommerce_order_amount_shipping_tax' => 'woocommerce_order_get_shipping_tax',
327
+ 'woocommerce_order_amount_cart_tax' => 'woocommerce_order_get_cart_tax',
328
+ 'woocommerce_order_amount_total' => 'woocommerce_order_get_total',
329
+ 'woocommerce_order_amount_total_tax' => 'woocommerce_order_get_total_tax',
330
+ 'woocommerce_order_amount_total_discount' => 'woocommerce_order_get_total_discount',
331
+ 'woocommerce_order_amount_subtotal' => 'woocommerce_order_get_subtotal',
332
+ 'woocommerce_order_tax_totals' => 'woocommerce_order_get_tax_totals',
333
+ 'woocommerce_refund_amount' => 'woocommerce_get_order_refund_get_amount',
334
+ 'woocommerce_refund_reason' => 'woocommerce_get_order_refund_get_reason',
335
+ 'default_checkout_country' => 'default_checkout_billing_country',
336
+ 'default_checkout_state' => 'default_checkout_billing_state',
337
+ 'default_checkout_postcode' => 'default_checkout_billing_postcode',
338
+ 'woocommerce_add_order_item_meta' => 'woocommerce_new_order_item',
339
+
340
+ ) );
341
+ }
342
+ }
343
+
344
+ if ( ! function_exists( 'yit_fix_wc_deprecated_filters' ) ) {
345
+ /**
346
+ *
347
+ */
348
+ function yit_fix_wc_deprecated_filters() {
349
+
350
+ if ( ! version_compare( WC()->version, '2.7.0', '<' ) ) {
351
+ return;
352
+ }
353
+
354
+ $deprecated_filters = yit_wc_deprecated_filters();
355
+ foreach ( $deprecated_filters as $old => $new ) {
356
+ add_filter( $old, 'yit_wc_deprecated_filter_mapping', 10, 100 );
357
+ }
358
+ }
359
+ }
360
+
361
+ if ( ! function_exists( 'yit_wc_deprecated_filter_mapping' ) ) {
362
+ /**
363
+ *
364
+ */
365
+ function yit_wc_deprecated_filter_mapping() {
366
+ $deprecated_filters = yit_wc_deprecated_filters();
367
+
368
+ $filter = current_filter();
369
+ $args = func_get_args();
370
+ $data = $args[0];
371
+
372
+
373
+ if ( isset( $deprecated_filters[ $filter ] ) ) {
374
+ if ( has_filter( $deprecated_filters[ $filter ] ) ) {
375
+ $data = apply_filters_ref_array( $deprecated_filters[ $filter ], $args );
376
+ }
377
+ }
378
+
379
+ return $data;
380
+ }
381
+ }
382
+
383
+ if ( ! function_exists( 'yit_wc_check_post_columns' ) ) {
384
+ /**
385
+ *
386
+ */
387
+ function yit_wc_check_post_columns( $key ) {
388
+ $columns = array(
389
+ 'post_author',
390
+ 'post_date',
391
+ 'post_date_gmt',
392
+ 'post_content',
393
+ 'post_title',
394
+ 'post_excerpt',
395
+ 'post_status',
396
+ 'comment_status',
397
+ 'ping_status',
398
+ 'post_password',
399
+ 'post_name',
400
+ 'to_ping',
401
+ 'pinged',
402
+ 'post_modified',
403
+ 'post_modified_gmt',
404
+ 'post_content_filtered',
405
+ 'post_parent',
406
+ 'guid',
407
+ 'menu_order',
408
+ 'post_type',
409
+ 'post_mime_type',
410
+ 'comment_count',
411
+ );
412
+
413
+ return in_array( $key, $columns );
414
+ }
415
+ }
416
+
417
+
418
+ /* Shortcuts for common functions */
419
+
420
+ if ( ! function_exists( 'yit_get_order_id' ) ) {
421
+ /**
422
+ * Retrieve the order id
423
+ *
424
+ * @param WC_Order $order
425
+ *
426
+ * @return mixed
427
+ */
428
+ function yit_get_order_id( $order ) {
429
+ return yit_get_prop( $order, 'id' );
430
+ }
431
+ }
432
+
433
+ if ( ! function_exists( 'yit_get_product_id' ) ) {
434
+ /**
435
+ * Retrieve the product id
436
+ *
437
+ * @param WC_Product $product
438
+ *
439
+ * @return mixed
440
+ */
441
+ function yit_get_product_id( $product ) {
442
+ return yit_get_prop( $product, 'id' );
443
+ }
444
+ }
445
+
446
+ if ( ! function_exists( 'yit_get_base_product_id' ) ) {
447
+ /**
448
+ * New way to retrieve the $product->id as it was before WC 2.7.
449
+ *
450
+ * Retrieve the parent product id for WC_Product_Variation instances
451
+ * or the product id in the other cases.
452
+ *
453
+ * @param WC_Product $product
454
+ *
455
+ * @return mixed
456
+ */
457
+ function yit_get_base_product_id( $product ) {
458
+
459
+ return $product instanceof WC_Data && $product->is_type( 'variation' ) ?
460
+ yit_get_prop( $product, 'parent_id' ) :
461
+ yit_get_prop( $product, 'id' );
462
+ }
463
+ }
464
+
465
+ if ( ! function_exists( 'yit_get_display_price' ) ) {
466
+ /**
467
+ * @param WC_Product $product
468
+ * @param string $price
469
+ * @param int $qty
470
+ */
471
+ function yit_get_display_price( $product, $price = '', $qty = 1 ) {
472
+
473
+ if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
474
+
475
+ $price = wc_get_price_to_display( $product, array( 'qty' => $qty, 'price' => $price ) );
476
+ } else {
477
+
478
+ $price = $product->get_display_price( $price, $qty );
479
+ }
480
+
481
+ return $price;
482
+ }
483
+ }
484
+
485
+ if ( ! function_exists( 'yit_get_price_excluding_tax' ) ) {
486
+ /**
487
+ * @param WC_Product $product
488
+ * @param int $qty
489
+ * @param string $price
490
+ *
491
+ * @return float|string
492
+ */
493
+ function yit_get_price_excluding_tax( $product, $qty = 1, $price = '' ) {
494
+
495
+ if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
496
+
497
+ $price = wc_get_price_excluding_tax( $product, array( 'qty' => $qty, 'price' => $price ) );
498
+ } else {
499
+
500
+ $price = $product->get_price_excluding_tax( $qty, $price );
501
+ }
502
+
503
+ return $price;
504
+ }
505
+ }
506
+
507
+ if ( ! function_exists( 'yit_get_price_including_tax' ) ) {
508
+ /**
509
+ * @param WC_Product $product
510
+ * @param int $qty
511
+ * @param string $price
512
+ *
513
+ * @return float|string
514
+ */
515
+ function yit_get_price_including_tax( $product, $qty = 1, $price = '' ) {
516
+
517
+ if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
518
+
519
+ $price = wc_get_price_including_tax( $product, array( 'qty' => $qty, 'price' => $price ) );
520
+ } else {
521
+
522
+ $price = $product->get_price_including_tax( $qty, $price );
523
+ }
524
+
525
+ return $price;
526
+ }
527
+ }
528
+
529
+ if ( ! function_exists( 'yit_get_product_image_id' ) ) {
530
+ /**
531
+ * get the attach image id
532
+ *
533
+ * @param WC_Product $product
534
+ * @param string $context ( view/edit )
535
+ */
536
+ function yit_get_product_image_id( $product, $context = 'view' ) {
537
+
538
+ if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
539
+
540
+ $image_id = $product->get_image_id( $context );
541
+ } else {
542
+
543
+ $image_id = $product->get_image_id();
544
+ }
545
+
546
+ return $image_id;
547
+ }
548
+ }
549
+
550
+ if ( !function_exists( 'yit_get_refund_amount' ) ){
551
+ /**
552
+ * @param $refund \WC_Order_Refund
553
+ * @param $context string
554
+ *
555
+ * @return float
556
+ */
557
+ function yit_get_refund_amount( $refund, $context = 'view' ){
558
+ $is_wc_data = $refund instanceof WC_Data;
559
+
560
+ if( $is_wc_data ){
561
+ return $refund->get_amount( $context );
562
+ }
563
+ else{
564
+ return $refund->get_refund_amount();
565
+ }
566
+ }
567
+ }
568
+
569
+ if ( !function_exists( 'yit_set_refund_amount' ) ){
570
+ /**
571
+ * @param $refund \WC_Order_Refund
572
+ * @param $amount float
573
+ *
574
+ * @return float
575
+ */
576
+ function yit_set_refund_amount( $refund, $amount ){
577
+ $is_wc_data = $refund instanceof WC_Data;
578
+
579
+ if( $is_wc_data ){
580
+ $refund->set_amount( $amount );
581
+ }
582
+ else{
583
+ $refund->refund_amount = $amount;
584
+ }
585
+ }
586
+ }
587
+
588
+ if ( !function_exists( 'yit_get_refund_reason' ) ){
589
+ /**
590
+ * @param $refund \WC_Order_Refund
591
+ * @param $amount float
592
+ *
593
+ * @return float
594
+ */
595
+ function yit_get_refund_reason( $refund ){
596
+ $is_wc_data = $refund instanceof WC_Data;
597
+
598
+ if( $is_wc_data ){
599
+ return $refund->get_reason();
600
+ }
601
+ else{
602
+ return $refund->get_refund_reason();
603
+ }
604
+ }
605
+ }
606
+
607
+ if( ! function_exists( 'yit_add_select2_fields' ) ){
608
+ /**
609
+ * Add select 2
610
+ *
611
+ * @param array $args
612
+ */
613
+ function yit_add_select2_fields( $args = array() ){
614
+ $default = array(
615
+ 'type' => 'hidden',
616
+ 'class' => '',
617
+ 'id' => '',
618
+ 'name' => '',
619
+ 'data-placeholder' => '',
620
+ 'data-allow_clear' => false,
621
+ 'data-selected' => '',
622
+ 'data-multiple' => false,
623
+ 'data-action' => '',
624
+ 'value' => '',
625
+ 'style' => ''
626
+ );
627
+
628
+ $args = wp_parse_args( $args, $default );
629
+
630
+ if( version_compare( WC()->version, '2.7.0', '>=' ) ) :
631
+ if( $args['data-multiple']=== true && substr( $args['name'], -2 ) != '[]'){
632
+ $args['name'] = $args['name'] . '[]';
633
+ }
634
+ ?>
635
+
636
+ <select
637
+ id="<?php echo $args['id'] ?>"
638
+ class="<?php echo $args['class'] ?>"
639
+ name="<?php echo $args['name'] ?>"
640
+ data-placeholder="<?php echo $args['data-placeholder'] ?>"
641
+ data-allow_clear="<?php echo $args['data-allow_clear'] ?>"
642
+ <?php echo ! empty( $args['data-action'] ) ? 'data-action="' . $args['data-action'] . '"' : ''; ?>
643
+ <?php echo ! empty( $args['data-multiple'] ) ? 'multiple="multiple"' : ''; ?>
644
+ style="<?php echo $args['style'] ?>"
645
+ >
646
+
647
+ <?php if( ! empty( $args['value'] ) ) {
648
+ $values = $args['value'];
649
+
650
+ if( ! is_array( $values ) ){
651
+ $values = explode( ',', $values );
652
+ }
653
+
654
+ foreach( $values as $value ): ?>
655
+ <option value="<?php echo $value; ?>" <?php selected( true, true, true ) ?> >
656
+ <?php echo $args['data-selected'][ $value ]; ?>
657
+ </option>
658
+ <?php endforeach;
659
+ }
660
+ ?>
661
+ </select>
662
+ <?php
663
+ else :
664
+ if( is_array( $args['data-selected'] ) ){
665
+ $args['data-selected'] = $args['data-multiple'] === true ? json_encode( $args['data-selected'] ) : array_shift( $args['data-selected'] );
666
+ }
667
+ ?>
668
+ <input
669
+ type="hidden"
670
+ id="<?php echo $args['id'] ?>"
671
+ class="<?php echo $args['class'] ?>"
672
+ name="<?php echo $args['name'] ?>"
673
+ data-placeholder="<?php echo $args['data-placeholder'] ?>"
674
+ data-allow_clear="<?php echo $args['data-allow_clear'] ?>"
675
+ data-selected="<?php echo $args['data-selected'] ?>"
676
+ data-multiple="<?php echo $args['data-multiple'] === true ? 'true' : 'false' ?>"
677
+ <?php if( ! empty( $args['data-action'] ) ? 'data-action="' . $args['data-action'] . '"' : '' ) ?>
678
+ value="<?php echo $args['value'] ?>"
679
+ style="<?php echo $args['style'] ?>"
680
+ />
681
+ <?php
682
+ endif;
683
+ }
684
+ }
685
+
686
+
687
+ yit_fix_wc_deprecated_filters();
688
+ add_action( 'shutdown', 'yit_send_changes_to_db' );
screenshot-1.png DELETED
Binary file
screenshot-2.png DELETED
Binary file