Skip to content

Commit c08f07f

Browse files
v3.1.8
1 parent fab2337 commit c08f07f

13 files changed

+645
-528
lines changed

git-tag.sh

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/usr/bin/env bash
22
# Releases a new tag.
33
read -p "Enter tag version: " version
4+
git pull
5+
git rm -r --cached .
46
git add --all :/
57
git commit -am "$version"
68
git push

includes/admin/class-alg-wc-wish-list-settings-list.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Wishlist for WooCommerce - Wishlist Section Settings
44
*
5-
* @version 3.1.3
5+
* @version 3.1.8
66
* @since 1.0.0
77
* @author WPFactory
88
*/
@@ -32,6 +32,7 @@ class Alg_WC_Wish_List_Settings_List extends Alg_WC_Wish_List_Settings_Section {
3232
const OPTION_NOTE_FIELD_LABEL = 'alg_wc_wl_note_field_label';
3333
const OPTION_NOTE_FIELD_TYPE = 'alg_wc_wl_note_field_type';
3434
const OPTION_NOTE_FIELD_MAX_LENGTH = 'alg_wc_wl_note_field_max_length';
35+
const OPTION_NOTE_FIELD_Email_ENABLE = 'alg_wc_wl_note_field_email_enable';
3536
const OPTION_SHOW_SKU = 'alg_wc_wl_show_sku';
3637
const OPTION_SHOW_QUANTITY = 'alg_wc_wl_show_quantity';
3738
const OPTION_SHOW_PRODUCT_CATEGORY = 'alg_wc_wl_show_prod_category';
@@ -82,7 +83,7 @@ function get_section_priority() {
8283
/**
8384
* get_settings.
8485
*
85-
* @version 3.1.3
86+
* @version 3.1.8
8687
* @since 1.0.0
8788
*/
8889
function get_settings( $settings = array() ) {
@@ -440,6 +441,13 @@ function get_settings( $settings = array() ) {
440441
'default' => 20,
441442
'type' => 'number',
442443
),
444+
array(
445+
'title' => __( 'Note email', 'wish-list-for-woocommerce' ),
446+
'desc' => __( 'Enable Wishlist note in email', 'wish-list-for-woocommerce' ),
447+
'id' => self::OPTION_NOTE_FIELD_Email_ENABLE,
448+
'default' => 'no',
449+
'type' => 'checkbox',
450+
),
443451
array(
444452
'type' => 'sectionend',
445453
'id' => 'alg_wc_wl_note_opt',

includes/class-alg-wc-wish-list-core.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ final class Alg_WC_Wish_List_Core {
2121
* @since 1.0.0
2222
* @var string
2323
*/
24-
public $version = '3.1.7';
24+
public $version = '3.1.8';
2525

2626
/**
2727
* @since 1.0.0
@@ -77,11 +77,14 @@ public static function instance() {
7777
/**
7878
* Method called when the plugin is activated
7979
*
80-
* @version 1.2.8
80+
* @version 3.1.8
8181
* @since 1.0.0
8282
*/
8383
public static function on_install() {
8484
Alg_WC_Wish_List_Page::create_page();
85+
$tab = new Alg_WC_Wish_List_Tab();
86+
$tab->add_endpoints();
87+
flush_rewrite_rules();
8588
}
8689

8790
/**
@@ -312,7 +315,6 @@ function __construct() {
312315
// Admin Multiple Wishlist.
313316
$this->admin_multiple_wishlist = new Alg_WC_Wish_List_Admin_Multiple();
314317
$this->admin_multiple_wishlist->init();
315-
316318
}
317319
}
318320

includes/free/class-alg-wc-wish-list-ajax.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Wishlist for WooCommerce - Ajax.
44
*
5-
* @version 3.1.6
5+
* @version 3.1.8
66
* @since 1.0.0
77
* @author WPFactory
88
*/
@@ -331,10 +331,11 @@ public static function get_wishlist_via_ajax( $handle ) {
331331
/**
332332
* Ajax method for save new wishlist.
333333
*
334-
* @version 3.0.8
334+
* @version 3.1.8
335335
* @since 2.0.5
336336
*/
337337
public static function save_to_multiple_wishlist() {
338+
check_ajax_referer( 'alg_wc_wl_toggle_item', 'nonce' );
338339
$args = wp_parse_args( $_POST, array(
339340
'ignore_excluded_items' => false,
340341
) );
@@ -346,10 +347,9 @@ public static function save_to_multiple_wishlist() {
346347
$user_id = Alg_WC_Wish_List_Unlogged_User::get_unlogged_user_id();
347348
}
348349

349-
350350
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE;
351351

352-
$value = $args['value'];
352+
$value = sanitize_text_field( $args['value'] );
353353

354354
$wishlist_list = Alg_WC_Wish_List::get_multiple_wishlists( $user_id );
355355
if ( ! $wishlist_list ) {
@@ -366,7 +366,6 @@ public static function save_to_multiple_wishlist() {
366366
$response = array( 'wishlist_list' => ! is_array( $wishlist_list ) ? array() : $wishlist_list );
367367

368368
wp_send_json_success( $response );
369-
370369
}
371370

372371
/**
@@ -708,10 +707,11 @@ public static function add_variable_product_data_to_response_text( $texts ) {
708707
/**
709708
* Ajax method for get from new multiple wishlist.
710709
*
711-
* @version 3.1.7
710+
* @version 3.1.8
712711
* @since 2.0.5
713712
*/
714713
public static function get_multiple_wishlist() {
714+
check_ajax_referer( 'alg_wc_wl_toggle_item', 'nonce' );
715715
$args = wp_parse_args( $_POST, array(
716716
'ignore_excluded_items' => false,
717717
) );
@@ -730,11 +730,9 @@ public static function get_multiple_wishlist() {
730730
$wishlist_list = $user_id ? Alg_WC_Wish_List::get_multiple_wishlists( $user_id ) : '';
731731

732732
if ( is_int( $user_id ) && $user_id > 0 ) {
733-
734733
// get only multiple wishlist items
735734
$arrange_arr = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, true );
736735
} else {
737-
738736
$transient_store = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
739737
$arrange_arr = get_transient( "{$transient_store}{$user_id}" );
740738
}
@@ -786,7 +784,7 @@ public static function get_multiple_wishlist() {
786784
?>
787785
<li>
788786
<div class="algwcwishlistmodal-checkbox-wrapper">
789-
<span class="titlebox"><?php echo $list; ?></span>
787+
<span class="titlebox"><?php echo esc_attr( $list ); ?></span>
790788
<label for="algwcwishlistmodal-cbk<?php echo $k + 1; ?>">
791789
<input type="checkbox" id="algwcwishlistmodal-cbk<?php echo $k + 1; ?>" class="whichlist-check" value="<?php echo $k; ?>" <?php echo $checked; ?>>
792790
<span class="cbx">

includes/free/class-alg-wc-wish-list-auto-remove.php

+19-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ function init() {
3434
/**
3535
* remove_on_added_to_cart.
3636
*
37-
* @version 2.1.1
37+
* @version 3.1.8
3838
* @since 2.0.8
3939
*
4040
* @param $cart_id
@@ -49,6 +49,24 @@ function remove_on_added_to_cart( $cart_id, $product_id, $qty, $variation_id ) {
4949
$user_id = is_user_logged_in() ? get_current_user_id() : null;
5050
$use_id_from_unlogged_user = is_user_logged_in() ? false : true;
5151
$wishlisted_items = Alg_WC_Wish_List::get_wish_list( $user_id, $use_id_from_unlogged_user, true );
52+
53+
if ( 'yes' === get_option( 'alg_wc_wl_multiple_wishlist_enabled', 'no' ) ) {
54+
if( !$user_id ){
55+
$user_id = Alg_WC_Wish_List_Unlogged_User::get_unlogged_user_id();
56+
}
57+
$multiple_wishlisted_items = Alg_WC_Wish_List::get_multiple_wishlist_unique_items( $user_id );
58+
59+
if ( is_array( $wishlisted_items ) && count( $wishlisted_items ) > 0 && is_array( $multiple_wishlisted_items ) && count( $multiple_wishlisted_items ) > 0 ) {
60+
// Merge the arrays
61+
$merged_items = array_merge( $wishlisted_items, $multiple_wishlisted_items );
62+
63+
// Remove duplicates
64+
$wishlisted_items = array_unique( $merged_items );
65+
} else if ( is_array( $multiple_wishlisted_items ) && count( $multiple_wishlisted_items ) > 0 ) {
66+
$wishlisted_items = $multiple_wishlisted_items;
67+
}
68+
}
69+
5270
if ( ! empty( $wishlisted_items ) && is_array( $wishlisted_items ) ) {
5371
$items_to_check = array( $variation_id, $product_id );
5472
foreach ( $items_to_check as $item_id ) {

includes/free/class-alg-wc-wish-list-item.php

+44-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Wishlist for WooCommerce - Wishlist Item.
44
*
5-
* @version 1.9.2
5+
* @version 3.1.8
66
* @since 1.0.0
77
* @author WPFactory
88
*/
@@ -84,7 +84,7 @@ public static function add_item_to_wish_list( $item_id, $user_id = null, $use_id
8484
/**
8585
* Add metas to wishlist item.
8686
*
87-
* @version 3.0.8
87+
* @version 3.1.8
8888
* @since 1.2.6
8989
*
9090
* @param $item_id
@@ -161,6 +161,17 @@ public static function update_wish_list_item_metas( $item_id, $meta_key, $meta_v
161161
if ( $tab_id > 0 ) {
162162
$new_user_meta_multiple[ $tab_id ] = $new_user_meta;
163163

164+
if ( $old_user_meta_multiple ) {
165+
foreach ( [ $old_user_meta_multiple, $new_user_meta_multiple ] as $array ) {
166+
foreach ( $array as $key => $subArray ) {
167+
foreach ( $subArray as $subKey => $value ) {
168+
$result[ $key ][ $subKey ] = $value;
169+
}
170+
}
171+
}
172+
$new_user_meta_multiple = $result;
173+
}
174+
164175
if ( is_int( $user_id ) && $user_id > 0 ) {
165176

166177
// update only multiple wishlist items
@@ -186,7 +197,7 @@ public static function update_wish_list_item_metas( $item_id, $meta_key, $meta_v
186197
/**
187198
* Remove item from wishlist user.
188199
*
189-
* @version 3.1.6
200+
* @version 3.1.8
190201
* @since 1.0.0
191202
*
192203
* @param $item_id
@@ -199,6 +210,19 @@ public static function update_wish_list_item_metas( $item_id, $meta_key, $meta_v
199210
public static function remove_item_from_wish_list( $item_id, $user_id = null, $use_id_from_unlogged_user = false ) {
200211
if ( ! $use_id_from_unlogged_user ) {
201212
$response = delete_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM, $item_id, false );
213+
if ( 'yes' === get_option( 'alg_wc_wl_multiple_wishlist_enabled', 'no' ) ) {
214+
$arrange_arr = get_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, true );
215+
if ( is_array( $arrange_arr ) && ! empty( $arrange_arr ) ) {
216+
foreach ( $arrange_arr as $k => $arr ) {
217+
if ( is_array( $arr ) ) {
218+
if ( ( $key = array_search( $item_id, $arr ) ) !== false ) {
219+
unset( $arrange_arr[ $k ][ $key ] );
220+
}
221+
}
222+
}
223+
}
224+
$response = update_user_meta( $user_id, Alg_WC_Wish_List_User_Metas::WISH_LIST_ITEM_MULTIPLE, $arrange_arr );
225+
}
202226
} else {
203227
if ( ! $user_id ) {
204228
$user_id = Alg_WC_Wish_List_Unlogged_User::get_unlogged_user_id();
@@ -215,7 +239,24 @@ public static function remove_item_from_wish_list( $item_id, $user_id = null, $u
215239
}
216240

217241
$response = set_transient( "{$transient}{$user_id}", $wish_list, 1 * MONTH_IN_SECONDS );
242+
243+
if ( 'yes' === get_option( 'alg_wc_wl_multiple_wishlist_enabled', 'no' ) ) {
244+
$wish_list_tab = Alg_WC_Wish_List::get_multiple_wishlists_with_all_item( $user_id, true );
245+
if ( is_array( $wish_list_tab ) && ! empty( $wish_list_tab ) ) {
246+
foreach ( $wish_list_tab as $k => $val ) {
247+
if ( isset( $val ) && is_array( $val )){
248+
$key = array_search( $item_id, $val );
249+
if ( ( $key = array_search( $item_id, $val ) ) !== false ) {
250+
unset( $wish_list_tab[ $k ][ $key ] );
251+
}
252+
}
253+
}
254+
}
255+
$transient = Alg_WC_Wish_List_Transients::WISH_LIST_MULTIPLE_STORE;
256+
$response = set_transient( "{$transient}{$user_id}", $wish_list_tab, 1 * MONTH_IN_SECONDS );
257+
}
218258
}
259+
219260
self::handle_wishlist_counting( array(
220261
'item_id' => $item_id,
221262
'logged_user' => ! $use_id_from_unlogged_user,

includes/free/class-alg-wc-wish-list-note-field.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function get_field_label() {
9292
/**
9393
* get_field_output.
9494
*
95-
* @version 3.0.8
95+
* @version 3.1.8
9696
* @since 1.7.4
9797
*
9898
* @param $product
@@ -147,6 +147,12 @@ function get_field_output( $product, $params = null ) {
147147
} elseif ( 'textarea' == $field_type ) {
148148
$field_str_dynamic = '<textarea class="{class}" maxlength="{maxlength}" name="{name}" id="{name}" type="text" data-item_id="{item_id}" data-wtab_id="{wtab_id}">{value}</textarea>';
149149
}
150+
151+
// Wishlist note content for email.
152+
$is_email = isset( $params['is_email'] ) ? $params['is_email'] : false;
153+
if ( $is_email && $params['note_email'] == 'yes' ) {
154+
$field_str_dynamic = '<p>{value}</p>';
155+
}
150156
$field = str_replace( array_keys( $replace_arr ), array_values( $replace_arr ), $field_str_dynamic );
151157

152158
return $field;

0 commit comments

Comments
 (0)