Version Description
Release Date - 23 August 2017
- Fixed an issue when variation has additional attribute(s) with any value
Download this release
Release Info
Developer | templateinvaders |
Plugin | WooCommerce Wishlist Plugin |
Version | 1.5.2 |
Comparing to | |
See all releases |
Code changes from version 1.5.1 to 1.5.2
- public/cart.class.php +309 -295
- readme.txt +318 -313
- templates/ti-wishlist-user.php +147 -147
- templates/ti-wishlist.php +151 -151
- ti-woocommerce-wishlist.php +129 -129
- tinv-wishlists-function-integration.php +1079 -1079
- tinv-wishlists-function.php +956 -951
public/cart.class.php
CHANGED
@@ -1,295 +1,309 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Cart action for wishlists
|
4 |
-
*
|
5 |
-
* @since 1.0.0
|
6 |
-
* @package TInvWishlist\Public
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
/**
|
15 |
-
* Cart action for wishlists
|
16 |
-
*/
|
17 |
-
class TInvWL_Public_Cart {
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Plugin name
|
21 |
-
*
|
22 |
-
* @var string
|
23 |
-
*/
|
24 |
-
static $_n;
|
25 |
-
|
26 |
-
/**
|
27 |
-
* Default post object.
|
28 |
-
*
|
29 |
-
* @var array
|
30 |
-
*/
|
31 |
-
static $_request;
|
32 |
-
|
33 |
-
/**
|
34 |
-
* Default post object.
|
35 |
-
*
|
36 |
-
* @var array
|
37 |
-
*/
|
38 |
-
static $_post;
|
39 |
-
/**
|
40 |
-
* This class
|
41 |
-
*
|
42 |
-
* @var \TInvWL_Public_Cart
|
43 |
-
*/
|
44 |
-
protected static $_instance = null;
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Get this class object
|
48 |
-
*
|
49 |
-
* @param string $plugin_name Plugin name.
|
50 |
-
* @return \TInvWL_Public_Cart
|
51 |
-
*/
|
52 |
-
public static function instance( $plugin_name = TINVWL_PREFIX ) {
|
53 |
-
if ( is_null( self::$_instance ) ) {
|
54 |
-
self::$_instance = new self( $plugin_name );
|
55 |
-
}
|
56 |
-
return self::$_instance;
|
57 |
-
}
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Constructor
|
61 |
-
*
|
62 |
-
* @param string $plugin_name Plugin name.
|
63 |
-
*/
|
64 |
-
function __construct( $plugin_name ) {
|
65 |
-
self::$_n = $plugin_name;
|
66 |
-
$this->define_hooks();
|
67 |
-
}
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Define hooks
|
71 |
-
*/
|
72 |
-
function define_hooks() {
|
73 |
-
add_action( 'woocommerce_before_cart_item_quantity_zero', array( __CLASS__, 'remove_item_data' ) );
|
74 |
-
add_action( 'woocommerce_cart_emptied', array( __CLASS__, 'remove_item_data' ) );
|
75 |
-
if ( version_compare( WC_VERSION, '3.0.0', '<' ) ) {
|
76 |
-
add_action( 'woocommerce_add_order_item_meta', array( $this, 'add_order_item_meta' ), 10, 3 );
|
77 |
-
} else {
|
78 |
-
add_action( 'woocommerce_checkout_create_order', array( $this, 'add_order_item_meta_v3' ) );
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
/**
|
83 |
-
* Add product to cart from wishlist
|
84 |
-
*
|
85 |
-
* @param array $wishlist Wishlist object.
|
86 |
-
* @param integer $wl_product Wishlist product id.
|
87 |
-
* @param integer $wl_quantity Product quantity.
|
88 |
-
* @return boolean
|
89 |
-
*/
|
90 |
-
public static function add( $wishlist = null, $wl_product = 0, $wl_quantity = 1 ) {
|
91 |
-
if ( empty( $wishlist ) ) {
|
92 |
-
$wishlist = tinv_wishlist_get();
|
93 |
-
}
|
94 |
-
$wlp = null;
|
95 |
-
if ( 0 === $wishlist['ID'] ) {
|
96 |
-
$wlp = TInvWL_Product_Local::instance();
|
97 |
-
} else {
|
98 |
-
$wlp = new TInvWL_Product( $wishlist );
|
99 |
-
}
|
100 |
-
$product = $wlp->get_wishlist( array( 'ID' => $wl_product ) );
|
101 |
-
$product = array_shift( $product );
|
102 |
-
if ( empty( $product ) ) {
|
103 |
-
return false;
|
104 |
-
}
|
105 |
-
if ( empty( $product['data'] ) ) {
|
106 |
-
return false;
|
107 |
-
}
|
108 |
-
|
109 |
-
self::prepare_post( $product );
|
110 |
-
|
111 |
-
$product = apply_filters( 'tinvwl_addproduct_tocart', $product );
|
112 |
-
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $product['product_id'] ) );
|
113 |
-
$quantity = empty( $wl_quantity ) ? 1 : wc_stock_amount( $wl_quantity );
|
114 |
-
$variation_id = $product['variation_id'];
|
115 |
-
$variations = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product['data']->variation_data : ( $product['data']->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product['data']->get_id() ) : array() ) );
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
}
|
147 |
-
|
148 |
-
/**
|
149 |
-
*
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
*
|
245 |
-
*
|
246 |
-
* @param
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
*
|
259 |
-
*
|
260 |
-
* @param
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
$
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
}
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Cart action for wishlists
|
4 |
+
*
|
5 |
+
* @since 1.0.0
|
6 |
+
* @package TInvWishlist\Public
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Cart action for wishlists
|
16 |
+
*/
|
17 |
+
class TInvWL_Public_Cart {
|
18 |
+
|
19 |
+
/**
|
20 |
+
* Plugin name
|
21 |
+
*
|
22 |
+
* @var string
|
23 |
+
*/
|
24 |
+
static $_n;
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Default post object.
|
28 |
+
*
|
29 |
+
* @var array
|
30 |
+
*/
|
31 |
+
static $_request;
|
32 |
+
|
33 |
+
/**
|
34 |
+
* Default post object.
|
35 |
+
*
|
36 |
+
* @var array
|
37 |
+
*/
|
38 |
+
static $_post;
|
39 |
+
/**
|
40 |
+
* This class
|
41 |
+
*
|
42 |
+
* @var \TInvWL_Public_Cart
|
43 |
+
*/
|
44 |
+
protected static $_instance = null;
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get this class object
|
48 |
+
*
|
49 |
+
* @param string $plugin_name Plugin name.
|
50 |
+
* @return \TInvWL_Public_Cart
|
51 |
+
*/
|
52 |
+
public static function instance( $plugin_name = TINVWL_PREFIX ) {
|
53 |
+
if ( is_null( self::$_instance ) ) {
|
54 |
+
self::$_instance = new self( $plugin_name );
|
55 |
+
}
|
56 |
+
return self::$_instance;
|
57 |
+
}
|
58 |
+
|
59 |
+
/**
|
60 |
+
* Constructor
|
61 |
+
*
|
62 |
+
* @param string $plugin_name Plugin name.
|
63 |
+
*/
|
64 |
+
function __construct( $plugin_name ) {
|
65 |
+
self::$_n = $plugin_name;
|
66 |
+
$this->define_hooks();
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* Define hooks
|
71 |
+
*/
|
72 |
+
function define_hooks() {
|
73 |
+
add_action( 'woocommerce_before_cart_item_quantity_zero', array( __CLASS__, 'remove_item_data' ) );
|
74 |
+
add_action( 'woocommerce_cart_emptied', array( __CLASS__, 'remove_item_data' ) );
|
75 |
+
if ( version_compare( WC_VERSION, '3.0.0', '<' ) ) {
|
76 |
+
add_action( 'woocommerce_add_order_item_meta', array( $this, 'add_order_item_meta' ), 10, 3 );
|
77 |
+
} else {
|
78 |
+
add_action( 'woocommerce_checkout_create_order', array( $this, 'add_order_item_meta_v3' ) );
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Add product to cart from wishlist
|
84 |
+
*
|
85 |
+
* @param array $wishlist Wishlist object.
|
86 |
+
* @param integer $wl_product Wishlist product id.
|
87 |
+
* @param integer $wl_quantity Product quantity.
|
88 |
+
* @return boolean
|
89 |
+
*/
|
90 |
+
public static function add( $wishlist = null, $wl_product = 0, $wl_quantity = 1 ) {
|
91 |
+
if ( empty( $wishlist ) ) {
|
92 |
+
$wishlist = tinv_wishlist_get();
|
93 |
+
}
|
94 |
+
$wlp = null;
|
95 |
+
if ( 0 === $wishlist['ID'] ) {
|
96 |
+
$wlp = TInvWL_Product_Local::instance();
|
97 |
+
} else {
|
98 |
+
$wlp = new TInvWL_Product( $wishlist );
|
99 |
+
}
|
100 |
+
$product = $wlp->get_wishlist( array( 'ID' => $wl_product ) );
|
101 |
+
$product = array_shift( $product );
|
102 |
+
if ( empty( $product ) ) {
|
103 |
+
return false;
|
104 |
+
}
|
105 |
+
if ( empty( $product['data'] ) ) {
|
106 |
+
return false;
|
107 |
+
}
|
108 |
+
|
109 |
+
self::prepare_post( $product );
|
110 |
+
|
111 |
+
$product = apply_filters( 'tinvwl_addproduct_tocart', $product );
|
112 |
+
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $product['product_id'] ) );
|
113 |
+
$quantity = empty( $wl_quantity ) ? 1 : wc_stock_amount( $wl_quantity );
|
114 |
+
$variation_id = $product['variation_id'];
|
115 |
+
$variations = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product['data']->variation_data : ( $product['data']->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product['data']->get_id() ) : array() ) );
|
116 |
+
|
117 |
+
if ( ! empty( $variation_id ) && is_array( $variations ) ) {
|
118 |
+
foreach ( $variations as $name => $value ) {
|
119 |
+
if ( '' === $value ) {
|
120 |
+
// Could be any value that saved to a custom meta.
|
121 |
+
if ( array_key_exists( 'meta', $product ) && array_key_exists( $name, $product['meta'] ) ) {
|
122 |
+
$variations[ $name ] = $product['meta'][ $name ];
|
123 |
+
} else {
|
124 |
+
continue;
|
125 |
+
}
|
126 |
+
}
|
127 |
+
}
|
128 |
+
}
|
129 |
+
|
130 |
+
$passed_validation = $product['data']->is_purchasable() && ( $product['data']->is_in_stock() || $product['data']->backorders_allowed() ) && 'external' !== ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product['data']->product_type : $product['data']->get_type() );
|
131 |
+
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations );
|
132 |
+
if ( $passed_validation ) {
|
133 |
+
$cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations );
|
134 |
+
if ( $cart_item_key ) {
|
135 |
+
do_action( 'tinvwl_addedproduct_tocart', $cart_item_key, $product_id, $quantity, $variation_id );
|
136 |
+
if ( ( 'private' !== $wishlist['status'] && tinv_get_option( 'processing', 'autoremove_anyone' ) ) || $wishlist['is_owner'] && 'tinvwl-addcart' === tinv_get_option( 'processing', 'autoremove_status' ) ) {
|
137 |
+
self::ar_f_wl( $wishlist, $product_id, $quantity, $variation_id, $product['meta'] );
|
138 |
+
}
|
139 |
+
self::set_item_data( $cart_item_key, $wishlist['share_key'], $quantity );
|
140 |
+
self::unprepare_post();
|
141 |
+
return array( $product_id => $quantity );
|
142 |
+
}
|
143 |
+
}
|
144 |
+
self::unprepare_post();
|
145 |
+
return false;
|
146 |
+
}
|
147 |
+
|
148 |
+
/**
|
149 |
+
* Prepare _POST data
|
150 |
+
*
|
151 |
+
* @param array $product Wishlist Product.
|
152 |
+
*/
|
153 |
+
public static function prepare_post( $product ) {
|
154 |
+
self::$_post = $_POST;
|
155 |
+
self::$_request = $_REQUEST;
|
156 |
+
if ( array_key_exists( 'meta', $product ) && ! empty( $product['meta'] ) ) {
|
157 |
+
$_POST = $product['meta']; // May be a conflict there will be no GET attributes.
|
158 |
+
$_REQUEST = $product['meta'];
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Unrepare _POST data
|
164 |
+
*/
|
165 |
+
public static function unprepare_post() {
|
166 |
+
$_POST = self::$_post;
|
167 |
+
$_REQUEST = self::$_request;
|
168 |
+
}
|
169 |
+
|
170 |
+
/**
|
171 |
+
* Get product added from wishlist
|
172 |
+
*
|
173 |
+
* @param string $cart_item_key Cart product key.
|
174 |
+
* @param array $wishlist Wishlist object.
|
175 |
+
* @return array
|
176 |
+
*/
|
177 |
+
public static function get_item_data( $cart_item_key, $wishlist = null ) {
|
178 |
+
$data = (array) WC()->session->get( 'tinvwl_wishlist_cart', array() );
|
179 |
+
if ( empty( $data[ $cart_item_key ] ) ) {
|
180 |
+
$data[ $cart_item_key ] = array();
|
181 |
+
}
|
182 |
+
|
183 |
+
if ( empty( $wishlist ) ) {
|
184 |
+
return $data[ $cart_item_key ];
|
185 |
+
} else {
|
186 |
+
return empty( $data[ $cart_item_key ][ $wishlist ] ) ? 0 : $data[ $cart_item_key ][ $wishlist ];
|
187 |
+
}
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Set product added from wishlist
|
192 |
+
*
|
193 |
+
* @param string $cart_item_key Cart product key.
|
194 |
+
* @param array $wishlist Wishlist object.
|
195 |
+
* @param integer $quantity Product quantity.
|
196 |
+
* @return boolean
|
197 |
+
*/
|
198 |
+
public static function set_item_data( $cart_item_key, $wishlist, $quantity = 1 ) {
|
199 |
+
$data = (array) WC()->session->get( '_tinvwl_wishlist_cart', array() );
|
200 |
+
if ( empty( $data[ $cart_item_key ] ) ) {
|
201 |
+
$data[ $cart_item_key ] = array();
|
202 |
+
}
|
203 |
+
|
204 |
+
if ( array_key_exists( $wishlist, $data[ $cart_item_key ] ) ) {
|
205 |
+
$data[ $cart_item_key ][ $wishlist ] += $quantity;
|
206 |
+
} else {
|
207 |
+
$data[ $cart_item_key ][ $wishlist ] = $quantity;
|
208 |
+
}
|
209 |
+
|
210 |
+
WC()->session->set( 'tinvwl_wishlist_cart', $data );
|
211 |
+
return true;
|
212 |
+
}
|
213 |
+
|
214 |
+
/**
|
215 |
+
* Remove product added from wishlist
|
216 |
+
*
|
217 |
+
* @param string $cart_item_key Cart product key.
|
218 |
+
* @param array $wishlist Wishlist object.
|
219 |
+
* @return boolean
|
220 |
+
*/
|
221 |
+
public static function remove_item_data( $cart_item_key = null, $wishlist = null ) {
|
222 |
+
$data = (array) WC()->session->get( 'tinvwl_wishlist_cart', array() );
|
223 |
+
if ( empty( $cart_item_key ) ) {
|
224 |
+
WC()->session->set( 'tinvwl_wishlist_cart', array() );
|
225 |
+
return true;
|
226 |
+
}
|
227 |
+
if ( ! array_key_exists( $cart_item_key, $data ) ) {
|
228 |
+
return false;
|
229 |
+
}
|
230 |
+
if ( empty( $wishlist ) ) {
|
231 |
+
unset( $data[ $cart_item_key ] );
|
232 |
+
} else {
|
233 |
+
if ( ! array_key_exists( $wishlist, $data[ $cart_item_key ] ) ) {
|
234 |
+
return false;
|
235 |
+
}
|
236 |
+
unset( $data[ $cart_item_key ][ $wishlist ] );
|
237 |
+
}
|
238 |
+
WC()->session->set( 'tinvwl_wishlist_cart', $data );
|
239 |
+
return true;
|
240 |
+
}
|
241 |
+
|
242 |
+
/**
|
243 |
+
* Add meta data for product when created order
|
244 |
+
*
|
245 |
+
* @param string $item_id Order item id.
|
246 |
+
* @param string $values Not used.
|
247 |
+
* @param string $cart_item_key Cart product key.
|
248 |
+
*/
|
249 |
+
public function add_order_item_meta( $item_id, $values, $cart_item_key ) {
|
250 |
+
$data = self::get_item_data( $cart_item_key );
|
251 |
+
$data = apply_filters( 'tinvwl_addproduct_toorder', $data, $cart_item_key, $values );
|
252 |
+
if ( ! empty( $data ) ) {
|
253 |
+
wc_add_order_item_meta( $item_id, '_tinvwl_wishlist_cart', $data );
|
254 |
+
}
|
255 |
+
}
|
256 |
+
|
257 |
+
/**
|
258 |
+
* Add meta data for product when created order
|
259 |
+
*
|
260 |
+
* @param \WC_Order $order Order object.
|
261 |
+
*/
|
262 |
+
public function add_order_item_meta_v3( $order ) {
|
263 |
+
foreach ( $order->get_items() as $item ) {
|
264 |
+
$data = self::get_item_data( $item->legacy_cart_item_key );
|
265 |
+
$data = apply_filters( 'tinvwl_addproduct_toorder', $data, $item->legacy_cart_item_key, $item->legacy_values );
|
266 |
+
$item->update_meta_data( '_tinvwl_wishlist_cart', $data );
|
267 |
+
}
|
268 |
+
}
|
269 |
+
|
270 |
+
/**
|
271 |
+
* Autoremove product from wishlist
|
272 |
+
*
|
273 |
+
* @param array $wishlist Wishlist object.
|
274 |
+
* @param integer $product_id Product id.
|
275 |
+
* @param integer $quantity Quantity product.
|
276 |
+
* @param integer $variation_id Variation product id.
|
277 |
+
* @param array $meta Meta array for post form.
|
278 |
+
* @return integer
|
279 |
+
*/
|
280 |
+
private static function ar_f_wl( $wishlist, $product_id, $quantity = 1, $variation_id = 0, $meta = array() ) {
|
281 |
+
$product_id = absint( $product_id );
|
282 |
+
$quantity = absint( $quantity );
|
283 |
+
$variation_id = absint( $variation_id );
|
284 |
+
if ( ! tinv_get_option( 'processing', 'autoremove' ) || empty( $wishlist ) || empty( $product_id ) || empty( $quantity ) ) {
|
285 |
+
return $quantity;
|
286 |
+
}
|
287 |
+
$wlp = null;
|
288 |
+
if ( 0 === $wishlist['ID'] ) {
|
289 |
+
$wlp = TInvWL_Product_Local::instance();
|
290 |
+
} else {
|
291 |
+
$wlp = new TInvWL_Product( $wishlist, self::$_n );
|
292 |
+
}
|
293 |
+
if ( empty( $wlp ) ) {
|
294 |
+
return 0;
|
295 |
+
}
|
296 |
+
$products = $wlp->get_wishlist( array(
|
297 |
+
'product_id' => $product_id,
|
298 |
+
'variation_id' => $variation_id,
|
299 |
+
'meta' => $meta,
|
300 |
+
'external' => false,
|
301 |
+
) );
|
302 |
+
$product = array_shift( $products );
|
303 |
+
if ( empty( $product ) ) {
|
304 |
+
return $quantity;
|
305 |
+
}
|
306 |
+
$wlp->remove_product_from_wl( 0, $product_id, $variation_id, $product['meta'] );
|
307 |
+
return 0;
|
308 |
+
}
|
309 |
+
}
|
readme.txt
CHANGED
@@ -1,313 +1,318 @@
|
|
1 |
-
=== WooCommerce Wishlist Plugin ===
|
2 |
-
Contributors: templateinvaders
|
3 |
-
Donate link: https://templateinvaders.com/?utm_source=wordpressorg&utm_content=donate
|
4 |
-
Tags: wishlist, woocommerce, products, e-commerce, shop, ecommerce wishlist, woocommerce wishlist, woocommerce , shop wishlist, wishlist for Woocommerce
|
5 |
-
Requires at least: 4.5
|
6 |
-
Tested up to: 4.8
|
7 |
-
Stable tag: 1.5.
|
8 |
-
License: GPLv3
|
9 |
-
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
-
|
11 |
-
Allow your store guests and customers to add products to Wishlist.
|
12 |
-
Add Wishlist functionality to your store for free.
|
13 |
-
|
14 |
-
== Description ==
|
15 |
-
|
16 |
-
= Increase Sales and Conversions =
|
17 |
-
WooCommerce Wishlist is a simple but powerful tool that can help you to convert your site visitors into loyal customers. There are many situations when customers can’t buy a product at this time or simply don’t want. Possibility to save products for later encourages users to return to your site and after all, make a purchase. Adding products to Wishlist is easy and convenient so it may also force your customers to buy even more products than they planned. Users can share their wishlist, for example, to help their friends choose a gift for upcoming holiday and so on. By sharing their Wishlists, they are bringing you, new potential customers. All in all this increasing amount of your site visitors, conversion and as a result sales.
|
18 |
-
|
19 |
-
[Live Preview](https://demo.templateinvaders.com/wordpress/plugins/wishlist/?utm_source=wordpressorg&utm_content=preview)
|
20 |
-
|
21 |
-
[View documentation](https://templateinvaders.com/documentation/ti-woocommerce-wishlist-free/?utm_source=wordpressorg&utm_content=documentation)
|
22 |
-
|
23 |
-
= Features List =
|
24 |
-
|
25 |
-
+ Select Wishlist page and Name
|
26 |
-
+ Remove product from wishlist automatically, after adding it to cart
|
27 |
-
+ Position of "Add to wishlist" button on product page and catalog
|
28 |
-
+ Shortcode for "Add to wishlist" button to place it anywhere on the page.
|
29 |
-
+ "Add to wishlist" Button or Link on product page
|
30 |
-
+ Predefined icons for "Add to Wishlist" button in two colors
|
31 |
-
+ Upload your custom "Add to Wishlist" button icon
|
32 |
-
+ Redirect to wishlist page after adding items to the wishlist
|
33 |
-
+ Customize wishlist table columns:
|
34 |
-
+ Show "Add to Cart" button
|
35 |
-
+ Show "Add all to cart" button
|
36 |
-
+ Show "Add selected to cart" button
|
37 |
-
+ Show unit price
|
38 |
-
+ Show stock status
|
39 |
-
+ Show the date when the product has been added to the wishlist
|
40 |
-
+ Show bulk actions
|
41 |
-
+ Show checkboxes
|
42 |
-
+ Share wishlist on social channels (Facebook, Twitter, Pinterest, Google+, email)
|
43 |
-
+ Fully Customizable Appearance
|
44 |
-
+ Custom CSS styles
|
45 |
-
+ Responsive & Retina Ready
|
46 |
-
+ Translation ready
|
47 |
-
+ WPML Support
|
48 |
-
+ Product variations Support
|
49 |
-
|
50 |
-
= Add to Wishlist button =
|
51 |
-
You can adjust Add to wishlist button settings to make it work best for your website.
|
52 |
-
Make it a link or a button, choose from predefined icons or upload your own. Select predefined button position or place it wherever you want using shortcode.
|
53 |
-
|
54 |
-
= Customizable Wishlist table =
|
55 |
-
You can show/hide any column in wishlist table on wishlist page. So it is for you to decide what information to show and what not. Make your wishlist page informative or simple.
|
56 |
-
|
57 |
-
= Make it fit your website perfectly =
|
58 |
-
WooCommerce Wishlist Plugin comes with over 60 appearance options such as colors, font size, borders, etc. Not enough? You can add your custom CSS styles directly in admin panel.
|
59 |
-
|
60 |
-
= Translation Ready =
|
61 |
-
|
62 |
-
You can easily translate WooCommerce Wishlist Plugin to any language. Simply choose the most convenient way for you: using poEdit tool, Loco Translate or WPML.
|
63 |
-
|
64 |
-
= Responsive & Retina Ready =
|
65 |
-
We know how important responsive website for the online store in nowadays.
|
66 |
-
That is why we made sure that Wishlist looks and works perfectly on any devices and the layouts are user-friendly. Simply check screenshots or preview.
|
67 |
-
|
68 |
-
|
69 |
-
== Installation ==
|
70 |
-
|
71 |
-
There are few ways to install WooCommerce Wishlist Plugin:
|
72 |
-
|
73 |
-
= 1. From WordPress admin panel: =
|
74 |
-
|
75 |
-
+ Go to "Plugins" > "Add New" and search for "WooCommerce Wishlist Plugin"
|
76 |
-
|
77 |
-
+ Press "Install Now" button for the "WooCommerce Wishlist Plugin" plugin
|
78 |
-
|
79 |
-
+ After the installation is complete click "Activate" link (Plugins > Installed Plugins).
|
80 |
-
|
81 |
-
= 2. Install manually using FTP method. =
|
82 |
-
|
83 |
-
+ Download the plugin
|
84 |
-
|
85 |
-
+ Upload the plugin folder into /wp-content/plugins directory of your WordPress installation using your favorite FTP client.
|
86 |
-
|
87 |
-
+ Navigate to "Plugins" > "Installed Plugins" section in your dashboard and activate the plugin.
|
88 |
-
|
89 |
-
= 3. Install manually from WordPress admin panel =
|
90 |
-
|
91 |
-
+ Download the plugin
|
92 |
-
|
93 |
-
+ Go to "Plugins" > "Add New" and press "Upload Plugin" button.
|
94 |
-
|
95 |
-
+ Browse the plugin archive and click "Install Now"
|
96 |
-
|
97 |
-
+ After the installation is complete click "Activate" link (Plugins > Installed Plugins).
|
98 |
-
|
99 |
-
== Frequently Asked Questions ==
|
100 |
-
|
101 |
-
= Where can I find documentation? =
|
102 |
-
|
103 |
-
For help setting up and configuring, please refer to our [online documentation](https://templateinvaders.com/documentation/ti-woocommerce-wishlist-free/?utm_source=wordpressorg&utm_content=documentation_faq)
|
104 |
-
|
105 |
-
= Where can I get support or talk to other users? =
|
106 |
-
|
107 |
-
If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.org/support/plugin/ti-woocommerce-wishlist) or [help page](https://templateinvaders.com/help/?utm_source=wordpressorg&utm_content=help_faq) on our website.
|
108 |
-
|
109 |
-
|
110 |
-
== Screenshots ==
|
111 |
-
|
112 |
-
1. Wishlist Settings page
|
113 |
-
2. Wishlist Appearance Options
|
114 |
-
3. "Add to Wishlist" button options
|
115 |
-
4. The look of "Add to Wishlist" button on frontend with different settings
|
116 |
-
5. Wishlist page with all columns, desktop view
|
117 |
-
6. Wishlist page with turned off date of addition, checkboxes and bulk actions.
|
118 |
-
7. When you click Add to Wishlist button a popup with success or error message appears.
|
119 |
-
8. Wishlist page, Tablet view
|
120 |
-
9. Wishlist page, Mobile view
|
121 |
-
10. Simplified Wishlist page, Mobile view
|
122 |
-
11. WooCommerce Wishlist Plugin Comes with a setup Wizard to help you configure the settings.
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
== Changelog ==
|
127 |
-
|
128 |
-
= 1.5.
|
129 |
-
*Release Date -
|
130 |
-
|
131 |
-
* Fixed
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
*
|
138 |
-
|
139 |
-
*
|
140 |
-
|
141 |
-
|
142 |
-
*
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
* WooCommerce
|
149 |
-
* WooCommerce
|
150 |
-
|
151 |
-
|
152 |
-
*
|
153 |
-
|
154 |
-
*
|
155 |
-
|
156 |
-
|
157 |
-
*
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
*
|
162 |
-
|
163 |
-
*
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
*
|
169 |
-
|
170 |
-
*
|
171 |
-
|
172 |
-
|
173 |
-
*
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
*
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
* Improved
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
*
|
192 |
-
|
193 |
-
|
194 |
-
*
|
195 |
-
|
196 |
-
|
197 |
-
*
|
198 |
-
|
199 |
-
*
|
200 |
-
|
201 |
-
= 1.2.
|
202 |
-
*Release Date -
|
203 |
-
|
204 |
-
* WooCommerce 3.0+
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
*
|
211 |
-
|
212 |
-
= 1.1.
|
213 |
-
*Release Date -
|
214 |
-
|
215 |
-
* Fixed
|
216 |
-
|
217 |
-
= 1.1.
|
218 |
-
*Release Date -
|
219 |
-
|
220 |
-
*
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
*
|
226 |
-
|
227 |
-
* Fixed
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
*
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
*
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
*
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
*
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
*
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
*
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
*
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
*
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
*
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
=== WooCommerce Wishlist Plugin ===
|
2 |
+
Contributors: templateinvaders
|
3 |
+
Donate link: https://templateinvaders.com/?utm_source=wordpressorg&utm_content=donate
|
4 |
+
Tags: wishlist, woocommerce, products, e-commerce, shop, ecommerce wishlist, woocommerce wishlist, woocommerce , shop wishlist, wishlist for Woocommerce
|
5 |
+
Requires at least: 4.5
|
6 |
+
Tested up to: 4.8
|
7 |
+
Stable tag: 1.5.2
|
8 |
+
License: GPLv3
|
9 |
+
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
+
|
11 |
+
Allow your store guests and customers to add products to Wishlist.
|
12 |
+
Add Wishlist functionality to your store for free.
|
13 |
+
|
14 |
+
== Description ==
|
15 |
+
|
16 |
+
= Increase Sales and Conversions =
|
17 |
+
WooCommerce Wishlist is a simple but powerful tool that can help you to convert your site visitors into loyal customers. There are many situations when customers can’t buy a product at this time or simply don’t want. Possibility to save products for later encourages users to return to your site and after all, make a purchase. Adding products to Wishlist is easy and convenient so it may also force your customers to buy even more products than they planned. Users can share their wishlist, for example, to help their friends choose a gift for upcoming holiday and so on. By sharing their Wishlists, they are bringing you, new potential customers. All in all this increasing amount of your site visitors, conversion and as a result sales.
|
18 |
+
|
19 |
+
[Live Preview](https://demo.templateinvaders.com/wordpress/plugins/wishlist/?utm_source=wordpressorg&utm_content=preview)
|
20 |
+
|
21 |
+
[View documentation](https://templateinvaders.com/documentation/ti-woocommerce-wishlist-free/?utm_source=wordpressorg&utm_content=documentation)
|
22 |
+
|
23 |
+
= Features List =
|
24 |
+
|
25 |
+
+ Select Wishlist page and Name
|
26 |
+
+ Remove product from wishlist automatically, after adding it to cart
|
27 |
+
+ Position of "Add to wishlist" button on product page and catalog
|
28 |
+
+ Shortcode for "Add to wishlist" button to place it anywhere on the page.
|
29 |
+
+ "Add to wishlist" Button or Link on product page
|
30 |
+
+ Predefined icons for "Add to Wishlist" button in two colors
|
31 |
+
+ Upload your custom "Add to Wishlist" button icon
|
32 |
+
+ Redirect to wishlist page after adding items to the wishlist
|
33 |
+
+ Customize wishlist table columns:
|
34 |
+
+ Show "Add to Cart" button
|
35 |
+
+ Show "Add all to cart" button
|
36 |
+
+ Show "Add selected to cart" button
|
37 |
+
+ Show unit price
|
38 |
+
+ Show stock status
|
39 |
+
+ Show the date when the product has been added to the wishlist
|
40 |
+
+ Show bulk actions
|
41 |
+
+ Show checkboxes
|
42 |
+
+ Share wishlist on social channels (Facebook, Twitter, Pinterest, Google+, email)
|
43 |
+
+ Fully Customizable Appearance
|
44 |
+
+ Custom CSS styles
|
45 |
+
+ Responsive & Retina Ready
|
46 |
+
+ Translation ready
|
47 |
+
+ WPML Support
|
48 |
+
+ Product variations Support
|
49 |
+
|
50 |
+
= Add to Wishlist button =
|
51 |
+
You can adjust Add to wishlist button settings to make it work best for your website.
|
52 |
+
Make it a link or a button, choose from predefined icons or upload your own. Select predefined button position or place it wherever you want using shortcode.
|
53 |
+
|
54 |
+
= Customizable Wishlist table =
|
55 |
+
You can show/hide any column in wishlist table on wishlist page. So it is for you to decide what information to show and what not. Make your wishlist page informative or simple.
|
56 |
+
|
57 |
+
= Make it fit your website perfectly =
|
58 |
+
WooCommerce Wishlist Plugin comes with over 60 appearance options such as colors, font size, borders, etc. Not enough? You can add your custom CSS styles directly in admin panel.
|
59 |
+
|
60 |
+
= Translation Ready =
|
61 |
+
|
62 |
+
You can easily translate WooCommerce Wishlist Plugin to any language. Simply choose the most convenient way for you: using poEdit tool, Loco Translate or WPML.
|
63 |
+
|
64 |
+
= Responsive & Retina Ready =
|
65 |
+
We know how important responsive website for the online store in nowadays.
|
66 |
+
That is why we made sure that Wishlist looks and works perfectly on any devices and the layouts are user-friendly. Simply check screenshots or preview.
|
67 |
+
|
68 |
+
|
69 |
+
== Installation ==
|
70 |
+
|
71 |
+
There are few ways to install WooCommerce Wishlist Plugin:
|
72 |
+
|
73 |
+
= 1. From WordPress admin panel: =
|
74 |
+
|
75 |
+
+ Go to "Plugins" > "Add New" and search for "WooCommerce Wishlist Plugin"
|
76 |
+
|
77 |
+
+ Press "Install Now" button for the "WooCommerce Wishlist Plugin" plugin
|
78 |
+
|
79 |
+
+ After the installation is complete click "Activate" link (Plugins > Installed Plugins).
|
80 |
+
|
81 |
+
= 2. Install manually using FTP method. =
|
82 |
+
|
83 |
+
+ Download the plugin
|
84 |
+
|
85 |
+
+ Upload the plugin folder into /wp-content/plugins directory of your WordPress installation using your favorite FTP client.
|
86 |
+
|
87 |
+
+ Navigate to "Plugins" > "Installed Plugins" section in your dashboard and activate the plugin.
|
88 |
+
|
89 |
+
= 3. Install manually from WordPress admin panel =
|
90 |
+
|
91 |
+
+ Download the plugin
|
92 |
+
|
93 |
+
+ Go to "Plugins" > "Add New" and press "Upload Plugin" button.
|
94 |
+
|
95 |
+
+ Browse the plugin archive and click "Install Now"
|
96 |
+
|
97 |
+
+ After the installation is complete click "Activate" link (Plugins > Installed Plugins).
|
98 |
+
|
99 |
+
== Frequently Asked Questions ==
|
100 |
+
|
101 |
+
= Where can I find documentation? =
|
102 |
+
|
103 |
+
For help setting up and configuring, please refer to our [online documentation](https://templateinvaders.com/documentation/ti-woocommerce-wishlist-free/?utm_source=wordpressorg&utm_content=documentation_faq)
|
104 |
+
|
105 |
+
= Where can I get support or talk to other users? =
|
106 |
+
|
107 |
+
If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.org/support/plugin/ti-woocommerce-wishlist) or [help page](https://templateinvaders.com/help/?utm_source=wordpressorg&utm_content=help_faq) on our website.
|
108 |
+
|
109 |
+
|
110 |
+
== Screenshots ==
|
111 |
+
|
112 |
+
1. Wishlist Settings page
|
113 |
+
2. Wishlist Appearance Options
|
114 |
+
3. "Add to Wishlist" button options
|
115 |
+
4. The look of "Add to Wishlist" button on frontend with different settings
|
116 |
+
5. Wishlist page with all columns, desktop view
|
117 |
+
6. Wishlist page with turned off date of addition, checkboxes and bulk actions.
|
118 |
+
7. When you click Add to Wishlist button a popup with success or error message appears.
|
119 |
+
8. Wishlist page, Tablet view
|
120 |
+
9. Wishlist page, Mobile view
|
121 |
+
10. Simplified Wishlist page, Mobile view
|
122 |
+
11. WooCommerce Wishlist Plugin Comes with a setup Wizard to help you configure the settings.
|
123 |
+
|
124 |
+
|
125 |
+
|
126 |
+
== Changelog ==
|
127 |
+
|
128 |
+
= 1.5.2 =
|
129 |
+
*Release Date - 23 August 2017*
|
130 |
+
|
131 |
+
* Fixed an issue when variation has additional attribute(s) with any value
|
132 |
+
|
133 |
+
= 1.5.1 =
|
134 |
+
*Release Date - 14 August 2017*
|
135 |
+
|
136 |
+
* Fixed a fatal error on Dashboard menu
|
137 |
+
* Minor CSS fixes
|
138 |
+
* Added support for plugins/woocommerce add-ons:
|
139 |
+
* WooCommerce Quantity Increment
|
140 |
+
|
141 |
+
= 1.5.0 =
|
142 |
+
*Release Date - 11 August 2017*
|
143 |
+
|
144 |
+
* Added an option to allow users remove products from a wishlist on the second click
|
145 |
+
* Added the ability to load custom translation files
|
146 |
+
* Overall frontend performance optimization
|
147 |
+
* Added support for plugins/woocommerce add-ons that use custom meta:
|
148 |
+
* WooCommerce Gift Cards
|
149 |
+
* WooCommerce Bookings
|
150 |
+
* WooCommerce Subscriptions
|
151 |
+
* WooCommerce Composite Products
|
152 |
+
* WooCommerce Product Bundles
|
153 |
+
* WooCommerce Mix and Match
|
154 |
+
* WooCommerce Gravity Forms Product Add-Ons
|
155 |
+
|
156 |
+
= 1.4.0 =
|
157 |
+
*Release Date - 14 July 2017*
|
158 |
+
|
159 |
+
* Added "Add to Wishlist" button for a catalog page
|
160 |
+
* Added the ability to remove product from a Wishlist on the second click
|
161 |
+
* Added an option to show/hide a popup with successful or error notices after adding or removing products from a Wishlist
|
162 |
+
* Added "Wishlist Products counter" shortcode & widget
|
163 |
+
* Added some missing settings descriptions in the admin panel
|
164 |
+
|
165 |
+
= 1.3.4 =
|
166 |
+
*Release Date - 08 May 2017*
|
167 |
+
|
168 |
+
* Fixed critical issue when plugin activated by TGMPA class
|
169 |
+
* Fixed few PHP notices
|
170 |
+
* Cleanup of the code
|
171 |
+
|
172 |
+
= 1.3.3 =
|
173 |
+
*Release Date - 07 May 2017*
|
174 |
+
|
175 |
+
* Improved WPML compatibility (fixed an issue with URL formats)
|
176 |
+
* Fixed issues with deprecated hooks related to WooCommerce 3.0.5
|
177 |
+
* Added Polylang plugin support
|
178 |
+
* Added new option that allows product automatic removal when it's added to cart by anyone
|
179 |
+
|
180 |
+
|
181 |
+
= 1.3.2 =
|
182 |
+
*Release Date - 27 April 2017*
|
183 |
+
|
184 |
+
* Fixed extra redirect to Setup Wizard
|
185 |
+
* Improved theme compatibility tests performance
|
186 |
+
|
187 |
+
= 1.3.1 =
|
188 |
+
*Release Date - 26 April 2017*
|
189 |
+
|
190 |
+
* Improved theme compatibility tests for shared hosts
|
191 |
+
* Improved compatibility for WooCommerce 2 & 3
|
192 |
+
|
193 |
+
= 1.3.0 =
|
194 |
+
*Release Date - 24 April 2017*
|
195 |
+
|
196 |
+
* Fixed WPML string translations issue
|
197 |
+
* Added theme compatibility notices
|
198 |
+
* Wishlist custom item meta hidden from order
|
199 |
+
* Added compatibility with WooCommerce – Gift Cards
|
200 |
+
|
201 |
+
= 1.2.1 =
|
202 |
+
*Release Date - 08 April 2017*
|
203 |
+
|
204 |
+
* Fixed critical error in 'add to wishlist' shortcode for WooCommerce 3.0+
|
205 |
+
|
206 |
+
= 1.2.0 =
|
207 |
+
*Release Date - 07 April 2017*
|
208 |
+
|
209 |
+
* WooCommerce 3.0+ support
|
210 |
+
* Added template overrides check for WooCommerce system report
|
211 |
+
|
212 |
+
= 1.1.14 =
|
213 |
+
*Release Date - 04 April 2017*
|
214 |
+
|
215 |
+
* Fixed multiple issues with WPML support.
|
216 |
+
|
217 |
+
= 1.1.13 =
|
218 |
+
*Release Date - 16 March 2017*
|
219 |
+
|
220 |
+
* Fixed an issue when the Wishlist was not refreshed after the product is removed or added to cart by the unauthenticated user.
|
221 |
+
|
222 |
+
= 1.1.12 =
|
223 |
+
*Release Date - 05 March 2017*
|
224 |
+
|
225 |
+
* Added "Contact Us" page on the plugin menu
|
226 |
+
* Added the usage stats opt-in to help us improve the plugin
|
227 |
+
* Fixed some translations
|
228 |
+
|
229 |
+
= 1.1.11 =
|
230 |
+
*Release Date - 03 March 2017*
|
231 |
+
|
232 |
+
* Fixed an issue with external products link
|
233 |
+
|
234 |
+
|
235 |
+
= 1.1.10 =
|
236 |
+
*Release Date - 02 March 2017*
|
237 |
+
|
238 |
+
* The Setup Wizard enhancements
|
239 |
+
* Added new hooks for wishlist create|update|delete and wishlist product add|update|remove events
|
240 |
+
|
241 |
+
= 1.1.9 =
|
242 |
+
*Release Date - 26 February 2017*
|
243 |
+
|
244 |
+
* Fixed an issue with W3 Total Cache compatibility
|
245 |
+
* Added public functions
|
246 |
+
|
247 |
+
= 1.1.8 =
|
248 |
+
*Release Date - 03 February 2017*
|
249 |
+
|
250 |
+
* Fixed an issue with "Add to Wishlist" function in a quick view popup (Compatibility with plugins that provide QuickView functionality)
|
251 |
+
* Added JavaScript alert for the "Add to Wishlist" button on a single product page when no variations are selected
|
252 |
+
|
253 |
+
|
254 |
+
= 1.1.7 =
|
255 |
+
*Release Date - 30 January 2017*
|
256 |
+
|
257 |
+
* Fixed an issue when maximum 10 products can be added to cart from a Wishlist page using the "Add all to cart" button
|
258 |
+
|
259 |
+
|
260 |
+
= 1.1.6 =
|
261 |
+
*Release Date - 27 January 2017*
|
262 |
+
|
263 |
+
* Fixed class loading critical error after plugin activation
|
264 |
+
|
265 |
+
|
266 |
+
= 1.1.5 =
|
267 |
+
*Release Date - 10 January 2017*
|
268 |
+
|
269 |
+
* Fixed issue with empty wishlist page
|
270 |
+
* Fixed issue with wrong product quantity on add to cart event from wishlist
|
271 |
+
|
272 |
+
|
273 |
+
= 1.1.4 =
|
274 |
+
*Release Date - 12 December 2016*
|
275 |
+
|
276 |
+
* Fixed issue with translations
|
277 |
+
|
278 |
+
|
279 |
+
= 1.1.3 =
|
280 |
+
*Release Date - 09 December 2016*
|
281 |
+
|
282 |
+
* Fixed issues with pagination
|
283 |
+
* Added support for WordPress 4.7
|
284 |
+
|
285 |
+
|
286 |
+
= 1.1.2 =
|
287 |
+
*Release Date - 23 November 2016*
|
288 |
+
|
289 |
+
* Added minified versions of public CSS
|
290 |
+
* Fixed issue with sharing buttons for non-logged users
|
291 |
+
* Fixed issue with pagination URLs for guests
|
292 |
+
* Removed Genericicons fonts
|
293 |
+
|
294 |
+
|
295 |
+
= 1.1.1 =
|
296 |
+
*Release Date - 08 November 2016*
|
297 |
+
|
298 |
+
* Fixed issue with upgrade from free to premium version
|
299 |
+
|
300 |
+
|
301 |
+
= 1.1.0 =
|
302 |
+
*Release Date - 11 October 2016*
|
303 |
+
|
304 |
+
* Added support for WP Super Cache plugin
|
305 |
+
* Added support for W3 Total Cache plugin
|
306 |
+
* Added support for WooCommerce - Gravity Forms Product Add-Ons
|
307 |
+
* Added option to show link to Wishlist on My Account page
|
308 |
+
* Added minimized versions of JS
|
309 |
+
|
310 |
+
|
311 |
+
= 1.0.0 =
|
312 |
+
*Release Date - 22 September 2016*
|
313 |
+
|
314 |
+
* Initial release
|
315 |
+
|
316 |
+
== Upgrade Notice ==
|
317 |
+
= 1.5 =
|
318 |
+
Improved frontend performance. Added plugin support for WooCommerce Gift Cards, WooCommerce Bookings, WooCommerce Subscriptions, WooCommerce Composite Products, WooCommerce Product Bundles, WooCommerce Mix and Match, WooCommerce Gravity Forms Product Add-Ons.
|
templates/ti-wishlist-user.php
CHANGED
@@ -1,147 +1,147 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The Template for displaying user wishlist.
|
4 |
-
*
|
5 |
-
* @version 1.0.0
|
6 |
-
* @package TInvWishlist\Template
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit; // Exit if accessed directly.
|
11 |
-
}
|
12 |
-
|
13 |
-
?>
|
14 |
-
<div class="tinv-wishlist woocommerce tinv-wishlist-clear">
|
15 |
-
<?php do_action( 'tinvwl_before_wishlist', $wishlist ); ?>
|
16 |
-
<?php if ( function_exists( 'wc_print_notices' ) ) { wc_print_notices(); } ?>
|
17 |
-
<form action="<?php echo esc_url( tinv_url_wishlist() ); ?>" method="post" autocomplete="off">
|
18 |
-
<?php do_action( 'tinvwl_before_wishlist_table', $wishlist ); ?>
|
19 |
-
<table class="tinvwl-table-manage-list">
|
20 |
-
<thead>
|
21 |
-
<tr>
|
22 |
-
<?php if ( $wishlist_table['colm_checkbox'] ) { ?>
|
23 |
-
<th class="product-cb"><input type="checkbox" class="global-cb"></th>
|
24 |
-
<?php } ?>
|
25 |
-
<th class="product-thumbnail"> </th>
|
26 |
-
<th class="product-name"><span class="tinvwl-full"><?php esc_html_e( 'Product Name', 'ti-woocommerce-wishlist' ); ?></span><span class="tinvwl-mobile"><?php esc_html_e( 'Product', 'ti-woocommerce-wishlist' ); ?></span></th>
|
27 |
-
<?php if ( $wishlist_table_row['colm_price'] ) { ?>
|
28 |
-
<th class="product-price"><?php esc_html_e( 'Unit Price', 'ti-woocommerce-wishlist' ); ?></th>
|
29 |
-
<?php } ?>
|
30 |
-
<?php if ( $wishlist_table_row['colm_date'] ) { ?>
|
31 |
-
<th class="product-date"><?php esc_html_e( 'Date Added', 'ti-woocommerce-wishlist' ); ?></th>
|
32 |
-
<?php } ?>
|
33 |
-
<?php if ( $wishlist_table_row['colm_stock'] ) { ?>
|
34 |
-
<th class="product-stock"><?php esc_html_e( 'Stock Status', 'ti-woocommerce-wishlist' ); ?></th>
|
35 |
-
<?php } ?>
|
36 |
-
<?php if ( $wishlist_table_row['add_to_card'] ) { ?>
|
37 |
-
<th class="product-action"> </th>
|
38 |
-
<?php } ?>
|
39 |
-
</tr>
|
40 |
-
</thead>
|
41 |
-
<tbody>
|
42 |
-
<?php do_action( 'tinvwl_wishlist_contents_before' ); ?>
|
43 |
-
|
44 |
-
<?php
|
45 |
-
foreach ( $products as $wl_product ) {
|
46 |
-
$product = apply_filters( 'tinvwl_wishlist_item', $wl_product['data'] );
|
47 |
-
unset( $wl_product['data'] );
|
48 |
-
if ( $wl_product['quantity'] > 0 && apply_filters( 'tinvwl_wishlist_item_visible', true, $wl_product, $product ) ) {
|
49 |
-
$product_url = apply_filters( 'tinvwl_wishlist_item_url', $product->get_permalink(), $wl_product, $product );
|
50 |
-
do_action( 'tinvwl_wishlist_row_before', $wl_product, $product );
|
51 |
-
?>
|
52 |
-
<tr class="<?php echo esc_attr( apply_filters( 'tinvwl_wishlist_item_class', 'wishlist_item', $wl_product, $product ) ); ?>">
|
53 |
-
<?php if ( $wishlist_table['colm_checkbox'] ) { ?>
|
54 |
-
<td class="product-cb">
|
55 |
-
<?php
|
56 |
-
echo apply_filters( 'tinvwl_wishlist_item_cb', sprintf( // WPCS: xss ok.
|
57 |
-
'<input type="checkbox" name="wishlist_pr[]" value="%d">', esc_attr( $wl_product['ID'] )
|
58 |
-
), $wl_product, $product );
|
59 |
-
?>
|
60 |
-
</td>
|
61 |
-
<?php } ?>
|
62 |
-
<td class="product-thumbnail">
|
63 |
-
<?php
|
64 |
-
$thumbnail = apply_filters( 'tinvwl_wishlist_item_thumbnail', $product->get_image(), $wl_product, $product );
|
65 |
-
|
66 |
-
if ( ! $product->is_visible() ) {
|
67 |
-
echo $thumbnail; // WPCS: xss ok.
|
68 |
-
} else {
|
69 |
-
printf( '<a href="%s">%s</a>', esc_url( $product_url ), $thumbnail ); // WPCS: xss ok.
|
70 |
-
}
|
71 |
-
?>
|
72 |
-
</td>
|
73 |
-
<td class="product-name">
|
74 |
-
<?php
|
75 |
-
if ( ! $product->is_visible() ) {
|
76 |
-
echo apply_filters( 'tinvwl_wishlist_item_name', $product->get_title(), $wl_product, $product ) . ' '; // WPCS: xss ok.
|
77 |
-
} else {
|
78 |
-
echo apply_filters( 'tinvwl_wishlist_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product->get_title() ), $wl_product, $product ); // WPCS: xss ok.
|
79 |
-
}
|
80 |
-
|
81 |
-
echo apply_filters( 'tinvwl_wishlist_item_meta_data', tinv_wishlist_get_item_data( $product ), $wl_product, $product ); // WPCS: xss ok.
|
82 |
-
?>
|
83 |
-
</td>
|
84 |
-
<?php if ( $wishlist_table_row['colm_price'] ) { ?>
|
85 |
-
<td class="product-price">
|
86 |
-
<?php
|
87 |
-
echo apply_filters( 'tinvwl_wishlist_item_price', $product->get_price_html(), $wl_product, $product ); // WPCS: xss ok.
|
88 |
-
?>
|
89 |
-
</td>
|
90 |
-
<?php } ?>
|
91 |
-
<?php if ( $wishlist_table_row['colm_date'] ) { ?>
|
92 |
-
<td class="product-date">
|
93 |
-
<?php
|
94 |
-
echo apply_filters( 'tinvwl_wishlist_item_date', sprintf( // WPCS: xss ok.
|
95 |
-
'<time class="entry-date" datetime="%1$s">%2$s</time>', $wl_product['date'], mysql2date( get_option( 'date_format' ), $wl_product['date'] )
|
96 |
-
), $wl_product, $product );
|
97 |
-
?>
|
98 |
-
</td>
|
99 |
-
<?php } ?>
|
100 |
-
<?php if ( $wishlist_table_row['colm_stock'] ) { ?>
|
101 |
-
<td class="product-stock">
|
102 |
-
<?php
|
103 |
-
$availability = (array) $product->get_availability();
|
104 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
105 |
-
$availability['availability'] = '';
|
106 |
-
}
|
107 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
108 |
-
$availability['class'] = '';
|
109 |
-
}
|
110 |
-
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
111 |
-
|
112 |
-
echo apply_filters( 'tinvwl_wishlist_item_status', $availability_html, $availability['availability'], $wl_product, $product ); // WPCS: xss ok.
|
113 |
-
?>
|
114 |
-
</td>
|
115 |
-
<?php } ?>
|
116 |
-
<?php if ( $wishlist_table_row['add_to_card'] ) { ?>
|
117 |
-
<td class="product-action">
|
118 |
-
<?php
|
119 |
-
if ( apply_filters( 'tinvwl_wishlist_item_action_add_to_card', $wishlist_table_row['add_to_card'], $wl_product, $product ) ) {
|
120 |
-
?>
|
121 |
-
<button class="button alt" name="tinvwl-add-to-cart" value="<?php echo esc_attr( $wl_product['ID'] ); ?>"><i class="fa fa-shopping-cart"></i><span class="tinvwl-txt"><?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_card', $wishlist_table_row['text_add_to_card'], $wl_product, $product ) ); ?></span></button>
|
122 |
-
<?php } ?>
|
123 |
-
</td>
|
124 |
-
<?php } ?>
|
125 |
-
</tr>
|
126 |
-
<?php
|
127 |
-
do_action( 'tinvwl_wishlist_row_after', $wl_product, $product );
|
128 |
-
} // End if().
|
129 |
-
} // End foreach().
|
130 |
-
?>
|
131 |
-
<?php do_action( 'tinvwl_wishlist_contents_after' ); ?>
|
132 |
-
</tbody>
|
133 |
-
<tfoot>
|
134 |
-
<tr>
|
135 |
-
<td colspan="100%">
|
136 |
-
<?php do_action( 'tinvwl_after_wishlist_table', $wishlist ); ?>
|
137 |
-
<?php wp_nonce_field( 'tinvwl_wishlist_user', 'wishlist_nonce' ); ?>
|
138 |
-
</td>
|
139 |
-
</tr>
|
140 |
-
</tfoot>
|
141 |
-
</table>
|
142 |
-
</form>
|
143 |
-
<?php do_action( 'tinvwl_after_wishlist', $wishlist ); ?>
|
144 |
-
<div class="tinv-lists-nav tinv-wishlist-clear">
|
145 |
-
<?php do_action( 'tinvwl_pagenation_wishlist', $wishlist ); ?>
|
146 |
-
</div>
|
147 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Template for displaying user wishlist.
|
4 |
+
*
|
5 |
+
* @version 1.0.0
|
6 |
+
* @package TInvWishlist\Template
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit; // Exit if accessed directly.
|
11 |
+
}
|
12 |
+
|
13 |
+
?>
|
14 |
+
<div class="tinv-wishlist woocommerce tinv-wishlist-clear">
|
15 |
+
<?php do_action( 'tinvwl_before_wishlist', $wishlist ); ?>
|
16 |
+
<?php if ( function_exists( 'wc_print_notices' ) ) { wc_print_notices(); } ?>
|
17 |
+
<form action="<?php echo esc_url( tinv_url_wishlist() ); ?>" method="post" autocomplete="off">
|
18 |
+
<?php do_action( 'tinvwl_before_wishlist_table', $wishlist ); ?>
|
19 |
+
<table class="tinvwl-table-manage-list">
|
20 |
+
<thead>
|
21 |
+
<tr>
|
22 |
+
<?php if ( $wishlist_table['colm_checkbox'] ) { ?>
|
23 |
+
<th class="product-cb"><input type="checkbox" class="global-cb"></th>
|
24 |
+
<?php } ?>
|
25 |
+
<th class="product-thumbnail"> </th>
|
26 |
+
<th class="product-name"><span class="tinvwl-full"><?php esc_html_e( 'Product Name', 'ti-woocommerce-wishlist' ); ?></span><span class="tinvwl-mobile"><?php esc_html_e( 'Product', 'ti-woocommerce-wishlist' ); ?></span></th>
|
27 |
+
<?php if ( $wishlist_table_row['colm_price'] ) { ?>
|
28 |
+
<th class="product-price"><?php esc_html_e( 'Unit Price', 'ti-woocommerce-wishlist' ); ?></th>
|
29 |
+
<?php } ?>
|
30 |
+
<?php if ( $wishlist_table_row['colm_date'] ) { ?>
|
31 |
+
<th class="product-date"><?php esc_html_e( 'Date Added', 'ti-woocommerce-wishlist' ); ?></th>
|
32 |
+
<?php } ?>
|
33 |
+
<?php if ( $wishlist_table_row['colm_stock'] ) { ?>
|
34 |
+
<th class="product-stock"><?php esc_html_e( 'Stock Status', 'ti-woocommerce-wishlist' ); ?></th>
|
35 |
+
<?php } ?>
|
36 |
+
<?php if ( $wishlist_table_row['add_to_card'] ) { ?>
|
37 |
+
<th class="product-action"> </th>
|
38 |
+
<?php } ?>
|
39 |
+
</tr>
|
40 |
+
</thead>
|
41 |
+
<tbody>
|
42 |
+
<?php do_action( 'tinvwl_wishlist_contents_before' ); ?>
|
43 |
+
|
44 |
+
<?php
|
45 |
+
foreach ( $products as $wl_product ) {
|
46 |
+
$product = apply_filters( 'tinvwl_wishlist_item', $wl_product['data'] );
|
47 |
+
unset( $wl_product['data'] );
|
48 |
+
if ( $wl_product['quantity'] > 0 && apply_filters( 'tinvwl_wishlist_item_visible', true, $wl_product, $product ) ) {
|
49 |
+
$product_url = apply_filters( 'tinvwl_wishlist_item_url', $product->get_permalink(), $wl_product, $product );
|
50 |
+
do_action( 'tinvwl_wishlist_row_before', $wl_product, $product );
|
51 |
+
?>
|
52 |
+
<tr class="<?php echo esc_attr( apply_filters( 'tinvwl_wishlist_item_class', 'wishlist_item', $wl_product, $product ) ); ?>">
|
53 |
+
<?php if ( $wishlist_table['colm_checkbox'] ) { ?>
|
54 |
+
<td class="product-cb">
|
55 |
+
<?php
|
56 |
+
echo apply_filters( 'tinvwl_wishlist_item_cb', sprintf( // WPCS: xss ok.
|
57 |
+
'<input type="checkbox" name="wishlist_pr[]" value="%d">', esc_attr( $wl_product['ID'] )
|
58 |
+
), $wl_product, $product );
|
59 |
+
?>
|
60 |
+
</td>
|
61 |
+
<?php } ?>
|
62 |
+
<td class="product-thumbnail">
|
63 |
+
<?php
|
64 |
+
$thumbnail = apply_filters( 'tinvwl_wishlist_item_thumbnail', $product->get_image(), $wl_product, $product );
|
65 |
+
|
66 |
+
if ( ! $product->is_visible() ) {
|
67 |
+
echo $thumbnail; // WPCS: xss ok.
|
68 |
+
} else {
|
69 |
+
printf( '<a href="%s">%s</a>', esc_url( $product_url ), $thumbnail ); // WPCS: xss ok.
|
70 |
+
}
|
71 |
+
?>
|
72 |
+
</td>
|
73 |
+
<td class="product-name">
|
74 |
+
<?php
|
75 |
+
if ( ! $product->is_visible() ) {
|
76 |
+
echo apply_filters( 'tinvwl_wishlist_item_name', $product->get_title(), $wl_product, $product ) . ' '; // WPCS: xss ok.
|
77 |
+
} else {
|
78 |
+
echo apply_filters( 'tinvwl_wishlist_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product->get_title() ), $wl_product, $product ); // WPCS: xss ok.
|
79 |
+
}
|
80 |
+
|
81 |
+
echo apply_filters( 'tinvwl_wishlist_item_meta_data', tinv_wishlist_get_item_data( $product, $wl_product ), $wl_product, $product ); // WPCS: xss ok.
|
82 |
+
?>
|
83 |
+
</td>
|
84 |
+
<?php if ( $wishlist_table_row['colm_price'] ) { ?>
|
85 |
+
<td class="product-price">
|
86 |
+
<?php
|
87 |
+
echo apply_filters( 'tinvwl_wishlist_item_price', $product->get_price_html(), $wl_product, $product ); // WPCS: xss ok.
|
88 |
+
?>
|
89 |
+
</td>
|
90 |
+
<?php } ?>
|
91 |
+
<?php if ( $wishlist_table_row['colm_date'] ) { ?>
|
92 |
+
<td class="product-date">
|
93 |
+
<?php
|
94 |
+
echo apply_filters( 'tinvwl_wishlist_item_date', sprintf( // WPCS: xss ok.
|
95 |
+
'<time class="entry-date" datetime="%1$s">%2$s</time>', $wl_product['date'], mysql2date( get_option( 'date_format' ), $wl_product['date'] )
|
96 |
+
), $wl_product, $product );
|
97 |
+
?>
|
98 |
+
</td>
|
99 |
+
<?php } ?>
|
100 |
+
<?php if ( $wishlist_table_row['colm_stock'] ) { ?>
|
101 |
+
<td class="product-stock">
|
102 |
+
<?php
|
103 |
+
$availability = (array) $product->get_availability();
|
104 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
105 |
+
$availability['availability'] = '';
|
106 |
+
}
|
107 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
108 |
+
$availability['class'] = '';
|
109 |
+
}
|
110 |
+
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
111 |
+
|
112 |
+
echo apply_filters( 'tinvwl_wishlist_item_status', $availability_html, $availability['availability'], $wl_product, $product ); // WPCS: xss ok.
|
113 |
+
?>
|
114 |
+
</td>
|
115 |
+
<?php } ?>
|
116 |
+
<?php if ( $wishlist_table_row['add_to_card'] ) { ?>
|
117 |
+
<td class="product-action">
|
118 |
+
<?php
|
119 |
+
if ( apply_filters( 'tinvwl_wishlist_item_action_add_to_card', $wishlist_table_row['add_to_card'], $wl_product, $product ) ) {
|
120 |
+
?>
|
121 |
+
<button class="button alt" name="tinvwl-add-to-cart" value="<?php echo esc_attr( $wl_product['ID'] ); ?>"><i class="fa fa-shopping-cart"></i><span class="tinvwl-txt"><?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_card', $wishlist_table_row['text_add_to_card'], $wl_product, $product ) ); ?></span></button>
|
122 |
+
<?php } ?>
|
123 |
+
</td>
|
124 |
+
<?php } ?>
|
125 |
+
</tr>
|
126 |
+
<?php
|
127 |
+
do_action( 'tinvwl_wishlist_row_after', $wl_product, $product );
|
128 |
+
} // End if().
|
129 |
+
} // End foreach().
|
130 |
+
?>
|
131 |
+
<?php do_action( 'tinvwl_wishlist_contents_after' ); ?>
|
132 |
+
</tbody>
|
133 |
+
<tfoot>
|
134 |
+
<tr>
|
135 |
+
<td colspan="100%">
|
136 |
+
<?php do_action( 'tinvwl_after_wishlist_table', $wishlist ); ?>
|
137 |
+
<?php wp_nonce_field( 'tinvwl_wishlist_user', 'wishlist_nonce' ); ?>
|
138 |
+
</td>
|
139 |
+
</tr>
|
140 |
+
</tfoot>
|
141 |
+
</table>
|
142 |
+
</form>
|
143 |
+
<?php do_action( 'tinvwl_after_wishlist', $wishlist ); ?>
|
144 |
+
<div class="tinv-lists-nav tinv-wishlist-clear">
|
145 |
+
<?php do_action( 'tinvwl_pagenation_wishlist', $wishlist ); ?>
|
146 |
+
</div>
|
147 |
+
</div>
|
templates/ti-wishlist.php
CHANGED
@@ -1,151 +1,151 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* The Template for displaying wishlist.
|
4 |
-
*
|
5 |
-
* @version 1.0.0
|
6 |
-
* @package TInvWishlist\Template
|
7 |
-
*/
|
8 |
-
|
9 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
-
exit; // Exit if accessed directly.
|
11 |
-
}
|
12 |
-
|
13 |
-
?>
|
14 |
-
<div class="tinv-wishlist woocommerce tinv-wishlist-clear">
|
15 |
-
<?php do_action( 'tinvwl_before_wishlist', $wishlist ); ?>
|
16 |
-
<?php if ( function_exists( 'wc_print_notices' ) ) { wc_print_notices(); } ?>
|
17 |
-
<form action="<?php echo esc_url( tinv_url_wishlist() ); ?>" method="post" autocomplete="off">
|
18 |
-
<?php do_action( 'tinvwl_before_wishlist_table', $wishlist ); ?>
|
19 |
-
<table class="tinvwl-table-manage-list">
|
20 |
-
<thead>
|
21 |
-
<tr>
|
22 |
-
<?php if ( $wishlist_table['colm_checkbox'] ) { ?>
|
23 |
-
<th class="product-cb"><input type="checkbox" class="global-cb"></th>
|
24 |
-
<?php } ?>
|
25 |
-
<th class="product-remove"></th>
|
26 |
-
<th class="product-thumbnail"> </th>
|
27 |
-
<th class="product-name"><span class="tinvwl-full"><?php esc_html_e( 'Product Name', 'ti-woocommerce-wishlist' ); ?></span><span class="tinvwl-mobile"><?php esc_html_e( 'Product', 'ti-woocommerce-wishlist' ); ?></span></th>
|
28 |
-
<?php if ( $wishlist_table_row['colm_price'] ) { ?>
|
29 |
-
<th class="product-price"><?php esc_html_e( 'Unit Price', 'ti-woocommerce-wishlist' ); ?></th>
|
30 |
-
<?php } ?>
|
31 |
-
<?php if ( $wishlist_table_row['colm_date'] ) { ?>
|
32 |
-
<th class="product-date"><?php esc_html_e( 'Date Added', 'ti-woocommerce-wishlist' ); ?></th>
|
33 |
-
<?php } ?>
|
34 |
-
<?php if ( $wishlist_table_row['colm_stock'] ) { ?>
|
35 |
-
<th class="product-stock"><?php esc_html_e( 'Stock Status', 'ti-woocommerce-wishlist' ); ?></th>
|
36 |
-
<?php } ?>
|
37 |
-
<?php if ( $wishlist_table_row['add_to_card'] ) { ?>
|
38 |
-
<th class="product-action"> </th>
|
39 |
-
<?php } ?>
|
40 |
-
</tr>
|
41 |
-
</thead>
|
42 |
-
<tbody>
|
43 |
-
<?php do_action( 'tinvwl_wishlist_contents_before' ); ?>
|
44 |
-
|
45 |
-
<?php
|
46 |
-
foreach ( $products as $wl_product ) {
|
47 |
-
$product = apply_filters( 'tinvwl_wishlist_item', $wl_product['data'] );
|
48 |
-
unset( $wl_product['data'] );
|
49 |
-
if ( $wl_product['quantity'] > 0 && apply_filters( 'tinvwl_wishlist_item_visible', true, $wl_product, $product ) ) {
|
50 |
-
$product_url = apply_filters( 'tinvwl_wishlist_item_url', $product->get_permalink(), $wl_product, $product );
|
51 |
-
do_action( 'tinvwl_wishlist_row_before', $wl_product, $product );
|
52 |
-
?>
|
53 |
-
<tr class="<?php echo esc_attr( apply_filters( 'tinvwl_wishlist_item_class', 'wishlist_item', $wl_product, $product ) ); ?>">
|
54 |
-
<?php if ( $wishlist_table['colm_checkbox'] ) { ?>
|
55 |
-
<td class="product-cb">
|
56 |
-
<?php
|
57 |
-
echo apply_filters( 'tinvwl_wishlist_item_cb', sprintf( // WPCS: xss ok.
|
58 |
-
'<input type="checkbox" name="wishlist_pr[]" value="%d">', esc_attr( $wl_product['ID'] )
|
59 |
-
), $wl_product, $product );
|
60 |
-
?>
|
61 |
-
</td>
|
62 |
-
<?php } ?>
|
63 |
-
<td class="product-remove">
|
64 |
-
<button type="submit" name="tinvwl-remove" value="<?php echo esc_attr( $wl_product['ID'] ); ?>" >X</button>
|
65 |
-
</td>
|
66 |
-
<td class="product-thumbnail">
|
67 |
-
<?php
|
68 |
-
$thumbnail = apply_filters( 'tinvwl_wishlist_item_thumbnail', $product->get_image(), $wl_product, $product );
|
69 |
-
|
70 |
-
if ( ! $product->is_visible() ) {
|
71 |
-
echo $thumbnail; // WPCS: xss ok.
|
72 |
-
} else {
|
73 |
-
printf( '<a href="%s">%s</a>', esc_url( $product_url ), $thumbnail ); // WPCS: xss ok.
|
74 |
-
}
|
75 |
-
?>
|
76 |
-
</td>
|
77 |
-
<td class="product-name">
|
78 |
-
<?php
|
79 |
-
if ( ! $product->is_visible() ) {
|
80 |
-
echo apply_filters( 'tinvwl_wishlist_item_name', $product->get_title(), $wl_product, $product ) . ' '; // WPCS: xss ok.
|
81 |
-
} else {
|
82 |
-
echo apply_filters( 'tinvwl_wishlist_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product->get_title() ), $wl_product, $product ); // WPCS: xss ok.
|
83 |
-
}
|
84 |
-
|
85 |
-
echo apply_filters( 'tinvwl_wishlist_item_meta_data', tinv_wishlist_get_item_data( $product ), $wl_product, $product ); // WPCS: xss ok.
|
86 |
-
?>
|
87 |
-
</td>
|
88 |
-
<?php if ( $wishlist_table_row['colm_price'] ) { ?>
|
89 |
-
<td class="product-price">
|
90 |
-
<?php
|
91 |
-
echo apply_filters( 'tinvwl_wishlist_item_price', $product->get_price_html(), $wl_product, $product ); // WPCS: xss ok.
|
92 |
-
?>
|
93 |
-
</td>
|
94 |
-
<?php } ?>
|
95 |
-
<?php if ( $wishlist_table_row['colm_date'] ) { ?>
|
96 |
-
<td class="product-date">
|
97 |
-
<?php
|
98 |
-
echo apply_filters( 'tinvwl_wishlist_item_date', sprintf( // WPCS: xss ok.
|
99 |
-
'<time class="entry-date" datetime="%1$s">%2$s</time>', $wl_product['date'], mysql2date( get_option( 'date_format' ), $wl_product['date'] )
|
100 |
-
), $wl_product, $product );
|
101 |
-
?>
|
102 |
-
</td>
|
103 |
-
<?php } ?>
|
104 |
-
<?php if ( $wishlist_table_row['colm_stock'] ) { ?>
|
105 |
-
<td class="product-stock">
|
106 |
-
<?php
|
107 |
-
$availability = (array) $product->get_availability();
|
108 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
109 |
-
$availability['availability'] = '';
|
110 |
-
}
|
111 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
112 |
-
$availability['class'] = '';
|
113 |
-
}
|
114 |
-
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
115 |
-
|
116 |
-
echo apply_filters( 'tinvwl_wishlist_item_status', $availability_html, $availability['availability'], $wl_product, $product ); // WPCS: xss ok.
|
117 |
-
?>
|
118 |
-
</td>
|
119 |
-
<?php } ?>
|
120 |
-
<?php if ( $wishlist_table_row['add_to_card'] ) { ?>
|
121 |
-
<td class="product-action">
|
122 |
-
<?php
|
123 |
-
if ( apply_filters( 'tinvwl_wishlist_item_action_add_to_card', $wishlist_table_row['add_to_card'], $wl_product, $product ) ) {
|
124 |
-
?>
|
125 |
-
<button class="button alt" name="tinvwl-add-to-cart" value="<?php echo esc_attr( $wl_product['ID'] ); ?>"><i class="fa fa-shopping-cart"></i><span class="tinvwl-txt"><?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_card', $wishlist_table_row['text_add_to_card'], $wl_product, $product ) ); ?></span></button>
|
126 |
-
<?php } ?>
|
127 |
-
</td>
|
128 |
-
<?php } ?>
|
129 |
-
</tr>
|
130 |
-
<?php
|
131 |
-
do_action( 'tinvwl_wishlist_row_after', $wl_product, $product );
|
132 |
-
} // End if().
|
133 |
-
} // End foreach().
|
134 |
-
?>
|
135 |
-
<?php do_action( 'tinvwl_wishlist_contents_after' ); ?>
|
136 |
-
</tbody>
|
137 |
-
<tfoot>
|
138 |
-
<tr>
|
139 |
-
<td colspan="100%">
|
140 |
-
<?php do_action( 'tinvwl_after_wishlist_table', $wishlist ); ?>
|
141 |
-
<?php wp_nonce_field( 'tinvwl_wishlist_owner', 'wishlist_nonce' ); ?>
|
142 |
-
</td>
|
143 |
-
</tr>
|
144 |
-
</tfoot>
|
145 |
-
</table>
|
146 |
-
</form>
|
147 |
-
<?php do_action( 'tinvwl_after_wishlist', $wishlist ); ?>
|
148 |
-
<div class="tinv-lists-nav tinv-wishlist-clear">
|
149 |
-
<?php do_action( 'tinvwl_pagenation_wishlist', $wishlist ); ?>
|
150 |
-
</div>
|
151 |
-
</div>
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Template for displaying wishlist.
|
4 |
+
*
|
5 |
+
* @version 1.0.0
|
6 |
+
* @package TInvWishlist\Template
|
7 |
+
*/
|
8 |
+
|
9 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
10 |
+
exit; // Exit if accessed directly.
|
11 |
+
}
|
12 |
+
|
13 |
+
?>
|
14 |
+
<div class="tinv-wishlist woocommerce tinv-wishlist-clear">
|
15 |
+
<?php do_action( 'tinvwl_before_wishlist', $wishlist ); ?>
|
16 |
+
<?php if ( function_exists( 'wc_print_notices' ) ) { wc_print_notices(); } ?>
|
17 |
+
<form action="<?php echo esc_url( tinv_url_wishlist() ); ?>" method="post" autocomplete="off">
|
18 |
+
<?php do_action( 'tinvwl_before_wishlist_table', $wishlist ); ?>
|
19 |
+
<table class="tinvwl-table-manage-list">
|
20 |
+
<thead>
|
21 |
+
<tr>
|
22 |
+
<?php if ( $wishlist_table['colm_checkbox'] ) { ?>
|
23 |
+
<th class="product-cb"><input type="checkbox" class="global-cb"></th>
|
24 |
+
<?php } ?>
|
25 |
+
<th class="product-remove"></th>
|
26 |
+
<th class="product-thumbnail"> </th>
|
27 |
+
<th class="product-name"><span class="tinvwl-full"><?php esc_html_e( 'Product Name', 'ti-woocommerce-wishlist' ); ?></span><span class="tinvwl-mobile"><?php esc_html_e( 'Product', 'ti-woocommerce-wishlist' ); ?></span></th>
|
28 |
+
<?php if ( $wishlist_table_row['colm_price'] ) { ?>
|
29 |
+
<th class="product-price"><?php esc_html_e( 'Unit Price', 'ti-woocommerce-wishlist' ); ?></th>
|
30 |
+
<?php } ?>
|
31 |
+
<?php if ( $wishlist_table_row['colm_date'] ) { ?>
|
32 |
+
<th class="product-date"><?php esc_html_e( 'Date Added', 'ti-woocommerce-wishlist' ); ?></th>
|
33 |
+
<?php } ?>
|
34 |
+
<?php if ( $wishlist_table_row['colm_stock'] ) { ?>
|
35 |
+
<th class="product-stock"><?php esc_html_e( 'Stock Status', 'ti-woocommerce-wishlist' ); ?></th>
|
36 |
+
<?php } ?>
|
37 |
+
<?php if ( $wishlist_table_row['add_to_card'] ) { ?>
|
38 |
+
<th class="product-action"> </th>
|
39 |
+
<?php } ?>
|
40 |
+
</tr>
|
41 |
+
</thead>
|
42 |
+
<tbody>
|
43 |
+
<?php do_action( 'tinvwl_wishlist_contents_before' ); ?>
|
44 |
+
|
45 |
+
<?php
|
46 |
+
foreach ( $products as $wl_product ) {
|
47 |
+
$product = apply_filters( 'tinvwl_wishlist_item', $wl_product['data'] );
|
48 |
+
unset( $wl_product['data'] );
|
49 |
+
if ( $wl_product['quantity'] > 0 && apply_filters( 'tinvwl_wishlist_item_visible', true, $wl_product, $product ) ) {
|
50 |
+
$product_url = apply_filters( 'tinvwl_wishlist_item_url', $product->get_permalink(), $wl_product, $product );
|
51 |
+
do_action( 'tinvwl_wishlist_row_before', $wl_product, $product );
|
52 |
+
?>
|
53 |
+
<tr class="<?php echo esc_attr( apply_filters( 'tinvwl_wishlist_item_class', 'wishlist_item', $wl_product, $product ) ); ?>">
|
54 |
+
<?php if ( $wishlist_table['colm_checkbox'] ) { ?>
|
55 |
+
<td class="product-cb">
|
56 |
+
<?php
|
57 |
+
echo apply_filters( 'tinvwl_wishlist_item_cb', sprintf( // WPCS: xss ok.
|
58 |
+
'<input type="checkbox" name="wishlist_pr[]" value="%d">', esc_attr( $wl_product['ID'] )
|
59 |
+
), $wl_product, $product );
|
60 |
+
?>
|
61 |
+
</td>
|
62 |
+
<?php } ?>
|
63 |
+
<td class="product-remove">
|
64 |
+
<button type="submit" name="tinvwl-remove" value="<?php echo esc_attr( $wl_product['ID'] ); ?>" >X</button>
|
65 |
+
</td>
|
66 |
+
<td class="product-thumbnail">
|
67 |
+
<?php
|
68 |
+
$thumbnail = apply_filters( 'tinvwl_wishlist_item_thumbnail', $product->get_image(), $wl_product, $product );
|
69 |
+
|
70 |
+
if ( ! $product->is_visible() ) {
|
71 |
+
echo $thumbnail; // WPCS: xss ok.
|
72 |
+
} else {
|
73 |
+
printf( '<a href="%s">%s</a>', esc_url( $product_url ), $thumbnail ); // WPCS: xss ok.
|
74 |
+
}
|
75 |
+
?>
|
76 |
+
</td>
|
77 |
+
<td class="product-name">
|
78 |
+
<?php
|
79 |
+
if ( ! $product->is_visible() ) {
|
80 |
+
echo apply_filters( 'tinvwl_wishlist_item_name', $product->get_title(), $wl_product, $product ) . ' '; // WPCS: xss ok.
|
81 |
+
} else {
|
82 |
+
echo apply_filters( 'tinvwl_wishlist_item_name', sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product->get_title() ), $wl_product, $product ); // WPCS: xss ok.
|
83 |
+
}
|
84 |
+
|
85 |
+
echo apply_filters( 'tinvwl_wishlist_item_meta_data', tinv_wishlist_get_item_data( $product, $wl_product ), $wl_product, $product ); // WPCS: xss ok.
|
86 |
+
?>
|
87 |
+
</td>
|
88 |
+
<?php if ( $wishlist_table_row['colm_price'] ) { ?>
|
89 |
+
<td class="product-price">
|
90 |
+
<?php
|
91 |
+
echo apply_filters( 'tinvwl_wishlist_item_price', $product->get_price_html(), $wl_product, $product ); // WPCS: xss ok.
|
92 |
+
?>
|
93 |
+
</td>
|
94 |
+
<?php } ?>
|
95 |
+
<?php if ( $wishlist_table_row['colm_date'] ) { ?>
|
96 |
+
<td class="product-date">
|
97 |
+
<?php
|
98 |
+
echo apply_filters( 'tinvwl_wishlist_item_date', sprintf( // WPCS: xss ok.
|
99 |
+
'<time class="entry-date" datetime="%1$s">%2$s</time>', $wl_product['date'], mysql2date( get_option( 'date_format' ), $wl_product['date'] )
|
100 |
+
), $wl_product, $product );
|
101 |
+
?>
|
102 |
+
</td>
|
103 |
+
<?php } ?>
|
104 |
+
<?php if ( $wishlist_table_row['colm_stock'] ) { ?>
|
105 |
+
<td class="product-stock">
|
106 |
+
<?php
|
107 |
+
$availability = (array) $product->get_availability();
|
108 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
109 |
+
$availability['availability'] = '';
|
110 |
+
}
|
111 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
112 |
+
$availability['class'] = '';
|
113 |
+
}
|
114 |
+
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
115 |
+
|
116 |
+
echo apply_filters( 'tinvwl_wishlist_item_status', $availability_html, $availability['availability'], $wl_product, $product ); // WPCS: xss ok.
|
117 |
+
?>
|
118 |
+
</td>
|
119 |
+
<?php } ?>
|
120 |
+
<?php if ( $wishlist_table_row['add_to_card'] ) { ?>
|
121 |
+
<td class="product-action">
|
122 |
+
<?php
|
123 |
+
if ( apply_filters( 'tinvwl_wishlist_item_action_add_to_card', $wishlist_table_row['add_to_card'], $wl_product, $product ) ) {
|
124 |
+
?>
|
125 |
+
<button class="button alt" name="tinvwl-add-to-cart" value="<?php echo esc_attr( $wl_product['ID'] ); ?>"><i class="fa fa-shopping-cart"></i><span class="tinvwl-txt"><?php echo esc_html( apply_filters( 'tinvwl_wishlist_item_add_to_card', $wishlist_table_row['text_add_to_card'], $wl_product, $product ) ); ?></span></button>
|
126 |
+
<?php } ?>
|
127 |
+
</td>
|
128 |
+
<?php } ?>
|
129 |
+
</tr>
|
130 |
+
<?php
|
131 |
+
do_action( 'tinvwl_wishlist_row_after', $wl_product, $product );
|
132 |
+
} // End if().
|
133 |
+
} // End foreach().
|
134 |
+
?>
|
135 |
+
<?php do_action( 'tinvwl_wishlist_contents_after' ); ?>
|
136 |
+
</tbody>
|
137 |
+
<tfoot>
|
138 |
+
<tr>
|
139 |
+
<td colspan="100%">
|
140 |
+
<?php do_action( 'tinvwl_after_wishlist_table', $wishlist ); ?>
|
141 |
+
<?php wp_nonce_field( 'tinvwl_wishlist_owner', 'wishlist_nonce' ); ?>
|
142 |
+
</td>
|
143 |
+
</tr>
|
144 |
+
</tfoot>
|
145 |
+
</table>
|
146 |
+
</form>
|
147 |
+
<?php do_action( 'tinvwl_after_wishlist', $wishlist ); ?>
|
148 |
+
<div class="tinv-lists-nav tinv-wishlist-clear">
|
149 |
+
<?php do_action( 'tinvwl_pagenation_wishlist', $wishlist ); ?>
|
150 |
+
</div>
|
151 |
+
</div>
|
ti-woocommerce-wishlist.php
CHANGED
@@ -1,129 +1,129 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* WooCommerce Wishlist Plugin.
|
4 |
-
* Plugin Name: WooCommerce Wishlist Plugin
|
5 |
-
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
-
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
-
* Version: 1.5.
|
8 |
-
* Author: TemplateInvaders
|
9 |
-
* Author URI: https://templateinvaders.com/
|
10 |
-
* License: GPL-2.0+
|
11 |
-
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
12 |
-
* Text Domain: ti-woocommerce-wishlist
|
13 |
-
* Domain Path: /languages
|
14 |
-
*
|
15 |
-
* @package TInvWishlist
|
16 |
-
*/
|
17 |
-
|
18 |
-
// If this file is called directly, abort.
|
19 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
-
die;
|
21 |
-
}
|
22 |
-
|
23 |
-
// Define default path.
|
24 |
-
if ( ! defined( 'TINVWL_URL' ) ) {
|
25 |
-
define( 'TINVWL_URL', plugins_url( '/', __FILE__ ) );
|
26 |
-
}
|
27 |
-
if ( ! defined( 'TINVWL_PATH' ) ) {
|
28 |
-
define( 'TINVWL_PATH', plugin_dir_path( __FILE__ ) );
|
29 |
-
}
|
30 |
-
|
31 |
-
if ( ! defined( 'TINVWL_PREFIX' ) ) {
|
32 |
-
define( 'TINVWL_PREFIX', 'tinvwl' );
|
33 |
-
}
|
34 |
-
|
35 |
-
if ( ! defined( 'TINVWL_DOMAIN' ) ) {
|
36 |
-
define( 'TINVWL_DOMAIN', 'ti-woocommerce-wishlist' );
|
37 |
-
}
|
38 |
-
|
39 |
-
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
40 |
-
define( 'TINVWL_FVERSION', '1.5.
|
41 |
-
}
|
42 |
-
|
43 |
-
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
44 |
-
define( 'TINVWL_LOAD_FREE', plugin_basename( __FILE__ ) );
|
45 |
-
}
|
46 |
-
|
47 |
-
require_once TINVWL_PATH . 'tinv-wishlists-function.php';
|
48 |
-
require_once TINVWL_PATH . 'tinv-wishlists-function-integration.php';
|
49 |
-
|
50 |
-
if ( ! function_exists( 'activation_tinv_wishlist' ) ) {
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Activation plugin
|
54 |
-
*/
|
55 |
-
function activation_tinv_wishlist() {
|
56 |
-
if ( dependency_tinv_wishlist( false ) ) {
|
57 |
-
TInvWL_Activator::activate();
|
58 |
-
flush_rewrite_rules();
|
59 |
-
}
|
60 |
-
}
|
61 |
-
}
|
62 |
-
|
63 |
-
if ( ! function_exists( 'deactivation_tinv_wishlist' ) ) {
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Deactivation plugin
|
67 |
-
*/
|
68 |
-
function deactivation_tinv_wishlist() {
|
69 |
-
flush_rewrite_rules();
|
70 |
-
}
|
71 |
-
}
|
72 |
-
|
73 |
-
if ( ! function_exists( 'uninstall_tinv_wishlist' ) ) {
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Uninstall plugin
|
77 |
-
*/
|
78 |
-
function uninstall_tinv_wishlist() {
|
79 |
-
if ( ! defined( 'TINVWL_LOAD_PREMIUM' ) ) {
|
80 |
-
TInvWL_Activator::uninstall();
|
81 |
-
flush_rewrite_rules();
|
82 |
-
}
|
83 |
-
}
|
84 |
-
}
|
85 |
-
|
86 |
-
if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
|
87 |
-
|
88 |
-
/**
|
89 |
-
* Dependency plugin
|
90 |
-
*
|
91 |
-
* @param boolean $run For run hooks dependency or return error message.
|
92 |
-
* @return boolean
|
93 |
-
*/
|
94 |
-
function dependency_tinv_wishlist( $run = true ) {
|
95 |
-
$ext = new TInvWL_PluginExtend( null, __FILE__, TINVWL_PREFIX );
|
96 |
-
$ext->set_dependency( 'woocommerce/woocommerce.php', 'WooCommerce' )->need();
|
97 |
-
if ( $run ) {
|
98 |
-
$ext->run();
|
99 |
-
}
|
100 |
-
return $ext->status_dependency();
|
101 |
-
}
|
102 |
-
}
|
103 |
-
|
104 |
-
if ( ! function_exists( 'run_tinv_wishlist' ) ) {
|
105 |
-
|
106 |
-
/**
|
107 |
-
* Run plugin
|
108 |
-
*/
|
109 |
-
function run_tinv_wishlist() {
|
110 |
-
if ( ! function_exists( 'is_plugin_active' ) ) {
|
111 |
-
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
112 |
-
}
|
113 |
-
if ( defined( 'TINVWL_LOAD_PREMIUM' ) && defined( 'TINVWL_LOAD_FREE' ) ) {
|
114 |
-
$redirect = tinv_wishlist_status( plugin_basename( __FILE__ ) );
|
115 |
-
if ( $redirect ) {
|
116 |
-
header( 'Location: ' . $redirect );
|
117 |
-
exit;
|
118 |
-
}
|
119 |
-
} elseif ( dependency_tinv_wishlist() ) {
|
120 |
-
$plugin = new TInvWL();
|
121 |
-
$plugin->run();
|
122 |
-
}
|
123 |
-
}
|
124 |
-
}
|
125 |
-
|
126 |
-
register_activation_hook( __FILE__, 'activation_tinv_wishlist' );
|
127 |
-
register_deactivation_hook( __FILE__, 'deactivation_tinv_wishlist' );
|
128 |
-
|
129 |
-
add_action( 'plugins_loaded', 'run_tinv_wishlist', 11 );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* WooCommerce Wishlist Plugin.
|
4 |
+
* Plugin Name: WooCommerce Wishlist Plugin
|
5 |
+
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
6 |
+
* Description: Wishlist functionality for your WooCommerce store.
|
7 |
+
* Version: 1.5.2
|
8 |
+
* Author: TemplateInvaders
|
9 |
+
* Author URI: https://templateinvaders.com/
|
10 |
+
* License: GPL-2.0+
|
11 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
12 |
+
* Text Domain: ti-woocommerce-wishlist
|
13 |
+
* Domain Path: /languages
|
14 |
+
*
|
15 |
+
* @package TInvWishlist
|
16 |
+
*/
|
17 |
+
|
18 |
+
// If this file is called directly, abort.
|
19 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
+
die;
|
21 |
+
}
|
22 |
+
|
23 |
+
// Define default path.
|
24 |
+
if ( ! defined( 'TINVWL_URL' ) ) {
|
25 |
+
define( 'TINVWL_URL', plugins_url( '/', __FILE__ ) );
|
26 |
+
}
|
27 |
+
if ( ! defined( 'TINVWL_PATH' ) ) {
|
28 |
+
define( 'TINVWL_PATH', plugin_dir_path( __FILE__ ) );
|
29 |
+
}
|
30 |
+
|
31 |
+
if ( ! defined( 'TINVWL_PREFIX' ) ) {
|
32 |
+
define( 'TINVWL_PREFIX', 'tinvwl' );
|
33 |
+
}
|
34 |
+
|
35 |
+
if ( ! defined( 'TINVWL_DOMAIN' ) ) {
|
36 |
+
define( 'TINVWL_DOMAIN', 'ti-woocommerce-wishlist' );
|
37 |
+
}
|
38 |
+
|
39 |
+
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
40 |
+
define( 'TINVWL_FVERSION', '1.5.2' );
|
41 |
+
}
|
42 |
+
|
43 |
+
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
44 |
+
define( 'TINVWL_LOAD_FREE', plugin_basename( __FILE__ ) );
|
45 |
+
}
|
46 |
+
|
47 |
+
require_once TINVWL_PATH . 'tinv-wishlists-function.php';
|
48 |
+
require_once TINVWL_PATH . 'tinv-wishlists-function-integration.php';
|
49 |
+
|
50 |
+
if ( ! function_exists( 'activation_tinv_wishlist' ) ) {
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Activation plugin
|
54 |
+
*/
|
55 |
+
function activation_tinv_wishlist() {
|
56 |
+
if ( dependency_tinv_wishlist( false ) ) {
|
57 |
+
TInvWL_Activator::activate();
|
58 |
+
flush_rewrite_rules();
|
59 |
+
}
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
if ( ! function_exists( 'deactivation_tinv_wishlist' ) ) {
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Deactivation plugin
|
67 |
+
*/
|
68 |
+
function deactivation_tinv_wishlist() {
|
69 |
+
flush_rewrite_rules();
|
70 |
+
}
|
71 |
+
}
|
72 |
+
|
73 |
+
if ( ! function_exists( 'uninstall_tinv_wishlist' ) ) {
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Uninstall plugin
|
77 |
+
*/
|
78 |
+
function uninstall_tinv_wishlist() {
|
79 |
+
if ( ! defined( 'TINVWL_LOAD_PREMIUM' ) ) {
|
80 |
+
TInvWL_Activator::uninstall();
|
81 |
+
flush_rewrite_rules();
|
82 |
+
}
|
83 |
+
}
|
84 |
+
}
|
85 |
+
|
86 |
+
if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
|
87 |
+
|
88 |
+
/**
|
89 |
+
* Dependency plugin
|
90 |
+
*
|
91 |
+
* @param boolean $run For run hooks dependency or return error message.
|
92 |
+
* @return boolean
|
93 |
+
*/
|
94 |
+
function dependency_tinv_wishlist( $run = true ) {
|
95 |
+
$ext = new TInvWL_PluginExtend( null, __FILE__, TINVWL_PREFIX );
|
96 |
+
$ext->set_dependency( 'woocommerce/woocommerce.php', 'WooCommerce' )->need();
|
97 |
+
if ( $run ) {
|
98 |
+
$ext->run();
|
99 |
+
}
|
100 |
+
return $ext->status_dependency();
|
101 |
+
}
|
102 |
+
}
|
103 |
+
|
104 |
+
if ( ! function_exists( 'run_tinv_wishlist' ) ) {
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Run plugin
|
108 |
+
*/
|
109 |
+
function run_tinv_wishlist() {
|
110 |
+
if ( ! function_exists( 'is_plugin_active' ) ) {
|
111 |
+
require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
|
112 |
+
}
|
113 |
+
if ( defined( 'TINVWL_LOAD_PREMIUM' ) && defined( 'TINVWL_LOAD_FREE' ) ) {
|
114 |
+
$redirect = tinv_wishlist_status( plugin_basename( __FILE__ ) );
|
115 |
+
if ( $redirect ) {
|
116 |
+
header( 'Location: ' . $redirect );
|
117 |
+
exit;
|
118 |
+
}
|
119 |
+
} elseif ( dependency_tinv_wishlist() ) {
|
120 |
+
$plugin = new TInvWL();
|
121 |
+
$plugin->run();
|
122 |
+
}
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
register_activation_hook( __FILE__, 'activation_tinv_wishlist' );
|
127 |
+
register_deactivation_hook( __FILE__, 'deactivation_tinv_wishlist' );
|
128 |
+
|
129 |
+
add_action( 'plugins_loaded', 'run_tinv_wishlist', 11 );
|
tinv-wishlists-function-integration.php
CHANGED
@@ -1,1079 +1,1079 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Support functions for other plugins
|
4 |
-
*
|
5 |
-
* @since 1.5.0
|
6 |
-
* @package TInvWishlist
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
if ( ! function_exists( 'tinvwl_rocket_reject_uri' ) ) {
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Disable cache for WP Rocket
|
18 |
-
*
|
19 |
-
* @param array $uri URI.
|
20 |
-
*
|
21 |
-
* @return array
|
22 |
-
*/
|
23 |
-
function tinvwl_rocket_reject_uri( $uri = array() ) {
|
24 |
-
$ids = array(
|
25 |
-
tinv_get_option( 'page', 'wishlist' ),
|
26 |
-
);
|
27 |
-
$pages = $ids;
|
28 |
-
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
29 |
-
'skip_missing' => 0,
|
30 |
-
'orderby' => 'code',
|
31 |
-
) );
|
32 |
-
if ( ! empty( $languages ) ) {
|
33 |
-
foreach ( $ids as $id ) {
|
34 |
-
foreach ( $languages as $l ) {
|
35 |
-
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
36 |
-
}
|
37 |
-
}
|
38 |
-
$pages = array_unique( $pages );
|
39 |
-
}
|
40 |
-
$pages = array_filter( $pages );
|
41 |
-
if ( ! empty( $pages ) ) {
|
42 |
-
foreach ( $pages as $page ) {
|
43 |
-
$uri[] = str_replace( get_site_url(), '', get_permalink( $page ) );
|
44 |
-
}
|
45 |
-
}
|
46 |
-
|
47 |
-
return $uri;
|
48 |
-
}
|
49 |
-
|
50 |
-
add_filter( 'rocket_cache_reject_uri', 'tinvwl_rocket_reject_uri' );
|
51 |
-
} // End if().
|
52 |
-
|
53 |
-
if ( ! function_exists( 'tinvwl_rocket_reject_cookies' ) ) {
|
54 |
-
|
55 |
-
/**
|
56 |
-
* Disable cache for WP Rocket
|
57 |
-
*
|
58 |
-
* @param array $cookies Cookies.
|
59 |
-
*
|
60 |
-
* @return array
|
61 |
-
*/
|
62 |
-
function tinvwl_rocket_reject_cookies( $cookies = array() ) {
|
63 |
-
$cookies[] = 'tinv_wishlist';
|
64 |
-
|
65 |
-
return $cookies;
|
66 |
-
}
|
67 |
-
|
68 |
-
add_filter( 'rocket_cache_reject_cookies', 'tinvwl_rocket_reject_cookies' );
|
69 |
-
}
|
70 |
-
|
71 |
-
if ( ! function_exists( 'tinvwl_supercache_reject_uri' ) ) {
|
72 |
-
|
73 |
-
/**
|
74 |
-
* Disable cache for WP Super Cache
|
75 |
-
*
|
76 |
-
* @global array $cache_rejected_uri
|
77 |
-
*
|
78 |
-
* @param string $buffer Intercepted the output of the page.
|
79 |
-
*
|
80 |
-
* @return string
|
81 |
-
*/
|
82 |
-
function tinvwl_supercache_reject_uri( $buffer ) {
|
83 |
-
global $cache_rejected_uri;
|
84 |
-
if ( ! is_null( $cache_rejected_uri ) && is_array( $cache_rejected_uri ) ) {
|
85 |
-
$ids = array(
|
86 |
-
tinv_get_option( 'page', 'wishlist' ),
|
87 |
-
);
|
88 |
-
$pages = $ids;
|
89 |
-
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
90 |
-
'skip_missing' => 0,
|
91 |
-
'orderby' => 'code',
|
92 |
-
) );
|
93 |
-
if ( ! empty( $languages ) ) {
|
94 |
-
foreach ( $ids as $id ) {
|
95 |
-
foreach ( $languages as $l ) {
|
96 |
-
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
97 |
-
}
|
98 |
-
}
|
99 |
-
$pages = array_unique( $pages );
|
100 |
-
}
|
101 |
-
$pages = array_filter( $pages );
|
102 |
-
if ( ! empty( $pages ) ) {
|
103 |
-
foreach ( $pages as $page ) {
|
104 |
-
$cache_rejected_uri[] = str_replace( get_site_url(), '', get_permalink( $page ) );
|
105 |
-
}
|
106 |
-
}
|
107 |
-
}
|
108 |
-
|
109 |
-
return $buffer;
|
110 |
-
}
|
111 |
-
|
112 |
-
add_filter( 'wp_cache_ob_callback_filter', 'tinvwl_supercache_reject_uri' );
|
113 |
-
} // End if().
|
114 |
-
|
115 |
-
if ( ! function_exists( 'tinvwl_w3total_reject_uri' ) ) {
|
116 |
-
|
117 |
-
/**
|
118 |
-
* Disable cache for W3 Total Cache
|
119 |
-
*/
|
120 |
-
function tinvwl_w3total_reject_uri() {
|
121 |
-
if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) {
|
122 |
-
return;
|
123 |
-
}
|
124 |
-
$ids = array(
|
125 |
-
tinv_get_option( 'page', 'wishlist' ),
|
126 |
-
);
|
127 |
-
$pages = $ids;
|
128 |
-
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
129 |
-
'skip_missing' => 0,
|
130 |
-
'orderby' => 'code',
|
131 |
-
) );
|
132 |
-
if ( ! empty( $languages ) ) {
|
133 |
-
foreach ( $ids as $id ) {
|
134 |
-
foreach ( $languages as $l ) {
|
135 |
-
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
136 |
-
}
|
137 |
-
}
|
138 |
-
$pages = array_unique( $pages );
|
139 |
-
}
|
140 |
-
$pages = array_filter( $pages );
|
141 |
-
if ( ! empty( $pages ) ) {
|
142 |
-
foreach ( $pages as $i => $page ) {
|
143 |
-
$pages[ $i ] = preg_replace( "/^\//", '', str_replace( get_site_url(), '', get_permalink( $page ) ) ); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
|
144 |
-
}
|
145 |
-
}
|
146 |
-
$pages = array_unique( $pages );
|
147 |
-
$pages = array_filter( $pages );
|
148 |
-
|
149 |
-
if ( ! empty( $pages ) ) {
|
150 |
-
$config = w3_instance( 'W3_Config' );
|
151 |
-
$sections = array( 'dbcache.reject.uri', 'pgcache.reject.uri' );
|
152 |
-
foreach ( $sections as $section ) {
|
153 |
-
$settings = array_map( 'trim', $config->get_array( $section ) );
|
154 |
-
$changed = false;
|
155 |
-
foreach ( $pages as $page ) {
|
156 |
-
if ( ! in_array( $page, $settings ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
|
157 |
-
$settings[] = $page;
|
158 |
-
$changed = true;
|
159 |
-
}
|
160 |
-
}
|
161 |
-
if ( $changed ) {
|
162 |
-
$config->set( $section, $settings );
|
163 |
-
$config->save();
|
164 |
-
}
|
165 |
-
}
|
166 |
-
}
|
167 |
-
|
168 |
-
$settings = array_map( 'trim', $config->get_array( 'pgcache.reject.cookie' ) );
|
169 |
-
if ( ! in_array( 'tinv_wishlist', $settings ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
|
170 |
-
$settings[] = 'tinv_wishlist';
|
171 |
-
$config->set( 'pgcache.reject.cookie', $settings );
|
172 |
-
$config->save();
|
173 |
-
}
|
174 |
-
}
|
175 |
-
|
176 |
-
add_action( 'admin_init', 'tinvwl_w3total_reject_uri' );
|
177 |
-
} // End if().
|
178 |
-
|
179 |
-
if ( ! function_exists( 'gf_productaddon_support' ) ) {
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Add supports WooCommerce - Gravity Forms Product Add-Ons
|
183 |
-
*/
|
184 |
-
function gf_productaddon_support() {
|
185 |
-
if ( ! class_exists( 'woocommerce_gravityforms' ) ) {
|
186 |
-
return false;
|
187 |
-
}
|
188 |
-
if ( ! function_exists( 'gf_productaddon_text_button' ) ) {
|
189 |
-
|
190 |
-
/**
|
191 |
-
* Change text for button add to cart
|
192 |
-
*
|
193 |
-
* @param string $text_add_to_card Text "Add to cart".
|
194 |
-
* @param array $wl_product Wishlist product.
|
195 |
-
* @param object $product WooCommerce Product.
|
196 |
-
*
|
197 |
-
* @return string
|
198 |
-
*/
|
199 |
-
function gf_productaddon_text_button( $text_add_to_card, $wl_product, $product ) {
|
200 |
-
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
201 |
-
|
202 |
-
return ( $gravity_form_data ) ? __( 'Select options', 'woocommerce' ) : $text_add_to_card;
|
203 |
-
}
|
204 |
-
|
205 |
-
add_filter( 'tinvwl_wishlist_item_add_to_card', 'gf_productaddon_text_button', 10, 3 );
|
206 |
-
}
|
207 |
-
|
208 |
-
if ( ! function_exists( 'gf_productaddon_run_action_button' ) ) {
|
209 |
-
|
210 |
-
/**
|
211 |
-
* Check for make redirect to url
|
212 |
-
*
|
213 |
-
* @param boolean $need Need redirect or not.
|
214 |
-
* @param object $product WooCommerce Product.
|
215 |
-
*
|
216 |
-
* @return boolean
|
217 |
-
*/
|
218 |
-
function gf_productaddon_run_action_button( $need, $product ) {
|
219 |
-
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
220 |
-
|
221 |
-
return ( $gravity_form_data ) ? true : $need;
|
222 |
-
}
|
223 |
-
|
224 |
-
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'gf_productaddon_run_action_button', 10, 2 );
|
225 |
-
}
|
226 |
-
|
227 |
-
if ( ! function_exists( 'gf_productaddon_action_button' ) ) {
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Redirect url
|
231 |
-
*
|
232 |
-
* @param string $url Redirect URL.
|
233 |
-
* @param object $product WooCommerce Product.
|
234 |
-
*
|
235 |
-
* @return string
|
236 |
-
*/
|
237 |
-
function gf_productaddon_action_button( $url, $product ) {
|
238 |
-
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
239 |
-
|
240 |
-
return ( $gravity_form_data ) ? $product->get_permalink() : $url;
|
241 |
-
}
|
242 |
-
|
243 |
-
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'gf_productaddon_action_button', 10, 2 );
|
244 |
-
}
|
245 |
-
}
|
246 |
-
|
247 |
-
add_action( 'init', 'gf_productaddon_support' );
|
248 |
-
} // End if().
|
249 |
-
|
250 |
-
if ( ! function_exists( 'tinvwl_wpml_product_get' ) ) {
|
251 |
-
|
252 |
-
/**
|
253 |
-
* Change product data if product need translate
|
254 |
-
*
|
255 |
-
* @param array $product Wishlistl product.
|
256 |
-
*
|
257 |
-
* @return array
|
258 |
-
*/
|
259 |
-
function tinvwl_wpml_product_get( $product ) {
|
260 |
-
if ( array_key_exists( 'data', $product ) ) {
|
261 |
-
$_product_id = $product_id = $product['product_id'];
|
262 |
-
$_variation_id = $variation_id = $product['variation_id'];
|
263 |
-
$_product_id = apply_filters( 'wpml_object_id', $_product_id, 'product', true );
|
264 |
-
if ( ! empty( $_variation_id ) ) {
|
265 |
-
$_variation_id = apply_filters( 'wpml_object_id', $_variation_id, 'product', true );
|
266 |
-
}
|
267 |
-
if ( $_product_id !== $product_id || $_variation_id !== $variation_id ) {
|
268 |
-
$product['data'] = wc_get_product( $variation_id ? $_variation_id : $_product_id );
|
269 |
-
}
|
270 |
-
}
|
271 |
-
|
272 |
-
return $product;
|
273 |
-
}
|
274 |
-
|
275 |
-
add_filter( 'tinvwl_wishlist_product_get', 'tinvwl_wpml_product_get' );
|
276 |
-
}
|
277 |
-
|
278 |
-
if ( ! function_exists( 'tinvwl_wpml_filter_link' ) ) {
|
279 |
-
|
280 |
-
/**
|
281 |
-
* Corect add wishlist key for WPML plugin.
|
282 |
-
*
|
283 |
-
* @param string $full_link Link for page.
|
284 |
-
* @param array $l Language.
|
285 |
-
*
|
286 |
-
* @return string
|
287 |
-
*/
|
288 |
-
function tinvwl_wpml_filter_link( $full_link, $l ) {
|
289 |
-
$share_key = get_query_var( 'tinvwlID', null );
|
290 |
-
if ( ! empty( $share_key ) ) {
|
291 |
-
if ( get_option( 'permalink_structure' ) ) {
|
292 |
-
$suffix = '';
|
293 |
-
if ( preg_match( '/([^\?]+)\?*?(.*)/i', $full_link, $_full_link ) ) {
|
294 |
-
$full_link = $_full_link[1];
|
295 |
-
$suffix = $_full_link[2];
|
296 |
-
}
|
297 |
-
if ( ! preg_match( '/\/$/', $full_link ) ) {
|
298 |
-
$full_link .= '/';
|
299 |
-
}
|
300 |
-
$full_link .= $share_key . '/' . $suffix;
|
301 |
-
} else {
|
302 |
-
$full_link .= add_query_arg( 'tinvwlID', $share_key, $full_link );
|
303 |
-
}
|
304 |
-
}
|
305 |
-
|
306 |
-
return $full_link;
|
307 |
-
}
|
308 |
-
|
309 |
-
add_filter( 'WPML_filter_link', 'tinvwl_wpml_filter_link', 0, 2 );
|
310 |
-
}
|
311 |
-
|
312 |
-
if ( ! function_exists( 'tinvwl_gift_card_add' ) ) {
|
313 |
-
|
314 |
-
/**
|
315 |
-
* Support WooCommerce - Gift Cards
|
316 |
-
* Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
|
317 |
-
*
|
318 |
-
* @param boolean $redirect Default value to redirect.
|
319 |
-
* @param \WC_Product $product Product data.
|
320 |
-
*
|
321 |
-
* @return boolean
|
322 |
-
*/
|
323 |
-
function tinvwl_gift_card_add( $redirect, $product ) {
|
324 |
-
if ( $redirect ) {
|
325 |
-
return true;
|
326 |
-
}
|
327 |
-
$is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
|
328 |
-
|
329 |
-
if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
|
330 |
-
$is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
|
331 |
-
if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
|
332 |
-
return true;
|
333 |
-
}
|
334 |
-
}
|
335 |
-
|
336 |
-
return $redirect;
|
337 |
-
}
|
338 |
-
|
339 |
-
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_gift_card_add', 20, 2 );
|
340 |
-
}
|
341 |
-
|
342 |
-
if ( ! function_exists( 'tinvwl_gift_card_add_url' ) ) {
|
343 |
-
|
344 |
-
/**
|
345 |
-
* Support WooCommerce - Gift Cards
|
346 |
-
* Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
|
347 |
-
*
|
348 |
-
* @param string $redirect_url Default value to redirect.
|
349 |
-
* @param \WC_Product $product Product data.
|
350 |
-
*
|
351 |
-
* @return boolean
|
352 |
-
*/
|
353 |
-
function tinvwl_gift_card_add_url( $redirect_url, $product ) {
|
354 |
-
$is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
|
355 |
-
|
356 |
-
if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
|
357 |
-
$is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
|
358 |
-
if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
|
359 |
-
return $product->get_permalink();
|
360 |
-
}
|
361 |
-
}
|
362 |
-
|
363 |
-
return $redirect_url;
|
364 |
-
}
|
365 |
-
|
366 |
-
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'tinvwl_gift_card_add_url', 20, 2 );
|
367 |
-
}
|
368 |
-
|
369 |
-
if ( ! function_exists( 'tinv_wishlist_meta_support_rpgiftcards' ) ) {
|
370 |
-
|
371 |
-
/**
|
372 |
-
* Set descrition for meta WooCommerce - Gift Cards
|
373 |
-
*
|
374 |
-
* @param array $meta Meta array.
|
375 |
-
*
|
376 |
-
* @return array
|
377 |
-
*/
|
378 |
-
function tinv_wishlist_metasupport_rpgiftcards( $meta ) {
|
379 |
-
foreach ( $meta as $key => $data ) {
|
380 |
-
switch ( $data['key'] ) {
|
381 |
-
case 'rpgc_note':
|
382 |
-
$meta[ $key ]['key'] = __( 'Note', 'rpgiftcards' );
|
383 |
-
break;
|
384 |
-
case 'rpgc_to':
|
385 |
-
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_to' ) <> null ? get_option( 'woocommerce_giftcard_to' ) : __( 'To', 'rpgiftcards' ) ); // WPCS: loose comparison ok.
|
386 |
-
break;
|
387 |
-
case 'rpgc_to_email':
|
388 |
-
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_toEmail' ) <> null ? get_option( 'woocommerce_giftcard_toEmail' ) : __( 'To Email', 'rpgiftcards' ) ); // WPCS: loose comparison ok.
|
389 |
-
break;
|
390 |
-
case 'rpgc_address':
|
391 |
-
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_address' ) <> null ? get_option( 'woocommerce_giftcard_address' ) : __( 'Address', 'rpgiftcards' ) ); // WPCS: loose comparison ok.
|
392 |
-
break;
|
393 |
-
case 'rpgc_reload_card':
|
394 |
-
$meta[ $key ]['key'] = __( 'Reload existing Gift Card', 'rpgiftcards' );
|
395 |
-
break;
|
396 |
-
case 'rpgc_description':
|
397 |
-
case 'rpgc_reload_check':
|
398 |
-
unset( $meta[ $key ] );
|
399 |
-
break;
|
400 |
-
}
|
401 |
-
}
|
402 |
-
|
403 |
-
return $meta;
|
404 |
-
}
|
405 |
-
|
406 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_rpgiftcards' );
|
407 |
-
} // End if().
|
408 |
-
|
409 |
-
if ( ! function_exists( 'tinv_wishlist_metaprepare_rpgiftcards' ) ) {
|
410 |
-
|
411 |
-
/**
|
412 |
-
* Prepare save meta for WooCommerce - Gift Cards
|
413 |
-
*
|
414 |
-
* @param array $meta Meta array.
|
415 |
-
*
|
416 |
-
* @return array
|
417 |
-
*/
|
418 |
-
function tinv_wishlist_metaprepare_rpgiftcards( $meta ) {
|
419 |
-
if ( array_key_exists( 'rpgc_reload_check', $meta ) ) {
|
420 |
-
foreach ( array( 'rpgc_note', 'rpgc_to', 'rpgc_to_email', 'rpgc_address' ) as $value ) {
|
421 |
-
if ( array_key_exists( $value, $meta ) ) {
|
422 |
-
unset( $meta[ $value ] );
|
423 |
-
}
|
424 |
-
}
|
425 |
-
}
|
426 |
-
|
427 |
-
return $meta;
|
428 |
-
}
|
429 |
-
|
430 |
-
add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_rpgiftcards' );
|
431 |
-
}
|
432 |
-
|
433 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_bookings' ) ) {
|
434 |
-
|
435 |
-
/**
|
436 |
-
* Set descrition for meta WooCommerce Bookings
|
437 |
-
*
|
438 |
-
* @param array $meta Meta array.
|
439 |
-
* @param integer $product_id Priduct ID.
|
440 |
-
* @param integer $variation_id Variation Product ID.
|
441 |
-
*
|
442 |
-
* @return array
|
443 |
-
*/
|
444 |
-
function tinv_wishlist_metasupport_woocommerce_bookings( $meta, $product_id, $variation_id ) {
|
445 |
-
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
446 |
-
return $meta;
|
447 |
-
}
|
448 |
-
$product = wc_get_product( $variation_id ? $variation_id : $product_id );
|
449 |
-
if ( is_wc_booking_product( $product ) ) {
|
450 |
-
$booking_form = new WC_Booking_Form( $product );
|
451 |
-
$post_data = array();
|
452 |
-
foreach ( $meta as $data ) {
|
453 |
-
$post_data[ $data['key'] ] = $data['display'];
|
454 |
-
}
|
455 |
-
$booking_data = $booking_form->get_posted_data( $post_data );
|
456 |
-
$meta = array();
|
457 |
-
foreach ( $booking_data as $key => $value ) {
|
458 |
-
if ( ! preg_match( '/^_/', $key ) ) {
|
459 |
-
$meta[ $key ] = array(
|
460 |
-
'key' => get_wc_booking_data_label( $key, $product ),
|
461 |
-
'display' => $value,
|
462 |
-
);
|
463 |
-
}
|
464 |
-
}
|
465 |
-
}
|
466 |
-
|
467 |
-
return $meta;
|
468 |
-
}
|
469 |
-
|
470 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_bookings', 10, 3 );
|
471 |
-
} // End if().
|
472 |
-
|
473 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_bookings' ) ) {
|
474 |
-
|
475 |
-
/**
|
476 |
-
* Modify price for WooCommerce Bookings
|
477 |
-
*
|
478 |
-
* @param string $price Returned price.
|
479 |
-
* @param array $wl_product Wishlist Product.
|
480 |
-
* @param \WC_Product $product Woocommerce Product.
|
481 |
-
*
|
482 |
-
* @return string
|
483 |
-
*/
|
484 |
-
function tinvwl_item_price_woocommerce_bookings( $price, $wl_product, $product ) {
|
485 |
-
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
486 |
-
return $price;
|
487 |
-
}
|
488 |
-
if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
|
489 |
-
$booking_form = new WC_Booking_Form( $product );
|
490 |
-
$cost = $booking_form->calculate_booking_cost( $wl_product['meta'] );
|
491 |
-
if ( is_wp_error( $cost ) ) {
|
492 |
-
return $price;
|
493 |
-
}
|
494 |
-
|
495 |
-
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
|
496 |
-
|
497 |
-
if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
|
498 |
-
if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
|
499 |
-
$display_price = wc_get_price_including_tax( $product, array( 'price' => $cost ) );
|
500 |
-
} else {
|
501 |
-
$display_price = $product->get_price_including_tax( 1, $cost );
|
502 |
-
}
|
503 |
-
} else {
|
504 |
-
if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
|
505 |
-
$display_price = wc_get_price_excluding_tax( $product, array( 'price' => $cost ) );
|
506 |
-
} else {
|
507 |
-
$display_price = $product->get_price_excluding_tax( 1, $cost );
|
508 |
-
}
|
509 |
-
}
|
510 |
-
|
511 |
-
if ( version_compare( WC_VERSION, '2.4.0', '>=' ) ) {
|
512 |
-
$price_suffix = $product->get_price_suffix( $cost, 1 );
|
513 |
-
} else {
|
514 |
-
$price_suffix = $product->get_price_suffix();
|
515 |
-
}
|
516 |
-
$price = wc_price( $display_price ) . $price_suffix;
|
517 |
-
}
|
518 |
-
|
519 |
-
return $price;
|
520 |
-
}
|
521 |
-
|
522 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_bookings', 10, 3 );
|
523 |
-
} // End if().
|
524 |
-
|
525 |
-
if ( ! function_exists( 'tinvwl_item_status_woocommerce_bookings' ) ) {
|
526 |
-
|
527 |
-
/**
|
528 |
-
* Modify availability for WooCommerce Bookings
|
529 |
-
*
|
530 |
-
* @param string $status Status availability.
|
531 |
-
* @param string $availability Default availability.
|
532 |
-
* @param array $wl_product Wishlist Product.
|
533 |
-
* @param \WC_Product $product Woocommerce Product.
|
534 |
-
*
|
535 |
-
* @return type
|
536 |
-
*/
|
537 |
-
function tinvwl_item_status_woocommerce_bookings( $status, $availability, $wl_product, $product ) {
|
538 |
-
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
539 |
-
return $status;
|
540 |
-
}
|
541 |
-
if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
|
542 |
-
$booking_form = new WC_Booking_Form( $product );
|
543 |
-
$cost = $booking_form->calculate_booking_cost( $wl_product['meta'] );
|
544 |
-
if ( is_wp_error( $cost ) ) {
|
545 |
-
return '<p class="stock out-of-stock"><span><i class="fa fa-times"></i></span><span>' . $cost->get_error_message() . '</span></p>';
|
546 |
-
}
|
547 |
-
}
|
548 |
-
|
549 |
-
return $status;
|
550 |
-
}
|
551 |
-
|
552 |
-
add_filter( 'tinvwl_wishlist_item_status', 'tinvwl_item_status_woocommerce_bookings', 10, 4 );
|
553 |
-
}
|
554 |
-
|
555 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
|
556 |
-
|
557 |
-
/**
|
558 |
-
* Set descrition for meta WooCommerce - Gravity Forms Product Add-Ons
|
559 |
-
*
|
560 |
-
* @param array $meta Meta array.
|
561 |
-
*
|
562 |
-
* @return array
|
563 |
-
*/
|
564 |
-
function tinv_wishlist_metasupport_wc_gf_addons( $meta ) {
|
565 |
-
if ( array_key_exists( 'wc_gforms_form_id', $meta ) && class_exists( 'RGFormsModel' ) ) {
|
566 |
-
$form_meta = RGFormsModel::get_form_meta( $meta['wc_gforms_form_id']['display'] );
|
567 |
-
if ( array_key_exists( 'fields', $form_meta ) ) {
|
568 |
-
$_meta = array();
|
569 |
-
foreach ( $form_meta['fields'] as $field ) {
|
570 |
-
$field_name = $field->get_first_input_id( array( 'id' => 0 ) );
|
571 |
-
if ( array_key_exists( $field_name, $meta ) ) {
|
572 |
-
$meta[ $field_name ]['key'] = $field->label;
|
573 |
-
$_meta[ $field_name ] = $meta[ $field_name ];
|
574 |
-
}
|
575 |
-
}
|
576 |
-
$meta = $_meta;
|
577 |
-
}
|
578 |
-
}
|
579 |
-
|
580 |
-
return $meta;
|
581 |
-
}
|
582 |
-
|
583 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_wc_gf_addons' );
|
584 |
-
}
|
585 |
-
|
586 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_composite_products' ) ) {
|
587 |
-
|
588 |
-
/**
|
589 |
-
* Set descrition for meta WooCommerce Composite Products
|
590 |
-
*
|
591 |
-
* @param array $meta Meta array.
|
592 |
-
* @param integer $product_id Product ID.
|
593 |
-
*
|
594 |
-
* @return array
|
595 |
-
*/
|
596 |
-
function tinv_wishlist_metasupport_woocommerce_composite_products( $meta, $product_id ) {
|
597 |
-
if ( array_key_exists( 'wccp_component_selection', $meta ) && is_array( $meta['wccp_component_selection'] ) ) {
|
598 |
-
$meta = array();
|
599 |
-
} // End if().
|
600 |
-
|
601 |
-
return $meta;
|
602 |
-
}
|
603 |
-
|
604 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_composite_products', 10, 2 );
|
605 |
-
} // End if().
|
606 |
-
|
607 |
-
if ( ! function_exists( 'tinvwl_row_woocommerce_composite_products' ) ) {
|
608 |
-
|
609 |
-
/**
|
610 |
-
* Add rows for sub product for WooCommerce Composite Products
|
611 |
-
*
|
612 |
-
* @param array $wl_product Wishlist Product.
|
613 |
-
* @param \WC_Product $product Woocommerce Product.
|
614 |
-
*/
|
615 |
-
function tinvwl_row_woocommerce_composite_products( $wl_product, $product ) {
|
616 |
-
if ( is_object( $product ) && $product->is_type( 'composite' ) && array_key_exists( 'wccp_component_selection', $wl_product['meta'] ) ) {
|
617 |
-
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
618 |
-
|
619 |
-
$components = $product->get_components();
|
620 |
-
foreach ( $components as $component_id => $component ) {
|
621 |
-
$composited_product_id = ! empty( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) : '';
|
622 |
-
$composited_product_quantity = isset( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) : $component->get_quantity( 'min' );
|
623 |
-
|
624 |
-
$composited_variation_id = isset( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) ? wc_clean( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) : '';
|
625 |
-
|
626 |
-
if ( $composited_product_id ) {
|
627 |
-
|
628 |
-
$composited_product_wrapper = $component->get_option( $composited_variation_id ? $composited_variation_id : $composited_product_id );
|
629 |
-
|
630 |
-
if ( ! $composited_product_wrapper ) {
|
631 |
-
continue;
|
632 |
-
}
|
633 |
-
|
634 |
-
$composited_product = $composited_product_wrapper->get_product();
|
635 |
-
|
636 |
-
if ( $composited_product->is_sold_individually() && $composited_product_quantity > 1 ) {
|
637 |
-
$composited_product_quantity = 1;
|
638 |
-
}
|
639 |
-
|
640 |
-
$product_url = $composited_product->get_permalink();
|
641 |
-
$product_image = $composited_product->get_image();
|
642 |
-
$product_title = $composited_product->get_title();
|
643 |
-
$product_price = $composited_product->get_price_html();
|
644 |
-
if ( $composited_product->is_visible() ) {
|
645 |
-
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
646 |
-
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
647 |
-
}
|
648 |
-
$product_title .= tinv_wishlist_get_item_data( $composited_product );
|
649 |
-
|
650 |
-
$availability = (array) $composited_product->get_availability();
|
651 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
652 |
-
$availability['availability'] = '';
|
653 |
-
}
|
654 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
655 |
-
$availability['class'] = '';
|
656 |
-
}
|
657 |
-
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
658 |
-
$row_string = '<tr>';
|
659 |
-
$row_string .= '<td colspan="2"></td> <td class="product-thumbnail">%2$s</td><td class="product-name">%1$s:<br/>%3$s</td>';
|
660 |
-
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
661 |
-
$row_string .= '<td class="product-price">%3$s × %6$s</td>';
|
662 |
-
}
|
663 |
-
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
664 |
-
$row_string .= '<td class="product-date"> </td>';
|
665 |
-
}
|
666 |
-
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
667 |
-
$row_string .= '<td class="product-stock">%5$s</td>';
|
668 |
-
}
|
669 |
-
if ( tinv_get_option( 'product_table', 'add_to_card' ) ) {
|
670 |
-
$row_string .= '<td class="product-action"> </td>';
|
671 |
-
}
|
672 |
-
$row_string .= '</tr>';
|
673 |
-
|
674 |
-
echo sprintf( $row_string, $component->get_title(), $product_image, $product_title, $product_price, $availability_html, $composited_product_quantity * $product_quantity ); // WPCS: xss ok.
|
675 |
-
} // End if().
|
676 |
-
} // End foreach().
|
677 |
-
} // End if().
|
678 |
-
}
|
679 |
-
|
680 |
-
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_composite_products', 10, 2 );
|
681 |
-
} // End if().
|
682 |
-
|
683 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_product_bundles' ) ) {
|
684 |
-
|
685 |
-
/**
|
686 |
-
* Set descrition for meta WooCommerce Product Bundles
|
687 |
-
*
|
688 |
-
* @param array $meta Meta array.
|
689 |
-
* @param integer $product_id Product ID.
|
690 |
-
*
|
691 |
-
* @return array
|
692 |
-
*/
|
693 |
-
function tinv_wishlist_metasupport_woocommerce_product_bundles( $meta, $product_id ) {
|
694 |
-
$bundled_item_id = 1;
|
695 |
-
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
696 |
-
if ( array_key_exists( $bundled_item_quantity_request_key, $meta ) ) {
|
697 |
-
$meta = array();
|
698 |
-
}
|
699 |
-
|
700 |
-
return $meta;
|
701 |
-
}
|
702 |
-
|
703 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_bundles', 10, 2 );
|
704 |
-
} // End if().
|
705 |
-
|
706 |
-
if ( ! function_exists( 'tinvwl_row_woocommerce_product_bundles' ) ) {
|
707 |
-
|
708 |
-
/**
|
709 |
-
* Add rows for sub product for WooCommerce Product Bundles
|
710 |
-
*
|
711 |
-
* @param array $wl_product Wishlist Product.
|
712 |
-
* @param \WC_Product $product Woocommerce Product.
|
713 |
-
*/
|
714 |
-
function tinvwl_row_woocommerce_product_bundles( $wl_product, $product ) {
|
715 |
-
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
716 |
-
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
717 |
-
|
718 |
-
$product_id = WC_PB_Core_Compatibility::get_id( $product );
|
719 |
-
$bundled_items = $product->get_bundled_items();
|
720 |
-
if ( ! empty( $bundled_items ) ) {
|
721 |
-
foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
|
722 |
-
$bundled_product_id = $bundled_item->product_id;
|
723 |
-
$bundled_product_type = $bundled_item->product->get_type();
|
724 |
-
$is_optional = $bundled_item->is_optional();
|
725 |
-
|
726 |
-
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
727 |
-
$bundled_product_qty = isset( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) ? absint( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) : $bundled_item->get_quantity();
|
728 |
-
|
729 |
-
if ( $is_optional ) {
|
730 |
-
|
731 |
-
/** Documented in method 'get_posted_bundle_configuration'. */
|
732 |
-
$bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
|
733 |
-
|
734 |
-
if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
|
735 |
-
$bundled_product_qty = 0;
|
736 |
-
}
|
737 |
-
}
|
738 |
-
if ( 0 === $bundled_product_qty ) {
|
739 |
-
continue;
|
740 |
-
}
|
741 |
-
|
742 |
-
$product_url = $bundled_item->product->get_permalink();
|
743 |
-
$product_image = $bundled_item->product->get_image();
|
744 |
-
$product_title = $bundled_item->product->get_title();
|
745 |
-
$product_price = $bundled_item->product->get_price_html();
|
746 |
-
if ( $bundled_item->product->is_visible() ) {
|
747 |
-
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
748 |
-
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
749 |
-
}
|
750 |
-
$product_title .= tinv_wishlist_get_item_data( $bundled_item->product );
|
751 |
-
|
752 |
-
$availability = (array) $bundled_item->product->get_availability();
|
753 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
754 |
-
$availability['availability'] = '';
|
755 |
-
}
|
756 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
757 |
-
$availability['class'] = '';
|
758 |
-
}
|
759 |
-
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
760 |
-
$row_string = '<tr>';
|
761 |
-
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
762 |
-
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
763 |
-
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
764 |
-
}
|
765 |
-
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
766 |
-
$row_string .= '<td class="product-date"> </td>';
|
767 |
-
}
|
768 |
-
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
769 |
-
$row_string .= '<td class="product-stock">%4$s</td>';
|
770 |
-
}
|
771 |
-
|
772 |
-
if ( tinv_get_option( 'product_table', 'add_to_card' ) ) {
|
773 |
-
$row_string .= '<td class="product-action"> </td>';
|
774 |
-
}
|
775 |
-
$row_string .= '</tr>';
|
776 |
-
|
777 |
-
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $bundled_product_qty ); // WPCS: xss ok.
|
778 |
-
} // End foreach().
|
779 |
-
} // End if().
|
780 |
-
} // End if().
|
781 |
-
}
|
782 |
-
|
783 |
-
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_product_bundles', 10, 2 );
|
784 |
-
} // End if().
|
785 |
-
|
786 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_bundles' ) ) {
|
787 |
-
|
788 |
-
/**
|
789 |
-
* Modify price for WooCommerce Product Bundles
|
790 |
-
*
|
791 |
-
* @param string $price Returned price.
|
792 |
-
* @param array $wl_product Wishlist Product.
|
793 |
-
* @param \WC_Product $product Woocommerce Product.
|
794 |
-
*
|
795 |
-
* @return string
|
796 |
-
*/
|
797 |
-
function tinvwl_item_price_woocommerce_product_bundles( $price, $wl_product, $product ) {
|
798 |
-
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
799 |
-
|
800 |
-
$bundle_price = $product->get_price();
|
801 |
-
$product_id = WC_PB_Core_Compatibility::get_id( $product );
|
802 |
-
$bundled_items = $product->get_bundled_items();
|
803 |
-
|
804 |
-
if ( ! empty( $bundled_items ) ) {
|
805 |
-
|
806 |
-
$bundled_items_price = 0.0;
|
807 |
-
|
808 |
-
foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
|
809 |
-
$is_optional = $bundled_item->is_optional();
|
810 |
-
|
811 |
-
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
812 |
-
$bundled_product_qty = isset( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) ? absint( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) : $bundled_item->get_quantity();
|
813 |
-
|
814 |
-
if ( $is_optional ) {
|
815 |
-
|
816 |
-
/** Documented in method 'get_posted_bundle_configuration'. */
|
817 |
-
$bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
|
818 |
-
|
819 |
-
if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
|
820 |
-
$bundled_product_qty = 0;
|
821 |
-
}
|
822 |
-
}
|
823 |
-
if ( 0 === $bundled_product_qty ) {
|
824 |
-
continue;
|
825 |
-
}
|
826 |
-
|
827 |
-
$bundled_item_price = $bundled_item->product->get_price() * $bundled_product_qty;
|
828 |
-
|
829 |
-
$bundled_items_price += (double) $bundled_item_price;
|
830 |
-
|
831 |
-
} // End foreach().
|
832 |
-
$price = wc_price( (double) $bundle_price + $bundled_items_price );
|
833 |
-
$price = apply_filters( 'woocommerce_get_price_html', $price, $product );
|
834 |
-
} // End if().
|
835 |
-
} // End if().
|
836 |
-
|
837 |
-
return $price;
|
838 |
-
}
|
839 |
-
|
840 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_bundles', 10, 3 );
|
841 |
-
} // End if().
|
842 |
-
|
843 |
-
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products' ) ) {
|
844 |
-
|
845 |
-
/**
|
846 |
-
* Set descrition for meta WooCommerce Mix and Match
|
847 |
-
*
|
848 |
-
* @param array $meta Meta array.
|
849 |
-
* @param integer $product_id Product ID.
|
850 |
-
*
|
851 |
-
* @return array
|
852 |
-
*/
|
853 |
-
function tinv_wishlist_metasupport_woocommerce_mix_and_match_products( $meta, $product_id ) {
|
854 |
-
if ( array_key_exists( 'mnm_quantity', $meta ) ) {
|
855 |
-
$product = wc_get_product( $product_id );
|
856 |
-
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) ) {
|
857 |
-
$meta = array();
|
858 |
-
}
|
859 |
-
}
|
860 |
-
|
861 |
-
return $meta;
|
862 |
-
}
|
863 |
-
|
864 |
-
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products', 10, 2 );
|
865 |
-
} // End if().
|
866 |
-
|
867 |
-
if ( ! function_exists( 'tinvwl_row_woocommerce_mix_and_match_products' ) ) {
|
868 |
-
|
869 |
-
/**
|
870 |
-
* Add rows for sub product for WooCommerce Mix and Match
|
871 |
-
*
|
872 |
-
* @param array $wl_product Wishlist Product.
|
873 |
-
* @param \WC_Product $product Woocommerce Product.
|
874 |
-
*/
|
875 |
-
function tinvwl_row_woocommerce_mix_and_match_products( $wl_product, $product ) {
|
876 |
-
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && array_key_exists( 'mnm_quantity', $wl_product['meta'] ) ) {
|
877 |
-
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
878 |
-
$mnm_items = $product->get_children();
|
879 |
-
if ( ! empty( $mnm_items ) ) {
|
880 |
-
foreach ( $mnm_items as $id => $mnm_item ) {
|
881 |
-
$item_quantity = 0;
|
882 |
-
if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
|
883 |
-
$item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
|
884 |
-
}
|
885 |
-
if ( 0 >= $item_quantity ) {
|
886 |
-
continue;
|
887 |
-
}
|
888 |
-
|
889 |
-
$product_url = $mnm_item->get_permalink();
|
890 |
-
$product_image = $mnm_item->get_image();
|
891 |
-
$product_title = $mnm_item->get_title();
|
892 |
-
$product_price = $mnm_item->get_price_html();
|
893 |
-
if ( $mnm_item->is_visible() ) {
|
894 |
-
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
895 |
-
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
896 |
-
}
|
897 |
-
$product_title .= tinv_wishlist_get_item_data( $mnm_item );
|
898 |
-
|
899 |
-
$availability = (array) $mnm_item->get_availability();
|
900 |
-
if ( ! array_key_exists( 'availability', $availability ) ) {
|
901 |
-
$availability['availability'] = '';
|
902 |
-
}
|
903 |
-
if ( ! array_key_exists( 'class', $availability ) ) {
|
904 |
-
$availability['class'] = '';
|
905 |
-
}
|
906 |
-
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
907 |
-
$row_string = '<tr>';
|
908 |
-
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
909 |
-
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
910 |
-
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
911 |
-
}
|
912 |
-
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
913 |
-
$row_string .= '<td class="product-date"> </td>';
|
914 |
-
}
|
915 |
-
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
916 |
-
$row_string .= '<td class="product-stock">%4$s</td>';
|
917 |
-
}
|
918 |
-
if ( tinv_get_option( 'product_table', 'add_to_card' ) ) {
|
919 |
-
$row_string .= '<td class="product-action"> </td>';
|
920 |
-
}
|
921 |
-
$row_string .= '</tr>';
|
922 |
-
|
923 |
-
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity ); // WPCS: xss ok.
|
924 |
-
} // End foreach().
|
925 |
-
} // End if().
|
926 |
-
} // End if().
|
927 |
-
}
|
928 |
-
|
929 |
-
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_mix_and_match_products', 10, 2 );
|
930 |
-
} // End if().
|
931 |
-
|
932 |
-
if ( ! function_exists( 'tinvwl_item_price_woocommerce_mix_and_match_products' ) ) {
|
933 |
-
|
934 |
-
/**
|
935 |
-
* Modify price for WooCommerce Mix and Match
|
936 |
-
*
|
937 |
-
* @param string $price Returned price.
|
938 |
-
* @param array $wl_product Wishlist Product.
|
939 |
-
* @param \WC_Product $product Woocommerce Product.
|
940 |
-
*
|
941 |
-
* @return string
|
942 |
-
*/
|
943 |
-
function tinvwl_item_price_woocommerce_mix_and_match_products( $price, $wl_product, $product ) {
|
944 |
-
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && $product->is_priced_per_product() ) {
|
945 |
-
$mnm_items = $product->get_children();
|
946 |
-
if ( ! empty( $mnm_items ) ) {
|
947 |
-
$_price = 0;
|
948 |
-
foreach ( $mnm_items as $id => $mnm_item ) {
|
949 |
-
$item_quantity = 0;
|
950 |
-
if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
|
951 |
-
$item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
|
952 |
-
}
|
953 |
-
if ( 0 >= $item_quantity ) {
|
954 |
-
continue;
|
955 |
-
}
|
956 |
-
$_price += wc_get_price_to_display( $mnm_item, array( 'qty' => $item_quantity ) );
|
957 |
-
}
|
958 |
-
if ( 0 < $_price ) {
|
959 |
-
if ( $product->is_on_sale() ) {
|
960 |
-
$price = wc_format_sale_price( $_price + wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ), $_price + wc_get_price_to_display( $product ) ) . $product->get_price_suffix();
|
961 |
-
} else {
|
962 |
-
$price = wc_price( $_price + wc_get_price_to_display( $product ) ) . $product->get_price_suffix();
|
963 |
-
}
|
964 |
-
$price = apply_filters( 'woocommerce_get_price_html', $price, $product );
|
965 |
-
}
|
966 |
-
}
|
967 |
-
}
|
968 |
-
|
969 |
-
return $price;
|
970 |
-
}
|
971 |
-
|
972 |
-
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_mix_and_match_products', 10, 3 );
|
973 |
-
} // End if().
|
974 |
-
|
975 |
-
if ( ! function_exists( 'tinvwl_add_form_woocommerce_mix_and_match_products' ) ) {
|
976 |
-
|
977 |
-
/**
|
978 |
-
* Remove empty meta for WooCommerce Mix and Match
|
979 |
-
*
|
980 |
-
* @param array $form Post form data.
|
981 |
-
* @return array
|
982 |
-
*/
|
983 |
-
function tinvwl_add_form_woocommerce_mix_and_match_products( $form = array() ) {
|
984 |
-
if ( array_key_exists( 'mnm_quantity', $form ) ) {
|
985 |
-
if ( is_array( $form['mnm_quantity'] ) && ! empty( $form['mnm_quantity'] ) ) {
|
986 |
-
foreach ( $form['mnm_quantity'] as $key => $value ) {
|
987 |
-
$value = absint( $value );
|
988 |
-
if ( empty( $value ) ) {
|
989 |
-
unset( $form['mnm_quantity'][ $key ] );
|
990 |
-
}
|
991 |
-
}
|
992 |
-
if ( empty( $form['mnm_quantity'] ) ) {
|
993 |
-
unset( $form['mnm_quantity'] );
|
994 |
-
}
|
995 |
-
}
|
996 |
-
}
|
997 |
-
return $form;
|
998 |
-
}
|
999 |
-
|
1000 |
-
add_filter( 'tinvwl_addtowishlist_add_form', 'tinvwl_add_form_woocommerce_mix_and_match_products' );
|
1001 |
-
}
|
1002 |
-
|
1003 |
-
if ( ! function_exists( 'TII18n' ) ) {
|
1004 |
-
|
1005 |
-
/**
|
1006 |
-
* Return TI Yoasti 18n module class
|
1007 |
-
*
|
1008 |
-
* @return \TInvWL_Includes_API_Yoasti18n
|
1009 |
-
*/
|
1010 |
-
function TII18n() { // @codingStandardsIgnoreLine WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
|
1011 |
-
return TInvWL_Includes_API_Yoasti18n::instance();
|
1012 |
-
}
|
1013 |
-
}
|
1014 |
-
|
1015 |
-
// Create a helper function for easy SDK access.
|
1016 |
-
if ( ! function_exists( 'tinvwl_fs' ) ) {
|
1017 |
-
|
1018 |
-
/**
|
1019 |
-
* Freemius
|
1020 |
-
*
|
1021 |
-
* @return array
|
1022 |
-
*/
|
1023 |
-
function tinvwl_fs() {
|
1024 |
-
global $tinvwl_fs;
|
1025 |
-
|
1026 |
-
if ( ! isset( $tinvwl_fs ) ) {
|
1027 |
-
// Include Freemius SDK.
|
1028 |
-
require_once dirname( __FILE__ ) . '/freemius/start.php';
|
1029 |
-
|
1030 |
-
$tinvwl_fs = fs_dynamic_init( array(
|
1031 |
-
'id' => '839',
|
1032 |
-
'slug' => 'ti-woocommerce-wishlist',
|
1033 |
-
'type' => 'plugin',
|
1034 |
-
'public_key' => 'pk_1944d351ab27040c8f65c72d1e7e7',
|
1035 |
-
'is_premium' => false,
|
1036 |
-
'has_premium_version' => false,
|
1037 |
-
'has_addons' => false,
|
1038 |
-
'has_paid_plans' => false,
|
1039 |
-
'menu' => array(
|
1040 |
-
'slug' => 'tinvwl',
|
1041 |
-
'first-path' => 'admin.php?page=tinvwl' . ( get_option( TINVWL_PREFIX . '_wizard' ) ? '' : '-wizard' ),
|
1042 |
-
'account' => false,
|
1043 |
-
'support' => false,
|
1044 |
-
),
|
1045 |
-
) );
|
1046 |
-
}
|
1047 |
-
|
1048 |
-
return $tinvwl_fs;
|
1049 |
-
}
|
1050 |
-
|
1051 |
-
// Init Freemius.
|
1052 |
-
tinvwl_fs();
|
1053 |
-
} // End if().
|
1054 |
-
|
1055 |
-
function tinvwl_fs_custom_connect_message_on_update(
|
1056 |
-
$message, $user_first_name, $plugin_title, $user_login, $site_link,
|
1057 |
-
$freemius_link
|
1058 |
-
) {
|
1059 |
-
return sprintf(
|
1060 |
-
__fs( 'hey-x' ) . '<br>' .
|
1061 |
-
__( 'Please help us improve %2$s! If you opt-in, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'ti-woocommerce-wishlist' ), $user_first_name, '<b>' . $plugin_title . '</b>', '<b>' . $user_login . '</b>', $site_link, $freemius_link
|
1062 |
-
);
|
1063 |
-
}
|
1064 |
-
|
1065 |
-
tinvwl_fs()->add_filter( 'connect_message_on_update', 'tinvwl_fs_custom_connect_message_on_update', 10, 6 );
|
1066 |
-
|
1067 |
-
function tinvwl_fs_custom_connect_message(
|
1068 |
-
$message, $user_first_name, $plugin_title, $user_login, $site_link,
|
1069 |
-
$freemius_link
|
1070 |
-
) {
|
1071 |
-
return sprintf(
|
1072 |
-
__fs( 'hey-x' ) . '<br>' .
|
1073 |
-
__( 'Allow %6$s to collect some usage data with %5$s to make the plugin even more awesome. If you skip this, that\'s okay! %2$s will still work just fine.', 'ti-woocommerce-wishlist' ), $user_first_name, '<b>' . __( 'WooCommerce Wishlist Plugin', 'ti-woocommerce-wishlist' ) . '</b>', '<b>' . $user_login . '</b>', $site_link, $freemius_link, '<b>' . __( 'TemplateInvaders', 'ti-woocommerce-wishlist' ) . '</b>'
|
1074 |
-
);
|
1075 |
-
}
|
1076 |
-
|
1077 |
-
tinvwl_fs()->add_filter( 'connect_message', 'tinvwl_fs_custom_connect_message', 10, 6 );
|
1078 |
-
|
1079 |
-
tinvwl_fs()->add_action( 'after_uninstall', 'uninstall_tinv_wishlist' );
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Support functions for other plugins
|
4 |
+
*
|
5 |
+
* @since 1.5.0
|
6 |
+
* @package TInvWishlist
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
if ( ! function_exists( 'tinvwl_rocket_reject_uri' ) ) {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Disable cache for WP Rocket
|
18 |
+
*
|
19 |
+
* @param array $uri URI.
|
20 |
+
*
|
21 |
+
* @return array
|
22 |
+
*/
|
23 |
+
function tinvwl_rocket_reject_uri( $uri = array() ) {
|
24 |
+
$ids = array(
|
25 |
+
tinv_get_option( 'page', 'wishlist' ),
|
26 |
+
);
|
27 |
+
$pages = $ids;
|
28 |
+
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
29 |
+
'skip_missing' => 0,
|
30 |
+
'orderby' => 'code',
|
31 |
+
) );
|
32 |
+
if ( ! empty( $languages ) ) {
|
33 |
+
foreach ( $ids as $id ) {
|
34 |
+
foreach ( $languages as $l ) {
|
35 |
+
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
36 |
+
}
|
37 |
+
}
|
38 |
+
$pages = array_unique( $pages );
|
39 |
+
}
|
40 |
+
$pages = array_filter( $pages );
|
41 |
+
if ( ! empty( $pages ) ) {
|
42 |
+
foreach ( $pages as $page ) {
|
43 |
+
$uri[] = str_replace( get_site_url(), '', get_permalink( $page ) );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
+
return $uri;
|
48 |
+
}
|
49 |
+
|
50 |
+
add_filter( 'rocket_cache_reject_uri', 'tinvwl_rocket_reject_uri' );
|
51 |
+
} // End if().
|
52 |
+
|
53 |
+
if ( ! function_exists( 'tinvwl_rocket_reject_cookies' ) ) {
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Disable cache for WP Rocket
|
57 |
+
*
|
58 |
+
* @param array $cookies Cookies.
|
59 |
+
*
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
+
function tinvwl_rocket_reject_cookies( $cookies = array() ) {
|
63 |
+
$cookies[] = 'tinv_wishlist';
|
64 |
+
|
65 |
+
return $cookies;
|
66 |
+
}
|
67 |
+
|
68 |
+
add_filter( 'rocket_cache_reject_cookies', 'tinvwl_rocket_reject_cookies' );
|
69 |
+
}
|
70 |
+
|
71 |
+
if ( ! function_exists( 'tinvwl_supercache_reject_uri' ) ) {
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Disable cache for WP Super Cache
|
75 |
+
*
|
76 |
+
* @global array $cache_rejected_uri
|
77 |
+
*
|
78 |
+
* @param string $buffer Intercepted the output of the page.
|
79 |
+
*
|
80 |
+
* @return string
|
81 |
+
*/
|
82 |
+
function tinvwl_supercache_reject_uri( $buffer ) {
|
83 |
+
global $cache_rejected_uri;
|
84 |
+
if ( ! is_null( $cache_rejected_uri ) && is_array( $cache_rejected_uri ) ) {
|
85 |
+
$ids = array(
|
86 |
+
tinv_get_option( 'page', 'wishlist' ),
|
87 |
+
);
|
88 |
+
$pages = $ids;
|
89 |
+
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
90 |
+
'skip_missing' => 0,
|
91 |
+
'orderby' => 'code',
|
92 |
+
) );
|
93 |
+
if ( ! empty( $languages ) ) {
|
94 |
+
foreach ( $ids as $id ) {
|
95 |
+
foreach ( $languages as $l ) {
|
96 |
+
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
97 |
+
}
|
98 |
+
}
|
99 |
+
$pages = array_unique( $pages );
|
100 |
+
}
|
101 |
+
$pages = array_filter( $pages );
|
102 |
+
if ( ! empty( $pages ) ) {
|
103 |
+
foreach ( $pages as $page ) {
|
104 |
+
$cache_rejected_uri[] = str_replace( get_site_url(), '', get_permalink( $page ) );
|
105 |
+
}
|
106 |
+
}
|
107 |
+
}
|
108 |
+
|
109 |
+
return $buffer;
|
110 |
+
}
|
111 |
+
|
112 |
+
add_filter( 'wp_cache_ob_callback_filter', 'tinvwl_supercache_reject_uri' );
|
113 |
+
} // End if().
|
114 |
+
|
115 |
+
if ( ! function_exists( 'tinvwl_w3total_reject_uri' ) ) {
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Disable cache for W3 Total Cache
|
119 |
+
*/
|
120 |
+
function tinvwl_w3total_reject_uri() {
|
121 |
+
if ( ! function_exists( 'w3tc_pgcache_flush' ) || ! function_exists( 'w3_instance' ) ) {
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
$ids = array(
|
125 |
+
tinv_get_option( 'page', 'wishlist' ),
|
126 |
+
);
|
127 |
+
$pages = $ids;
|
128 |
+
$languages = apply_filters( 'wpml_active_languages', array(), array(
|
129 |
+
'skip_missing' => 0,
|
130 |
+
'orderby' => 'code',
|
131 |
+
) );
|
132 |
+
if ( ! empty( $languages ) ) {
|
133 |
+
foreach ( $ids as $id ) {
|
134 |
+
foreach ( $languages as $l ) {
|
135 |
+
$pages[] = apply_filters( 'wpml_object_id', $id, 'page', true, $l['language_code'] );
|
136 |
+
}
|
137 |
+
}
|
138 |
+
$pages = array_unique( $pages );
|
139 |
+
}
|
140 |
+
$pages = array_filter( $pages );
|
141 |
+
if ( ! empty( $pages ) ) {
|
142 |
+
foreach ( $pages as $i => $page ) {
|
143 |
+
$pages[ $i ] = preg_replace( "/^\//", '', str_replace( get_site_url(), '', get_permalink( $page ) ) ); // @codingStandardsIgnoreLine Squiz.Strings.DoubleQuoteUsage.NotRequired
|
144 |
+
}
|
145 |
+
}
|
146 |
+
$pages = array_unique( $pages );
|
147 |
+
$pages = array_filter( $pages );
|
148 |
+
|
149 |
+
if ( ! empty( $pages ) ) {
|
150 |
+
$config = w3_instance( 'W3_Config' );
|
151 |
+
$sections = array( 'dbcache.reject.uri', 'pgcache.reject.uri' );
|
152 |
+
foreach ( $sections as $section ) {
|
153 |
+
$settings = array_map( 'trim', $config->get_array( $section ) );
|
154 |
+
$changed = false;
|
155 |
+
foreach ( $pages as $page ) {
|
156 |
+
if ( ! in_array( $page, $settings ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
|
157 |
+
$settings[] = $page;
|
158 |
+
$changed = true;
|
159 |
+
}
|
160 |
+
}
|
161 |
+
if ( $changed ) {
|
162 |
+
$config->set( $section, $settings );
|
163 |
+
$config->save();
|
164 |
+
}
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
$settings = array_map( 'trim', $config->get_array( 'pgcache.reject.cookie' ) );
|
169 |
+
if ( ! in_array( 'tinv_wishlist', $settings ) ) { // @codingStandardsIgnoreLine WordPress.PHP.StrictInArray.MissingTrueStrict
|
170 |
+
$settings[] = 'tinv_wishlist';
|
171 |
+
$config->set( 'pgcache.reject.cookie', $settings );
|
172 |
+
$config->save();
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
add_action( 'admin_init', 'tinvwl_w3total_reject_uri' );
|
177 |
+
} // End if().
|
178 |
+
|
179 |
+
if ( ! function_exists( 'gf_productaddon_support' ) ) {
|
180 |
+
|
181 |
+
/**
|
182 |
+
* Add supports WooCommerce - Gravity Forms Product Add-Ons
|
183 |
+
*/
|
184 |
+
function gf_productaddon_support() {
|
185 |
+
if ( ! class_exists( 'woocommerce_gravityforms' ) ) {
|
186 |
+
return false;
|
187 |
+
}
|
188 |
+
if ( ! function_exists( 'gf_productaddon_text_button' ) ) {
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Change text for button add to cart
|
192 |
+
*
|
193 |
+
* @param string $text_add_to_card Text "Add to cart".
|
194 |
+
* @param array $wl_product Wishlist product.
|
195 |
+
* @param object $product WooCommerce Product.
|
196 |
+
*
|
197 |
+
* @return string
|
198 |
+
*/
|
199 |
+
function gf_productaddon_text_button( $text_add_to_card, $wl_product, $product ) {
|
200 |
+
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
201 |
+
|
202 |
+
return ( $gravity_form_data ) ? __( 'Select options', 'woocommerce' ) : $text_add_to_card;
|
203 |
+
}
|
204 |
+
|
205 |
+
add_filter( 'tinvwl_wishlist_item_add_to_card', 'gf_productaddon_text_button', 10, 3 );
|
206 |
+
}
|
207 |
+
|
208 |
+
if ( ! function_exists( 'gf_productaddon_run_action_button' ) ) {
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Check for make redirect to url
|
212 |
+
*
|
213 |
+
* @param boolean $need Need redirect or not.
|
214 |
+
* @param object $product WooCommerce Product.
|
215 |
+
*
|
216 |
+
* @return boolean
|
217 |
+
*/
|
218 |
+
function gf_productaddon_run_action_button( $need, $product ) {
|
219 |
+
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
220 |
+
|
221 |
+
return ( $gravity_form_data ) ? true : $need;
|
222 |
+
}
|
223 |
+
|
224 |
+
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'gf_productaddon_run_action_button', 10, 2 );
|
225 |
+
}
|
226 |
+
|
227 |
+
if ( ! function_exists( 'gf_productaddon_action_button' ) ) {
|
228 |
+
|
229 |
+
/**
|
230 |
+
* Redirect url
|
231 |
+
*
|
232 |
+
* @param string $url Redirect URL.
|
233 |
+
* @param object $product WooCommerce Product.
|
234 |
+
*
|
235 |
+
* @return string
|
236 |
+
*/
|
237 |
+
function gf_productaddon_action_button( $url, $product ) {
|
238 |
+
$gravity_form_data = get_post_meta( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), '_gravity_form_data', true );
|
239 |
+
|
240 |
+
return ( $gravity_form_data ) ? $product->get_permalink() : $url;
|
241 |
+
}
|
242 |
+
|
243 |
+
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'gf_productaddon_action_button', 10, 2 );
|
244 |
+
}
|
245 |
+
}
|
246 |
+
|
247 |
+
add_action( 'init', 'gf_productaddon_support' );
|
248 |
+
} // End if().
|
249 |
+
|
250 |
+
if ( ! function_exists( 'tinvwl_wpml_product_get' ) ) {
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Change product data if product need translate
|
254 |
+
*
|
255 |
+
* @param array $product Wishlistl product.
|
256 |
+
*
|
257 |
+
* @return array
|
258 |
+
*/
|
259 |
+
function tinvwl_wpml_product_get( $product ) {
|
260 |
+
if ( array_key_exists( 'data', $product ) ) {
|
261 |
+
$_product_id = $product_id = $product['product_id'];
|
262 |
+
$_variation_id = $variation_id = $product['variation_id'];
|
263 |
+
$_product_id = apply_filters( 'wpml_object_id', $_product_id, 'product', true );
|
264 |
+
if ( ! empty( $_variation_id ) ) {
|
265 |
+
$_variation_id = apply_filters( 'wpml_object_id', $_variation_id, 'product', true );
|
266 |
+
}
|
267 |
+
if ( $_product_id !== $product_id || $_variation_id !== $variation_id ) {
|
268 |
+
$product['data'] = wc_get_product( $variation_id ? $_variation_id : $_product_id );
|
269 |
+
}
|
270 |
+
}
|
271 |
+
|
272 |
+
return $product;
|
273 |
+
}
|
274 |
+
|
275 |
+
add_filter( 'tinvwl_wishlist_product_get', 'tinvwl_wpml_product_get' );
|
276 |
+
}
|
277 |
+
|
278 |
+
if ( ! function_exists( 'tinvwl_wpml_filter_link' ) ) {
|
279 |
+
|
280 |
+
/**
|
281 |
+
* Corect add wishlist key for WPML plugin.
|
282 |
+
*
|
283 |
+
* @param string $full_link Link for page.
|
284 |
+
* @param array $l Language.
|
285 |
+
*
|
286 |
+
* @return string
|
287 |
+
*/
|
288 |
+
function tinvwl_wpml_filter_link( $full_link, $l ) {
|
289 |
+
$share_key = get_query_var( 'tinvwlID', null );
|
290 |
+
if ( ! empty( $share_key ) ) {
|
291 |
+
if ( get_option( 'permalink_structure' ) ) {
|
292 |
+
$suffix = '';
|
293 |
+
if ( preg_match( '/([^\?]+)\?*?(.*)/i', $full_link, $_full_link ) ) {
|
294 |
+
$full_link = $_full_link[1];
|
295 |
+
$suffix = $_full_link[2];
|
296 |
+
}
|
297 |
+
if ( ! preg_match( '/\/$/', $full_link ) ) {
|
298 |
+
$full_link .= '/';
|
299 |
+
}
|
300 |
+
$full_link .= $share_key . '/' . $suffix;
|
301 |
+
} else {
|
302 |
+
$full_link .= add_query_arg( 'tinvwlID', $share_key, $full_link );
|
303 |
+
}
|
304 |
+
}
|
305 |
+
|
306 |
+
return $full_link;
|
307 |
+
}
|
308 |
+
|
309 |
+
add_filter( 'WPML_filter_link', 'tinvwl_wpml_filter_link', 0, 2 );
|
310 |
+
}
|
311 |
+
|
312 |
+
if ( ! function_exists( 'tinvwl_gift_card_add' ) ) {
|
313 |
+
|
314 |
+
/**
|
315 |
+
* Support WooCommerce - Gift Cards
|
316 |
+
* Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
|
317 |
+
*
|
318 |
+
* @param boolean $redirect Default value to redirect.
|
319 |
+
* @param \WC_Product $product Product data.
|
320 |
+
*
|
321 |
+
* @return boolean
|
322 |
+
*/
|
323 |
+
function tinvwl_gift_card_add( $redirect, $product ) {
|
324 |
+
if ( $redirect ) {
|
325 |
+
return true;
|
326 |
+
}
|
327 |
+
$is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
|
328 |
+
|
329 |
+
if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
|
330 |
+
$is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
|
331 |
+
if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
|
332 |
+
return true;
|
333 |
+
}
|
334 |
+
}
|
335 |
+
|
336 |
+
return $redirect;
|
337 |
+
}
|
338 |
+
|
339 |
+
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_gift_card_add', 20, 2 );
|
340 |
+
}
|
341 |
+
|
342 |
+
if ( ! function_exists( 'tinvwl_gift_card_add_url' ) ) {
|
343 |
+
|
344 |
+
/**
|
345 |
+
* Support WooCommerce - Gift Cards
|
346 |
+
* Redirect to page gift card, if requires that customers enter a name and email when purchasing a Gift Card.
|
347 |
+
*
|
348 |
+
* @param string $redirect_url Default value to redirect.
|
349 |
+
* @param \WC_Product $product Product data.
|
350 |
+
*
|
351 |
+
* @return boolean
|
352 |
+
*/
|
353 |
+
function tinvwl_gift_card_add_url( $redirect_url, $product ) {
|
354 |
+
$is_required_field_giftcard = get_option( 'woocommerce_enable_giftcard_info_requirements' );
|
355 |
+
|
356 |
+
if ( 'yes' == $is_required_field_giftcard ) { // WPCS: loose comparison ok.
|
357 |
+
$is_giftcard = get_post_meta( $product->get_id(), '_giftcard', true );
|
358 |
+
if ( 'yes' == $is_giftcard ) { // WPCS: loose comparison ok.
|
359 |
+
return $product->get_permalink();
|
360 |
+
}
|
361 |
+
}
|
362 |
+
|
363 |
+
return $redirect_url;
|
364 |
+
}
|
365 |
+
|
366 |
+
add_filter( 'tinvwl_product_add_to_cart_redirect_url', 'tinvwl_gift_card_add_url', 20, 2 );
|
367 |
+
}
|
368 |
+
|
369 |
+
if ( ! function_exists( 'tinv_wishlist_meta_support_rpgiftcards' ) ) {
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Set descrition for meta WooCommerce - Gift Cards
|
373 |
+
*
|
374 |
+
* @param array $meta Meta array.
|
375 |
+
*
|
376 |
+
* @return array
|
377 |
+
*/
|
378 |
+
function tinv_wishlist_metasupport_rpgiftcards( $meta ) {
|
379 |
+
foreach ( $meta as $key => $data ) {
|
380 |
+
switch ( $data['key'] ) {
|
381 |
+
case 'rpgc_note':
|
382 |
+
$meta[ $key ]['key'] = __( 'Note', 'rpgiftcards' );
|
383 |
+
break;
|
384 |
+
case 'rpgc_to':
|
385 |
+
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_to' ) <> null ? get_option( 'woocommerce_giftcard_to' ) : __( 'To', 'rpgiftcards' ) ); // WPCS: loose comparison ok.
|
386 |
+
break;
|
387 |
+
case 'rpgc_to_email':
|
388 |
+
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_toEmail' ) <> null ? get_option( 'woocommerce_giftcard_toEmail' ) : __( 'To Email', 'rpgiftcards' ) ); // WPCS: loose comparison ok.
|
389 |
+
break;
|
390 |
+
case 'rpgc_address':
|
391 |
+
$meta[ $key ]['key'] = ( get_option( 'woocommerce_giftcard_address' ) <> null ? get_option( 'woocommerce_giftcard_address' ) : __( 'Address', 'rpgiftcards' ) ); // WPCS: loose comparison ok.
|
392 |
+
break;
|
393 |
+
case 'rpgc_reload_card':
|
394 |
+
$meta[ $key ]['key'] = __( 'Reload existing Gift Card', 'rpgiftcards' );
|
395 |
+
break;
|
396 |
+
case 'rpgc_description':
|
397 |
+
case 'rpgc_reload_check':
|
398 |
+
unset( $meta[ $key ] );
|
399 |
+
break;
|
400 |
+
}
|
401 |
+
}
|
402 |
+
|
403 |
+
return $meta;
|
404 |
+
}
|
405 |
+
|
406 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_rpgiftcards' );
|
407 |
+
} // End if().
|
408 |
+
|
409 |
+
if ( ! function_exists( 'tinv_wishlist_metaprepare_rpgiftcards' ) ) {
|
410 |
+
|
411 |
+
/**
|
412 |
+
* Prepare save meta for WooCommerce - Gift Cards
|
413 |
+
*
|
414 |
+
* @param array $meta Meta array.
|
415 |
+
*
|
416 |
+
* @return array
|
417 |
+
*/
|
418 |
+
function tinv_wishlist_metaprepare_rpgiftcards( $meta ) {
|
419 |
+
if ( array_key_exists( 'rpgc_reload_check', $meta ) ) {
|
420 |
+
foreach ( array( 'rpgc_note', 'rpgc_to', 'rpgc_to_email', 'rpgc_address' ) as $value ) {
|
421 |
+
if ( array_key_exists( $value, $meta ) ) {
|
422 |
+
unset( $meta[ $value ] );
|
423 |
+
}
|
424 |
+
}
|
425 |
+
}
|
426 |
+
|
427 |
+
return $meta;
|
428 |
+
}
|
429 |
+
|
430 |
+
add_filter( 'tinvwl_product_prepare_meta', 'tinv_wishlist_metaprepare_rpgiftcards' );
|
431 |
+
}
|
432 |
+
|
433 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_bookings' ) ) {
|
434 |
+
|
435 |
+
/**
|
436 |
+
* Set descrition for meta WooCommerce Bookings
|
437 |
+
*
|
438 |
+
* @param array $meta Meta array.
|
439 |
+
* @param integer $product_id Priduct ID.
|
440 |
+
* @param integer $variation_id Variation Product ID.
|
441 |
+
*
|
442 |
+
* @return array
|
443 |
+
*/
|
444 |
+
function tinv_wishlist_metasupport_woocommerce_bookings( $meta, $product_id, $variation_id ) {
|
445 |
+
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
446 |
+
return $meta;
|
447 |
+
}
|
448 |
+
$product = wc_get_product( $variation_id ? $variation_id : $product_id );
|
449 |
+
if ( is_wc_booking_product( $product ) ) {
|
450 |
+
$booking_form = new WC_Booking_Form( $product );
|
451 |
+
$post_data = array();
|
452 |
+
foreach ( $meta as $data ) {
|
453 |
+
$post_data[ $data['key'] ] = $data['display'];
|
454 |
+
}
|
455 |
+
$booking_data = $booking_form->get_posted_data( $post_data );
|
456 |
+
$meta = array();
|
457 |
+
foreach ( $booking_data as $key => $value ) {
|
458 |
+
if ( ! preg_match( '/^_/', $key ) ) {
|
459 |
+
$meta[ $key ] = array(
|
460 |
+
'key' => get_wc_booking_data_label( $key, $product ),
|
461 |
+
'display' => $value,
|
462 |
+
);
|
463 |
+
}
|
464 |
+
}
|
465 |
+
}
|
466 |
+
|
467 |
+
return $meta;
|
468 |
+
}
|
469 |
+
|
470 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_bookings', 10, 3 );
|
471 |
+
} // End if().
|
472 |
+
|
473 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_bookings' ) ) {
|
474 |
+
|
475 |
+
/**
|
476 |
+
* Modify price for WooCommerce Bookings
|
477 |
+
*
|
478 |
+
* @param string $price Returned price.
|
479 |
+
* @param array $wl_product Wishlist Product.
|
480 |
+
* @param \WC_Product $product Woocommerce Product.
|
481 |
+
*
|
482 |
+
* @return string
|
483 |
+
*/
|
484 |
+
function tinvwl_item_price_woocommerce_bookings( $price, $wl_product, $product ) {
|
485 |
+
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
486 |
+
return $price;
|
487 |
+
}
|
488 |
+
if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
|
489 |
+
$booking_form = new WC_Booking_Form( $product );
|
490 |
+
$cost = $booking_form->calculate_booking_cost( $wl_product['meta'] );
|
491 |
+
if ( is_wp_error( $cost ) ) {
|
492 |
+
return $price;
|
493 |
+
}
|
494 |
+
|
495 |
+
$tax_display_mode = get_option( 'woocommerce_tax_display_shop' );
|
496 |
+
|
497 |
+
if ( 'incl' === get_option( 'woocommerce_tax_display_shop' ) ) {
|
498 |
+
if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
|
499 |
+
$display_price = wc_get_price_including_tax( $product, array( 'price' => $cost ) );
|
500 |
+
} else {
|
501 |
+
$display_price = $product->get_price_including_tax( 1, $cost );
|
502 |
+
}
|
503 |
+
} else {
|
504 |
+
if ( function_exists( 'wc_get_price_excluding_tax' ) ) {
|
505 |
+
$display_price = wc_get_price_excluding_tax( $product, array( 'price' => $cost ) );
|
506 |
+
} else {
|
507 |
+
$display_price = $product->get_price_excluding_tax( 1, $cost );
|
508 |
+
}
|
509 |
+
}
|
510 |
+
|
511 |
+
if ( version_compare( WC_VERSION, '2.4.0', '>=' ) ) {
|
512 |
+
$price_suffix = $product->get_price_suffix( $cost, 1 );
|
513 |
+
} else {
|
514 |
+
$price_suffix = $product->get_price_suffix();
|
515 |
+
}
|
516 |
+
$price = wc_price( $display_price ) . $price_suffix;
|
517 |
+
}
|
518 |
+
|
519 |
+
return $price;
|
520 |
+
}
|
521 |
+
|
522 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_bookings', 10, 3 );
|
523 |
+
} // End if().
|
524 |
+
|
525 |
+
if ( ! function_exists( 'tinvwl_item_status_woocommerce_bookings' ) ) {
|
526 |
+
|
527 |
+
/**
|
528 |
+
* Modify availability for WooCommerce Bookings
|
529 |
+
*
|
530 |
+
* @param string $status Status availability.
|
531 |
+
* @param string $availability Default availability.
|
532 |
+
* @param array $wl_product Wishlist Product.
|
533 |
+
* @param \WC_Product $product Woocommerce Product.
|
534 |
+
*
|
535 |
+
* @return type
|
536 |
+
*/
|
537 |
+
function tinvwl_item_status_woocommerce_bookings( $status, $availability, $wl_product, $product ) {
|
538 |
+
if ( ! class_exists( 'WC_Booking_Form' ) || ! function_exists( 'is_wc_booking_product' ) ) {
|
539 |
+
return $status;
|
540 |
+
}
|
541 |
+
if ( is_wc_booking_product( $product ) && array_key_exists( 'meta', $wl_product ) ) {
|
542 |
+
$booking_form = new WC_Booking_Form( $product );
|
543 |
+
$cost = $booking_form->calculate_booking_cost( $wl_product['meta'] );
|
544 |
+
if ( is_wp_error( $cost ) ) {
|
545 |
+
return '<p class="stock out-of-stock"><span><i class="fa fa-times"></i></span><span>' . $cost->get_error_message() . '</span></p>';
|
546 |
+
}
|
547 |
+
}
|
548 |
+
|
549 |
+
return $status;
|
550 |
+
}
|
551 |
+
|
552 |
+
add_filter( 'tinvwl_wishlist_item_status', 'tinvwl_item_status_woocommerce_bookings', 10, 4 );
|
553 |
+
}
|
554 |
+
|
555 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_wc_gf_addons' ) ) {
|
556 |
+
|
557 |
+
/**
|
558 |
+
* Set descrition for meta WooCommerce - Gravity Forms Product Add-Ons
|
559 |
+
*
|
560 |
+
* @param array $meta Meta array.
|
561 |
+
*
|
562 |
+
* @return array
|
563 |
+
*/
|
564 |
+
function tinv_wishlist_metasupport_wc_gf_addons( $meta ) {
|
565 |
+
if ( array_key_exists( 'wc_gforms_form_id', $meta ) && class_exists( 'RGFormsModel' ) ) {
|
566 |
+
$form_meta = RGFormsModel::get_form_meta( $meta['wc_gforms_form_id']['display'] );
|
567 |
+
if ( array_key_exists( 'fields', $form_meta ) ) {
|
568 |
+
$_meta = array();
|
569 |
+
foreach ( $form_meta['fields'] as $field ) {
|
570 |
+
$field_name = $field->get_first_input_id( array( 'id' => 0 ) );
|
571 |
+
if ( array_key_exists( $field_name, $meta ) ) {
|
572 |
+
$meta[ $field_name ]['key'] = $field->label;
|
573 |
+
$_meta[ $field_name ] = $meta[ $field_name ];
|
574 |
+
}
|
575 |
+
}
|
576 |
+
$meta = $_meta;
|
577 |
+
}
|
578 |
+
}
|
579 |
+
|
580 |
+
return $meta;
|
581 |
+
}
|
582 |
+
|
583 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_wc_gf_addons' );
|
584 |
+
}
|
585 |
+
|
586 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_composite_products' ) ) {
|
587 |
+
|
588 |
+
/**
|
589 |
+
* Set descrition for meta WooCommerce Composite Products
|
590 |
+
*
|
591 |
+
* @param array $meta Meta array.
|
592 |
+
* @param integer $product_id Product ID.
|
593 |
+
*
|
594 |
+
* @return array
|
595 |
+
*/
|
596 |
+
function tinv_wishlist_metasupport_woocommerce_composite_products( $meta, $product_id ) {
|
597 |
+
if ( array_key_exists( 'wccp_component_selection', $meta ) && is_array( $meta['wccp_component_selection'] ) ) {
|
598 |
+
$meta = array();
|
599 |
+
} // End if().
|
600 |
+
|
601 |
+
return $meta;
|
602 |
+
}
|
603 |
+
|
604 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_composite_products', 10, 2 );
|
605 |
+
} // End if().
|
606 |
+
|
607 |
+
if ( ! function_exists( 'tinvwl_row_woocommerce_composite_products' ) ) {
|
608 |
+
|
609 |
+
/**
|
610 |
+
* Add rows for sub product for WooCommerce Composite Products
|
611 |
+
*
|
612 |
+
* @param array $wl_product Wishlist Product.
|
613 |
+
* @param \WC_Product $product Woocommerce Product.
|
614 |
+
*/
|
615 |
+
function tinvwl_row_woocommerce_composite_products( $wl_product, $product ) {
|
616 |
+
if ( is_object( $product ) && $product->is_type( 'composite' ) && array_key_exists( 'wccp_component_selection', $wl_product['meta'] ) ) {
|
617 |
+
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
618 |
+
|
619 |
+
$components = $product->get_components();
|
620 |
+
foreach ( $components as $component_id => $component ) {
|
621 |
+
$composited_product_id = ! empty( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_selection'][ $component_id ] ) : '';
|
622 |
+
$composited_product_quantity = isset( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) ? absint( $wl_product['meta']['wccp_component_quantity'][ $component_id ] ) : $component->get_quantity( 'min' );
|
623 |
+
|
624 |
+
$composited_variation_id = isset( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) ? wc_clean( $wl_product['meta']['wccp_variation_id'][ $component_id ] ) : '';
|
625 |
+
|
626 |
+
if ( $composited_product_id ) {
|
627 |
+
|
628 |
+
$composited_product_wrapper = $component->get_option( $composited_variation_id ? $composited_variation_id : $composited_product_id );
|
629 |
+
|
630 |
+
if ( ! $composited_product_wrapper ) {
|
631 |
+
continue;
|
632 |
+
}
|
633 |
+
|
634 |
+
$composited_product = $composited_product_wrapper->get_product();
|
635 |
+
|
636 |
+
if ( $composited_product->is_sold_individually() && $composited_product_quantity > 1 ) {
|
637 |
+
$composited_product_quantity = 1;
|
638 |
+
}
|
639 |
+
|
640 |
+
$product_url = $composited_product->get_permalink();
|
641 |
+
$product_image = $composited_product->get_image();
|
642 |
+
$product_title = $composited_product->get_title();
|
643 |
+
$product_price = $composited_product->get_price_html();
|
644 |
+
if ( $composited_product->is_visible() ) {
|
645 |
+
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
646 |
+
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
647 |
+
}
|
648 |
+
$product_title .= tinv_wishlist_get_item_data( $composited_product, $wl_product );
|
649 |
+
|
650 |
+
$availability = (array) $composited_product->get_availability();
|
651 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
652 |
+
$availability['availability'] = '';
|
653 |
+
}
|
654 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
655 |
+
$availability['class'] = '';
|
656 |
+
}
|
657 |
+
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
658 |
+
$row_string = '<tr>';
|
659 |
+
$row_string .= '<td colspan="2"></td> <td class="product-thumbnail">%2$s</td><td class="product-name">%1$s:<br/>%3$s</td>';
|
660 |
+
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
661 |
+
$row_string .= '<td class="product-price">%3$s × %6$s</td>';
|
662 |
+
}
|
663 |
+
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
664 |
+
$row_string .= '<td class="product-date"> </td>';
|
665 |
+
}
|
666 |
+
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
667 |
+
$row_string .= '<td class="product-stock">%5$s</td>';
|
668 |
+
}
|
669 |
+
if ( tinv_get_option( 'product_table', 'add_to_card' ) ) {
|
670 |
+
$row_string .= '<td class="product-action"> </td>';
|
671 |
+
}
|
672 |
+
$row_string .= '</tr>';
|
673 |
+
|
674 |
+
echo sprintf( $row_string, $component->get_title(), $product_image, $product_title, $product_price, $availability_html, $composited_product_quantity * $product_quantity ); // WPCS: xss ok.
|
675 |
+
} // End if().
|
676 |
+
} // End foreach().
|
677 |
+
} // End if().
|
678 |
+
}
|
679 |
+
|
680 |
+
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_composite_products', 10, 2 );
|
681 |
+
} // End if().
|
682 |
+
|
683 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_product_bundles' ) ) {
|
684 |
+
|
685 |
+
/**
|
686 |
+
* Set descrition for meta WooCommerce Product Bundles
|
687 |
+
*
|
688 |
+
* @param array $meta Meta array.
|
689 |
+
* @param integer $product_id Product ID.
|
690 |
+
*
|
691 |
+
* @return array
|
692 |
+
*/
|
693 |
+
function tinv_wishlist_metasupport_woocommerce_product_bundles( $meta, $product_id ) {
|
694 |
+
$bundled_item_id = 1;
|
695 |
+
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
696 |
+
if ( array_key_exists( $bundled_item_quantity_request_key, $meta ) ) {
|
697 |
+
$meta = array();
|
698 |
+
}
|
699 |
+
|
700 |
+
return $meta;
|
701 |
+
}
|
702 |
+
|
703 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_product_bundles', 10, 2 );
|
704 |
+
} // End if().
|
705 |
+
|
706 |
+
if ( ! function_exists( 'tinvwl_row_woocommerce_product_bundles' ) ) {
|
707 |
+
|
708 |
+
/**
|
709 |
+
* Add rows for sub product for WooCommerce Product Bundles
|
710 |
+
*
|
711 |
+
* @param array $wl_product Wishlist Product.
|
712 |
+
* @param \WC_Product $product Woocommerce Product.
|
713 |
+
*/
|
714 |
+
function tinvwl_row_woocommerce_product_bundles( $wl_product, $product ) {
|
715 |
+
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
716 |
+
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
717 |
+
|
718 |
+
$product_id = WC_PB_Core_Compatibility::get_id( $product );
|
719 |
+
$bundled_items = $product->get_bundled_items();
|
720 |
+
if ( ! empty( $bundled_items ) ) {
|
721 |
+
foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
|
722 |
+
$bundled_product_id = $bundled_item->product_id;
|
723 |
+
$bundled_product_type = $bundled_item->product->get_type();
|
724 |
+
$is_optional = $bundled_item->is_optional();
|
725 |
+
|
726 |
+
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
727 |
+
$bundled_product_qty = isset( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) ? absint( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) : $bundled_item->get_quantity();
|
728 |
+
|
729 |
+
if ( $is_optional ) {
|
730 |
+
|
731 |
+
/** Documented in method 'get_posted_bundle_configuration'. */
|
732 |
+
$bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
|
733 |
+
|
734 |
+
if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
|
735 |
+
$bundled_product_qty = 0;
|
736 |
+
}
|
737 |
+
}
|
738 |
+
if ( 0 === $bundled_product_qty ) {
|
739 |
+
continue;
|
740 |
+
}
|
741 |
+
|
742 |
+
$product_url = $bundled_item->product->get_permalink();
|
743 |
+
$product_image = $bundled_item->product->get_image();
|
744 |
+
$product_title = $bundled_item->product->get_title();
|
745 |
+
$product_price = $bundled_item->product->get_price_html();
|
746 |
+
if ( $bundled_item->product->is_visible() ) {
|
747 |
+
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
748 |
+
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
749 |
+
}
|
750 |
+
$product_title .= tinv_wishlist_get_item_data( $bundled_item->product, $wl_product );
|
751 |
+
|
752 |
+
$availability = (array) $bundled_item->product->get_availability();
|
753 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
754 |
+
$availability['availability'] = '';
|
755 |
+
}
|
756 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
757 |
+
$availability['class'] = '';
|
758 |
+
}
|
759 |
+
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
760 |
+
$row_string = '<tr>';
|
761 |
+
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
762 |
+
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
763 |
+
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
764 |
+
}
|
765 |
+
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
766 |
+
$row_string .= '<td class="product-date"> </td>';
|
767 |
+
}
|
768 |
+
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
769 |
+
$row_string .= '<td class="product-stock">%4$s</td>';
|
770 |
+
}
|
771 |
+
|
772 |
+
if ( tinv_get_option( 'product_table', 'add_to_card' ) ) {
|
773 |
+
$row_string .= '<td class="product-action"> </td>';
|
774 |
+
}
|
775 |
+
$row_string .= '</tr>';
|
776 |
+
|
777 |
+
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $bundled_product_qty ); // WPCS: xss ok.
|
778 |
+
} // End foreach().
|
779 |
+
} // End if().
|
780 |
+
} // End if().
|
781 |
+
}
|
782 |
+
|
783 |
+
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_product_bundles', 10, 2 );
|
784 |
+
} // End if().
|
785 |
+
|
786 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_product_bundles' ) ) {
|
787 |
+
|
788 |
+
/**
|
789 |
+
* Modify price for WooCommerce Product Bundles
|
790 |
+
*
|
791 |
+
* @param string $price Returned price.
|
792 |
+
* @param array $wl_product Wishlist Product.
|
793 |
+
* @param \WC_Product $product Woocommerce Product.
|
794 |
+
*
|
795 |
+
* @return string
|
796 |
+
*/
|
797 |
+
function tinvwl_item_price_woocommerce_product_bundles( $price, $wl_product, $product ) {
|
798 |
+
if ( is_object( $product ) && $product->is_type( 'bundle' ) ) {
|
799 |
+
|
800 |
+
$bundle_price = $product->get_price();
|
801 |
+
$product_id = WC_PB_Core_Compatibility::get_id( $product );
|
802 |
+
$bundled_items = $product->get_bundled_items();
|
803 |
+
|
804 |
+
if ( ! empty( $bundled_items ) ) {
|
805 |
+
|
806 |
+
$bundled_items_price = 0.0;
|
807 |
+
|
808 |
+
foreach ( $bundled_items as $bundled_item_id => $bundled_item ) {
|
809 |
+
$is_optional = $bundled_item->is_optional();
|
810 |
+
|
811 |
+
$bundled_item_quantity_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_quantity_' . $bundled_item_id;
|
812 |
+
$bundled_product_qty = isset( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) ? absint( $wl_product['meta'][ $bundled_item_quantity_request_key ] ) : $bundled_item->get_quantity();
|
813 |
+
|
814 |
+
if ( $is_optional ) {
|
815 |
+
|
816 |
+
/** Documented in method 'get_posted_bundle_configuration'. */
|
817 |
+
$bundled_item_selected_request_key = apply_filters( 'woocommerce_product_bundle_field_prefix', '', $product_id ) . 'bundle_selected_optional_' . $bundled_item_id;
|
818 |
+
|
819 |
+
if ( ! array_key_exists( $bundled_item_selected_request_key, $wl_product['meta'] ) ) {
|
820 |
+
$bundled_product_qty = 0;
|
821 |
+
}
|
822 |
+
}
|
823 |
+
if ( 0 === $bundled_product_qty ) {
|
824 |
+
continue;
|
825 |
+
}
|
826 |
+
|
827 |
+
$bundled_item_price = $bundled_item->product->get_price() * $bundled_product_qty;
|
828 |
+
|
829 |
+
$bundled_items_price += (double) $bundled_item_price;
|
830 |
+
|
831 |
+
} // End foreach().
|
832 |
+
$price = wc_price( (double) $bundle_price + $bundled_items_price );
|
833 |
+
$price = apply_filters( 'woocommerce_get_price_html', $price, $product );
|
834 |
+
} // End if().
|
835 |
+
} // End if().
|
836 |
+
|
837 |
+
return $price;
|
838 |
+
}
|
839 |
+
|
840 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_product_bundles', 10, 3 );
|
841 |
+
} // End if().
|
842 |
+
|
843 |
+
if ( ! function_exists( 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products' ) ) {
|
844 |
+
|
845 |
+
/**
|
846 |
+
* Set descrition for meta WooCommerce Mix and Match
|
847 |
+
*
|
848 |
+
* @param array $meta Meta array.
|
849 |
+
* @param integer $product_id Product ID.
|
850 |
+
*
|
851 |
+
* @return array
|
852 |
+
*/
|
853 |
+
function tinv_wishlist_metasupport_woocommerce_mix_and_match_products( $meta, $product_id ) {
|
854 |
+
if ( array_key_exists( 'mnm_quantity', $meta ) ) {
|
855 |
+
$product = wc_get_product( $product_id );
|
856 |
+
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) ) {
|
857 |
+
$meta = array();
|
858 |
+
}
|
859 |
+
}
|
860 |
+
|
861 |
+
return $meta;
|
862 |
+
}
|
863 |
+
|
864 |
+
add_filter( 'tinvwl_wishlist_item_meta_post', 'tinv_wishlist_metasupport_woocommerce_mix_and_match_products', 10, 2 );
|
865 |
+
} // End if().
|
866 |
+
|
867 |
+
if ( ! function_exists( 'tinvwl_row_woocommerce_mix_and_match_products' ) ) {
|
868 |
+
|
869 |
+
/**
|
870 |
+
* Add rows for sub product for WooCommerce Mix and Match
|
871 |
+
*
|
872 |
+
* @param array $wl_product Wishlist Product.
|
873 |
+
* @param \WC_Product $product Woocommerce Product.
|
874 |
+
*/
|
875 |
+
function tinvwl_row_woocommerce_mix_and_match_products( $wl_product, $product ) {
|
876 |
+
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && array_key_exists( 'mnm_quantity', $wl_product['meta'] ) ) {
|
877 |
+
$product_quantity = $product->is_sold_individually() ? 1 : $wl_product['quantity'];
|
878 |
+
$mnm_items = $product->get_children();
|
879 |
+
if ( ! empty( $mnm_items ) ) {
|
880 |
+
foreach ( $mnm_items as $id => $mnm_item ) {
|
881 |
+
$item_quantity = 0;
|
882 |
+
if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
|
883 |
+
$item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
|
884 |
+
}
|
885 |
+
if ( 0 >= $item_quantity ) {
|
886 |
+
continue;
|
887 |
+
}
|
888 |
+
|
889 |
+
$product_url = $mnm_item->get_permalink();
|
890 |
+
$product_image = $mnm_item->get_image();
|
891 |
+
$product_title = $mnm_item->get_title();
|
892 |
+
$product_price = $mnm_item->get_price_html();
|
893 |
+
if ( $mnm_item->is_visible() ) {
|
894 |
+
$product_image = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_image );
|
895 |
+
$product_title = sprintf( '<a href="%s">%s</a>', esc_url( $product_url ), $product_title );
|
896 |
+
}
|
897 |
+
$product_title .= tinv_wishlist_get_item_data( $mnm_item, $wl_product );
|
898 |
+
|
899 |
+
$availability = (array) $mnm_item->get_availability();
|
900 |
+
if ( ! array_key_exists( 'availability', $availability ) ) {
|
901 |
+
$availability['availability'] = '';
|
902 |
+
}
|
903 |
+
if ( ! array_key_exists( 'class', $availability ) ) {
|
904 |
+
$availability['class'] = '';
|
905 |
+
}
|
906 |
+
$availability_html = empty( $availability['availability'] ) ? '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-check"></i></span><span class="tinvwl-txt">' . esc_html__( 'In stock', 'ti-woocommerce-wishlist-premium' ) . '</span></p>' : '<p class="stock ' . esc_attr( $availability['class'] ) . '"><span><i class="fa fa-times"></i></span><span>' . esc_html( $availability['availability'] ) . '</span></p>';
|
907 |
+
$row_string = '<tr>';
|
908 |
+
$row_string .= '<td colspan="2"> </td><td class="product-thumbnail">%1$s</td><td class="product-name">%2$s</td>';
|
909 |
+
if ( tinv_get_option( 'product_table', 'colm_price' ) ) {
|
910 |
+
$row_string .= '<td class="product-price">%3$s × %5$s</td>';
|
911 |
+
}
|
912 |
+
if ( tinv_get_option( 'product_table', 'colm_date' ) ) {
|
913 |
+
$row_string .= '<td class="product-date"> </td>';
|
914 |
+
}
|
915 |
+
if ( tinv_get_option( 'product_table', 'colm_stock' ) ) {
|
916 |
+
$row_string .= '<td class="product-stock">%4$s</td>';
|
917 |
+
}
|
918 |
+
if ( tinv_get_option( 'product_table', 'add_to_card' ) ) {
|
919 |
+
$row_string .= '<td class="product-action"> </td>';
|
920 |
+
}
|
921 |
+
$row_string .= '</tr>';
|
922 |
+
|
923 |
+
echo sprintf( $row_string, $product_image, $product_title, $product_price, $availability_html, $item_quantity * $product_quantity ); // WPCS: xss ok.
|
924 |
+
} // End foreach().
|
925 |
+
} // End if().
|
926 |
+
} // End if().
|
927 |
+
}
|
928 |
+
|
929 |
+
add_action( 'tinvwl_wishlist_row_after', 'tinvwl_row_woocommerce_mix_and_match_products', 10, 2 );
|
930 |
+
} // End if().
|
931 |
+
|
932 |
+
if ( ! function_exists( 'tinvwl_item_price_woocommerce_mix_and_match_products' ) ) {
|
933 |
+
|
934 |
+
/**
|
935 |
+
* Modify price for WooCommerce Mix and Match
|
936 |
+
*
|
937 |
+
* @param string $price Returned price.
|
938 |
+
* @param array $wl_product Wishlist Product.
|
939 |
+
* @param \WC_Product $product Woocommerce Product.
|
940 |
+
*
|
941 |
+
* @return string
|
942 |
+
*/
|
943 |
+
function tinvwl_item_price_woocommerce_mix_and_match_products( $price, $wl_product, $product ) {
|
944 |
+
if ( is_object( $product ) && $product->is_type( 'mix-and-match' ) && $product->is_priced_per_product() ) {
|
945 |
+
$mnm_items = $product->get_children();
|
946 |
+
if ( ! empty( $mnm_items ) ) {
|
947 |
+
$_price = 0;
|
948 |
+
foreach ( $mnm_items as $id => $mnm_item ) {
|
949 |
+
$item_quantity = 0;
|
950 |
+
if ( array_key_exists( $id, $wl_product['meta']['mnm_quantity'] ) ) {
|
951 |
+
$item_quantity = absint( $wl_product['meta']['mnm_quantity'][ $id ] );
|
952 |
+
}
|
953 |
+
if ( 0 >= $item_quantity ) {
|
954 |
+
continue;
|
955 |
+
}
|
956 |
+
$_price += wc_get_price_to_display( $mnm_item, array( 'qty' => $item_quantity ) );
|
957 |
+
}
|
958 |
+
if ( 0 < $_price ) {
|
959 |
+
if ( $product->is_on_sale() ) {
|
960 |
+
$price = wc_format_sale_price( $_price + wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ), $_price + wc_get_price_to_display( $product ) ) . $product->get_price_suffix();
|
961 |
+
} else {
|
962 |
+
$price = wc_price( $_price + wc_get_price_to_display( $product ) ) . $product->get_price_suffix();
|
963 |
+
}
|
964 |
+
$price = apply_filters( 'woocommerce_get_price_html', $price, $product );
|
965 |
+
}
|
966 |
+
}
|
967 |
+
}
|
968 |
+
|
969 |
+
return $price;
|
970 |
+
}
|
971 |
+
|
972 |
+
add_filter( 'tinvwl_wishlist_item_price', 'tinvwl_item_price_woocommerce_mix_and_match_products', 10, 3 );
|
973 |
+
} // End if().
|
974 |
+
|
975 |
+
if ( ! function_exists( 'tinvwl_add_form_woocommerce_mix_and_match_products' ) ) {
|
976 |
+
|
977 |
+
/**
|
978 |
+
* Remove empty meta for WooCommerce Mix and Match
|
979 |
+
*
|
980 |
+
* @param array $form Post form data.
|
981 |
+
* @return array
|
982 |
+
*/
|
983 |
+
function tinvwl_add_form_woocommerce_mix_and_match_products( $form = array() ) {
|
984 |
+
if ( array_key_exists( 'mnm_quantity', $form ) ) {
|
985 |
+
if ( is_array( $form['mnm_quantity'] ) && ! empty( $form['mnm_quantity'] ) ) {
|
986 |
+
foreach ( $form['mnm_quantity'] as $key => $value ) {
|
987 |
+
$value = absint( $value );
|
988 |
+
if ( empty( $value ) ) {
|
989 |
+
unset( $form['mnm_quantity'][ $key ] );
|
990 |
+
}
|
991 |
+
}
|
992 |
+
if ( empty( $form['mnm_quantity'] ) ) {
|
993 |
+
unset( $form['mnm_quantity'] );
|
994 |
+
}
|
995 |
+
}
|
996 |
+
}
|
997 |
+
return $form;
|
998 |
+
}
|
999 |
+
|
1000 |
+
add_filter( 'tinvwl_addtowishlist_add_form', 'tinvwl_add_form_woocommerce_mix_and_match_products' );
|
1001 |
+
}
|
1002 |
+
|
1003 |
+
if ( ! function_exists( 'TII18n' ) ) {
|
1004 |
+
|
1005 |
+
/**
|
1006 |
+
* Return TI Yoasti 18n module class
|
1007 |
+
*
|
1008 |
+
* @return \TInvWL_Includes_API_Yoasti18n
|
1009 |
+
*/
|
1010 |
+
function TII18n() { // @codingStandardsIgnoreLine WordPress.NamingConventions.ValidFunctionName.FunctionNameInvalid
|
1011 |
+
return TInvWL_Includes_API_Yoasti18n::instance();
|
1012 |
+
}
|
1013 |
+
}
|
1014 |
+
|
1015 |
+
// Create a helper function for easy SDK access.
|
1016 |
+
if ( ! function_exists( 'tinvwl_fs' ) ) {
|
1017 |
+
|
1018 |
+
/**
|
1019 |
+
* Freemius
|
1020 |
+
*
|
1021 |
+
* @return array
|
1022 |
+
*/
|
1023 |
+
function tinvwl_fs() {
|
1024 |
+
global $tinvwl_fs;
|
1025 |
+
|
1026 |
+
if ( ! isset( $tinvwl_fs ) ) {
|
1027 |
+
// Include Freemius SDK.
|
1028 |
+
require_once dirname( __FILE__ ) . '/freemius/start.php';
|
1029 |
+
|
1030 |
+
$tinvwl_fs = fs_dynamic_init( array(
|
1031 |
+
'id' => '839',
|
1032 |
+
'slug' => 'ti-woocommerce-wishlist',
|
1033 |
+
'type' => 'plugin',
|
1034 |
+
'public_key' => 'pk_1944d351ab27040c8f65c72d1e7e7',
|
1035 |
+
'is_premium' => false,
|
1036 |
+
'has_premium_version' => false,
|
1037 |
+
'has_addons' => false,
|
1038 |
+
'has_paid_plans' => false,
|
1039 |
+
'menu' => array(
|
1040 |
+
'slug' => 'tinvwl',
|
1041 |
+
'first-path' => 'admin.php?page=tinvwl' . ( get_option( TINVWL_PREFIX . '_wizard' ) ? '' : '-wizard' ),
|
1042 |
+
'account' => false,
|
1043 |
+
'support' => false,
|
1044 |
+
),
|
1045 |
+
) );
|
1046 |
+
}
|
1047 |
+
|
1048 |
+
return $tinvwl_fs;
|
1049 |
+
}
|
1050 |
+
|
1051 |
+
// Init Freemius.
|
1052 |
+
tinvwl_fs();
|
1053 |
+
} // End if().
|
1054 |
+
|
1055 |
+
function tinvwl_fs_custom_connect_message_on_update(
|
1056 |
+
$message, $user_first_name, $plugin_title, $user_login, $site_link,
|
1057 |
+
$freemius_link
|
1058 |
+
) {
|
1059 |
+
return sprintf(
|
1060 |
+
__fs( 'hey-x' ) . '<br>' .
|
1061 |
+
__( 'Please help us improve %2$s! If you opt-in, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'ti-woocommerce-wishlist' ), $user_first_name, '<b>' . $plugin_title . '</b>', '<b>' . $user_login . '</b>', $site_link, $freemius_link
|
1062 |
+
);
|
1063 |
+
}
|
1064 |
+
|
1065 |
+
tinvwl_fs()->add_filter( 'connect_message_on_update', 'tinvwl_fs_custom_connect_message_on_update', 10, 6 );
|
1066 |
+
|
1067 |
+
function tinvwl_fs_custom_connect_message(
|
1068 |
+
$message, $user_first_name, $plugin_title, $user_login, $site_link,
|
1069 |
+
$freemius_link
|
1070 |
+
) {
|
1071 |
+
return sprintf(
|
1072 |
+
__fs( 'hey-x' ) . '<br>' .
|
1073 |
+
__( 'Allow %6$s to collect some usage data with %5$s to make the plugin even more awesome. If you skip this, that\'s okay! %2$s will still work just fine.', 'ti-woocommerce-wishlist' ), $user_first_name, '<b>' . __( 'WooCommerce Wishlist Plugin', 'ti-woocommerce-wishlist' ) . '</b>', '<b>' . $user_login . '</b>', $site_link, $freemius_link, '<b>' . __( 'TemplateInvaders', 'ti-woocommerce-wishlist' ) . '</b>'
|
1074 |
+
);
|
1075 |
+
}
|
1076 |
+
|
1077 |
+
tinvwl_fs()->add_filter( 'connect_message', 'tinvwl_fs_custom_connect_message', 10, 6 );
|
1078 |
+
|
1079 |
+
tinvwl_fs()->add_action( 'after_uninstall', 'uninstall_tinv_wishlist' );
|
tinv-wishlists-function.php
CHANGED
@@ -1,951 +1,956 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Basic function for plugin
|
4 |
-
*
|
5 |
-
* @since 1.0.0
|
6 |
-
* @package TInvWishlist
|
7 |
-
*/
|
8 |
-
|
9 |
-
// If this file is called directly, abort.
|
10 |
-
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
-
die;
|
12 |
-
}
|
13 |
-
|
14 |
-
if ( function_exists( 'spl_autoload_register' ) ) {
|
15 |
-
|
16 |
-
/**
|
17 |
-
* Autoloader class. If no function spl_autoload_register, then all the files will be required
|
18 |
-
*
|
19 |
-
* @param string $_class Required class name.
|
20 |
-
*
|
21 |
-
* @return boolean
|
22 |
-
*/
|
23 |
-
function autoload_tinv_wishlist( $_class ) {
|
24 |
-
$preffix = 'TInvWL';
|
25 |
-
$ext = '.php';
|
26 |
-
$class = explode( '_', $_class );
|
27 |
-
$object = array_shift( $class );
|
28 |
-
if ( $preffix !== $object ) {
|
29 |
-
return false;
|
30 |
-
}
|
31 |
-
if ( empty( $class ) ) {
|
32 |
-
$class = array( $preffix );
|
33 |
-
}
|
34 |
-
$basicclass = $class;
|
35 |
-
array_unshift( $class, 'includes' );
|
36 |
-
$classs = array(
|
37 |
-
TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $basicclass ) ),
|
38 |
-
TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $class ) ),
|
39 |
-
);
|
40 |
-
foreach ( $classs as $class ) {
|
41 |
-
foreach ( array( '.class', '.helper' ) as $suffix ) {
|
42 |
-
$filename = $class . $suffix . $ext;
|
43 |
-
if ( file_exists( $filename ) ) {
|
44 |
-
require_once $filename;
|
45 |
-
return true;
|
46 |
-
}
|
47 |
-
}
|
48 |
-
}
|
49 |
-
return false;
|
50 |
-
}
|
51 |
-
|
52 |
-
spl_autoload_register( 'autoload_tinv_wishlist' );
|
53 |
-
} // End if().
|
54 |
-
|
55 |
-
if ( ! function_exists( 'tinv_array_merge' ) ) {
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Function to merge arrays with replacement options
|
59 |
-
*
|
60 |
-
* @param array $array1 Array.
|
61 |
-
* @param array $_ Array.
|
62 |
-
*
|
63 |
-
* @return array
|
64 |
-
*/
|
65 |
-
function tinv_array_merge( $array1, $_ = null ) {
|
66 |
-
if ( ! is_array( $array1 ) ) {
|
67 |
-
return $array1;
|
68 |
-
}
|
69 |
-
$args = func_get_args();
|
70 |
-
array_shift( $args );
|
71 |
-
foreach ( $args as $array2 ) {
|
72 |
-
if ( is_array( $array2 ) ) {
|
73 |
-
foreach ( $array2 as $key => $value ) {
|
74 |
-
$array1[ $key ] = $value;
|
75 |
-
}
|
76 |
-
}
|
77 |
-
}
|
78 |
-
return $array1;
|
79 |
-
}
|
80 |
-
}
|
81 |
-
|
82 |
-
if ( ! function_exists( 'tinv_get_option_defaults' ) ) {
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Extract default options from settings class
|
86 |
-
*
|
87 |
-
* @param string $category Name category settings.
|
88 |
-
*
|
89 |
-
* @return array
|
90 |
-
*/
|
91 |
-
function tinv_get_option_defaults( $category ) {
|
92 |
-
$dir = TINVWL_PATH . 'admin/settings/';
|
93 |
-
if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
|
94 |
-
return array();
|
95 |
-
}
|
96 |
-
$files = scandir( $dir );
|
97 |
-
foreach ( $files as $key => $value ) {
|
98 |
-
if ( preg_match( '/\.class\.php$/i', $value ) ) {
|
99 |
-
$files[ $key ] = preg_replace( '/\.class\.php$/i', '', $value );
|
100 |
-
} else {
|
101 |
-
unset( $files[ $key ] );
|
102 |
-
}
|
103 |
-
}
|
104 |
-
$defaults = array();
|
105 |
-
foreach ( $files as $file ) {
|
106 |
-
$class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
|
107 |
-
$class = new $class( '', '' );
|
108 |
-
$class_methods = get_class_methods( $class );
|
109 |
-
foreach ( $class_methods as $method ) {
|
110 |
-
if ( preg_match( '/_data$/i', $method ) ) {
|
111 |
-
$settings = $class->get_defaults( $class->$method() );
|
112 |
-
$defaults = tinv_array_merge( $defaults, $settings );
|
113 |
-
}
|
114 |
-
}
|
115 |
-
}
|
116 |
-
if ( 'all' === $category ) {
|
117 |
-
return $defaults;
|
118 |
-
}
|
119 |
-
if ( array_key_exists( $category, $defaults ) ) {
|
120 |
-
return $defaults[ $category ];
|
121 |
-
}
|
122 |
-
return array();
|
123 |
-
}
|
124 |
-
} // End if().
|
125 |
-
|
126 |
-
if ( ! function_exists( 'tinv_get_option' ) ) {
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Extract options from database or default array settings.
|
130 |
-
*
|
131 |
-
* @param string $category Name category settings.
|
132 |
-
* @param string $option Name paremetr. If is empty string, then function return array category settings.
|
133 |
-
*
|
134 |
-
* @return mixed
|
135 |
-
*/
|
136 |
-
function tinv_get_option( $category, $option = '' ) {
|
137 |
-
$prefix = TINVWL_PREFIX . '-';
|
138 |
-
$values = get_option( $prefix . $category, array() );
|
139 |
-
if ( empty( $values ) ) {
|
140 |
-
$values = tinv_get_option_defaults( $category );
|
141 |
-
}
|
142 |
-
if ( empty( $option ) ) {
|
143 |
-
return $values;
|
144 |
-
} else {
|
145 |
-
if ( array_key_exists( $option, $values ) ) {
|
146 |
-
return $values[ $option ];
|
147 |
-
} else {
|
148 |
-
$values = tinv_get_option_defaults( $category );
|
149 |
-
if ( array_key_exists( $option, (array) $values ) ) {
|
150 |
-
return $values[ $option ];
|
151 |
-
}
|
152 |
-
}
|
153 |
-
}
|
154 |
-
return null;
|
155 |
-
}
|
156 |
-
}
|
157 |
-
|
158 |
-
if ( ! function_exists( 'tinv_get_option_admin' ) ) {
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Extract options from database or default array settings.
|
162 |
-
*
|
163 |
-
* @param string $category Name category settings.
|
164 |
-
* @param string $option Name paremetr. If is empty string, then function return array category settings.
|
165 |
-
*
|
166 |
-
* @return mixed
|
167 |
-
*/
|
168 |
-
function tinv_get_option_admin( $category, $option = '' ) {
|
169 |
-
$prefix = TINVWL_PREFIX . '-';
|
170 |
-
$values = get_option( $prefix . $category, array() );
|
171 |
-
if ( empty( $values ) ) {
|
172 |
-
$values = array();
|
173 |
-
}
|
174 |
-
if ( empty( $option ) ) {
|
175 |
-
return $values;
|
176 |
-
} elseif ( array_key_exists( $option, $values ) ) {
|
177 |
-
return $values[ $option ];
|
178 |
-
}
|
179 |
-
return null;
|
180 |
-
}
|
181 |
-
}
|
182 |
-
|
183 |
-
if ( ! function_exists( 'tinv_style' ) ) {
|
184 |
-
|
185 |
-
/**
|
186 |
-
* Get style for custom style
|
187 |
-
*
|
188 |
-
* @param string $selector Selector style.
|
189 |
-
* @param string $element Attribute name.
|
190 |
-
*
|
191 |
-
* @return string
|
192 |
-
*/
|
193 |
-
function tinv_style( $selector = '', $element = '' ) {
|
194 |
-
$key = md5( $selector . '||' . $element );
|
195 |
-
$values = get_option( TINVWL_PREFIX . '-style_options', array() );
|
196 |
-
if ( empty( $values ) ) {
|
197 |
-
return '';
|
198 |
-
}
|
199 |
-
if ( array_key_exists( $key, $values ) ) {
|
200 |
-
return $values[ $key ];
|
201 |
-
}
|
202 |
-
return '';
|
203 |
-
}
|
204 |
-
}
|
205 |
-
|
206 |
-
if ( ! function_exists( 'tinv_update_option' ) ) {
|
207 |
-
|
208 |
-
/**
|
209 |
-
* Update options in database.
|
210 |
-
*
|
211 |
-
* @param string $category Name category settings.
|
212 |
-
* @param string $option Name paremetr. If is empty string, then function update array category settings.
|
213 |
-
* @param mixed $value Value option.
|
214 |
-
*
|
215 |
-
* @return boolean
|
216 |
-
*/
|
217 |
-
function tinv_update_option( $category, $option = '', $value = false ) {
|
218 |
-
$prefix = TINVWL_PREFIX . '-';
|
219 |
-
if ( empty( $option ) ) {
|
220 |
-
if ( is_array( $value ) ) {
|
221 |
-
update_option( $prefix . $category, $value );
|
222 |
-
return true;
|
223 |
-
}
|
224 |
-
} else {
|
225 |
-
$values = get_option( $prefix . $category, array() );
|
226 |
-
|
227 |
-
$values[ $option ] = $value;
|
228 |
-
update_option( $prefix . $category, $values );
|
229 |
-
return true;
|
230 |
-
}
|
231 |
-
return false;
|
232 |
-
}
|
233 |
-
}
|
234 |
-
|
235 |
-
if ( ! function_exists( 'tinv_wishlist_template' ) ) {
|
236 |
-
|
237 |
-
/**
|
238 |
-
* The function overwrites the method output templates woocommerce
|
239 |
-
*
|
240 |
-
* @param string $template_name Name file template.
|
241 |
-
* @param array $args Array variable in template.
|
242 |
-
* @param string $template_path Customization path.
|
243 |
-
*/
|
244 |
-
function tinv_wishlist_template( $template_name, $args = array(), $template_path = '' ) {
|
245 |
-
if ( function_exists( 'wc_get_template' ) ) {
|
246 |
-
wc_get_template( $template_name, $args, $template_path );
|
247 |
-
} else {
|
248 |
-
woocommerce_get_template( $template_name, $args, $template_path );
|
249 |
-
}
|
250 |
-
}
|
251 |
-
}
|
252 |
-
|
253 |
-
if ( ! function_exists( 'tinv_wishlist_locate_template' ) ) {
|
254 |
-
|
255 |
-
/**
|
256 |
-
* Overwrites path for email and other template
|
257 |
-
*
|
258 |
-
* @param string $template_name Requered Template file.
|
259 |
-
* @param string $template_path Template path.
|
260 |
-
* @param string $default_path Template default path.
|
261 |
-
*
|
262 |
-
* @return string
|
263 |
-
*/
|
264 |
-
function tinv_wishlist_locate_template( $template_name, $template_path = '', $default_path = '' ) {
|
265 |
-
if ( ! $template_path ) {
|
266 |
-
$template_path = WC()->template_path();
|
267 |
-
}
|
268 |
-
|
269 |
-
if ( ! $default_path ) {
|
270 |
-
$default_path = TINVWL_PATH . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
|
271 |
-
}
|
272 |
-
|
273 |
-
// Look within passed path within the theme - this is priority.
|
274 |
-
$template = locate_template( array(
|
275 |
-
trailingslashit( $template_path ) . $template_name,
|
276 |
-
$template_name,
|
277 |
-
) );
|
278 |
-
|
279 |
-
// Get default template.
|
280 |
-
if ( ! $template && file_exists( $default_path . $template_name ) ) {
|
281 |
-
$template = $default_path . $template_name;
|
282 |
-
}
|
283 |
-
|
284 |
-
// Return what we found.
|
285 |
-
return apply_filters( 'tinvwl_locate_template', $template, $template_name, $template_path );
|
286 |
-
}
|
287 |
-
} // End if().
|
288 |
-
|
289 |
-
if ( ! function_exists( 'tinv_wishlist_template_html' ) ) {
|
290 |
-
|
291 |
-
/**
|
292 |
-
* The function overwrites the method return templates woocommerce
|
293 |
-
*
|
294 |
-
* @param string $template_name Name file template.
|
295 |
-
* @param array $args Array variable in template.
|
296 |
-
* @param string $template_path Customization path.
|
297 |
-
*
|
298 |
-
* @return string
|
299 |
-
*/
|
300 |
-
function tinv_wishlist_template_html( $template_name, $args = array(), $template_path = '' ) {
|
301 |
-
ob_start();
|
302 |
-
tinv_wishlist_template( $template_name, $args, $template_path );
|
303 |
-
return ob_get_clean();
|
304 |
-
}
|
305 |
-
}
|
306 |
-
|
307 |
-
if ( ! function_exists( 'tinv_wishlist_get_item_data' ) ) {
|
308 |
-
|
309 |
-
/**
|
310 |
-
* Extract meta attributes for product
|
311 |
-
*
|
312 |
-
* @param object $product Object selected product.
|
313 |
-
* @param boolean $flat Return text or template.
|
314 |
-
*
|
315 |
-
* @return string
|
316 |
-
*/
|
317 |
-
function tinv_wishlist_get_item_data( $product, $flat = false ) {
|
318 |
-
$item_data
|
319 |
-
$variation_id
|
320 |
-
$variation_data
|
321 |
-
if ( ! empty( $variation_id ) && is_array( $variation_data ) ) {
|
322 |
-
foreach ( $variation_data as $name => $value ) {
|
323 |
-
if ( '' === $value ) {
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
$
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
*
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
$wishlist
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
*
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
*
|
497 |
-
*
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
*
|
518 |
-
*
|
519 |
-
*
|
520 |
-
* @
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
604 |
-
|
605 |
-
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
-
|
612 |
-
|
613 |
-
|
614 |
-
|
615 |
-
|
616 |
-
|
617 |
-
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
*
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
-
|
673 |
-
|
674 |
-
|
675 |
-
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
-
|
680 |
-
*
|
681 |
-
*
|
682 |
-
|
683 |
-
|
684 |
-
|
685 |
-
|
686 |
-
|
687 |
-
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
$
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
-
|
701 |
-
|
702 |
-
|
703 |
-
|
704 |
-
|
705 |
-
|
706 |
-
|
707 |
-
}
|
708 |
-
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
*
|
718 |
-
*
|
719 |
-
* @
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
$
|
732 |
-
|
733 |
-
|
734 |
-
$
|
735 |
-
$
|
736 |
-
$
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
}
|
748 |
-
|
749 |
-
|
750 |
-
|
751 |
-
|
752 |
-
|
753 |
-
|
754 |
-
|
755 |
-
|
756 |
-
|
757 |
-
*
|
758 |
-
|
759 |
-
|
760 |
-
|
761 |
-
|
762 |
-
|
763 |
-
|
764 |
-
|
765 |
-
|
766 |
-
|
767 |
-
|
768 |
-
|
769 |
-
|
770 |
-
|
771 |
-
|
772 |
-
|
773 |
-
|
774 |
-
}
|
775 |
-
|
776 |
-
|
777 |
-
|
778 |
-
|
779 |
-
|
780 |
-
|
781 |
-
|
782 |
-
|
783 |
-
|
784 |
-
|
785 |
-
|
786 |
-
|
787 |
-
|
788 |
-
|
789 |
-
|
790 |
-
|
791 |
-
|
792 |
-
|
793 |
-
|
794 |
-
|
795 |
-
|
796 |
-
|
797 |
-
|
798 |
-
|
799 |
-
|
800 |
-
|
801 |
-
|
802 |
-
|
803 |
-
|
804 |
-
}
|
805 |
-
|
806 |
-
|
807 |
-
|
808 |
-
|
809 |
-
|
810 |
-
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
*
|
815 |
-
*
|
816 |
-
|
817 |
-
|
818 |
-
|
819 |
-
|
820 |
-
|
821 |
-
|
822 |
-
|
823 |
-
|
824 |
-
|
825 |
-
|
826 |
-
|
827 |
-
}
|
828 |
-
|
829 |
-
|
830 |
-
|
831 |
-
|
832 |
-
|
833 |
-
|
834 |
-
|
835 |
-
|
836 |
-
|
837 |
-
*
|
838 |
-
|
839 |
-
|
840 |
-
|
841 |
-
|
842 |
-
|
843 |
-
|
844 |
-
|
845 |
-
|
846 |
-
|
847 |
-
|
848 |
-
|
849 |
-
|
850 |
-
|
851 |
-
|
852 |
-
|
853 |
-
|
854 |
-
|
855 |
-
|
856 |
-
|
857 |
-
*
|
858 |
-
|
859 |
-
|
860 |
-
|
861 |
-
|
862 |
-
|
863 |
-
|
864 |
-
|
865 |
-
|
866 |
-
|
867 |
-
|
868 |
-
|
869 |
-
|
870 |
-
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
886 |
-
|
887 |
-
|
888 |
-
|
889 |
-
|
890 |
-
|
891 |
-
|
892 |
-
|
893 |
-
|
894 |
-
|
895 |
-
|
896 |
-
|
897 |
-
|
898 |
-
|
899 |
-
|
900 |
-
|
901 |
-
$
|
902 |
-
|
903 |
-
|
904 |
-
|
905 |
-
|
906 |
-
$
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
|
912 |
-
|
913 |
-
|
914 |
-
|
915 |
-
|
916 |
-
|
917 |
-
|
918 |
-
|
919 |
-
|
920 |
-
|
921 |
-
|
922 |
-
|
923 |
-
|
924 |
-
|
925 |
-
|
926 |
-
|
927 |
-
|
928 |
-
|
929 |
-
|
930 |
-
|
931 |
-
|
932 |
-
|
933 |
-
|
934 |
-
|
935 |
-
|
936 |
-
|
937 |
-
|
938 |
-
|
939 |
-
|
940 |
-
|
941 |
-
|
942 |
-
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
-
|
951 |
-
|
Â
|
|
Â
|
|
Â
|
|
Â
|
|
Â
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Basic function for plugin
|
4 |
+
*
|
5 |
+
* @since 1.0.0
|
6 |
+
* @package TInvWishlist
|
7 |
+
*/
|
8 |
+
|
9 |
+
// If this file is called directly, abort.
|
10 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
11 |
+
die;
|
12 |
+
}
|
13 |
+
|
14 |
+
if ( function_exists( 'spl_autoload_register' ) ) {
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Autoloader class. If no function spl_autoload_register, then all the files will be required
|
18 |
+
*
|
19 |
+
* @param string $_class Required class name.
|
20 |
+
*
|
21 |
+
* @return boolean
|
22 |
+
*/
|
23 |
+
function autoload_tinv_wishlist( $_class ) {
|
24 |
+
$preffix = 'TInvWL';
|
25 |
+
$ext = '.php';
|
26 |
+
$class = explode( '_', $_class );
|
27 |
+
$object = array_shift( $class );
|
28 |
+
if ( $preffix !== $object ) {
|
29 |
+
return false;
|
30 |
+
}
|
31 |
+
if ( empty( $class ) ) {
|
32 |
+
$class = array( $preffix );
|
33 |
+
}
|
34 |
+
$basicclass = $class;
|
35 |
+
array_unshift( $class, 'includes' );
|
36 |
+
$classs = array(
|
37 |
+
TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $basicclass ) ),
|
38 |
+
TINVWL_PATH . strtolower( implode( DIRECTORY_SEPARATOR, $class ) ),
|
39 |
+
);
|
40 |
+
foreach ( $classs as $class ) {
|
41 |
+
foreach ( array( '.class', '.helper' ) as $suffix ) {
|
42 |
+
$filename = $class . $suffix . $ext;
|
43 |
+
if ( file_exists( $filename ) ) {
|
44 |
+
require_once $filename;
|
45 |
+
return true;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
return false;
|
50 |
+
}
|
51 |
+
|
52 |
+
spl_autoload_register( 'autoload_tinv_wishlist' );
|
53 |
+
} // End if().
|
54 |
+
|
55 |
+
if ( ! function_exists( 'tinv_array_merge' ) ) {
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Function to merge arrays with replacement options
|
59 |
+
*
|
60 |
+
* @param array $array1 Array.
|
61 |
+
* @param array $_ Array.
|
62 |
+
*
|
63 |
+
* @return array
|
64 |
+
*/
|
65 |
+
function tinv_array_merge( $array1, $_ = null ) {
|
66 |
+
if ( ! is_array( $array1 ) ) {
|
67 |
+
return $array1;
|
68 |
+
}
|
69 |
+
$args = func_get_args();
|
70 |
+
array_shift( $args );
|
71 |
+
foreach ( $args as $array2 ) {
|
72 |
+
if ( is_array( $array2 ) ) {
|
73 |
+
foreach ( $array2 as $key => $value ) {
|
74 |
+
$array1[ $key ] = $value;
|
75 |
+
}
|
76 |
+
}
|
77 |
+
}
|
78 |
+
return $array1;
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
if ( ! function_exists( 'tinv_get_option_defaults' ) ) {
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Extract default options from settings class
|
86 |
+
*
|
87 |
+
* @param string $category Name category settings.
|
88 |
+
*
|
89 |
+
* @return array
|
90 |
+
*/
|
91 |
+
function tinv_get_option_defaults( $category ) {
|
92 |
+
$dir = TINVWL_PATH . 'admin/settings/';
|
93 |
+
if ( ! file_exists( $dir ) || ! is_dir( $dir ) ) {
|
94 |
+
return array();
|
95 |
+
}
|
96 |
+
$files = scandir( $dir );
|
97 |
+
foreach ( $files as $key => $value ) {
|
98 |
+
if ( preg_match( '/\.class\.php$/i', $value ) ) {
|
99 |
+
$files[ $key ] = preg_replace( '/\.class\.php$/i', '', $value );
|
100 |
+
} else {
|
101 |
+
unset( $files[ $key ] );
|
102 |
+
}
|
103 |
+
}
|
104 |
+
$defaults = array();
|
105 |
+
foreach ( $files as $file ) {
|
106 |
+
$class = 'TInvWL_Admin_Settings_' . ucfirst( $file );
|
107 |
+
$class = new $class( '', '' );
|
108 |
+
$class_methods = get_class_methods( $class );
|
109 |
+
foreach ( $class_methods as $method ) {
|
110 |
+
if ( preg_match( '/_data$/i', $method ) ) {
|
111 |
+
$settings = $class->get_defaults( $class->$method() );
|
112 |
+
$defaults = tinv_array_merge( $defaults, $settings );
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
if ( 'all' === $category ) {
|
117 |
+
return $defaults;
|
118 |
+
}
|
119 |
+
if ( array_key_exists( $category, $defaults ) ) {
|
120 |
+
return $defaults[ $category ];
|
121 |
+
}
|
122 |
+
return array();
|
123 |
+
}
|
124 |
+
} // End if().
|
125 |
+
|
126 |
+
if ( ! function_exists( 'tinv_get_option' ) ) {
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Extract options from database or default array settings.
|
130 |
+
*
|
131 |
+
* @param string $category Name category settings.
|
132 |
+
* @param string $option Name paremetr. If is empty string, then function return array category settings.
|
133 |
+
*
|
134 |
+
* @return mixed
|
135 |
+
*/
|
136 |
+
function tinv_get_option( $category, $option = '' ) {
|
137 |
+
$prefix = TINVWL_PREFIX . '-';
|
138 |
+
$values = get_option( $prefix . $category, array() );
|
139 |
+
if ( empty( $values ) ) {
|
140 |
+
$values = tinv_get_option_defaults( $category );
|
141 |
+
}
|
142 |
+
if ( empty( $option ) ) {
|
143 |
+
return $values;
|
144 |
+
} else {
|
145 |
+
if ( array_key_exists( $option, $values ) ) {
|
146 |
+
return $values[ $option ];
|
147 |
+
} else {
|
148 |
+
$values = tinv_get_option_defaults( $category );
|
149 |
+
if ( array_key_exists( $option, (array) $values ) ) {
|
150 |
+
return $values[ $option ];
|
151 |
+
}
|
152 |
+
}
|
153 |
+
}
|
154 |
+
return null;
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
if ( ! function_exists( 'tinv_get_option_admin' ) ) {
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Extract options from database or default array settings.
|
162 |
+
*
|
163 |
+
* @param string $category Name category settings.
|
164 |
+
* @param string $option Name paremetr. If is empty string, then function return array category settings.
|
165 |
+
*
|
166 |
+
* @return mixed
|
167 |
+
*/
|
168 |
+
function tinv_get_option_admin( $category, $option = '' ) {
|
169 |
+
$prefix = TINVWL_PREFIX . '-';
|
170 |
+
$values = get_option( $prefix . $category, array() );
|
171 |
+
if ( empty( $values ) ) {
|
172 |
+
$values = array();
|
173 |
+
}
|
174 |
+
if ( empty( $option ) ) {
|
175 |
+
return $values;
|
176 |
+
} elseif ( array_key_exists( $option, $values ) ) {
|
177 |
+
return $values[ $option ];
|
178 |
+
}
|
179 |
+
return null;
|
180 |
+
}
|
181 |
+
}
|
182 |
+
|
183 |
+
if ( ! function_exists( 'tinv_style' ) ) {
|
184 |
+
|
185 |
+
/**
|
186 |
+
* Get style for custom style
|
187 |
+
*
|
188 |
+
* @param string $selector Selector style.
|
189 |
+
* @param string $element Attribute name.
|
190 |
+
*
|
191 |
+
* @return string
|
192 |
+
*/
|
193 |
+
function tinv_style( $selector = '', $element = '' ) {
|
194 |
+
$key = md5( $selector . '||' . $element );
|
195 |
+
$values = get_option( TINVWL_PREFIX . '-style_options', array() );
|
196 |
+
if ( empty( $values ) ) {
|
197 |
+
return '';
|
198 |
+
}
|
199 |
+
if ( array_key_exists( $key, $values ) ) {
|
200 |
+
return $values[ $key ];
|
201 |
+
}
|
202 |
+
return '';
|
203 |
+
}
|
204 |
+
}
|
205 |
+
|
206 |
+
if ( ! function_exists( 'tinv_update_option' ) ) {
|
207 |
+
|
208 |
+
/**
|
209 |
+
* Update options in database.
|
210 |
+
*
|
211 |
+
* @param string $category Name category settings.
|
212 |
+
* @param string $option Name paremetr. If is empty string, then function update array category settings.
|
213 |
+
* @param mixed $value Value option.
|
214 |
+
*
|
215 |
+
* @return boolean
|
216 |
+
*/
|
217 |
+
function tinv_update_option( $category, $option = '', $value = false ) {
|
218 |
+
$prefix = TINVWL_PREFIX . '-';
|
219 |
+
if ( empty( $option ) ) {
|
220 |
+
if ( is_array( $value ) ) {
|
221 |
+
update_option( $prefix . $category, $value );
|
222 |
+
return true;
|
223 |
+
}
|
224 |
+
} else {
|
225 |
+
$values = get_option( $prefix . $category, array() );
|
226 |
+
|
227 |
+
$values[ $option ] = $value;
|
228 |
+
update_option( $prefix . $category, $values );
|
229 |
+
return true;
|
230 |
+
}
|
231 |
+
return false;
|
232 |
+
}
|
233 |
+
}
|
234 |
+
|
235 |
+
if ( ! function_exists( 'tinv_wishlist_template' ) ) {
|
236 |
+
|
237 |
+
/**
|
238 |
+
* The function overwrites the method output templates woocommerce
|
239 |
+
*
|
240 |
+
* @param string $template_name Name file template.
|
241 |
+
* @param array $args Array variable in template.
|
242 |
+
* @param string $template_path Customization path.
|
243 |
+
*/
|
244 |
+
function tinv_wishlist_template( $template_name, $args = array(), $template_path = '' ) {
|
245 |
+
if ( function_exists( 'wc_get_template' ) ) {
|
246 |
+
wc_get_template( $template_name, $args, $template_path );
|
247 |
+
} else {
|
248 |
+
woocommerce_get_template( $template_name, $args, $template_path );
|
249 |
+
}
|
250 |
+
}
|
251 |
+
}
|
252 |
+
|
253 |
+
if ( ! function_exists( 'tinv_wishlist_locate_template' ) ) {
|
254 |
+
|
255 |
+
/**
|
256 |
+
* Overwrites path for email and other template
|
257 |
+
*
|
258 |
+
* @param string $template_name Requered Template file.
|
259 |
+
* @param string $template_path Template path.
|
260 |
+
* @param string $default_path Template default path.
|
261 |
+
*
|
262 |
+
* @return string
|
263 |
+
*/
|
264 |
+
function tinv_wishlist_locate_template( $template_name, $template_path = '', $default_path = '' ) {
|
265 |
+
if ( ! $template_path ) {
|
266 |
+
$template_path = WC()->template_path();
|
267 |
+
}
|
268 |
+
|
269 |
+
if ( ! $default_path ) {
|
270 |
+
$default_path = TINVWL_PATH . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;
|
271 |
+
}
|
272 |
+
|
273 |
+
// Look within passed path within the theme - this is priority.
|
274 |
+
$template = locate_template( array(
|
275 |
+
trailingslashit( $template_path ) . $template_name,
|
276 |
+
$template_name,
|
277 |
+
) );
|
278 |
+
|
279 |
+
// Get default template.
|
280 |
+
if ( ! $template && file_exists( $default_path . $template_name ) ) {
|
281 |
+
$template = $default_path . $template_name;
|
282 |
+
}
|
283 |
+
|
284 |
+
// Return what we found.
|
285 |
+
return apply_filters( 'tinvwl_locate_template', $template, $template_name, $template_path );
|
286 |
+
}
|
287 |
+
} // End if().
|
288 |
+
|
289 |
+
if ( ! function_exists( 'tinv_wishlist_template_html' ) ) {
|
290 |
+
|
291 |
+
/**
|
292 |
+
* The function overwrites the method return templates woocommerce
|
293 |
+
*
|
294 |
+
* @param string $template_name Name file template.
|
295 |
+
* @param array $args Array variable in template.
|
296 |
+
* @param string $template_path Customization path.
|
297 |
+
*
|
298 |
+
* @return string
|
299 |
+
*/
|
300 |
+
function tinv_wishlist_template_html( $template_name, $args = array(), $template_path = '' ) {
|
301 |
+
ob_start();
|
302 |
+
tinv_wishlist_template( $template_name, $args, $template_path );
|
303 |
+
return ob_get_clean();
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
if ( ! function_exists( 'tinv_wishlist_get_item_data' ) ) {
|
308 |
+
|
309 |
+
/**
|
310 |
+
* Extract meta attributes for product
|
311 |
+
*
|
312 |
+
* @param object $product Object selected product.
|
313 |
+
* @param boolean $flat Return text or template.
|
314 |
+
*
|
315 |
+
* @return string
|
316 |
+
*/
|
317 |
+
function tinv_wishlist_get_item_data( $product, $wl_product = array(), $flat = false ) {
|
318 |
+
$item_data = array();
|
319 |
+
$variation_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 );
|
320 |
+
$variation_data = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_data : ( $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array() );
|
321 |
+
if ( ! empty( $variation_id ) && is_array( $variation_data ) ) {
|
322 |
+
foreach ( $variation_data as $name => $value ) {
|
323 |
+
if ( '' === $value ) {
|
324 |
+
// Could be any value that saved to a custom meta.
|
325 |
+
if ( array_key_exists( 'meta', $wl_product ) && array_key_exists( $name, $wl_product['meta'] ) ) {
|
326 |
+
$value = $wl_product['meta'][ $name ];
|
327 |
+
} else {
|
328 |
+
continue;
|
329 |
+
}
|
330 |
+
}
|
331 |
+
|
332 |
+
$taxonomy = wc_attribute_taxonomy_name( str_replace( 'attribute_pa_', '', urldecode( $name ) ) );
|
333 |
+
|
334 |
+
// If this is a term slug, get the term's nice name.
|
335 |
+
if ( taxonomy_exists( $taxonomy ) ) {
|
336 |
+
$term = get_term_by( 'slug', $value, $taxonomy ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.get_term_by
|
337 |
+
if ( !is_wp_error( $term ) && $term && $term->name ) {
|
338 |
+
$value = $term->name;
|
339 |
+
}
|
340 |
+
$label = wc_attribute_label( $taxonomy );
|
341 |
+
|
342 |
+
// If this is a custom option slug, get the options name.
|
343 |
+
} else {
|
344 |
+
$value = apply_filters( 'woocommerce_variation_option_name', $value );
|
345 |
+
$product_attributes = $product->get_attributes();
|
346 |
+
|
347 |
+
if ( isset( $product_attributes[ str_replace( 'attribute_', '', $name ) ] ) ) {
|
348 |
+
$label = wc_attribute_label( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_attributes[ str_replace( 'attribute_', '', $name ) ]['name'] : str_replace( 'attribute_', '', $name ) ) );
|
349 |
+
} else {
|
350 |
+
$label = $name;
|
351 |
+
}
|
352 |
+
}
|
353 |
+
$item_data[] = array(
|
354 |
+
'key' => $label,
|
355 |
+
'value' => $value,
|
356 |
+
);
|
357 |
+
}
|
358 |
+
}
|
359 |
+
|
360 |
+
// Filter item data to allow 3rd parties to add more to the array.
|
361 |
+
$item_data = apply_filters( 'tinv_wishlist_get_item_data', $item_data, $product );
|
362 |
+
|
363 |
+
// Format item data ready to display.
|
364 |
+
foreach ( $item_data as $key => $data ) {
|
365 |
+
// Set hidden to true to not display meta on cart.
|
366 |
+
if ( ! empty( $data['hidden'] ) ) {
|
367 |
+
unset( $item_data[ $key ] );
|
368 |
+
continue;
|
369 |
+
}
|
370 |
+
$item_data[ $key ]['key'] = ! empty( $data['key'] ) ? $data['key'] : $data['name'];
|
371 |
+
$item_data[ $key ]['display'] = ! empty( $data['display'] ) ? $data['display'] : $data['value'];
|
372 |
+
}
|
373 |
+
|
374 |
+
// Output flat or in list format.
|
375 |
+
if ( 0 < count( $item_data ) ) {
|
376 |
+
ob_start();
|
377 |
+
if ( $flat ) {
|
378 |
+
foreach ( $item_data as $data ) {
|
379 |
+
echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
|
380 |
+
}
|
381 |
+
} else {
|
382 |
+
tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
|
383 |
+
}
|
384 |
+
return ob_get_clean();
|
385 |
+
}
|
386 |
+
|
387 |
+
return '';
|
388 |
+
}
|
389 |
+
} // End if().
|
390 |
+
|
391 |
+
if ( ! function_exists( 'tinv_wishlist_get' ) ) {
|
392 |
+
|
393 |
+
/**
|
394 |
+
* Return Wishlist by id or share key
|
395 |
+
*
|
396 |
+
* @param mixed $id Integer wishlist ID, or Share Key wishlist.
|
397 |
+
* @param boolean $toend Switches to the extract the default or guest wishlist.
|
398 |
+
*
|
399 |
+
* @return array
|
400 |
+
*/
|
401 |
+
function tinv_wishlist_get( $id = '', $toend = true ) {
|
402 |
+
$wl = new TInvWL_Wishlist();
|
403 |
+
$wishlist = null;
|
404 |
+
if ( empty( $id ) ) {
|
405 |
+
$id = get_query_var( 'tinvwlID', null );
|
406 |
+
}
|
407 |
+
|
408 |
+
if ( ! empty( $id ) ) {
|
409 |
+
if ( is_integer( $id ) ) {
|
410 |
+
$wishlist = $wl->get_by_id( $id );
|
411 |
+
}
|
412 |
+
if ( empty( $wishlist ) ) {
|
413 |
+
$wishlist = $wl->get_by_share_key( $id );
|
414 |
+
}
|
415 |
+
|
416 |
+
if ( is_array( $wishlist ) ) {
|
417 |
+
$wishlist['is_owner'] = false;
|
418 |
+
if ( is_user_logged_in() ) {
|
419 |
+
$wishlist['is_owner'] = get_current_user_id() == $wishlist['author']; // WPCS: loose comparison ok.
|
420 |
+
} else {
|
421 |
+
$wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key']; // WPCS: loose comparison ok.
|
422 |
+
}
|
423 |
+
}
|
424 |
+
} elseif ( is_user_logged_in() && $toend ) {
|
425 |
+
$wishlist = $wl->add_user_default();
|
426 |
+
|
427 |
+
$wishlist['is_owner'] = true;
|
428 |
+
} elseif ( $toend ) {
|
429 |
+
$wishlist = $wl->add_sharekey_default();
|
430 |
+
$wishlist['is_owner'] = $wl->get_sharekey() === $wishlist['share_key'];
|
431 |
+
}
|
432 |
+
|
433 |
+
return $wishlist;
|
434 |
+
}
|
435 |
+
} // End if().
|
436 |
+
|
437 |
+
if ( ! function_exists( 'tinv_url_wishlist_default' ) ) {
|
438 |
+
|
439 |
+
/**
|
440 |
+
* Return the default wishlist url
|
441 |
+
*
|
442 |
+
* @return string
|
443 |
+
*/
|
444 |
+
function tinv_url_wishlist_default() {
|
445 |
+
$page = apply_filters( 'wpml_object_id', tinv_get_option( 'page', 'wishlist' ), 'page', true ); // @codingStandardsIgnoreLine WordPress.Variables.GlobalVariables.OverrideProhibited
|
446 |
+
if ( empty( $page ) ) {
|
447 |
+
return '';
|
448 |
+
}
|
449 |
+
$link = get_permalink( $page );
|
450 |
+
return $link;
|
451 |
+
}
|
452 |
+
}
|
453 |
+
|
454 |
+
if ( ! function_exists( 'tinv_url_wishlist_by_key' ) ) {
|
455 |
+
|
456 |
+
/**
|
457 |
+
* Return the wishlist url by share key
|
458 |
+
*
|
459 |
+
* @param string $share_key Share Key wishlist.
|
460 |
+
* @param integer $paged Page.
|
461 |
+
*
|
462 |
+
* @return string
|
463 |
+
*/
|
464 |
+
function tinv_url_wishlist_by_key( $share_key, $paged = 1 ) {
|
465 |
+
$paged = absint( $paged );
|
466 |
+
$paged = 1 < $paged ? $paged : 1;
|
467 |
+
$link = tinv_url_wishlist_default();
|
468 |
+
if ( empty( $link ) || empty( $share_key ) ) {
|
469 |
+
return $link;
|
470 |
+
}
|
471 |
+
|
472 |
+
if ( get_option( 'permalink_structure' ) ) {
|
473 |
+
$suffix = '';
|
474 |
+
if ( preg_match( '/([^\?]+)\?*?(.*)/i', $link, $_link ) ) {
|
475 |
+
$link = $_link[1];
|
476 |
+
$suffix = $_link[2];
|
477 |
+
}
|
478 |
+
if ( ! preg_match( '/\/$/', $link ) ) {
|
479 |
+
$link .= '/';
|
480 |
+
}
|
481 |
+
$link .= $share_key . '/' . $suffix;
|
482 |
+
} else {
|
483 |
+
$link .= add_query_arg( 'tinvwlID', $share_key, $link );
|
484 |
+
}
|
485 |
+
|
486 |
+
if ( 1 < $paged ) {
|
487 |
+
$link = add_query_arg( 'paged', $paged, $link );
|
488 |
+
}
|
489 |
+
return $link;
|
490 |
+
}
|
491 |
+
} // End if().
|
492 |
+
|
493 |
+
if ( ! function_exists( 'tinv_url_wishlist' ) ) {
|
494 |
+
|
495 |
+
/**
|
496 |
+
* Return the wishlist url by id or share key
|
497 |
+
*
|
498 |
+
* @param mixed $id Integer wishlist ID, or Share Key wishlist.
|
499 |
+
* @param integer $paged Page.
|
500 |
+
* @param boolean $full Return full url or shroted url for logged in user.
|
501 |
+
*
|
502 |
+
* @return string
|
503 |
+
*/
|
504 |
+
function tinv_url_wishlist( $id = '', $paged = 1, $full = true ) {
|
505 |
+
$share_key = $id;
|
506 |
+
if ( is_integer( $id ) ) {
|
507 |
+
$wishlist = tinv_wishlist_get( $id, false );
|
508 |
+
$share_key = $wishlist['share_key'];
|
509 |
+
}
|
510 |
+
return tinv_url_wishlist_by_key( $share_key, $paged );
|
511 |
+
}
|
512 |
+
}
|
513 |
+
|
514 |
+
if ( ! function_exists( 'tinv_wishlist_status' ) ) {
|
515 |
+
|
516 |
+
/**
|
517 |
+
* Check status free or premium plugin and disable free
|
518 |
+
*
|
519 |
+
* @global string $status
|
520 |
+
* @global string $page
|
521 |
+
* @global string $s
|
522 |
+
*
|
523 |
+
* @param string $transient Plugin transient name.
|
524 |
+
*
|
525 |
+
* @return string
|
526 |
+
*/
|
527 |
+
function tinv_wishlist_status( $transient ) {
|
528 |
+
if ( TINVWL_LOAD_FREE === $transient ) {
|
529 |
+
TInvWL_PluginExtend::deactivate_self( TINVWL_LOAD_FREE );
|
530 |
+
return 'plugins.php';
|
531 |
+
}
|
532 |
+
if ( TINVWL_LOAD_PREMIUM === $transient ) {
|
533 |
+
if ( is_plugin_active( TINVWL_LOAD_FREE ) ) {
|
534 |
+
TInvWL_PluginExtend::deactivate_self( TINVWL_LOAD_FREE );
|
535 |
+
if ( ! function_exists( 'wp_create_nonce' ) ) {
|
536 |
+
return 'plugins.php';
|
537 |
+
}
|
538 |
+
|
539 |
+
global $status, $page, $s;
|
540 |
+
$redirect = 'plugins.php?';
|
541 |
+
$redirect .= http_build_query( array(
|
542 |
+
'action' => 'activate',
|
543 |
+
'plugin' => $transient,
|
544 |
+
'plugin_status' => $status,
|
545 |
+
'paged' => $page,
|
546 |
+
's' => $s,
|
547 |
+
) );
|
548 |
+
$redirect = esc_url_raw( add_query_arg( '_wpnonce', wp_create_nonce( 'activate-plugin_' . $transient ), $redirect ) );
|
549 |
+
return $redirect;
|
550 |
+
}
|
551 |
+
}
|
552 |
+
return false;
|
553 |
+
}
|
554 |
+
} // End if().
|
555 |
+
|
556 |
+
if ( ! function_exists( 'tinvwl_body_classes' ) ) {
|
557 |
+
|
558 |
+
/**
|
559 |
+
* Add custom class
|
560 |
+
*
|
561 |
+
* @param array $classes Current classes.
|
562 |
+
*
|
563 |
+
* @return array
|
564 |
+
*/
|
565 |
+
function tinvwl_body_classes( $classes ) {
|
566 |
+
if ( tinv_get_option( 'style', 'customstyle' ) ) {
|
567 |
+
$classes[] = 'tinvwl-theme-style';
|
568 |
+
} else {
|
569 |
+
$classes[] = 'tinvwl-custom-style';
|
570 |
+
}
|
571 |
+
|
572 |
+
return $classes;
|
573 |
+
}
|
574 |
+
|
575 |
+
add_filter( 'body_class', 'tinvwl_body_classes' );
|
576 |
+
}
|
577 |
+
|
578 |
+
if ( ! function_exists( 'tinvwl_shortcode_addtowishlist' ) ) {
|
579 |
+
|
580 |
+
/**
|
581 |
+
* Shortcode Add To Wishlist
|
582 |
+
*
|
583 |
+
* @param array $atts Array parameter from shortcode.
|
584 |
+
*
|
585 |
+
* @return string
|
586 |
+
*/
|
587 |
+
function tinvwl_shortcode_addtowishlist( $atts = array() ) {
|
588 |
+
$class = TInvWL_Public_AddToWishlist::instance();
|
589 |
+
return $class->shortcode( $atts );
|
590 |
+
}
|
591 |
+
|
592 |
+
add_shortcode( 'ti_wishlists_addtowishlist', 'tinvwl_shortcode_addtowishlist' );
|
593 |
+
}
|
594 |
+
|
595 |
+
if ( ! function_exists( 'tinvwl_shortcode_view' ) ) {
|
596 |
+
|
597 |
+
/**
|
598 |
+
* Shortcode view Wishlist
|
599 |
+
*
|
600 |
+
* @param array $atts Array parameter from shortcode.
|
601 |
+
*
|
602 |
+
* @return string
|
603 |
+
*/
|
604 |
+
function tinvwl_shortcode_view( $atts = array() ) {
|
605 |
+
$class = TInvWL_Public_Wishlist_View::instance();
|
606 |
+
return $class->shortcode( $atts );
|
607 |
+
}
|
608 |
+
|
609 |
+
add_shortcode( 'ti_wishlistsview', 'tinvwl_shortcode_view' );
|
610 |
+
}
|
611 |
+
|
612 |
+
if ( ! function_exists( 'tinvwl_shortcode_products_counter' ) ) {
|
613 |
+
|
614 |
+
/**
|
615 |
+
* Shortcode view Wishlist
|
616 |
+
*
|
617 |
+
* @param array $atts Array parameter from shortcode.
|
618 |
+
*
|
619 |
+
* @return string
|
620 |
+
*/
|
621 |
+
function tinvwl_shortcode_products_counter( $atts = array() ) {
|
622 |
+
$class = TInvWL_Public_TopWishlist::instance();
|
623 |
+
return $class->shortcode( $atts );
|
624 |
+
}
|
625 |
+
|
626 |
+
add_shortcode( 'ti_wishlist_products_counter', 'tinvwl_shortcode_products_counter' );
|
627 |
+
}
|
628 |
+
|
629 |
+
if ( ! function_exists( 'tinvwl_view_addto_html' ) ) {
|
630 |
+
|
631 |
+
/**
|
632 |
+
* Show button Add to Wishlsit
|
633 |
+
*/
|
634 |
+
function tinvwl_view_addto_html() {
|
635 |
+
$class = TInvWL_Public_AddToWishlist::instance();
|
636 |
+
$class->htmloutput();
|
637 |
+
}
|
638 |
+
}
|
639 |
+
|
640 |
+
if ( ! function_exists( 'tinvwl_view_addto_htmlout' ) ) {
|
641 |
+
|
642 |
+
/**
|
643 |
+
* Show button Add to Wishlsit, if product is not purchasable
|
644 |
+
*/
|
645 |
+
function tinvwl_view_addto_htmlout() {
|
646 |
+
$class = TInvWL_Public_AddToWishlist::instance();
|
647 |
+
$class->htmloutput_out();
|
648 |
+
}
|
649 |
+
}
|
650 |
+
|
651 |
+
if ( ! function_exists( 'tinvwl_view_addto_htmlloop' ) ) {
|
652 |
+
|
653 |
+
/**
|
654 |
+
* Show button Add to Wishlsit, in loop
|
655 |
+
*/
|
656 |
+
function tinvwl_view_addto_htmlloop() {
|
657 |
+
$class = TInvWL_Public_AddToWishlist::instance();
|
658 |
+
$class->htmloutput_loop();
|
659 |
+
}
|
660 |
+
}
|
661 |
+
|
662 |
+
if ( ! function_exists( 'tinvwl_clean_url' ) ) {
|
663 |
+
|
664 |
+
/**
|
665 |
+
* Clear esc_url to original
|
666 |
+
*
|
667 |
+
* @param string $good_protocol_url Cleared URL.
|
668 |
+
* @param string $original_url Original URL.
|
669 |
+
*
|
670 |
+
* @return string
|
671 |
+
*/
|
672 |
+
function tinvwl_clean_url( $good_protocol_url, $original_url ) {
|
673 |
+
return $original_url;
|
674 |
+
}
|
675 |
+
}
|
676 |
+
|
677 |
+
if ( ! function_exists( 'tinvwl_add_to_cart_need_redirect' ) ) {
|
678 |
+
|
679 |
+
/**
|
680 |
+
* Check if the product is third-party, or has another link added to the cart then redirect to the product page.
|
681 |
+
*
|
682 |
+
* @param boolean $redirect Default value to redirect.
|
683 |
+
* @param \WC_Product $product Product data.
|
684 |
+
* @param string $redirect_url Current url for redirect.
|
685 |
+
*
|
686 |
+
* @return boolean
|
687 |
+
*/
|
688 |
+
function tinvwl_add_to_cart_need_redirect( $redirect, $product, $redirect_url ) {
|
689 |
+
if ( $redirect ) {
|
690 |
+
return true;
|
691 |
+
}
|
692 |
+
if ( 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) ) {
|
693 |
+
return true;
|
694 |
+
}
|
695 |
+
|
696 |
+
$need_url_data = array_filter( array_merge( array(
|
697 |
+
'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 ) ),
|
698 |
+
'add-to-cart' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ),
|
699 |
+
), array_map( 'urlencode', ( version_compare( WC_VERSION, '3.0.0', '<' ) ? ( is_array( $product->variation_data ) ? $product->variation_data : array() ) : array() ) ) ) );
|
700 |
+
$need_url = apply_filters( 'woocommerce_product_add_to_cart_url', remove_query_arg( 'added-to-cart', add_query_arg( $need_url_data ) ), $product );
|
701 |
+
$need_url_full = apply_filters( 'woocommerce_product_add_to_cart_url', remove_query_arg( 'added-to-cart', add_query_arg( $need_url_data, $product->get_permalink() ) ), $product );
|
702 |
+
add_filter( 'clean_url', 'tinvwl_clean_url', 10, 2 );
|
703 |
+
$_redirect_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_url', $product->add_to_cart_url(), $product );
|
704 |
+
remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
|
705 |
+
if ( $_redirect_url !== $need_url && $_redirect_url !== $need_url_full ) {
|
706 |
+
return true;
|
707 |
+
}
|
708 |
+
return $redirect;
|
709 |
+
}
|
710 |
+
|
711 |
+
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_add_to_cart_need_redirect', 10, 3 );
|
712 |
+
} // End if().
|
713 |
+
|
714 |
+
if ( ! function_exists( 'tinvwl_meta_validate_card_add' ) ) {
|
715 |
+
|
716 |
+
/**
|
717 |
+
* Checks the ability to add a product
|
718 |
+
*
|
719 |
+
* @param boolean $redirect Default value to redirect.
|
720 |
+
* @param \WC_Product $product Product data.
|
721 |
+
* @param string $redirect_url Current url for redirect.
|
722 |
+
* @param array $wl_product Wishlist Product.
|
723 |
+
*
|
724 |
+
* @return boolean
|
725 |
+
*/
|
726 |
+
function tinvwl_meta_validate_card_add( $redirect, $product, $redirect_url, $wl_product ) {
|
727 |
+
if ( $redirect && array_key_exists( 'meta', $wl_product ) && ! empty( $wl_product['meta'] ) ) {
|
728 |
+
|
729 |
+
TInvWL_Public_Cart::prepare_post( $wl_product );
|
730 |
+
|
731 |
+
$wl_product = apply_filters( 'tinvwl_addproduct_tocart', $wl_product );
|
732 |
+
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $wl_product['product_id'] ) );
|
733 |
+
$quantity = empty( $wl_quantity ) ? 1 : wc_stock_amount( $wl_quantity );
|
734 |
+
$variation_id = $wl_product['variation_id'];
|
735 |
+
$variations = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_data : ( $product->is_type( 'variation' ) ? wc_get_product_variation_attributes( $product->get_id() ) : array() ) );
|
736 |
+
$passed_validation = $product->is_purchasable() && ( $product->is_in_stock() || $product->backorders_allowed() ) && 'external' !== ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() );
|
737 |
+
ob_start();
|
738 |
+
wc_clear_notices();
|
739 |
+
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations );
|
740 |
+
$wc_errors = wc_get_notices( 'error' );
|
741 |
+
$wc_output = ob_get_clean();
|
742 |
+
if ( $passed_validation && empty( $wc_errors ) && empty( $wc_output ) ) {
|
743 |
+
$redirect = false;
|
744 |
+
}
|
745 |
+
|
746 |
+
TInvWL_Public_Cart::unprepare_post();
|
747 |
+
}
|
748 |
+
return $redirect;
|
749 |
+
}
|
750 |
+
|
751 |
+
add_filter( 'tinvwl_product_add_to_cart_need_redirect', 'tinvwl_meta_validate_card_add', 90, 4 );
|
752 |
+
} // End if().
|
753 |
+
|
754 |
+
if ( ! function_exists( 'tinv_wishlist_print_meta' ) ) {
|
755 |
+
|
756 |
+
/**
|
757 |
+
* Print meta data for wishlist form
|
758 |
+
*
|
759 |
+
* @param array $meta Meta Array.
|
760 |
+
* @param boolean $flat Return text or template.
|
761 |
+
*
|
762 |
+
* @return string
|
763 |
+
*/
|
764 |
+
function tinv_wishlist_print_meta( $meta = array(), $flat = false ) {
|
765 |
+
if ( ! is_array( $meta ) ) {
|
766 |
+
$meta = array();
|
767 |
+
}
|
768 |
+
$product_id = $variation_id = 0;
|
769 |
+
if ( array_key_exists( 'product_id', $meta ) ) {
|
770 |
+
$product_id = $meta['product_id'];
|
771 |
+
}
|
772 |
+
if ( array_key_exists( 'variation_id', $meta ) ) {
|
773 |
+
$variation_id = $meta['variation_id'];
|
774 |
+
}
|
775 |
+
foreach ( array( 'add-to-cart', 'product_id', 'variation_id', 'quantity' ) as $field ) {
|
776 |
+
if ( array_key_exists( $field, $meta ) ) {
|
777 |
+
unset( $meta[ $field ] );
|
778 |
+
}
|
779 |
+
}
|
780 |
+
$meta = array_filter( $meta );
|
781 |
+
if ( empty( $meta ) ) {
|
782 |
+
return '';
|
783 |
+
}
|
784 |
+
$item_data = array();
|
785 |
+
foreach ( $meta as $key => $value ) {
|
786 |
+
if ( ! preg_match( '/^\_/', $key ) ) {
|
787 |
+
$item_data[ $key ] = array(
|
788 |
+
'key' => $key,
|
789 |
+
'display' => $value,
|
790 |
+
);
|
791 |
+
}
|
792 |
+
}
|
793 |
+
$item_data = apply_filters( 'tinvwl_wishlist_item_meta_post', $item_data, $product_id, $variation_id );
|
794 |
+
foreach ( $item_data as $key => $data ) {
|
795 |
+
if ( is_object( $data['display'] ) || is_array( $data['display'] ) ) {
|
796 |
+
$item_data[ $key ]['display'] = json_encode( $data['display'] );
|
797 |
+
}
|
798 |
+
}
|
799 |
+
ob_start();
|
800 |
+
if ( $flat ) {
|
801 |
+
foreach ( $item_data as $data ) {
|
802 |
+
echo esc_html( $data['key'] ) . ': ' . wp_kses_post( $data['display'] ) . '<br>';
|
803 |
+
}
|
804 |
+
} else {
|
805 |
+
tinv_wishlist_template( 'ti-wishlist-item-data.php', array( 'item_data' => $item_data ) );
|
806 |
+
}
|
807 |
+
return apply_filters( 'tinvwl_wishlist_item_meta_wishlist', ob_get_clean() );
|
808 |
+
}
|
809 |
+
} // End if().
|
810 |
+
|
811 |
+
if ( ! function_exists( 'tinv_wishlistmeta' ) ) {
|
812 |
+
|
813 |
+
/**
|
814 |
+
* Show new meta data
|
815 |
+
*
|
816 |
+
* @param string $meta Print meta.
|
817 |
+
* @param array $wl_product Wishlist product.
|
818 |
+
* @param \WC_Product $product Woocommerce product.
|
819 |
+
*
|
820 |
+
* @return string
|
821 |
+
*/
|
822 |
+
function tinv_wishlistmeta( $meta = '', $wl_product, $product ) {
|
823 |
+
if ( empty( $meta ) ) {
|
824 |
+
if ( array_key_exists( 'meta', $wl_product ) ) {
|
825 |
+
$meta = apply_filters( 'tinvwl_wishlist_item_meta_wishlist_output', tinv_wishlist_print_meta( $wl_product['meta'] ), $wl_product, $product );
|
826 |
+
}
|
827 |
+
}
|
828 |
+
return $meta;
|
829 |
+
}
|
830 |
+
|
831 |
+
add_filter( 'tinvwl_wishlist_item_meta_data', 'tinv_wishlistmeta', 10, 3 );
|
832 |
+
}
|
833 |
+
|
834 |
+
if ( ! function_exists( 'tinvwl_add_to_cart_item_meta_post' ) ) {
|
835 |
+
|
836 |
+
/**
|
837 |
+
* Save post data to cart item
|
838 |
+
*
|
839 |
+
* @param array $cart_item_data Array with cart imet information.
|
840 |
+
* @param string $cart_item_key Cart item key.
|
841 |
+
*
|
842 |
+
* @return array
|
843 |
+
*/
|
844 |
+
function tinvwl_add_to_cart_item_meta_post( $cart_item_data, $cart_item_key ) {
|
845 |
+
$postdata = $_POST; // @codingStandardsIgnoreLine WordPress.VIP.SuperGlobalInputUsage.AccessDetected
|
846 |
+
|
847 |
+
$cart_item_data['tinvwl_formdata'] = $postdata;
|
848 |
+
return $cart_item_data;
|
849 |
+
}
|
850 |
+
|
851 |
+
add_action( 'woocommerce_add_cart_item', 'tinvwl_add_to_cart_item_meta_post', 10, 2 );
|
852 |
+
}
|
853 |
+
|
854 |
+
if ( ! function_exists( 'tinvwl_rating_notice_template' ) ) {
|
855 |
+
|
856 |
+
/**
|
857 |
+
* Show admin notice.
|
858 |
+
*
|
859 |
+
* @param string $output String.
|
860 |
+
* @param string $key Unique notification key.
|
861 |
+
* @param string $message Text message.
|
862 |
+
* @return string
|
863 |
+
*/
|
864 |
+
function tinvwl_rating_notice_template( $output, $key, $message ) {
|
865 |
+
|
866 |
+
TInvWL_View::view( 'notice-rating', array(
|
867 |
+
'name' => 'rating',
|
868 |
+
'message' => $message,
|
869 |
+
'key' => $key,
|
870 |
+
) );
|
871 |
+
|
872 |
+
return '';
|
873 |
+
}
|
874 |
+
|
875 |
+
add_filter( 'tinv_notice_rating', 'tinvwl_rating_notice_template', 10, 3 );
|
876 |
+
}
|
877 |
+
|
878 |
+
if ( ! function_exists( 'tinvwl_rating_notice_hide' ) ) {
|
879 |
+
|
880 |
+
/**
|
881 |
+
* Action for disable notice
|
882 |
+
*/
|
883 |
+
function tinvwl_rating_notice_hide() {
|
884 |
+
$data = filter_input( INPUT_GET, 'ti-redirect' );
|
885 |
+
if ( $data ) {
|
886 |
+
wp_redirect( 'https://wordpress.org/support/plugin/ti-woocommerce-wishlist/reviews/#new-post' );
|
887 |
+
}
|
888 |
+
}
|
889 |
+
|
890 |
+
add_action( 'tinv_notice_hide_rating', 'tinvwl_rating_notice_hide' );
|
891 |
+
}
|
892 |
+
|
893 |
+
if ( ! function_exists( 'tinvwl_rating_notice_trigger_30' ) ) {
|
894 |
+
|
895 |
+
/**
|
896 |
+
* Trigger for reset notice
|
897 |
+
*
|
898 |
+
* @return boolean
|
899 |
+
*/
|
900 |
+
function tinvwl_rating_notice_trigger_30() {
|
901 |
+
$tw = new TInvWL_Wishlist();
|
902 |
+
$wishlist = $tw->get( array(
|
903 |
+
'count' => 1,
|
904 |
+
'order_by' => 'date',
|
905 |
+
) );
|
906 |
+
$wishlist = array_shift( $wishlist );
|
907 |
+
if ( empty( $wishlist ) ) {
|
908 |
+
return false;
|
909 |
+
}
|
910 |
+
$date = $wishlist['date'];
|
911 |
+
$date = mysql2date( 'G', $date );
|
912 |
+
$date = floor( ( time() - $date ) / DAY_IN_SECONDS );
|
913 |
+
$step = floor( $date / 30 );
|
914 |
+
if ( 0 >= $step ) {
|
915 |
+
return false;
|
916 |
+
}
|
917 |
+
|
918 |
+
return $step;
|
919 |
+
}
|
920 |
+
}
|
921 |
+
|
922 |
+
if ( ! function_exists( 'tinvwl_set_utm' ) ) {
|
923 |
+
|
924 |
+
/**
|
925 |
+
* Set UTM sources.
|
926 |
+
*/
|
927 |
+
function tinvwl_set_utm() {
|
928 |
+
|
929 |
+
// Set a source.
|
930 |
+
$source = get_option( TINVWL_PREFIX . '_utm_source' );
|
931 |
+
if ( ! $source ) {
|
932 |
+
$source = defined( 'TINVWL_PARTNER' ) ? TINVWL_PARTNER : 'wordpress_org';
|
933 |
+
update_option( TINVWL_PREFIX . '_utm_source', $source );
|
934 |
+
}
|
935 |
+
|
936 |
+
define( 'TINVWL_UTM_SOURCE', $source );
|
937 |
+
|
938 |
+
// Set a medium.
|
939 |
+
$medium = get_option( TINVWL_PREFIX . '_utm_medium' );
|
940 |
+
if ( ! $medium ) {
|
941 |
+
$medium = defined( 'TINVWL_PARTNER' ) ? 'integration' : 'organic';
|
942 |
+
update_option( TINVWL_PREFIX . '_utm_medium', $medium );
|
943 |
+
}
|
944 |
+
|
945 |
+
define( 'TINVWL_UTM_MEDIUM', $medium );
|
946 |
+
|
947 |
+
// Set a campaign.
|
948 |
+
$campaign = get_option( TINVWL_PREFIX . '_utm_campaign' );
|
949 |
+
if ( ! $campaign ) {
|
950 |
+
$campaign = defined( 'TINVWL_PARTNER' ) ? ( defined( 'TINVWL_CAMPAIGN' ) ? TINVWL_CAMPAIGN : TINVWL_PARTNER ) : 'organic';
|
951 |
+
update_option( TINVWL_PREFIX . '_utm_campaign', $campaign );
|
952 |
+
}
|
953 |
+
|
954 |
+
define( 'TINVWL_UTM_CAMPAIGN', $campaign );
|
955 |
+
}
|
956 |
+
} // End if().
|