Version Description
Released Mar 31 - 2017
- New: Support to WordPress 4.7.3.
- New: Support to WooCommerce 3.0.0 RC2.
- New: Shortcode [yith_quick_view product_id="" label=""] for print "quick view" button of specified product.
- Update: Plugin Core.
Download this release
Release Info
Developer | yithemes |
Plugin | YITH WooCommerce Quick View |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.4 to 1.2.0
- README.txt +46 -35
- class.yith-wcqv-admin.php → includes/class.yith-wcqv-admin.php +0 -0
- class.yith-wcqv-frontend.php → includes/class.yith-wcqv-frontend.php +60 -4
- class.yith-wcqv.php → includes/class.yith-wcqv.php +37 -8
- init.php +4 -6
- plugin-fw/init.php +3 -3
- plugin-fw/lib/yit-cpt-unlimited.php +2 -2
- plugin-fw/lib/yit-metabox.php +24 -5
- plugin-fw/lib/yit-plugin-panel-wc.php +1 -1
- plugin-fw/lib/yit-plugin-panel.php +2 -2
- plugin-fw/lib/yit-upgrade.php +1 -1
- plugin-fw/licence/lib/yit-licence.php +6 -5
- plugin-fw/licence/lib/yit-plugin-licence.php +3 -3
- plugin-fw/licence/lib/yit-theme-licence.php +3 -3
- plugin-fw/licence/templates/panel/activation/activation-panel.php +3 -3
- plugin-fw/yit-plugin.php +40 -0
- plugin-fw/yit-woocommerce-compatibility.php +702 -0
- screenshot-1.jpg +0 -0
- screenshot-2.jpg +0 -0
- screenshot-3.jpg +0 -0
- templates/yith-quick-view-content.php +1 -1
README.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: yithemes
|
3 |
Tags: yith, woocommerce, quick view, woocommerce quick view, yit, single product, products quick view, free quick view, woocommerce extension, woocommerce plugin, product summary, summary, modal
|
4 |
Requires at least: 4.0
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -42,75 +42,82 @@ Full documentation is available [here](http://yithemes.com/docs-plugins/yith-woo
|
|
42 |
|
43 |
== Changelog ==
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
= 1.1.4 = Released Oct 24 - 2016
|
46 |
|
47 |
-
*
|
48 |
|
49 |
= 1.1.3 = Released Oct 20 - 2016
|
50 |
|
51 |
-
*
|
52 |
-
*
|
53 |
-
*
|
54 |
-
*
|
55 |
-
*
|
56 |
|
57 |
= 1.1.2 = Released Jun 10 - 2016
|
58 |
|
59 |
-
*
|
60 |
-
*
|
61 |
-
*
|
62 |
|
63 |
= 1.1.1 = Released Apr 18 - 2016
|
64 |
|
65 |
-
*
|
66 |
-
*
|
67 |
|
68 |
= 1.1.0 = Released Oct 30 - 2015
|
69 |
|
70 |
-
*
|
71 |
-
*
|
72 |
-
*
|
73 |
-
*
|
74 |
-
*
|
75 |
|
76 |
= 1.0.8 = Released Aug 24 - 2015
|
77 |
|
78 |
-
*
|
79 |
|
80 |
= 1.0.7 = Released Aug 21 - 2015
|
81 |
|
82 |
-
*
|
83 |
-
*
|
84 |
-
*
|
85 |
-
*
|
86 |
|
87 |
= 1.0.6 = Released Aug 12 - 2015
|
88 |
|
89 |
-
*
|
90 |
|
91 |
= 1.0.5 = Released Aug 11 - 2015
|
92 |
|
93 |
-
*
|
94 |
-
*
|
95 |
-
*
|
96 |
|
97 |
= 1.0.4 = Released May 18 - 2015
|
98 |
|
99 |
-
*
|
100 |
* Compatibility with Wordpress 4.2.2
|
101 |
* Minor bug fix
|
102 |
-
*
|
103 |
-
*
|
104 |
|
105 |
= 1.0.3 = Released Mar 11 - 2015
|
106 |
|
107 |
* Minor bug fix
|
108 |
-
*
|
109 |
|
110 |
= 1.0.2 = Released Mar 06 - 2015
|
111 |
|
112 |
-
*
|
113 |
-
*
|
114 |
|
115 |
= 1.0.1 = Released Feb 26 - 2015
|
116 |
|
@@ -128,12 +135,16 @@ If you have suggestions about how to improve YITH WooCommerce Quick View, you ca
|
|
128 |
|
129 |
= Available Languages =
|
130 |
* English
|
|
|
131 |
|
132 |
If you have created your own language pack, or have an update for an existing one, you can send [gettext PO and MO file](http://codex.wordpress.org/Translating_WordPress "Translating WordPress")
|
133 |
[use](http://yithemes.com/contact/ "Your Inspiration Themes") so we can bundle it into YITH WooCommerce Quick View languages.
|
134 |
|
135 |
== Upgrade notice ==
|
136 |
|
137 |
-
= 1.
|
138 |
|
139 |
-
*
|
|
|
|
|
|
2 |
Contributors: yithemes
|
3 |
Tags: yith, woocommerce, quick view, woocommerce quick view, yit, single product, products quick view, free quick view, woocommerce extension, woocommerce plugin, product summary, summary, modal
|
4 |
Requires at least: 4.0
|
5 |
+
Tested up to: 4.7.3
|
6 |
+
Stable tag: 1.2.0
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
42 |
|
43 |
== Changelog ==
|
44 |
|
45 |
+
= 1.2.0 = Released Mar 31 - 2017
|
46 |
+
|
47 |
+
* New: Support to WordPress 4.7.3.
|
48 |
+
* New: Support to WooCommerce 3.0.0 RC2.
|
49 |
+
* New: Shortcode [yith_quick_view product_id="" label=""] for print "quick view" button of specified product.
|
50 |
+
* Update: Plugin Core.
|
51 |
+
|
52 |
= 1.1.4 = Released Oct 24 - 2016
|
53 |
|
54 |
+
* Fix: Status code 404 for "Quick View" on single product page
|
55 |
|
56 |
= 1.1.3 = Released Oct 20 - 2016
|
57 |
|
58 |
+
* New: Support to WooCommerce 2.6.5
|
59 |
+
* New: Support to WordPress 4.6.1
|
60 |
+
* Update: Plugin Core.
|
61 |
+
* Fix: Responsive style.
|
62 |
+
* Fix: Add inline css using WordPress function wp_add_inline_style.
|
63 |
|
64 |
= 1.1.2 = Released Jun 10 - 2016
|
65 |
|
66 |
+
* New: Added minimized js files. Plugin loads full files version if the constant "SCRIPT_DEBUG" is defined and is true.
|
67 |
+
* New: Support to WooCommerce 2.6 RC1
|
68 |
+
* Update: Plugin Core
|
69 |
|
70 |
= 1.1.1 = Released Apr 18 - 2016
|
71 |
|
72 |
+
* New: Compatibility with WordPress 4.5
|
73 |
+
* Update: Plugin Core
|
74 |
|
75 |
= 1.1.0 = Released Oct 30 - 2015
|
76 |
|
77 |
+
* New: Compatibility with YITH WooCommerce Wishlist
|
78 |
+
* New: Compatibility with YITH WooCommerce Badge Management
|
79 |
+
* New: Italian Language
|
80 |
+
* Update: Language file .pot. Changed textdomain to yith-wcqv to yith-woocommerce-quick-view
|
81 |
+
* Update: Plugin Core
|
82 |
|
83 |
= 1.0.8 = Released Aug 24 - 2015
|
84 |
|
85 |
+
* Fix: Main template issue
|
86 |
|
87 |
= 1.0.7 = Released Aug 21 - 2015
|
88 |
|
89 |
+
* New: Compatibility with Wordpress 4.3
|
90 |
+
* New: WPML config xml
|
91 |
+
* Update: Language file .pot
|
92 |
+
* Fix: Default variation select
|
93 |
|
94 |
= 1.0.6 = Released Aug 12 - 2015
|
95 |
|
96 |
+
* Update: Plugin Core
|
97 |
|
98 |
= 1.0.5 = Released Aug 11 - 2015
|
99 |
|
100 |
+
* New: Compatibility with WooCommerce 2.4
|
101 |
+
* Update: Plugin Core
|
102 |
+
* Update: Language file
|
103 |
|
104 |
= 1.0.4 = Released May 18 - 2015
|
105 |
|
106 |
+
* New option for enable quick view also in mobile device
|
107 |
* Compatibility with Wordpress 4.2.2
|
108 |
* Minor bug fix
|
109 |
+
* Update Plugin Core
|
110 |
+
* Update Language file
|
111 |
|
112 |
= 1.0.3 = Released Mar 11 - 2015
|
113 |
|
114 |
* Minor bug fix
|
115 |
+
* Update Plugin Core
|
116 |
|
117 |
= 1.0.2 = Released Mar 06 - 2015
|
118 |
|
119 |
+
* New: Action yith_quick_view_custom_style_scripts
|
120 |
+
* New: Filter 'yith_quick_view_loader_gif
|
121 |
|
122 |
= 1.0.1 = Released Feb 26 - 2015
|
123 |
|
135 |
|
136 |
= Available Languages =
|
137 |
* English
|
138 |
+
* Italian
|
139 |
|
140 |
If you have created your own language pack, or have an update for an existing one, you can send [gettext PO and MO file](http://codex.wordpress.org/Translating_WordPress "Translating WordPress")
|
141 |
[use](http://yithemes.com/contact/ "Your Inspiration Themes") so we can bundle it into YITH WooCommerce Quick View languages.
|
142 |
|
143 |
== Upgrade notice ==
|
144 |
|
145 |
+
= 1.2.0 = Released Mar 31 - 2017
|
146 |
|
147 |
+
* New: Support to WordPress 4.7.3.
|
148 |
+
* New: Support to WooCommerce 3.0.0 RC2.
|
149 |
+
* New: Shortcode [yith_quick_view product_id="" label=""] for print "quick view" button of specified product.
|
150 |
+
* Update: Plugin Core.
|
class.yith-wcqv-admin.php → includes/class.yith-wcqv-admin.php
RENAMED
File without changes
|
class.yith-wcqv-frontend.php → includes/class.yith-wcqv-frontend.php
RENAMED
@@ -74,6 +74,8 @@ if( ! class_exists( 'YITH_WCQV_Frontend' ) ) {
|
|
74 |
|
75 |
// load action for product template
|
76 |
$this->yith_quick_view_action_template();
|
|
|
|
|
77 |
}
|
78 |
|
79 |
/**
|
@@ -108,17 +110,32 @@ if( ! class_exists( 'YITH_WCQV_Frontend' ) ) {
|
|
108 |
* Add quick view button in wc product loop
|
109 |
*
|
110 |
* @access public
|
111 |
-
* @
|
|
|
|
|
|
|
112 |
* @since 1.0.0
|
113 |
* @author Francesco Licandro <francesco.licandro@yithemes.com>
|
114 |
*/
|
115 |
-
public function yith_add_quick_view_button() {
|
116 |
|
117 |
global $product;
|
118 |
|
119 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
-
echo
|
122 |
}
|
123 |
|
124 |
/**
|
@@ -239,6 +256,45 @@ if( ! class_exists( 'YITH_WCQV_Frontend' ) ) {
|
|
239 |
add_action( 'yith_wcqv_product_summary', 'woocommerce_template_single_add_to_cart', 25 );
|
240 |
add_action( 'yith_wcqv_product_summary', 'woocommerce_template_single_meta', 30 );
|
241 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
}
|
244 |
/**
|
74 |
|
75 |
// load action for product template
|
76 |
$this->yith_quick_view_action_template();
|
77 |
+
|
78 |
+
add_shortcode( 'yith_quick_view', array( $this, 'quick_view_shortcode' ) );
|
79 |
}
|
80 |
|
81 |
/**
|
110 |
* Add quick view button in wc product loop
|
111 |
*
|
112 |
* @access public
|
113 |
+
* @param integer|string $product_id The product id
|
114 |
+
* @param string $label The button label
|
115 |
+
* @param boolean $return
|
116 |
+
* @return string|void
|
117 |
* @since 1.0.0
|
118 |
* @author Francesco Licandro <francesco.licandro@yithemes.com>
|
119 |
*/
|
120 |
+
public function yith_add_quick_view_button( $product_id = 0, $label = '', $return = false ) {
|
121 |
|
122 |
global $product;
|
123 |
|
124 |
+
if( ! $product_id ){
|
125 |
+
$product_id = yit_get_prop( $product, 'id', true );
|
126 |
+
}
|
127 |
+
|
128 |
+
// get label
|
129 |
+
! $label && $label = $this->get_button_label();
|
130 |
+
|
131 |
+
$button = '<a href="#" class="button yith-wcqv-button" data-product_id="' . $product_id . '">' . $label . '</a>';
|
132 |
+
$button = apply_filters( 'yith_add_quick_view_button_html', $button, $label, $product );
|
133 |
+
|
134 |
+
if( $return ) {
|
135 |
+
return $button;
|
136 |
+
}
|
137 |
|
138 |
+
echo $button;
|
139 |
}
|
140 |
|
141 |
/**
|
256 |
add_action( 'yith_wcqv_product_summary', 'woocommerce_template_single_add_to_cart', 25 );
|
257 |
add_action( 'yith_wcqv_product_summary', 'woocommerce_template_single_meta', 30 );
|
258 |
}
|
259 |
+
|
260 |
+
/**
|
261 |
+
* Get Quick View button label
|
262 |
+
*
|
263 |
+
* @author Francesco Licandro
|
264 |
+
* @since 1.2.0
|
265 |
+
* @return string
|
266 |
+
*/
|
267 |
+
public function get_button_label(){
|
268 |
+
$label = get_option( 'yith-wcqv-button-label' );
|
269 |
+
$label = call_user_func( '__' , $label, 'yith-woocommerce-quick-view' );
|
270 |
+
|
271 |
+
return apply_filters( 'yith_wcqv_button_label', esc_html( $label ) );
|
272 |
+
}
|
273 |
+
|
274 |
+
/**
|
275 |
+
* Quick View shortcode button
|
276 |
+
*
|
277 |
+
* @access public
|
278 |
+
* @since 1.0.7
|
279 |
+
* @param array $atts
|
280 |
+
* @return string
|
281 |
+
* @author Francesco Licandro
|
282 |
+
*/
|
283 |
+
public function quick_view_shortcode( $atts ) {
|
284 |
+
|
285 |
+
$atts = shortcode_atts(array(
|
286 |
+
'product_id' => 0,
|
287 |
+
'label' => ''
|
288 |
+
), $atts );
|
289 |
+
|
290 |
+
extract( $atts );
|
291 |
+
|
292 |
+
if( ! intval( $product_id ) ) {
|
293 |
+
return '';
|
294 |
+
}
|
295 |
+
|
296 |
+
return $this->yith_add_quick_view_button( $product_id, $label, true );
|
297 |
+
}
|
298 |
}
|
299 |
}
|
300 |
/**
|
class.yith-wcqv.php → includes/class.yith-wcqv.php
RENAMED
@@ -66,6 +66,9 @@ if ( ! class_exists( 'YITH_WCQV' ) ) {
|
|
66 |
*/
|
67 |
public function __construct() {
|
68 |
|
|
|
|
|
|
|
69 |
$action = array(
|
70 |
'woocommerce_get_refreshed_fragments',
|
71 |
'woocommerce_apply_coupon',
|
@@ -81,21 +84,47 @@ if ( ! class_exists( 'YITH_WCQV' ) ) {
|
|
81 |
return;
|
82 |
}
|
83 |
|
84 |
-
if ( is_admin()
|
85 |
-
//
|
86 |
-
|
87 |
-
|
88 |
YITH_WCQV_Admin();
|
89 |
}
|
90 |
-
// Class frontend
|
91 |
-
$enable = get_option( 'yith-wcqv-enable' ) == 'yes' ? true : false;
|
92 |
-
$enable_on_mobile = get_option( 'yith-wcqv-enable-mobile' ) == 'yes' ? true : false;
|
93 |
|
94 |
-
if(
|
|
|
|
|
95 |
YITH_WCQV_Frontend();
|
96 |
}
|
97 |
}
|
98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
/**
|
101 |
* Load Plugin Framework
|
66 |
*/
|
67 |
public function __construct() {
|
68 |
|
69 |
+
// Load Plugin Framework
|
70 |
+
add_action( 'after_setup_theme', array( $this, 'plugin_fw_loader' ), 1 );
|
71 |
+
|
72 |
$action = array(
|
73 |
'woocommerce_get_refreshed_fragments',
|
74 |
'woocommerce_apply_coupon',
|
84 |
return;
|
85 |
}
|
86 |
|
87 |
+
if ( $this->is_admin() ) {
|
88 |
+
// load admin classes
|
89 |
+
require_once( 'class.yith-wcqv-admin.php' );
|
|
|
90 |
YITH_WCQV_Admin();
|
91 |
}
|
|
|
|
|
|
|
92 |
|
93 |
+
if( $this->load_frontend() ) {
|
94 |
+
// load frontend classes
|
95 |
+
require_once( 'class.yith-wcqv-frontend.php' );
|
96 |
YITH_WCQV_Frontend();
|
97 |
}
|
98 |
}
|
99 |
|
100 |
+
/**
|
101 |
+
* Check if context is admin
|
102 |
+
*
|
103 |
+
* @author Francesco Licandro
|
104 |
+
* @since 1.2.0
|
105 |
+
* @return boolean
|
106 |
+
*/
|
107 |
+
public function is_admin(){
|
108 |
+
$is_ajax = ( defined( 'DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['context'] ) && $_REQUEST['context'] == 'frontend' );
|
109 |
+
return apply_filters( 'yith_wcqv_is_admin', is_admin() && ! $is_ajax );
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Check if load or not frontend
|
114 |
+
*
|
115 |
+
* @author Francesco Licandro
|
116 |
+
* @since 1.2.0
|
117 |
+
* @return boolean
|
118 |
+
*/
|
119 |
+
public function load_frontend(){
|
120 |
+
// Class frontend
|
121 |
+
$enable = get_option( 'yith-wcqv-enable', 'yes' ) == 'yes';
|
122 |
+
$enable_on_mobile = get_option( 'yith-wcqv-enable-mobile', 'yes' ) == 'yes';
|
123 |
+
$is_mobile = wp_is_mobile();
|
124 |
+
|
125 |
+
return apply_filters( 'yith_wcqv_load_frontend', ( ! $is_mobile && $enable ) || ( $is_mobile && $enable_on_mobile ) );
|
126 |
+
}
|
127 |
+
|
128 |
|
129 |
/**
|
130 |
* Load Plugin Framework
|
init.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: YITH WooCommerce Quick View
|
4 |
* Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-quick-view
|
5 |
* Description: YITH WooCommerce Quick View allows your users to have a quick look about products.
|
6 |
-
* Version: 1.
|
7 |
* Author: YITHEMES
|
8 |
* Author URI: https://yithemes.com/
|
9 |
* Text Domain: yith-woocommerce-quick-view
|
@@ -11,7 +11,7 @@
|
|
11 |
*
|
12 |
* @author Yithemes
|
13 |
* @package YITH WooCommerce Quick View
|
14 |
-
* @version 1.
|
15 |
*/
|
16 |
/* Copyright 2015 Your Inspiration Themes (email : plugins@yithemes.com)
|
17 |
|
@@ -59,7 +59,7 @@ register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
|
|
59 |
|
60 |
|
61 |
if ( ! defined( 'YITH_WCQV_VERSION' ) ){
|
62 |
-
define( 'YITH_WCQV_VERSION', '1.
|
63 |
}
|
64 |
|
65 |
if ( ! defined( 'YITH_WCQV_FREE_INIT' ) ) {
|
@@ -101,9 +101,7 @@ function yith_wcqv_init() {
|
|
101 |
load_plugin_textdomain( 'yith-woocommerce-quick-view', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
|
102 |
|
103 |
// Load required classes and functions
|
104 |
-
require_once('class.yith-wcqv
|
105 |
-
require_once('class.yith-wcqv-frontend.php');
|
106 |
-
require_once('class.yith-wcqv.php');
|
107 |
|
108 |
// Let's start the game!
|
109 |
YITH_WCQV();
|
3 |
* Plugin Name: YITH WooCommerce Quick View
|
4 |
* Plugin URI: https://yithemes.com/themes/plugins/yith-woocommerce-quick-view
|
5 |
* Description: YITH WooCommerce Quick View allows your users to have a quick look about products.
|
6 |
+
* Version: 1.2.0
|
7 |
* Author: YITHEMES
|
8 |
* Author URI: https://yithemes.com/
|
9 |
* Text Domain: yith-woocommerce-quick-view
|
11 |
*
|
12 |
* @author Yithemes
|
13 |
* @package YITH WooCommerce Quick View
|
14 |
+
* @version 1.2.0
|
15 |
*/
|
16 |
/* Copyright 2015 Your Inspiration Themes (email : plugins@yithemes.com)
|
17 |
|
59 |
|
60 |
|
61 |
if ( ! defined( 'YITH_WCQV_VERSION' ) ){
|
62 |
+
define( 'YITH_WCQV_VERSION', '1.2.0' );
|
63 |
}
|
64 |
|
65 |
if ( ! defined( 'YITH_WCQV_FREE_INIT' ) ) {
|
101 |
load_plugin_textdomain( 'yith-woocommerce-quick-view', false, dirname( plugin_basename( __FILE__ ) ). '/languages/' );
|
102 |
|
103 |
// Load required classes and functions
|
104 |
+
require_once('includes/class.yith-wcqv.php');
|
|
|
|
|
105 |
|
106 |
// Let's start the game!
|
107 |
YITH_WCQV();
|
plugin-fw/init.php
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?php
|
2 |
/**
|
3 |
* Framework Name: YIT Plugin Framework
|
4 |
-
* Version: 2.9.
|
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.62
|
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( '
|
142 |
-
add_action( '
|
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 |
-
|
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 |
+
apply_filters('yit_plugin_panel_menu_page_capability', 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/lib/yit-upgrade.php
CHANGED
@@ -33,7 +33,7 @@ if ( ! class_exists( 'YIT_Upgrade' ) ) {
|
|
33 |
/**
|
34 |
* @var string api server url
|
35 |
*/
|
36 |
-
protected $_package_url = '
|
37 |
|
38 |
/**
|
39 |
* @var array The registered plugins
|
33 |
/**
|
34 |
* @var string api server url
|
35 |
*/
|
36 |
+
protected $_package_url = 'https://yithemes.com';
|
37 |
|
38 |
/**
|
39 |
* @var array The registered plugins
|
plugin-fw/licence/lib/yit-licence.php
CHANGED
@@ -48,7 +48,7 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
|
|
48 |
* @var string The yithemes api uri
|
49 |
* @since 1.0
|
50 |
*/
|
51 |
-
protected $_api_uri = '
|
52 |
|
53 |
/**
|
54 |
* @var string The yithemes api uri query args
|
@@ -95,8 +95,9 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
|
|
95 |
}
|
96 |
|
97 |
/* Update Licence Information */
|
98 |
-
|
99 |
-
add_action( '
|
|
|
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 |
/**
|
@@ -691,7 +692,7 @@ if ( ! class_exists( 'YIT_Licence' ) ) {
|
|
691 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
692 |
*/
|
693 |
public function display_product_name( $product_name ){
|
694 |
-
return str_replace( array( 'for WooCommerce', 'YITH', 'WooCommerce', 'Premium', 'Theme' ), '', $product_name );
|
695 |
}
|
696 |
|
697 |
public function get_number_of_membership_products(){
|
48 |
* @var string The yithemes api uri
|
49 |
* @since 1.0
|
50 |
*/
|
51 |
+
protected $_api_uri = 'https://yithemes.com';
|
52 |
|
53 |
/**
|
54 |
* @var string The yithemes api uri query args
|
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 |
/**
|
692 |
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
693 |
*/
|
694 |
public function display_product_name( $product_name ){
|
695 |
+
return str_replace( array( 'for WooCommerce', 'YITH', 'WooCommerce', 'Premium', 'Theme', 'WordPress' ), '', $product_name );
|
696 |
}
|
697 |
|
698 |
public function get_number_of_membership_products(){
|
plugin-fw/licence/lib/yit-plugin-licence.php
CHANGED
@@ -71,9 +71,9 @@ if ( !class_exists( 'YIT_Plugin_Licence' ) ) {
|
|
71 |
);
|
72 |
|
73 |
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
|
74 |
-
add_action( "
|
75 |
-
add_action( "
|
76 |
-
add_action( "
|
77 |
add_action( 'yit_licence_after_check', array( $this, 'licence_after_check' ) );
|
78 |
}
|
79 |
|
71 |
);
|
72 |
|
73 |
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
|
74 |
+
add_action( "wp_ajax_yith_activate-{$this->_product_type}", array( $this, 'activate' ) );
|
75 |
+
add_action( "wp_ajax_yith_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
|
76 |
+
add_action( "wp_ajax_yith_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
|
77 |
add_action( 'yit_licence_after_check', array( $this, 'licence_after_check' ) );
|
78 |
}
|
79 |
|
plugin-fw/licence/lib/yit-theme-licence.php
CHANGED
@@ -73,9 +73,9 @@ if ( !class_exists( 'YIT_Theme_Licence' ) ) {
|
|
73 |
);
|
74 |
|
75 |
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
|
76 |
-
add_action( "
|
77 |
-
add_action( "
|
78 |
-
add_action( "
|
79 |
}
|
80 |
|
81 |
/**
|
73 |
);
|
74 |
|
75 |
add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
|
76 |
+
add_action( "wp_ajax_yith_activate-{$this->_product_type}", array( $this, 'activate' ) );
|
77 |
+
add_action( "wp_ajax_yith_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
|
78 |
+
add_action( "wp_ajax_yith_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
|
79 |
}
|
80 |
|
81 |
/**
|
plugin-fw/licence/templates/panel/activation/activation-panel.php
CHANGED
@@ -25,7 +25,7 @@ $num_members_products_activate = $this->get_number_of_membership_products();
|
|
25 |
<div class="licence-check-section">
|
26 |
<form method="post" id="licence-check-update" action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
|
27 |
<span class="licence-label" style="display: block;"><?php _e( 'Have you updated your licenses? Have you asked for an extension? Update information concerning your products.', 'yith-plugin-fw' ); ?></span>
|
28 |
-
<input type="hidden" name="action" value="
|
29 |
<input type="submit" name="submit" value="<?php _e( 'Update license information', 'yith-plugin-fw' ) ?>" class="button-licence licence-check" />
|
30 |
<div class="spinner"></div>
|
31 |
</form>
|
@@ -61,7 +61,7 @@ $num_members_products_activate = $this->get_number_of_membership_products();
|
|
61 |
<input type="submit" name="submit" value="<?php _e( 'Activate', 'yith-plugin-fw' )?>" class="button-licence licence-activation" data-formid="<?php echo $info['product_id'] ?>"/>
|
62 |
</td>
|
63 |
</tr>
|
64 |
-
<input type="hidden" name="action" value="
|
65 |
<input type="hidden" name="product_init" value="<?php echo $init ?>" />
|
66 |
</tbody>
|
67 |
</table>
|
@@ -138,7 +138,7 @@ $num_members_products_activate = $this->get_number_of_membership_products();
|
|
138 |
data-licence-email="<?php echo $info['licence']['email'] ?>"
|
139 |
data-licence-key="<?php echo $info['licence']['licence_key'] ?>"
|
140 |
data-product-init="<?php echo $init ?>"
|
141 |
-
data-action="
|
142 |
<?php _e( 'Deactivate', 'yith-plugin-fw' ) ?>
|
143 |
</a>
|
144 |
|
25 |
<div class="licence-check-section">
|
26 |
<form method="post" id="licence-check-update" action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
|
27 |
<span class="licence-label" style="display: block;"><?php _e( 'Have you updated your licenses? Have you asked for an extension? Update information concerning your products.', 'yith-plugin-fw' ); ?></span>
|
28 |
+
<input type="hidden" name="action" value="yith_update_licence_information-<?php echo $this->get_product_type(); ?>" />
|
29 |
<input type="submit" name="submit" value="<?php _e( 'Update license information', 'yith-plugin-fw' ) ?>" class="button-licence licence-check" />
|
30 |
<div class="spinner"></div>
|
31 |
</form>
|
61 |
<input type="submit" name="submit" value="<?php _e( 'Activate', 'yith-plugin-fw' )?>" class="button-licence licence-activation" data-formid="<?php echo $info['product_id'] ?>"/>
|
62 |
</td>
|
63 |
</tr>
|
64 |
+
<input type="hidden" name="action" value="yith_activate-<?php echo $this->get_product_type(); ?>" />
|
65 |
<input type="hidden" name="product_init" value="<?php echo $init ?>" />
|
66 |
</tbody>
|
67 |
</table>
|
138 |
data-licence-email="<?php echo $info['licence']['email'] ?>"
|
139 |
data-licence-key="<?php echo $info['licence']['licence_key'] ?>"
|
140 |
data-product-init="<?php echo $init ?>"
|
141 |
+
data-action="yith_deactivate-<?php echo $this->get_product_type(); ?>">
|
142 |
<?php _e( 'Deactivate', 'yith-plugin-fw' ) ?>
|
143 |
</a>
|
144 |
|
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,42 @@ 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 |
+
/* === WooCommerce Update Message === */
|
46 |
+
|
47 |
+
/*if( apply_filters( 'yit_fw_wc_update_message_hook', true )
|
48 |
+
&&
|
49 |
+
( function_exists( 'WC' ) && ! version_compare( WC()->version, '2.7', '>=' ) )
|
50 |
+
&& ! isset( $_COOKIE['yith_wc_2_7_notice'] )
|
51 |
+
){
|
52 |
+
add_action( 'admin_notices', 'yit_fw_wc_update_message', 15 );
|
53 |
+
add_action( 'admin_enqueue_scripts', 'yit_plugin_fw_dismissable_notice', 20 );
|
54 |
+
|
55 |
+
if( ! function_exists( 'yit_fw_wc_update_message' ) ){
|
56 |
+
function yit_fw_wc_update_message(){
|
57 |
+
?>
|
58 |
+
<div id="yith-notice-is-dismissable" class="yith-wc-update-message notice notice-error is-dismissible">
|
59 |
+
<?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'; ?>
|
60 |
+
<?php $url = 'https://support.yithemes.com/hc/en-us/articles/215945378-Theme-and-Plugin-compatibility-with-WordPress-and-WooCommerce'; ?>
|
61 |
+
<p><?php printf( '<strong>%s</strong> - %s <a href="%s" target="_blank">HERE</a>.', 'Please note', $message, $url ); ?></p>
|
62 |
+
</div>
|
63 |
+
<?php
|
64 |
+
}
|
65 |
+
}
|
66 |
+
|
67 |
+
if( ! function_exists( 'yit_plugin_fw_dismissable_notice' ) ){
|
68 |
+
function yit_plugin_fw_dismissable_notice(){
|
69 |
+
$assets_path = str_replace( array( 'http:', 'https:' ), '', WC()->plugin_url() ) . '/assets/';
|
70 |
+
wp_enqueue_script( 'jquery-cookie', $assets_path . 'js/jquery-cookie/jquery.cookie.min.js', array( 'jquery' ), '1.4.1', true);
|
71 |
+
$js = "jQuery( document ).ready( function(){
|
72 |
+
jQuery( '#yith-notice-is-dismissable' ).find('.notice-dismiss').on( 'click', function(){
|
73 |
+
jQuery.cookie('yith_wc_2_7_notice', 'dismiss', { path: '/' });
|
74 |
+
} );
|
75 |
+
} ); ";
|
76 |
+
|
77 |
+
wp_add_inline_script( 'jquery-cookie', $js );
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}*/
|
81 |
+
|
82 |
+
/* ========================== */
|
plugin-fw/yit-woocommerce-compatibility.php
ADDED
@@ -0,0 +1,702 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
} else {
|
119 |
+
yit_store_changes( $object, $key, $value );
|
120 |
+
}
|
121 |
+
} else {
|
122 |
+
if ( yit_wc_check_post_columns( $key ) ) {
|
123 |
+
yit_store_changes( $object->post, $key, $value );
|
124 |
+
} else {
|
125 |
+
$object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id;
|
126 |
+
|
127 |
+
update_post_meta( $object_id, $key, $value );
|
128 |
+
}
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
if ( !function_exists( 'yit_delete_prop' ) ) {
|
135 |
+
/**
|
136 |
+
*
|
137 |
+
*/
|
138 |
+
function yit_delete_prop( $object, $key, $value = '' ) {
|
139 |
+
$prop_map = yit_return_new_attribute_map();
|
140 |
+
$is_wc_data = $object instanceof WC_Data;
|
141 |
+
|
142 |
+
if ( $is_wc_data ) {
|
143 |
+
$key = ( array_key_exists( $key, $prop_map ) ) ? $prop_map[ $key ] : $key;
|
144 |
+
|
145 |
+
if ( ( $setter = "set{$key}" ) && ( $getter = "get{$key}" ) && method_exists( $object, $setter ) && ( !$value || $object->$getter == $value ) ) {
|
146 |
+
$object->$setter( '' );
|
147 |
+
} elseif ( ( $setter = "set_{$key}" ) && ( $getter = "get_{$key}" ) && method_exists( $object, $setter ) && ( !$value || $object->$getter == $value ) ) {
|
148 |
+
$object->$setter( '' );
|
149 |
+
} elseif ( ( !$value || $object->get_meta( $key ) == $value ) ) {
|
150 |
+
$object->delete_meta_data( $key, $value );
|
151 |
+
}
|
152 |
+
|
153 |
+
yit_store_changes( $object, $key );
|
154 |
+
} else {
|
155 |
+
if ( yit_wc_check_post_columns( $key ) && ( !$value || $object->post->$key == $value ) ) {
|
156 |
+
yit_store_changes( $object->post, $key, '' );
|
157 |
+
} else {
|
158 |
+
$object_id = is_callable( array( $object, 'get_id' ) ) ? $object->get_id() : $object->id;
|
159 |
+
|
160 |
+
delete_post_meta( $object_id, $key, $value );
|
161 |
+
}
|
162 |
+
}
|
163 |
+
}
|
164 |
+
}
|
165 |
+
|
166 |
+
if ( !function_exists( 'yit_return_new_attribute_map' ) ) {
|
167 |
+
function yit_return_new_attribute_map() {
|
168 |
+
return array(
|
169 |
+
'post_parent' => 'parent_id',
|
170 |
+
'post_title' => 'name',
|
171 |
+
'post_status' => 'status',
|
172 |
+
'post_content' => 'description',
|
173 |
+
'post_excerpt' => 'short_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 |
+
'customer_user' => 'customer_id',
|
183 |
+
'_customer_user' => 'customer_id',
|
184 |
+
/* Products */
|
185 |
+
'visibility' => 'catalog_visibility',
|
186 |
+
'_visibility' => '_catalog_visibility',
|
187 |
+
'sale_price_dates_from' => 'date_on_sale_from',
|
188 |
+
'_sale_price_dates_from' => '_date_on_sale_from',
|
189 |
+
'sale_price_dates_to' => 'date_on_sale_to',
|
190 |
+
'_sale_price_dates_to' => '_date_on_sale_to',
|
191 |
+
/*Coupons*/
|
192 |
+
'coupon_amount' => 'amount',
|
193 |
+
'exclude_product_ids' => 'excluded_product_ids',
|
194 |
+
'exclude_product_categories' => 'excluded_product_categories',
|
195 |
+
'customer_email' => 'email_restrictions',
|
196 |
+
'expiry_date' => 'date_expires',
|
197 |
+
);
|
198 |
+
}
|
199 |
+
}
|
200 |
+
|
201 |
+
if ( !function_exists( 'yit_store_changes' ) ) {
|
202 |
+
function yit_store_changes( $object, $key, $value = false ) {
|
203 |
+
global $changed_objects;
|
204 |
+
|
205 |
+
$is_wc_data = $object instanceof WC_Data;
|
206 |
+
|
207 |
+
if ( $is_wc_data ) {
|
208 |
+
/**
|
209 |
+
* @var $object \WC_Data
|
210 |
+
*/
|
211 |
+
$object_reference = $object->get_id();
|
212 |
+
|
213 |
+
$cache_type = is_a( $object, 'WC_Product' ) ? 'product' : 'order';
|
214 |
+
$cache_key = $cache_type . '-' . $object_reference;
|
215 |
+
$cache_group = $cache_type . 's';
|
216 |
+
|
217 |
+
$changed_objects[ $object_reference ][ 'object' ] = $object;
|
218 |
+
$changed_objects[ $object_reference ][ 'changes' ][ $key ] = $value;
|
219 |
+
|
220 |
+
|
221 |
+
wp_cache_set( $cache_key, $object, $cache_group );
|
222 |
+
} else {
|
223 |
+
$changed_objects[ $object->ID ][ $key ] = $value;
|
224 |
+
}
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
if ( !function_exists( 'yit_send_changes_to_db' ) ) {
|
229 |
+
function yit_send_changes_to_db() {
|
230 |
+
global $changed_objects;
|
231 |
+
|
232 |
+
if ( !empty( $changed_objects ) ) {
|
233 |
+
foreach ( $changed_objects as $id => $data ) {
|
234 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
235 |
+
/**
|
236 |
+
* @var $object \WC_Data
|
237 |
+
*/
|
238 |
+
$object = is_a( $data[ 'object' ], 'WC_Product' ) ? wc_get_product( $id ) : wc_get_order( $id );
|
239 |
+
|
240 |
+
yit_set_prop( $object, $data[ 'changes' ] );
|
241 |
+
$object->save();
|
242 |
+
} else {
|
243 |
+
$data[ 'ID' ] = $id;
|
244 |
+
wp_update_post( $data );
|
245 |
+
}
|
246 |
+
}
|
247 |
+
}
|
248 |
+
}
|
249 |
+
}
|
250 |
+
|
251 |
+
if ( !function_exists( 'yit_get_orders' ) ) {
|
252 |
+
/**
|
253 |
+
*
|
254 |
+
*/
|
255 |
+
function yit_get_orders( $args ) {
|
256 |
+
if ( version_compare( WC()->version, '2.6', '<' ) ) {
|
257 |
+
$args[ 'fields' ] = 'objects';
|
258 |
+
$posts = get_posts( $args );
|
259 |
+
|
260 |
+
return array_map( 'wc_get_order', $posts );
|
261 |
+
} else {
|
262 |
+
return wc_get_orders( $args );
|
263 |
+
}
|
264 |
+
}
|
265 |
+
}
|
266 |
+
|
267 |
+
if ( !function_exists( 'yit_get_products' ) ) {
|
268 |
+
/**
|
269 |
+
*
|
270 |
+
*/
|
271 |
+
function yit_get_products( $args ) {
|
272 |
+
if ( version_compare( WC()->version, '2.6', '<' ) ) {
|
273 |
+
$args[ 'fields' ] = 'objects';
|
274 |
+
$posts = get_posts( $args );
|
275 |
+
|
276 |
+
return array_map( 'wc_get_product', $posts );
|
277 |
+
} else {
|
278 |
+
return wc_get_products( $args );
|
279 |
+
}
|
280 |
+
}
|
281 |
+
}
|
282 |
+
|
283 |
+
if ( !function_exists( 'yit_update_product_stock' ) ) {
|
284 |
+
/**
|
285 |
+
*
|
286 |
+
*/
|
287 |
+
function yit_update_product_stock( $product, $stock_quantity = 1, $operation = 'set' ) {
|
288 |
+
if ( function_exists( 'wc_update_product_stock' ) ) {
|
289 |
+
$stock = wc_update_product_stock( $product, $stock_quantity, $operation );
|
290 |
+
} else {
|
291 |
+
switch ( $operation ) {
|
292 |
+
case 'increase':
|
293 |
+
$stock = $product->increase_stock( $stock_quantity );
|
294 |
+
break;
|
295 |
+
case 'decrease':
|
296 |
+
$stock = $product->reduce_stock( $stock_quantity );
|
297 |
+
break;
|
298 |
+
case 'set':
|
299 |
+
default:
|
300 |
+
$stock = $product->set_stock( $stock_quantity );
|
301 |
+
break;
|
302 |
+
}
|
303 |
+
}
|
304 |
+
|
305 |
+
return $stock;
|
306 |
+
}
|
307 |
+
}
|
308 |
+
|
309 |
+
if ( !function_exists( 'yit_wc_deprecated_filters' ) ) {
|
310 |
+
/**
|
311 |
+
*
|
312 |
+
*/
|
313 |
+
function yit_wc_deprecated_filters() {
|
314 |
+
return apply_filters( 'yit_wc_deprecated_filters', array(
|
315 |
+
'woocommerce_email_order_schema_markup' => 'woocommerce_structured_data_order',
|
316 |
+
'woocommerce_product_width' => 'woocommerce_product_get_width',
|
317 |
+
'woocommerce_product_height' => 'woocommerce_product_get_height',
|
318 |
+
'woocommerce_product_length' => 'woocommerce_product_get_length',
|
319 |
+
'woocommerce_product_weight' => 'woocommerce_product_get_weight',
|
320 |
+
'woocommerce_get_sku' => 'woocommerce_product_get_sku',
|
321 |
+
'woocommerce_get_price' => 'woocommerce_product_get_price',
|
322 |
+
'woocommerce_get_regular_price' => 'woocommerce_product_get_regular_price',
|
323 |
+
'woocommerce_get_sale_price' => 'woocommerce_product_get_sale_price',
|
324 |
+
'woocommerce_product_tax_class' => 'woocommerce_product_get_tax_class',
|
325 |
+
'woocommerce_get_stock_quantity' => 'woocommerce_product_get_stock_quantity',
|
326 |
+
'woocommerce_get_product_attributes' => 'woocommerce_product_get_attributes',
|
327 |
+
'woocommerce_product_gallery_attachment_ids' => 'woocommerce_product_get_gallery_image_ids',
|
328 |
+
'woocommerce_product_review_count' => 'woocommerce_product_get_review_count',
|
329 |
+
'woocommerce_product_files' => 'woocommerce_product_get_downloads',
|
330 |
+
'woocommerce_get_currency' => 'woocommerce_order_get_currency',
|
331 |
+
'woocommerce_order_amount_discount_total' => 'woocommerce_order_get_discount_total',
|
332 |
+
'woocommerce_order_amount_discount_tax' => 'woocommerce_order_get_discount_tax',
|
333 |
+
'woocommerce_order_amount_shipping_total' => 'woocommerce_order_get_shipping_total',
|
334 |
+
'woocommerce_order_amount_shipping_tax' => 'woocommerce_order_get_shipping_tax',
|
335 |
+
'woocommerce_order_amount_cart_tax' => 'woocommerce_order_get_cart_tax',
|
336 |
+
'woocommerce_order_amount_total' => 'woocommerce_order_get_total',
|
337 |
+
'woocommerce_order_amount_total_tax' => 'woocommerce_order_get_total_tax',
|
338 |
+
'woocommerce_order_amount_total_discount' => 'woocommerce_order_get_total_discount',
|
339 |
+
'woocommerce_order_amount_subtotal' => 'woocommerce_order_get_subtotal',
|
340 |
+
'woocommerce_order_tax_totals' => 'woocommerce_order_get_tax_totals',
|
341 |
+
'woocommerce_refund_amount' => 'woocommerce_get_order_refund_get_amount',
|
342 |
+
'woocommerce_refund_reason' => 'woocommerce_get_order_refund_get_reason',
|
343 |
+
'default_checkout_country' => 'default_checkout_billing_country',
|
344 |
+
'default_checkout_state' => 'default_checkout_billing_state',
|
345 |
+
'default_checkout_postcode' => 'default_checkout_billing_postcode',
|
346 |
+
|
347 |
+
) );
|
348 |
+
}
|
349 |
+
}
|
350 |
+
|
351 |
+
if ( !function_exists( 'yit_fix_wc_deprecated_filters' ) ) {
|
352 |
+
/**
|
353 |
+
*
|
354 |
+
*/
|
355 |
+
function yit_fix_wc_deprecated_filters() {
|
356 |
+
|
357 |
+
if ( !version_compare( WC()->version, '2.7.0', '<' ) ) {
|
358 |
+
return;
|
359 |
+
}
|
360 |
+
|
361 |
+
$deprecated_filters = yit_wc_deprecated_filters();
|
362 |
+
foreach ( $deprecated_filters as $old => $new ) {
|
363 |
+
add_filter( $old, 'yit_wc_deprecated_filter_mapping', 10, 100 );
|
364 |
+
}
|
365 |
+
}
|
366 |
+
}
|
367 |
+
|
368 |
+
if ( !function_exists( 'yit_wc_deprecated_filter_mapping' ) ) {
|
369 |
+
/**
|
370 |
+
*
|
371 |
+
*/
|
372 |
+
function yit_wc_deprecated_filter_mapping() {
|
373 |
+
$deprecated_filters = yit_wc_deprecated_filters();
|
374 |
+
|
375 |
+
$filter = current_filter();
|
376 |
+
$args = func_get_args();
|
377 |
+
$data = $args[ 0 ];
|
378 |
+
|
379 |
+
|
380 |
+
if ( isset( $deprecated_filters[ $filter ] ) ) {
|
381 |
+
if ( has_filter( $deprecated_filters[ $filter ] ) ) {
|
382 |
+
$data = apply_filters_ref_array( $deprecated_filters[ $filter ], $args );
|
383 |
+
}
|
384 |
+
}
|
385 |
+
|
386 |
+
return $data;
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
if ( !function_exists( 'yit_wc_check_post_columns' ) ) {
|
391 |
+
/**
|
392 |
+
*
|
393 |
+
*/
|
394 |
+
function yit_wc_check_post_columns( $key ) {
|
395 |
+
$columns = array(
|
396 |
+
'post_author',
|
397 |
+
'post_date',
|
398 |
+
'post_date_gmt',
|
399 |
+
'post_content',
|
400 |
+
'post_title',
|
401 |
+
'post_excerpt',
|
402 |
+
'post_status',
|
403 |
+
'comment_status',
|
404 |
+
'ping_status',
|
405 |
+
'post_password',
|
406 |
+
'post_name',
|
407 |
+
'to_ping',
|
408 |
+
'pinged',
|
409 |
+
'post_modified',
|
410 |
+
'post_modified_gmt',
|
411 |
+
'post_content_filtered',
|
412 |
+
'post_parent',
|
413 |
+
'guid',
|
414 |
+
'menu_order',
|
415 |
+
'post_type',
|
416 |
+
'post_mime_type',
|
417 |
+
'comment_count',
|
418 |
+
);
|
419 |
+
|
420 |
+
return in_array( $key, $columns );
|
421 |
+
}
|
422 |
+
}
|
423 |
+
|
424 |
+
|
425 |
+
/* Shortcuts for common functions */
|
426 |
+
|
427 |
+
if ( !function_exists( 'yit_get_order_id' ) ) {
|
428 |
+
/**
|
429 |
+
* Retrieve the order id
|
430 |
+
*
|
431 |
+
* @param WC_Order $order
|
432 |
+
*
|
433 |
+
* @return mixed
|
434 |
+
*/
|
435 |
+
function yit_get_order_id( $order ) {
|
436 |
+
return yit_get_prop( $order, 'id' );
|
437 |
+
}
|
438 |
+
}
|
439 |
+
|
440 |
+
if ( !function_exists( 'yit_get_product_id' ) ) {
|
441 |
+
/**
|
442 |
+
* Retrieve the product id
|
443 |
+
*
|
444 |
+
* @param WC_Product $product
|
445 |
+
*
|
446 |
+
* @return mixed
|
447 |
+
*/
|
448 |
+
function yit_get_product_id( $product ) {
|
449 |
+
return yit_get_prop( $product, 'id' );
|
450 |
+
}
|
451 |
+
}
|
452 |
+
|
453 |
+
if ( !function_exists( 'yit_get_base_product_id' ) ) {
|
454 |
+
/**
|
455 |
+
* New way to retrieve the $product->id as it was before WC 2.7.
|
456 |
+
*
|
457 |
+
* Retrieve the parent product id for WC_Product_Variation instances
|
458 |
+
* or the product id in the other cases.
|
459 |
+
*
|
460 |
+
* @param WC_Product $product
|
461 |
+
*
|
462 |
+
* @return mixed
|
463 |
+
*/
|
464 |
+
function yit_get_base_product_id( $product ) {
|
465 |
+
|
466 |
+
return $product instanceof WC_Data && $product->is_type( 'variation' ) ?
|
467 |
+
yit_get_prop( $product, 'parent_id' ) :
|
468 |
+
yit_get_prop( $product, 'id' );
|
469 |
+
}
|
470 |
+
}
|
471 |
+
|
472 |
+
if ( !function_exists( 'yit_get_display_price' ) ) {
|
473 |
+
/**
|
474 |
+
* @param WC_Product $product
|
475 |
+
* @param string $price
|
476 |
+
* @param int $qty
|
477 |
+
*/
|
478 |
+
function yit_get_display_price( $product, $price = '', $qty = 1 ) {
|
479 |
+
|
480 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
481 |
+
|
482 |
+
$price = wc_get_price_to_display( $product, array( 'qty' => $qty, 'price' => $price ) );
|
483 |
+
} else {
|
484 |
+
|
485 |
+
$price = $product->get_display_price( $price, $qty );
|
486 |
+
}
|
487 |
+
|
488 |
+
return $price;
|
489 |
+
}
|
490 |
+
}
|
491 |
+
|
492 |
+
if ( !function_exists( 'yit_get_price_excluding_tax' ) ) {
|
493 |
+
/**
|
494 |
+
* @param WC_Product $product
|
495 |
+
* @param int $qty
|
496 |
+
* @param string $price
|
497 |
+
*
|
498 |
+
* @return float|string
|
499 |
+
*/
|
500 |
+
function yit_get_price_excluding_tax( $product, $qty = 1, $price = '' ) {
|
501 |
+
|
502 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
503 |
+
|
504 |
+
$price = wc_get_price_excluding_tax( $product, array( 'qty' => $qty, 'price' => $price ) );
|
505 |
+
} else {
|
506 |
+
|
507 |
+
$price = $product->get_price_excluding_tax( $qty, $price );
|
508 |
+
}
|
509 |
+
|
510 |
+
return $price;
|
511 |
+
}
|
512 |
+
}
|
513 |
+
|
514 |
+
if ( !function_exists( 'yit_get_price_including_tax' ) ) {
|
515 |
+
/**
|
516 |
+
* @param WC_Product $product
|
517 |
+
* @param int $qty
|
518 |
+
* @param string $price
|
519 |
+
*
|
520 |
+
* @return float|string
|
521 |
+
*/
|
522 |
+
function yit_get_price_including_tax( $product, $qty = 1, $price = '' ) {
|
523 |
+
|
524 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
525 |
+
|
526 |
+
$price = wc_get_price_including_tax( $product, array( 'qty' => $qty, 'price' => $price ) );
|
527 |
+
} else {
|
528 |
+
|
529 |
+
$price = $product->get_price_including_tax( $qty, $price );
|
530 |
+
}
|
531 |
+
|
532 |
+
return $price;
|
533 |
+
}
|
534 |
+
}
|
535 |
+
|
536 |
+
if ( !function_exists( 'yit_get_product_image_id' ) ) {
|
537 |
+
/**
|
538 |
+
* get the attach image id
|
539 |
+
*
|
540 |
+
* @param WC_Product $product
|
541 |
+
* @param string $context ( view/edit )
|
542 |
+
*/
|
543 |
+
function yit_get_product_image_id( $product, $context = 'view' ) {
|
544 |
+
|
545 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) {
|
546 |
+
|
547 |
+
$image_id = $product->get_image_id( $context );
|
548 |
+
} else {
|
549 |
+
|
550 |
+
$image_id = $product->get_image_id();
|
551 |
+
}
|
552 |
+
|
553 |
+
return $image_id;
|
554 |
+
}
|
555 |
+
}
|
556 |
+
|
557 |
+
if ( !function_exists( 'yit_get_refund_amount' ) ) {
|
558 |
+
/**
|
559 |
+
* @param $refund \WC_Order_Refund
|
560 |
+
* @param $context string
|
561 |
+
*
|
562 |
+
* @return float
|
563 |
+
*/
|
564 |
+
function yit_get_refund_amount( $refund, $context = 'view' ) {
|
565 |
+
$is_wc_data = $refund instanceof WC_Data;
|
566 |
+
|
567 |
+
if ( $is_wc_data ) {
|
568 |
+
return $refund->get_amount( $context );
|
569 |
+
} else {
|
570 |
+
return $refund->get_refund_amount();
|
571 |
+
}
|
572 |
+
}
|
573 |
+
}
|
574 |
+
|
575 |
+
if ( !function_exists( 'yit_add_select2_fields' ) ) {
|
576 |
+
/**
|
577 |
+
* Add select 2
|
578 |
+
*
|
579 |
+
* @param array $args
|
580 |
+
*/
|
581 |
+
function yit_add_select2_fields( $args = array() ) {
|
582 |
+
$default = array(
|
583 |
+
'type' => 'hidden',
|
584 |
+
'class' => '',
|
585 |
+
'id' => '',
|
586 |
+
'name' => '',
|
587 |
+
'data-placeholder' => '',
|
588 |
+
'data-allow_clear' => false,
|
589 |
+
'data-selected' => '',
|
590 |
+
'data-multiple' => false,
|
591 |
+
'data-action' => '',
|
592 |
+
'value' => '',
|
593 |
+
'style' => '',
|
594 |
+
'custom-attributes' => array()
|
595 |
+
);
|
596 |
+
|
597 |
+
$args = wp_parse_args( $args, $default );
|
598 |
+
|
599 |
+
$custom_attributes = array();
|
600 |
+
foreach ( $args[ 'custom-attributes' ] as $attribute => $attribute_value ) {
|
601 |
+
$custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
|
602 |
+
}
|
603 |
+
$custom_attributes = implode( ' ', $custom_attributes );
|
604 |
+
|
605 |
+
if ( version_compare( WC()->version, '2.7.0', '>=' ) ) :
|
606 |
+
if ( $args[ 'data-multiple' ] === true && substr( $args[ 'name' ], -2 ) != '[]' ) {
|
607 |
+
$args[ 'name' ] = $args[ 'name' ] . '[]';
|
608 |
+
}
|
609 |
+
?>
|
610 |
+
|
611 |
+
<select
|
612 |
+
id="<?php echo $args[ 'id' ] ?>"
|
613 |
+
class="<?php echo $args[ 'class' ] ?>"
|
614 |
+
name="<?php echo $args[ 'name' ] ?>"
|
615 |
+
data-placeholder="<?php echo $args[ 'data-placeholder' ] ?>"
|
616 |
+
data-allow_clear="<?php echo $args[ 'data-allow_clear' ] ?>"
|
617 |
+
<?php echo !empty( $args[ 'data-action' ] ) ? 'data-action="' . $args[ 'data-action' ] . '"' : ''; ?>
|
618 |
+
<?php echo !empty( $args[ 'data-multiple' ] ) ? 'multiple="multiple"' : ''; ?>
|
619 |
+
style="<?php echo $args[ 'style' ] ?>"
|
620 |
+
<?php echo $custom_attributes ?>
|
621 |
+
>
|
622 |
+
|
623 |
+
<?php if ( !empty( $args[ 'value' ] ) ) {
|
624 |
+
$values = $args[ 'value' ];
|
625 |
+
|
626 |
+
if ( !is_array( $values ) ) {
|
627 |
+
$values = explode( ',', $values );
|
628 |
+
}
|
629 |
+
|
630 |
+
foreach ( $values as $value ): ?>
|
631 |
+
<option value="<?php echo $value; ?>" <?php selected( true, true, true ) ?> >
|
632 |
+
<?php echo $args[ 'data-selected' ][ $value ]; ?>
|
633 |
+
</option>
|
634 |
+
<?php endforeach;
|
635 |
+
}
|
636 |
+
?>
|
637 |
+
</select>
|
638 |
+
<?php
|
639 |
+
else :
|
640 |
+
if ( $args[ 'data-multiple' ] === false && is_array( $args[ 'data-selected' ] ) ) {
|
641 |
+
$args[ 'data-selected' ] = current($args[ 'data-selected' ]);
|
642 |
+
}
|
643 |
+
|
644 |
+
?>
|
645 |
+
<input
|
646 |
+
type="hidden"
|
647 |
+
id="<?php echo $args[ 'id' ] ?>"
|
648 |
+
class="<?php echo $args[ 'class' ] ?>"
|
649 |
+
name="<?php echo $args[ 'name' ] ?>"
|
650 |
+
data-placeholder="<?php echo $args[ 'data-placeholder' ] ?>"
|
651 |
+
data-allow_clear="<?php echo $args[ 'data-allow_clear' ] ?>"
|
652 |
+
data-selected="<?php echo is_array( $args[ 'data-selected' ] ) ? esc_attr( json_encode( $args[ 'data-selected' ] ) ) : esc_attr( $args[ 'data-selected' ] ) ?>"
|
653 |
+
data-multiple="<?php echo $args[ 'data-multiple' ] === true ? 'true' : 'false' ?>"
|
654 |
+
<?php echo( !empty( $args[ 'data-action' ] ) ? 'data-action="' . $args[ 'data-action' ] . '"' : '' ) ?>
|
655 |
+
value="<?php echo $args[ 'value' ] ?>"
|
656 |
+
style="<?php echo $args[ 'style' ] ?>"
|
657 |
+
<?php echo $custom_attributes ?>
|
658 |
+
/>
|
659 |
+
<?php
|
660 |
+
endif;
|
661 |
+
}
|
662 |
+
}
|
663 |
+
|
664 |
+
if ( !function_exists( 'yit_product_visibility_meta' ) ) {
|
665 |
+
function yit_product_visibility_meta( $args ) {
|
666 |
+
if ( version_compare( WC()->version, '2.7.0', '<' ) ) {
|
667 |
+
$args[ 'meta_query' ] = isset( $args[ 'meta_query' ] ) ? $args[ 'meta_query' ] : array();
|
668 |
+
$args[ 'meta_query' ][] = WC()->query->visibility_meta_query();
|
669 |
+
} else {
|
670 |
+
$product_visibility_term_ids = wc_get_product_visibility_term_ids();
|
671 |
+
$args[ 'tax_query' ] = isset( $args[ 'tax_query' ] ) ? $args[ 'tax_query' ] : array();
|
672 |
+
$args[ 'tax_query' ][] = array(
|
673 |
+
'taxonomy' => 'product_visibility',
|
674 |
+
'field' => 'term_taxonomy_id',
|
675 |
+
'terms' => is_search() ? $product_visibility_term_ids[ 'exclude-from-search' ] : $product_visibility_term_ids[ 'exclude-from-catalog' ],
|
676 |
+
'operator' => 'NOT IN',
|
677 |
+
);
|
678 |
+
}
|
679 |
+
|
680 |
+
return $args;
|
681 |
+
}
|
682 |
+
}
|
683 |
+
|
684 |
+
if ( !function_exists( 'yit_datetime_to_timestamp' ) ) {
|
685 |
+
|
686 |
+
/**
|
687 |
+
*
|
688 |
+
*/
|
689 |
+
function yit_datetime_to_timestamp( $date ) {
|
690 |
+
|
691 |
+
if ( ! is_int( $date ) ) {
|
692 |
+
$date = strtotime( $date );
|
693 |
+
}
|
694 |
+
|
695 |
+
return $date;
|
696 |
+
}
|
697 |
+
|
698 |
+
}
|
699 |
+
|
700 |
+
|
701 |
+
yit_fix_wc_deprecated_filters();
|
702 |
+
add_action( 'shutdown', 'yit_send_changes_to_db' );
|
screenshot-1.jpg
DELETED
Binary file
|
screenshot-2.jpg
DELETED
Binary file
|
screenshot-3.jpg
DELETED
Binary file
|
templates/yith-quick-view-content.php
CHANGED
@@ -12,7 +12,7 @@ while ( have_posts() ) : the_post(); ?>
|
|
12 |
|
13 |
<div class="product">
|
14 |
|
15 |
-
<div
|
16 |
|
17 |
<?php do_action( 'yith_wcqv_product_image' ); ?>
|
18 |
|
12 |
|
13 |
<div class="product">
|
14 |
|
15 |
+
<div id="product-<?php the_ID(); ?>" <?php post_class('product'); ?>>
|
16 |
|
17 |
<?php do_action( 'yith_wcqv_product_image' ); ?>
|
18 |
|