YITH WooCommerce Zoom Magnifier - Version 1.2.24

Version Description

Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Zoom Magnifier
Version 1.2.24
Comparing to
See all releases

Code changes from version 1.2.22 to 1.2.24

README.txt CHANGED
@@ -3,8 +3,8 @@
3
  Contributors: yithemes
4
  Tags: zoom, magnifier, woocommerce, product image, themes, yit, e-commerce, shop, thumbnail, thumbnail slider, zoom image, carousel, image carousel
5
  Requires at least: 3.5.1
6
- Tested up to: 4.6.1
7
- Stable tag: 1.2.22
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -51,6 +51,15 @@ YITH WooCommerce Zoom Magnifier will add a new tab called "Zoom Magnifier" in "Y
51
 
52
  == Changelog ==
53
 
 
 
 
 
 
 
 
 
 
54
  = Version 1.2.22 - Released: Nov 08, 2016 =
55
 
56
  * Updated: Compatibility to WordPress up to 4.6.x
3
  Contributors: yithemes
4
  Tags: zoom, magnifier, woocommerce, product image, themes, yit, e-commerce, shop, thumbnail, thumbnail slider, zoom image, carousel, image carousel
5
  Requires at least: 3.5.1
6
+ Tested up to: 4.7.2
7
+ Stable tag: 1.2.24
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
51
 
52
  == Changelog ==
53
 
54
+ = Version 1.2.24 - Released: Mar 06, 2017 =
55
+
56
+ * New: Support to WooCommerce 2.7.0-RC1
57
+ * Update: YITH Plugin Framework
58
+
59
+ = Version 1.2.23 - Released: Jan 16, 2017 =
60
+
61
+ * New: WordPress 4.7 ready
62
+
63
  = Version 1.2.22 - Released: Nov 08, 2016 =
64
 
65
  * Updated: Compatibility to WordPress up to 4.6.x
init.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: YITH WooCommerce Zoom Magnifier
4
  * Plugin URI: http://yithemes.com/themes/plugins/yith-woocommerce-zoom-magnifier/
5
  * Description: YITH WooCommerce Zoom Magnifier enables you to add a zoom effect to product images and a thumbnail slider for the product image gallery.
6
- * Version: 1.2.22
7
  * Author: YITHEMES
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith-woocommerce-zoom-magnifier
@@ -11,7 +11,7 @@
11
  *
12
  * @author Your Inspiration Themes
13
  * @package YITH WooCommerce Magnifier
14
- * @version 1.2.22
15
  */
16
  /* Copyright 2013-2015 Your Inspiration Themes (email : plugins@yithemes.com)
17
 
@@ -76,7 +76,7 @@ if ( ! function_exists ( 'yith_plugin_registration_hook' ) ) {
76
  register_activation_hook ( __FILE__, 'yith_plugin_registration_hook' );
77
 
78
  defined ( 'YITH_YWZM_FREE_INIT' ) || define ( 'YITH_YWZM_FREE_INIT', plugin_basename ( __FILE__ ) );
79
- defined ( 'YITH_YWZM_VERSION' ) || define ( 'YITH_YWZM_VERSION', '1.2.22' );
80
  defined ( 'YITH_YWZM_FILE' ) || define ( 'YITH_YWZM_FILE', __FILE__ );
81
  defined ( 'YITH_YWZM_DIR' ) || define ( 'YITH_YWZM_DIR', plugin_dir_path ( __FILE__ ) );
82
  defined ( 'YITH_YWZM_URL' ) || define ( 'YITH_YWZM_URL', plugins_url ( '/', __FILE__ ) );
3
  * Plugin Name: YITH WooCommerce Zoom Magnifier
4
  * Plugin URI: http://yithemes.com/themes/plugins/yith-woocommerce-zoom-magnifier/
5
  * Description: YITH WooCommerce Zoom Magnifier enables you to add a zoom effect to product images and a thumbnail slider for the product image gallery.
6
+ * Version: 1.2.24
7
  * Author: YITHEMES
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith-woocommerce-zoom-magnifier
11
  *
12
  * @author Your Inspiration Themes
13
  * @package YITH WooCommerce Magnifier
14
+ * @version 1.2.24
15
  */
16
  /* Copyright 2013-2015 Your Inspiration Themes (email : plugins@yithemes.com)
17
 
76
  register_activation_hook ( __FILE__, 'yith_plugin_registration_hook' );
77
 
78
  defined ( 'YITH_YWZM_FREE_INIT' ) || define ( 'YITH_YWZM_FREE_INIT', plugin_basename ( __FILE__ ) );
79
+ defined ( 'YITH_YWZM_VERSION' ) || define ( 'YITH_YWZM_VERSION', '1.2.24' );
80
  defined ( 'YITH_YWZM_FILE' ) || define ( 'YITH_YWZM_FILE', __FILE__ );
81
  defined ( 'YITH_YWZM_DIR' ) || define ( 'YITH_YWZM_DIR', plugin_dir_path ( __FILE__ ) );
82
  defined ( 'YITH_YWZM_URL' ) || define ( 'YITH_YWZM_URL', plugins_url ( '/', __FILE__ ) );
plugin-fw/init.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /**
3
  * Framework Name: YIT Plugin Framework
4
- * Version: 2.9.39
5
  * Author: Yithemes
6
  * Text Domain: yith-plugin-fw
7
  * Domain Path: /languages/
@@ -19,7 +19,6 @@
19
  * http://www.gnu.org/licenses/gpl-3.0.txt
20
  */
21
 
22
-
23
  if ( ! defined ( 'ABSPATH' ) ) {
24
  exit;
25
  } // Exit if accessed directly
@@ -55,3 +54,5 @@ if ( ! function_exists ( 'yit_maybe_plugin_fw_loader' ) ) {
55
  }
56
  }
57
  }
 
 
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
@@ -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
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
screenshot-3.png DELETED
Binary file
screenshot-4.png DELETED
Binary file
screenshot-5.png DELETED
Binary file
screenshot-6.png DELETED
Binary file