Version Description
Release Date - 07 April 2017
- WooCommerce 3.0+ support
- Added template overrides check for WooCommerce system report
Download this release
Release Info
Developer | templateinvaders |
Plugin | WooCommerce Wishlist Plugin |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.14 to 1.2.0
- admin/tinvwl.class.php +70 -1
- includes/product.helper.php +20 -24
- includes/product/local.class.php +14 -20
- includes/tinvwl.class.php +3 -3
- public/addtowishlist.class.php +10 -10
- public/cart.class.php +2 -2
- public/tinvwl.class.php +1 -1
- public/wishlist/view.class.php +4 -4
- readme.txt +8 -2
- templates/index.php +0 -3
- templates/ti-addtowishlist.php +3 -3
- ti-woocommerce-wishlist.php +13 -5
- tinv-wishlists-function.php +8 -6
- views/admin/templates-status.php +38 -0
admin/tinvwl.class.php
CHANGED
@@ -73,10 +73,14 @@ class TInvWL_Admin_TInvWL extends TInvWL_Admin_Base {
|
|
73 |
} elseif ( ! tinv_get_option( 'page', 'wishlist' ) ) {
|
74 |
add_action( 'admin_notices', array( $this, 'empty_page_admin_notice' ) );
|
75 |
}
|
|
|
|
|
|
|
|
|
76 |
}
|
77 |
|
78 |
/**
|
79 |
-
* Error notice if wizard
|
80 |
*/
|
81 |
function wizard_run_admin_notice() {
|
82 |
printf( '<div class="notice notice-error"><p>%1$s</p><p><a href="%2$s" class="button-primary">%3$s</a> <a href="%4$s" class="button-secondary">%5$s</a></p></div>',
|
@@ -182,4 +186,69 @@ class TInvWL_Admin_TInvWL extends TInvWL_Admin_Base {
|
|
182 |
$panel[] = sprintf( '<a class="tinvwl-btn red w-icon smaller-txt" href="%s"><i class="fa fa-star"></i><span class="tinvwl-txt">%s</span></a>', $this->admin_url( 'upgrade' ), __( 'Upgrade to Pro', 'ti-woocommerce-wishlist' ) );
|
183 |
return $panel;
|
184 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
}
|
73 |
} elseif ( ! tinv_get_option( 'page', 'wishlist' ) ) {
|
74 |
add_action( 'admin_notices', array( $this, 'empty_page_admin_notice' ) );
|
75 |
}
|
76 |
+
add_action( 'woocommerce_system_status_report', array( $this, 'system_report_templates' ));
|
77 |
+
|
78 |
+
add_action( 'switch_theme', array( $this, 'admin_notice_outdated_templates' ) );
|
79 |
+
add_action( 'tinvwl_updated', array( $this, 'admin_notice_outdated_templates' ) );
|
80 |
}
|
81 |
|
82 |
/**
|
83 |
+
* Error notice if wizard didn't run.
|
84 |
*/
|
85 |
function wizard_run_admin_notice() {
|
86 |
printf( '<div class="notice notice-error"><p>%1$s</p><p><a href="%2$s" class="button-primary">%3$s</a> <a href="%4$s" class="button-secondary">%5$s</a></p></div>',
|
186 |
$panel[] = sprintf( '<a class="tinvwl-btn red w-icon smaller-txt" href="%s"><i class="fa fa-star"></i><span class="tinvwl-txt">%s</span></a>', $this->admin_url( 'upgrade' ), __( 'Upgrade to Pro', 'ti-woocommerce-wishlist' ) );
|
187 |
return $panel;
|
188 |
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Templates overriding status check.
|
192 |
+
*/
|
193 |
+
function templates_status_check( $outdated = false ) {
|
194 |
+
|
195 |
+
$found_files = array();
|
196 |
+
|
197 |
+
$scanned_files = WC_Admin_Status::scan_template_files( TINVWL_PATH . '/templates/' );
|
198 |
+
|
199 |
+
foreach ( $scanned_files as $file ) {
|
200 |
+
if ( file_exists( get_stylesheet_directory() . '/' . $file ) ) {
|
201 |
+
$theme_file = get_stylesheet_directory() . '/' . $file;
|
202 |
+
} elseif ( file_exists( get_stylesheet_directory() . '/woocommerce/' . $file ) ) {
|
203 |
+
$theme_file = get_stylesheet_directory() . '/woocommerce/' . $file;
|
204 |
+
} elseif ( file_exists( get_template_directory() . '/' . $file ) ) {
|
205 |
+
$theme_file = get_template_directory() . '/' . $file;
|
206 |
+
} elseif ( file_exists( get_template_directory() . '/woocommerce/' . $file ) ) {
|
207 |
+
$theme_file = get_template_directory() . '/woocommerce/' . $file;
|
208 |
+
} else {
|
209 |
+
$theme_file = false;
|
210 |
+
}
|
211 |
+
|
212 |
+
if ( ! empty( $theme_file ) ) {
|
213 |
+
$core_version = WC_Admin_Status::get_file_version( TINVWL_PATH . '/templates/' . $file );
|
214 |
+
$theme_version = WC_Admin_Status::get_file_version( $theme_file );
|
215 |
+
|
216 |
+
if ( $core_version && ( empty( $theme_version ) || version_compare( $theme_version, $core_version, '<' ) ) ) {
|
217 |
+
if ( $outdated ) {
|
218 |
+
return 'outdated';
|
219 |
+
}
|
220 |
+
$found_files[] = sprintf( __( '<code>%s</code> version <strong style="color:red">%s</strong> is out of date. The core version is %s', 'ti-woocommerce-wishlist' ), str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file ), $theme_version ? $theme_version : '-', $core_version );
|
221 |
+
} else {
|
222 |
+
$found_files[] = str_replace( WP_CONTENT_DIR . '/themes/', '', $theme_file );
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
|
227 |
+
return $found_files;
|
228 |
+
}
|
229 |
+
|
230 |
+
/**
|
231 |
+
* Templates overriding status for WooCommerce Status report page.
|
232 |
+
*/
|
233 |
+
function system_report_templates() {
|
234 |
+
|
235 |
+
TInvWL_View::view( 'templates-status', array( 'found_files' => $this->templates_status_check() ) );
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Outdated templates notice.
|
240 |
+
*/
|
241 |
+
function admin_notice_outdated_templates() {
|
242 |
+
if ( 'outdated' === $this->templates_status_check( true ) ) {
|
243 |
+
|
244 |
+
$theme = wp_get_theme();
|
245 |
+
|
246 |
+
$html = sprintf( __( '<strong>Your theme (%1$s) contains outdated copies of some WooCommerce Wishlist Plugin template files.</strong><br> These files may need updating to ensure they are compatible with the current version of WooCommerce Wishlist Plugin.<br> You can see which files are affected from the <a href="%2$s">system status page</a>.<br> If in doubt, check with the author of the theme.', 'ti-woocommerce-wishlist' ), esc_html( $theme[ 'Name' ] ), esc_url( admin_url( 'admin.php?page=wc-status' ) ) );
|
247 |
+
|
248 |
+
WC_Admin_Notices::add_custom_notice( 'outdated_templates', $html );
|
249 |
+
} else {
|
250 |
+
WC_Admin_Notices::remove_notice( 'outdated_templates' );
|
251 |
+
}
|
252 |
+
}
|
253 |
+
|
254 |
}
|
includes/product.helper.php
CHANGED
@@ -161,10 +161,10 @@ class TInvWL_Product {
|
|
161 |
}
|
162 |
|
163 |
$data = apply_filters( 'tinvwl_wishlist_product_add', $data );
|
164 |
-
$data['product_id'] = $product_data->id;
|
165 |
-
$data['variation_id'] = $product_data->variation_id;
|
166 |
$data['in_stock'] = $product_data->is_in_stock();
|
167 |
-
$data['price'] = $product_data->price;
|
168 |
|
169 |
global $wpdb;
|
170 |
if ( $wpdb->insert( $this->table, $data ) ) { // @codingStandardsIgnoreLine WordPress.VIP.DirectDatabaseQuery.DirectQuery
|
@@ -218,8 +218,8 @@ class TInvWL_Product {
|
|
218 |
}
|
219 |
|
220 |
$products = $this->get( array(
|
221 |
-
'product_id' => $product_data->id,
|
222 |
-
'variation_id' => $product_data->variation_id,
|
223 |
'wishlist_id' => $wishlist_id,
|
224 |
'count' => 1,
|
225 |
) );
|
@@ -313,16 +313,19 @@ class TInvWL_Product {
|
|
313 |
'variation_id' => FILTER_VALIDATE_INT,
|
314 |
'author' => FILTER_VALIDATE_INT,
|
315 |
'date' => FILTER_DEFAULT,
|
|
|
316 |
'price' => FILTER_SANITIZE_NUMBER_FLOAT,
|
317 |
'in_stock' => FILTER_VALIDATE_BOOLEAN,
|
318 |
) );
|
319 |
-
|
|
|
|
|
320 |
}
|
321 |
if ( $default['external'] ) {
|
322 |
$product_data = $this->product_data( $product['variation_id'], $product['product_id'] );
|
323 |
if ( $product_data ) {
|
324 |
-
$product['product_id']
|
325 |
-
$product['variation_id'] = $product_data->variation_id;
|
326 |
}
|
327 |
$product['data'] = $product_data;
|
328 |
}
|
@@ -349,19 +352,12 @@ class TInvWL_Product {
|
|
349 |
|
350 |
$product_data = wc_get_product( $variation_id ? $variation_id : $product_id );
|
351 |
|
352 |
-
if ( ! $product_data || 'trash' === $product_data->post->post_status ) {
|
353 |
return null;
|
354 |
}
|
355 |
|
356 |
-
$product_data->variation_id = absint( $product_data->variation_id );
|
357 |
-
|
358 |
-
if ( $product_data->is_purchasable() ) {
|
359 |
-
return $product_data;
|
360 |
-
}
|
361 |
-
} else {
|
362 |
-
return $product_data;
|
363 |
-
}
|
364 |
-
return false;
|
365 |
}
|
366 |
|
367 |
/**
|
@@ -400,10 +396,10 @@ class TInvWL_Product {
|
|
400 |
}
|
401 |
|
402 |
$data = apply_filters( 'tinvwl_wishlist_product_update', $data );
|
403 |
-
$data['product_id'] = $product_data->id;
|
404 |
-
$data['variation_id'] = $product_data->variation_id;
|
405 |
$data['in_stock'] = $product_data->is_in_stock();
|
406 |
-
$data['price'] = $product_data->price;
|
407 |
|
408 |
global $wpdb;
|
409 |
return false !== $wpdb->update( $this->table, $data, array(
|
@@ -439,12 +435,12 @@ class TInvWL_Product {
|
|
439 |
}
|
440 |
$data = array(
|
441 |
'wishlist_id' => $wishlist_id,
|
442 |
-
'product_id' => $product_data->id,
|
443 |
-
'variation_id' => $product_data->variation_id,
|
444 |
);
|
445 |
$result = false !== $wpdb->delete( $this->table, $data ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
|
446 |
if ( $result ) {
|
447 |
-
do_action( 'tinvwl_wishlist_product_removed_from_wishlist', $wishlist_id, $product_data->id, $product_data->variation_id );
|
448 |
}
|
449 |
return $result;
|
450 |
}
|
161 |
}
|
162 |
|
163 |
$data = apply_filters( 'tinvwl_wishlist_product_add', $data );
|
164 |
+
$data['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
|
165 |
+
$data['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
|
166 |
$data['in_stock'] = $product_data->is_in_stock();
|
167 |
+
$data['price'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->price : $product_data->get_price() );
|
168 |
|
169 |
global $wpdb;
|
170 |
if ( $wpdb->insert( $this->table, $data ) ) { // @codingStandardsIgnoreLine WordPress.VIP.DirectDatabaseQuery.DirectQuery
|
218 |
}
|
219 |
|
220 |
$products = $this->get( array(
|
221 |
+
'product_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ),
|
222 |
+
'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ),
|
223 |
'wishlist_id' => $wishlist_id,
|
224 |
'count' => 1,
|
225 |
) );
|
313 |
'variation_id' => FILTER_VALIDATE_INT,
|
314 |
'author' => FILTER_VALIDATE_INT,
|
315 |
'date' => FILTER_DEFAULT,
|
316 |
+
'quantity' => FILTER_VALIDATE_INT,
|
317 |
'price' => FILTER_SANITIZE_NUMBER_FLOAT,
|
318 |
'in_stock' => FILTER_VALIDATE_BOOLEAN,
|
319 |
) );
|
320 |
+
if ( ! tinv_get_option( 'product_table', 'colm_quantity' ) ) {
|
321 |
+
$product['quantity'] = 1;
|
322 |
+
}
|
323 |
}
|
324 |
if ( $default['external'] ) {
|
325 |
$product_data = $this->product_data( $product['variation_id'], $product['product_id'] );
|
326 |
if ( $product_data ) {
|
327 |
+
$product['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
|
328 |
+
$product['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
|
329 |
}
|
330 |
$product['data'] = $product_data;
|
331 |
}
|
352 |
|
353 |
$product_data = wc_get_product( $variation_id ? $variation_id : $product_id );
|
354 |
|
355 |
+
if ( ! $product_data || 'trash' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->post->post_status : get_post( $product_data->get_id() )->post_status ) ) {
|
356 |
return null;
|
357 |
}
|
358 |
|
359 |
+
$product_data->variation_id = absint( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) );
|
360 |
+
return $product_data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
361 |
}
|
362 |
|
363 |
/**
|
396 |
}
|
397 |
|
398 |
$data = apply_filters( 'tinvwl_wishlist_product_update', $data );
|
399 |
+
$data['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
|
400 |
+
$data['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
|
401 |
$data['in_stock'] = $product_data->is_in_stock();
|
402 |
+
$data['price'] = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->price : $product_data->get_price();
|
403 |
|
404 |
global $wpdb;
|
405 |
return false !== $wpdb->update( $this->table, $data, array(
|
435 |
}
|
436 |
$data = array(
|
437 |
'wishlist_id' => $wishlist_id,
|
438 |
+
'product_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ),
|
439 |
+
'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ),
|
440 |
);
|
441 |
$result = false !== $wpdb->delete( $this->table, $data ); // WPCS: db call ok; no-cache ok; unprepared SQL ok.
|
442 |
if ( $result ) {
|
443 |
+
do_action( 'tinvwl_wishlist_product_removed_from_wishlist', $wishlist_id, ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) );
|
444 |
}
|
445 |
return $result;
|
446 |
}
|
includes/product/local.class.php
CHANGED
@@ -132,6 +132,7 @@ class TInvWL_Product_Local {
|
|
132 |
|
133 |
/**
|
134 |
* Update cookie
|
|
|
135 |
*/
|
136 |
function update_cookie() {
|
137 |
@setcookie( 'tinv_wishlist', urlencode( wp_json_encode( $this->products ) ), time() + 31 * DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); // @codingStandardsIgnoreLine Generic.PHP.NoSilencedErrors.Discouraged WordPress.Sniffs.VIP.RestrictedFunctions
|
@@ -203,8 +204,8 @@ class TInvWL_Product_Local {
|
|
203 |
}
|
204 |
|
205 |
$data = apply_filters( 'tinvwl_wishlist_product_add', $data );
|
206 |
-
$data['product_id'] = $product_data->id;
|
207 |
-
$data['variation_id'] = $product_data->variation_id;
|
208 |
|
209 |
$this->add_cookies( $data );
|
210 |
|
@@ -239,8 +240,8 @@ class TInvWL_Product_Local {
|
|
239 |
}
|
240 |
|
241 |
$products = $this->get( array(
|
242 |
-
'product_id' => $product_data->id,
|
243 |
-
'variation_id' => $product_data->variation_id,
|
244 |
'count' => 1,
|
245 |
'external' => false,
|
246 |
) );
|
@@ -317,8 +318,8 @@ class TInvWL_Product_Local {
|
|
317 |
if ( $default['external'] ) {
|
318 |
$product_data = $this->product_data( $product['variation_id'], $product['product_id'] );
|
319 |
if ( $product_data ) {
|
320 |
-
$product['product_id'] = $product_data->id;
|
321 |
-
$product['variation_id'] = $product_data->variation_id;
|
322 |
}
|
323 |
$product['data'] = $product_data;
|
324 |
}
|
@@ -345,19 +346,12 @@ class TInvWL_Product_Local {
|
|
345 |
|
346 |
$product_data = wc_get_product( $variation_id ? $variation_id : $product_id );
|
347 |
|
348 |
-
if ( ! $product_data || 'trash' === $product_data->post->post_status ) {
|
349 |
return null;
|
350 |
}
|
351 |
|
352 |
-
$product_data->variation_id = absint( $product_data->variation_id );
|
353 |
-
|
354 |
-
if ( $product_data->is_purchasable() ) {
|
355 |
-
return $product_data;
|
356 |
-
}
|
357 |
-
} else {
|
358 |
-
return $product_data;
|
359 |
-
}
|
360 |
-
return false;
|
361 |
}
|
362 |
|
363 |
/**
|
@@ -391,8 +385,8 @@ class TInvWL_Product_Local {
|
|
391 |
}
|
392 |
|
393 |
$data = apply_filters( 'tinvwl_wishlist_product_update', $data );
|
394 |
-
$data['product_id'] = $product_data->id;
|
395 |
-
$data['variation_id'] = $product_data->variation_id;
|
396 |
|
397 |
return $this->update_cookies( $data, array( 'product_id' => $data['product_id'], 'variation_id' => $data['variation_id'] ) );
|
398 |
}
|
@@ -417,7 +411,7 @@ class TInvWL_Product_Local {
|
|
417 |
}
|
418 |
|
419 |
foreach ( $this->products as $key => $product ) {
|
420 |
-
if ( $product['product_id'] == $product_data->id && $product['variation_id'] == $product_data->variation_id ) { // WPCS: loose comparison ok.
|
421 |
$this->products[ $key ] = null;
|
422 |
}
|
423 |
}
|
@@ -428,7 +422,7 @@ class TInvWL_Product_Local {
|
|
428 |
|
429 |
if ( count( $this->products ) < $c ) {
|
430 |
$this->update_cookie();
|
431 |
-
do_action( 'tinvwl_wishlist_product_removed_from_wishlist', $wishlist_id, $product_data->id, $product_data->variation_id );
|
432 |
}
|
433 |
return true;
|
434 |
}
|
132 |
|
133 |
/**
|
134 |
* Update cookie
|
135 |
+
*
|
136 |
*/
|
137 |
function update_cookie() {
|
138 |
@setcookie( 'tinv_wishlist', urlencode( wp_json_encode( $this->products ) ), time() + 31 * DAY_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN ); // @codingStandardsIgnoreLine Generic.PHP.NoSilencedErrors.Discouraged WordPress.Sniffs.VIP.RestrictedFunctions
|
204 |
}
|
205 |
|
206 |
$data = apply_filters( 'tinvwl_wishlist_product_add', $data );
|
207 |
+
$data['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
|
208 |
+
$data['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
|
209 |
|
210 |
$this->add_cookies( $data );
|
211 |
|
240 |
}
|
241 |
|
242 |
$products = $this->get( array(
|
243 |
+
'product_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ),
|
244 |
+
'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ),
|
245 |
'count' => 1,
|
246 |
'external' => false,
|
247 |
) );
|
318 |
if ( $default['external'] ) {
|
319 |
$product_data = $this->product_data( $product['variation_id'], $product['product_id'] );
|
320 |
if ( $product_data ) {
|
321 |
+
$product['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
|
322 |
+
$product['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
|
323 |
}
|
324 |
$product['data'] = $product_data;
|
325 |
}
|
346 |
|
347 |
$product_data = wc_get_product( $variation_id ? $variation_id : $product_id );
|
348 |
|
349 |
+
if ( ! $product_data || 'trash' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->post->post_status : get_post( $product_data->get_id() )->post_status ) ) {
|
350 |
return null;
|
351 |
}
|
352 |
|
353 |
+
$product_data->variation_id = absint( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) );
|
354 |
+
return $product_data;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
}
|
356 |
|
357 |
/**
|
385 |
}
|
386 |
|
387 |
$data = apply_filters( 'tinvwl_wishlist_product_update', $data );
|
388 |
+
$data['product_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) );
|
389 |
+
$data['variation_id'] = ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) );
|
390 |
|
391 |
return $this->update_cookies( $data, array( 'product_id' => $data['product_id'], 'variation_id' => $data['variation_id'] ) );
|
392 |
}
|
411 |
}
|
412 |
|
413 |
foreach ( $this->products as $key => $product ) {
|
414 |
+
if ( $product['product_id'] == ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ) && $product['variation_id'] == ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) ) { // WPCS: loose comparison ok.
|
415 |
$this->products[ $key ] = null;
|
416 |
}
|
417 |
}
|
422 |
|
423 |
if ( count( $this->products ) < $c ) {
|
424 |
$this->update_cookie();
|
425 |
+
do_action( 'tinvwl_wishlist_product_removed_from_wishlist', $wishlist_id, ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->id : ( $product_data->is_type( 'variation' ) ? $product_data->get_parent_id() : $product_data->get_id() ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_data->variation_id : ( $product_data->is_type( 'variation' ) ? $product_data->get_id() : 0 ) ) );
|
426 |
}
|
427 |
return true;
|
428 |
}
|
includes/tinvwl.class.php
CHANGED
@@ -74,7 +74,7 @@ class TInvWL {
|
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
-
* Set
|
78 |
*/
|
79 |
private function set_locale() {
|
80 |
load_plugin_textdomain( TINVWL_DOMAIN, false, basename( TINVWL_PATH ) . DIRECTORY_SEPARATOR . 'languages' );
|
@@ -105,9 +105,9 @@ class TInvWL {
|
|
105 |
}
|
106 |
if ( version_compare( $this->_v, $prev, 'gt' ) ) {
|
107 |
TInvWL_Activator::update();
|
108 |
-
new TInvWL_Update( $this->_v, $prev );
|
109 |
-
do_action( 'tinvwl_updateing', $this->_v, $prev );
|
110 |
update_option( $this->_n . '_ver', $this->_v );
|
|
|
111 |
}
|
112 |
}
|
113 |
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
+
* Set localization
|
78 |
*/
|
79 |
private function set_locale() {
|
80 |
load_plugin_textdomain( TINVWL_DOMAIN, false, basename( TINVWL_PATH ) . DIRECTORY_SEPARATOR . 'languages' );
|
105 |
}
|
106 |
if ( version_compare( $this->_v, $prev, 'gt' ) ) {
|
107 |
TInvWL_Activator::update();
|
108 |
+
new TInvWL_Update( $this->_v, $prev );
|
|
|
109 |
update_option( $this->_n . '_ver', $this->_v );
|
110 |
+
do_action( 'tinvwl_updated', $current, $prev );
|
111 |
}
|
112 |
}
|
113 |
|
public/addtowishlist.class.php
CHANGED
@@ -264,7 +264,7 @@ class TInvWL_Public_AddToWishlist {
|
|
264 |
if ( ! empty( $available_variations ) && is_array( $available_variations ) ) {
|
265 |
$wishlist['in'] = array();
|
266 |
foreach ( $available_variations as $variation ) {
|
267 |
-
if ( $wlp->check_product( $product->id, $variation ) ) {
|
268 |
$wishlist['in'][] = $variation;
|
269 |
}
|
270 |
}
|
@@ -272,7 +272,7 @@ class TInvWL_Public_AddToWishlist {
|
|
272 |
$wishlist['in'] = false;
|
273 |
}
|
274 |
} else {
|
275 |
-
$wishlist['in'] = (bool) $wlp->check_product( $product->id );
|
276 |
}
|
277 |
$wishlists[ $key ] = $wishlist;
|
278 |
}
|
@@ -287,7 +287,7 @@ class TInvWL_Public_AddToWishlist {
|
|
287 |
if ( ! empty( $available_variations ) && is_array( $available_variations ) ) {
|
288 |
$wishlist['in'] = array();
|
289 |
foreach ( $available_variations as $variation ) {
|
290 |
-
if ( $wlp->check_product( $product->id, $variation ) ) {
|
291 |
$wishlist['in'][] = $variation;
|
292 |
}
|
293 |
}
|
@@ -295,7 +295,7 @@ class TInvWL_Public_AddToWishlist {
|
|
295 |
$wishlist['in'] = false;
|
296 |
}
|
297 |
} else {
|
298 |
-
$wishlist['in'] = (bool) $wlp->check_product( $product->id );
|
299 |
}
|
300 |
$wishlists[0] = $wishlist;
|
301 |
}
|
@@ -313,7 +313,7 @@ class TInvWL_Public_AddToWishlist {
|
|
313 |
global $product;
|
314 |
|
315 |
if ( $product ) {
|
316 |
-
if ( apply_filters( 'tinvwl_allow_addtowishlist_single_product_summary', ( $product->is_purchasable() && 'simple' === $product->product_type && ! $product->is_in_stock() ) ) ) {
|
317 |
$this->htmloutput();
|
318 |
}
|
319 |
}
|
@@ -343,7 +343,7 @@ class TInvWL_Public_AddToWishlist {
|
|
343 |
|
344 |
$product_data = wc_get_product( $variation_id ? $variation_id : $product_id );
|
345 |
|
346 |
-
if ( $product_data && 'trash' !== $
|
347 |
$this->product = $product_data;
|
348 |
} else {
|
349 |
return '';
|
@@ -401,9 +401,9 @@ class TInvWL_Public_AddToWishlist {
|
|
401 |
}
|
402 |
}
|
403 |
if ( 'button' == tinv_get_option( 'add_to_wishlist', 'type' ) ) { // WPCS: loose comparison ok.
|
404 |
-
$content .= sprintf( '<a class="tinvwl_add_to_wishlist_button %s button" tinv-wl-list="%s" tinv-wl-product="%s" tinv-wl-productvariation="%s" tinv-wl-producttype="%s">%s</a>', $icon, htmlspecialchars( wp_json_encode( $this->wishlist ) ), $this->product->id, $this->product->variation_id, $this->product->product_type, $text );
|
405 |
} else {
|
406 |
-
$content .= sprintf( '<a class="tinvwl_add_to_wishlist_button %s" tinv-wl-list="%s" tinv-wl-product="%s" tinv-wl-productvariation="%s" tinv-wl-producttype="%s" href="javascript:void(0);">%s</a>', $icon, htmlspecialchars( wp_json_encode( $this->wishlist ) ), $this->product->id, $this->product->variation_id, $this->product->product_type, $text );
|
407 |
}
|
408 |
$content .= apply_filters( 'tinvwl_wishlist_button_after', '' );
|
409 |
|
@@ -430,8 +430,8 @@ class TInvWL_Public_AddToWishlist {
|
|
430 |
);
|
431 |
if ( $product ) {
|
432 |
$default = array(
|
433 |
-
'product_id' => $product->id,
|
434 |
-
'variation_id' => $product->variation_id,
|
435 |
);
|
436 |
}
|
437 |
$atts = shortcode_atts( $default, $atts );
|
264 |
if ( ! empty( $available_variations ) && is_array( $available_variations ) ) {
|
265 |
$wishlist['in'] = array();
|
266 |
foreach ( $available_variations as $variation ) {
|
267 |
+
if ( $wlp->check_product( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), $variation ) ) {
|
268 |
$wishlist['in'][] = $variation;
|
269 |
}
|
270 |
}
|
272 |
$wishlist['in'] = false;
|
273 |
}
|
274 |
} else {
|
275 |
+
$wishlist['in'] = (bool) $wlp->check_product( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ) );
|
276 |
}
|
277 |
$wishlists[ $key ] = $wishlist;
|
278 |
}
|
287 |
if ( ! empty( $available_variations ) && is_array( $available_variations ) ) {
|
288 |
$wishlist['in'] = array();
|
289 |
foreach ( $available_variations as $variation ) {
|
290 |
+
if ( $wlp->check_product( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ), $variation ) ) {
|
291 |
$wishlist['in'][] = $variation;
|
292 |
}
|
293 |
}
|
295 |
$wishlist['in'] = false;
|
296 |
}
|
297 |
} else {
|
298 |
+
$wishlist['in'] = (bool) $wlp->check_product( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ) );
|
299 |
}
|
300 |
$wishlists[0] = $wishlist;
|
301 |
}
|
313 |
global $product;
|
314 |
|
315 |
if ( $product ) {
|
316 |
+
if ( apply_filters( 'tinvwl_allow_addtowishlist_single_product_summary', ( $product->is_purchasable() && 'simple' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) && ! $product->is_in_stock() ) ) ) {
|
317 |
$this->htmloutput();
|
318 |
}
|
319 |
}
|
343 |
|
344 |
$product_data = wc_get_product( $variation_id ? $variation_id : $product_id );
|
345 |
|
346 |
+
if ( $product_data && 'trash' !== ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->post->post_status : get_post( $product->get_id()->post_status ) ) ) {
|
347 |
$this->product = $product_data;
|
348 |
} else {
|
349 |
return '';
|
401 |
}
|
402 |
}
|
403 |
if ( 'button' == tinv_get_option( 'add_to_wishlist', 'type' ) ) { // WPCS: loose comparison ok.
|
404 |
+
$content .= sprintf( '<a class="tinvwl_add_to_wishlist_button %s button" tinv-wl-list="%s" tinv-wl-product="%s" tinv-wl-productvariation="%s" tinv-wl-producttype="%s">%s</a>', $icon, htmlspecialchars( wp_json_encode( $this->wishlist ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->id : ( $this->product->is_type( 'variation' ) ? $this->product->get_parent_id() : $this->product->get_id() ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->variation_id : ( $this->product->is_type( 'variation' ) ? $this->product->get_id() : 0 ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->product_type : $this->product->get_type() ), $text );
|
405 |
} else {
|
406 |
+
$content .= sprintf( '<a class="tinvwl_add_to_wishlist_button %s" tinv-wl-list="%s" tinv-wl-product="%s" tinv-wl-productvariation="%s" tinv-wl-producttype="%s" href="javascript:void(0);">%s</a>', $icon, htmlspecialchars( wp_json_encode( $this->wishlist ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->id : ( $this->product->is_type( 'variation' ) ? $this->product->get_parent_id() : $this->product->get_id() ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->variation_id : ( $this->product->is_type( 'variation' ) ? $this->product->get_id() : 0 ) ), ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->product_type : $this->product->get_type() ), $text );
|
407 |
}
|
408 |
$content .= apply_filters( 'tinvwl_wishlist_button_after', '' );
|
409 |
|
430 |
);
|
431 |
if ( $product ) {
|
432 |
$default = array(
|
433 |
+
'product_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->id : ( $this->product->is_type( 'variation' ) ? $this->product->get_parent_id() : $this->product->get_id() ) ),
|
434 |
+
'variation_id' => ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $this->product->variation_id : ( $this->product->is_type( 'variation' ) ? $this->product->get_id() : 0 ) ),
|
435 |
);
|
436 |
}
|
437 |
$atts = shortcode_atts( $default, $atts );
|
public/cart.class.php
CHANGED
@@ -91,8 +91,8 @@ class TInvWL_Public_Cart {
|
|
91 |
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $product['product_id'] ) );
|
92 |
$quantity = empty( $wl_quantity ) ? 1 : wc_stock_amount( $wl_quantity );
|
93 |
$variation_id = $product['variation_id'];
|
94 |
-
$variations = $product['data']->variation_data;
|
95 |
-
$passed_validation = $product['data']->is_purchasable() && ( $product['data']->is_in_stock() || $product['data']->backorders_allowed() ) && 'external' !== $product['data']->product_type;
|
96 |
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations );
|
97 |
if ( $passed_validation ) {
|
98 |
$cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations );
|
91 |
$product_id = apply_filters( 'woocommerce_add_to_cart_product_id', absint( $product['product_id'] ) );
|
92 |
$quantity = empty( $wl_quantity ) ? 1 : wc_stock_amount( $wl_quantity );
|
93 |
$variation_id = $product['variation_id'];
|
94 |
+
$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() ) );
|
95 |
+
$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() );
|
96 |
$passed_validation = apply_filters( 'woocommerce_add_to_cart_validation', $passed_validation, $product_id, $quantity, $variation_id, $variations );
|
97 |
if ( $passed_validation ) {
|
98 |
$cart_item_key = WC()->cart->add_to_cart( $product_id, $quantity, $variation_id, $variations );
|
public/tinvwl.class.php
CHANGED
@@ -365,7 +365,7 @@ class TInvWL_Public_TInvWL {
|
|
365 |
wp_localize_script( $this->_n, 'tinvwl_add_to_wishlist', array(
|
366 |
'text_create' => __( 'Create New', 'ti-woocommerce-wishlist' ),
|
367 |
'text_already_in' => tinv_get_option( 'add_to_wishlist', 'text_already_in' ),
|
368 |
-
'i18n_make_a_selection_text' => esc_attr__( 'Please select some product options before adding this product to your wishlist.', 'ti-woocommerce-wishlist
|
369 |
) );
|
370 |
wp_enqueue_script( $this->_n );
|
371 |
}
|
365 |
wp_localize_script( $this->_n, 'tinvwl_add_to_wishlist', array(
|
366 |
'text_create' => __( 'Create New', 'ti-woocommerce-wishlist' ),
|
367 |
'text_already_in' => tinv_get_option( 'add_to_wishlist', 'text_already_in' ),
|
368 |
+
'i18n_make_a_selection_text' => esc_attr__( 'Please select some product options before adding this product to your wishlist.', 'ti-woocommerce-wishlist' ),
|
369 |
) );
|
370 |
wp_enqueue_script( $this->_n );
|
371 |
}
|
public/wishlist/view.class.php
CHANGED
@@ -85,7 +85,7 @@ class TInvWL_Public_Wishlist_View {
|
|
85 |
* @return string
|
86 |
*/
|
87 |
function external_text( $text, $wl_product, $product ) {
|
88 |
-
if ( 'external' === $product->product_type ) {
|
89 |
return $product->single_add_to_cart_text();
|
90 |
}
|
91 |
return $text;
|
@@ -163,7 +163,7 @@ class TInvWL_Public_Wishlist_View {
|
|
163 |
if ( ! $allow ) {
|
164 |
return false;
|
165 |
}
|
166 |
-
return ( $product->is_purchasable() || 'external' === $product->product_type ) && ( $product->is_in_stock() || $product->backorders_allowed() );
|
167 |
}
|
168 |
|
169 |
/**
|
@@ -281,12 +281,12 @@ class TInvWL_Public_Wishlist_View {
|
|
281 |
if ( empty( $product ) || empty( $product['data'] ) ) {
|
282 |
return false;
|
283 |
}
|
284 |
-
$need_url = apply_filters( 'woocommerce_product_add_to_cart_url', remove_query_arg( 'added-to-cart', add_query_arg( array_filter( array_merge( array( 'variation_id' => $product['data']->variation_id, 'add-to-cart' => $product['data']->id ), array_map( 'urlencode', (array) $product['data']->variation_data ) ) ) ) ), $product['data'] );
|
285 |
|
286 |
add_filter( 'clean_url', 'tinvwl_clean_url', 10, 2 );
|
287 |
$redirect_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_url', $product['data']->add_to_cart_url(), $product['data'] );
|
288 |
remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
|
289 |
-
if ( 'external' === $product['data']->product_type || $redirect_url !== $need_url ) {
|
290 |
wp_redirect( $redirect_url ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.wp_redirect
|
291 |
return true;
|
292 |
}
|
85 |
* @return string
|
86 |
*/
|
87 |
function external_text( $text, $wl_product, $product ) {
|
88 |
+
if ( 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) ) {
|
89 |
return $product->single_add_to_cart_text();
|
90 |
}
|
91 |
return $text;
|
163 |
if ( ! $allow ) {
|
164 |
return false;
|
165 |
}
|
166 |
+
return ( $product->is_purchasable() || 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->product_type : $product->get_type() ) ) && ( $product->is_in_stock() || $product->backorders_allowed() );
|
167 |
}
|
168 |
|
169 |
/**
|
281 |
if ( empty( $product ) || empty( $product['data'] ) ) {
|
282 |
return false;
|
283 |
}
|
284 |
+
$need_url = apply_filters( 'woocommerce_product_add_to_cart_url', remove_query_arg( 'added-to-cart', ( version_compare( WC_VERSION, '3.0.0', '<' ) ? add_query_arg( array_filter( array_merge( array( 'variation_id' => $product['data']->variation_id, 'add-to-cart' => $product['data']->id ), array_map( 'urlencode', (array) $product['data']->variation_data ) ) ) ) : add_query_arg( array( 'variation_id' => $product['data']->get_id(), 'add-to-cart' => $product['data']->get_parent_id() ), $product['data']->get_permalink() ) ) ), $product['data'] );
|
285 |
|
286 |
add_filter( 'clean_url', 'tinvwl_clean_url', 10, 2 );
|
287 |
$redirect_url = apply_filters( 'tinvwl_product_add_to_cart_redirect_url', $product['data']->add_to_cart_url(), $product['data'] );
|
288 |
remove_filter( 'clean_url', 'tinvwl_clean_url', 10 );
|
289 |
+
if ( 'external' === ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product['data']->product_type : $product['data']->get_type() ) || $redirect_url !== $need_url ) {
|
290 |
wp_redirect( $redirect_url ); // @codingStandardsIgnoreLine WordPress.VIP.RestrictedFunctions.wp_redirect
|
291 |
return true;
|
292 |
}
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://templateinvaders.com/?utm_source=wordpressorg&utm_content=d
|
|
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.7.3
|
7 |
-
Stable tag: 1.
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
@@ -125,6 +125,12 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
|
|
125 |
|
126 |
== Changelog ==
|
127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
128 |
= 1.1.14 =
|
129 |
*Release Date - 04 April 2017*
|
130 |
|
@@ -227,4 +233,4 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
|
|
227 |
= 1.0.0 =
|
228 |
*Release Date - 22 September 2016*
|
229 |
|
230 |
-
* Initial release
|
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.7.3
|
7 |
+
Stable tag: 1.2.0
|
8 |
License: GPLv3
|
9 |
License URI: https://www.gnu.org/licenses/gpl-3.0.html
|
10 |
|
125 |
|
126 |
== Changelog ==
|
127 |
|
128 |
+
= 1.2.0 =
|
129 |
+
*Release Date - 07 April 2017*
|
130 |
+
|
131 |
+
* WooCommerce 3.0+ support
|
132 |
+
* Added template overrides check for WooCommerce system report
|
133 |
+
|
134 |
= 1.1.14 =
|
135 |
*Release Date - 04 April 2017*
|
136 |
|
233 |
= 1.0.0 =
|
234 |
*Release Date - 22 September 2016*
|
235 |
|
236 |
+
* Initial release
|
templates/index.php
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
// @codingStandardsIgnoreFile
|
3 |
-
// Silence is golden.
|
|
|
|
|
|
templates/ti-addtowishlist.php
CHANGED
@@ -11,9 +11,9 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
11 |
}
|
12 |
|
13 |
?>
|
14 |
-
<input type="hidden" name="product_id" value="<?php echo esc_attr( $product->id ); ?>" />
|
15 |
-
<?php if ( $product->variation_id ) { ?>
|
16 |
-
<input type="hidden" name="variation_id" value="<?php echo esc_attr( $product->variation_id ); ?>" />
|
17 |
<?php } ?>
|
18 |
<div class="tinv-wraper woocommerce tinv-wishlist <?php echo esc_attr( $class_postion )?>">
|
19 |
<?php do_action( 'tinv_wishlist_addtowishlist_button' ); ?>
|
11 |
}
|
12 |
|
13 |
?>
|
14 |
+
<input type="hidden" name="product_id" value="<?php echo esc_attr( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->id : ( $product->is_type( 'variation' ) ? $product->get_parent_id() : $product->get_id() ) ); ?>" />
|
15 |
+
<?php if ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 ) ) { ?>
|
16 |
+
<input type="hidden" name="variation_id" value="<?php echo esc_attr( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 ) ); ?>" />
|
17 |
<?php } ?>
|
18 |
<div class="tinv-wraper woocommerce tinv-wishlist <?php echo esc_attr( $class_postion )?>">
|
19 |
<?php do_action( 'tinv_wishlist_addtowishlist_button' ); ?>
|
ti-woocommerce-wishlist.php
CHANGED
@@ -1,10 +1,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.
|
8 |
* Author: TemplateInvaders
|
9 |
* Author URI: https://templateinvaders.com/
|
10 |
* License: GPL-2.0+
|
@@ -14,7 +15,6 @@
|
|
14 |
*
|
15 |
* @package TInvWishlist
|
16 |
*/
|
17 |
-
|
18 |
// If this file is called directly, abort.
|
19 |
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
die;
|
@@ -37,7 +37,7 @@ if ( ! defined( 'TINVWL_DOMAIN' ) ) {
|
|
37 |
}
|
38 |
|
39 |
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
40 |
-
define( 'TINVWL_FVERSION', '1.
|
41 |
}
|
42 |
|
43 |
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
@@ -57,18 +57,22 @@ if ( ! function_exists( 'activation_tinv_wishlist' ) ) {
|
|
57 |
flush_rewrite_rules();
|
58 |
}
|
59 |
}
|
|
|
60 |
}
|
61 |
|
62 |
if ( ! function_exists( 'deactivation_tinv_wishlist' ) ) {
|
|
|
63 |
/**
|
64 |
* Deactivation plugin
|
65 |
*/
|
66 |
function deactivation_tinv_wishlist() {
|
67 |
flush_rewrite_rules();
|
68 |
}
|
|
|
69 |
}
|
70 |
|
71 |
if ( ! function_exists( 'uninstall_tinv_wishlist' ) ) {
|
|
|
72 |
/**
|
73 |
* Uninstall plugin
|
74 |
*/
|
@@ -78,9 +82,11 @@ if ( ! function_exists( 'uninstall_tinv_wishlist' ) ) {
|
|
78 |
flush_rewrite_rules();
|
79 |
}
|
80 |
}
|
|
|
81 |
}
|
82 |
|
83 |
if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
|
|
|
84 |
/**
|
85 |
* Dependency plugin
|
86 |
*
|
@@ -88,13 +94,14 @@ if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
|
|
88 |
* @return boolean
|
89 |
*/
|
90 |
function dependency_tinv_wishlist( $run = true ) {
|
91 |
-
$ext
|
92 |
-
$ext->set_dependency( 'woocommerce/woocommerce.php','WooCommerce' )->need();
|
93 |
if ( $run ) {
|
94 |
$ext->run();
|
95 |
}
|
96 |
return $ext->status_dependency();
|
97 |
}
|
|
|
98 |
}
|
99 |
|
100 |
if ( ! function_exists( 'run_tinv_wishlist' ) ) {
|
@@ -117,6 +124,7 @@ if ( ! function_exists( 'run_tinv_wishlist' ) ) {
|
|
117 |
$plugin->run();
|
118 |
}
|
119 |
}
|
|
|
120 |
}
|
121 |
|
122 |
register_activation_hook( __FILE__, 'activation_tinv_wishlist' );
|
1 |
<?php
|
2 |
+
|
3 |
/**
|
4 |
* WooCommerce Wishlist Plugin.
|
5 |
* Plugin Name: WooCommerce Wishlist Plugin
|
6 |
* Plugin URI: https://wordpress.org/plugins/ti-woocommerce-wishlist/
|
7 |
* Description: Wishlist functionality for your WooCommerce store.
|
8 |
+
* Version: 1.2.0
|
9 |
* Author: TemplateInvaders
|
10 |
* Author URI: https://templateinvaders.com/
|
11 |
* License: GPL-2.0+
|
15 |
*
|
16 |
* @package TInvWishlist
|
17 |
*/
|
|
|
18 |
// If this file is called directly, abort.
|
19 |
if ( ! defined( 'ABSPATH' ) ) {
|
20 |
die;
|
37 |
}
|
38 |
|
39 |
if ( ! defined( 'TINVWL_FVERSION' ) ) {
|
40 |
+
define( 'TINVWL_FVERSION', '1.2.0' );
|
41 |
}
|
42 |
|
43 |
if ( ! defined( 'TINVWL_LOAD_FREE' ) ) {
|
57 |
flush_rewrite_rules();
|
58 |
}
|
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 |
|
74 |
if ( ! function_exists( 'uninstall_tinv_wishlist' ) ) {
|
75 |
+
|
76 |
/**
|
77 |
* Uninstall plugin
|
78 |
*/
|
82 |
flush_rewrite_rules();
|
83 |
}
|
84 |
}
|
85 |
+
|
86 |
}
|
87 |
|
88 |
if ( ! function_exists( 'dependency_tinv_wishlist' ) ) {
|
89 |
+
|
90 |
/**
|
91 |
* Dependency plugin
|
92 |
*
|
94 |
* @return boolean
|
95 |
*/
|
96 |
function dependency_tinv_wishlist( $run = true ) {
|
97 |
+
$ext = new TInvWL_PluginExtend( null, __FILE__, TINVWL_PREFIX );
|
98 |
+
$ext->set_dependency( 'woocommerce/woocommerce.php', 'WooCommerce' )->need();
|
99 |
if ( $run ) {
|
100 |
$ext->run();
|
101 |
}
|
102 |
return $ext->status_dependency();
|
103 |
}
|
104 |
+
|
105 |
}
|
106 |
|
107 |
if ( ! function_exists( 'run_tinv_wishlist' ) ) {
|
124 |
$plugin->run();
|
125 |
}
|
126 |
}
|
127 |
+
|
128 |
}
|
129 |
|
130 |
register_activation_hook( __FILE__, 'activation_tinv_wishlist' );
|
tinv-wishlists-function.php
CHANGED
@@ -282,8 +282,10 @@ if ( ! function_exists( 'tinv_wishlist_get_item_data' ) ) {
|
|
282 |
*/
|
283 |
function tinv_wishlist_get_item_data( $product, $flat = false ) {
|
284 |
$item_data = array();
|
285 |
-
|
286 |
-
|
|
|
|
|
287 |
if ( '' === $value ) {
|
288 |
continue;
|
289 |
}
|
@@ -304,7 +306,7 @@ if ( ! function_exists( 'tinv_wishlist_get_item_data' ) ) {
|
|
304 |
$product_attributes = $product->get_attributes();
|
305 |
|
306 |
if ( isset( $product_attributes[ str_replace( 'attribute_', '', $name ) ] ) ) {
|
307 |
-
$label = wc_attribute_label( $product_attributes[ str_replace( 'attribute_', '', $name ) ]['name'] );
|
308 |
} else {
|
309 |
$label = $name;
|
310 |
}
|
@@ -689,7 +691,7 @@ if ( ! function_exists( 'gf_productaddon_support' ) ) {
|
|
689 |
* @return string
|
690 |
*/
|
691 |
function gf_productaddon_text_button( $text_add_to_card, $wl_product, $product ) {
|
692 |
-
$gravity_form_data = get_post_meta( $product->id, '_gravity_form_data', true );
|
693 |
return ( $gravity_form_data ) ? __( 'Select options', 'woocommerce' ) : $text_add_to_card;
|
694 |
}
|
695 |
|
@@ -706,7 +708,7 @@ if ( ! function_exists( 'gf_productaddon_support' ) ) {
|
|
706 |
* @return boolean
|
707 |
*/
|
708 |
function gf_productaddon_run_action_button( $need, $product ) {
|
709 |
-
$gravity_form_data = get_post_meta( $product->id, '_gravity_form_data', true );
|
710 |
return ( $gravity_form_data ) ? true : $need;
|
711 |
}
|
712 |
|
@@ -723,7 +725,7 @@ if ( ! function_exists( 'gf_productaddon_support' ) ) {
|
|
723 |
* @return string
|
724 |
*/
|
725 |
function gf_productaddon_action_button( $url, $product ) {
|
726 |
-
$gravity_form_data = get_post_meta( $product->id, '_gravity_form_data', true );
|
727 |
return ( $gravity_form_data ) ? $product->get_permalink() : $url;
|
728 |
}
|
729 |
|
282 |
*/
|
283 |
function tinv_wishlist_get_item_data( $product, $flat = false ) {
|
284 |
$item_data = array();
|
285 |
+
$variation_id = version_compare( WC_VERSION, '3.0.0', '<' ) ? $product->variation_id : ( $product->is_type( 'variation' ) ? $product->get_id() : 0 );
|
286 |
+
$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() );
|
287 |
+
if ( ! empty( $variation_id ) && is_array( $variation_data ) ) {
|
288 |
+
foreach ( $variation_data as $name => $value ) {
|
289 |
if ( '' === $value ) {
|
290 |
continue;
|
291 |
}
|
306 |
$product_attributes = $product->get_attributes();
|
307 |
|
308 |
if ( isset( $product_attributes[ str_replace( 'attribute_', '', $name ) ] ) ) {
|
309 |
+
$label = wc_attribute_label( ( version_compare( WC_VERSION, '3.0.0', '<' ) ? $product_attributes[ str_replace( 'attribute_', '', $name ) ]['name'] : str_replace( 'attribute_', '', $name ) ) );
|
310 |
} else {
|
311 |
$label = $name;
|
312 |
}
|
691 |
* @return string
|
692 |
*/
|
693 |
function gf_productaddon_text_button( $text_add_to_card, $wl_product, $product ) {
|
694 |
+
$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 );
|
695 |
return ( $gravity_form_data ) ? __( 'Select options', 'woocommerce' ) : $text_add_to_card;
|
696 |
}
|
697 |
|
708 |
* @return boolean
|
709 |
*/
|
710 |
function gf_productaddon_run_action_button( $need, $product ) {
|
711 |
+
$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 );
|
712 |
return ( $gravity_form_data ) ? true : $need;
|
713 |
}
|
714 |
|
725 |
* @return string
|
726 |
*/
|
727 |
function gf_productaddon_action_button( $url, $product ) {
|
728 |
+
$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 );
|
729 |
return ( $gravity_form_data ) ? $product->get_permalink() : $url;
|
730 |
}
|
731 |
|
views/admin/templates-status.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* The Template for displaying wishlist templates overrides status on WooCOmmerce System Status page.
|
4 |
+
*
|
5 |
+
* @since 1.2.0
|
6 |
+
* @package TInvWishlist\Admin\Template
|
7 |
+
*/
|
8 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
9 |
+
exit; // Exit if accessed directly.
|
10 |
+
}
|
11 |
+
?>
|
12 |
+
|
13 |
+
<table class="wc_status_table widefat" cellspacing="0">
|
14 |
+
<thead>
|
15 |
+
<tr>
|
16 |
+
<th colspan="3" data-export-label="<?php _e( 'TI WooCommerce Wishlist Templates', 'ti-woocommerce-wishlist' ); ?>"><h2><?php _e( 'TI WooCommerce Wishlist Templates', 'ti-woocommerce-wishlist' ); ?><?php echo wc_help_tip( __( 'This section shows any files that are overriding the default TI WooCommerce Wishlist template pages.', 'woocommerce' ) ); ?></h2></th>
|
17 |
+
</tr>
|
18 |
+
</thead>
|
19 |
+
<tbody>
|
20 |
+
<?php
|
21 |
+
if ( $found_files ) {
|
22 |
+
?>
|
23 |
+
<tr>
|
24 |
+
<td data-export-label="<?php _e( 'Overrides', 'ti-woocommerce-wishlist' ); ?>"><?php _e( 'Overrides', 'ti-woocommerce-wishlist' ); ?></td>
|
25 |
+
<td class="help"> </td>
|
26 |
+
<td><?php echo implode( ', <br/>', $found_files ); ?></td>
|
27 |
+
</tr>
|
28 |
+
<?php } else {
|
29 |
+
?>
|
30 |
+
<tr>
|
31 |
+
<td data-export-label="<?php _e( 'Overrides', 'ti-woocommerce-wishlist' ); ?>"><?php _e( 'Overrides', 'ti-woocommerce-wishlist' ); ?>:</td>
|
32 |
+
<td class="help"> </td>
|
33 |
+
<td>–</td>
|
34 |
+
</tr>
|
35 |
+
<?php }
|
36 |
+
?>
|
37 |
+
</tbody>
|
38 |
+
</table>
|