Skip to content

Commit b2ef89e

Browse files
v3.2.5
1 parent e6f90c9 commit b2ef89e

18 files changed

+279
-226
lines changed

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Wishlist for WooCommerce - Social Section Settings
44
*
5-
* @version 3.2.2
5+
* @version 3.2.5
66
* @since 1.0.0
77
* @author WPFactory
88
*/
@@ -64,7 +64,7 @@ function get_section_priority() {
6464
/**
6565
* get_settings.
6666
*
67-
* @version 3.1.4
67+
* @version 3.2.5
6868
* @since 1.0.0
6969
*/
7070
function get_settings( $settings = array() ) {
@@ -100,7 +100,7 @@ function get_settings( $settings = array() ) {
100100
'desc_tip' => __( 'Separate multiple values using commas. ', 'wish-list-for-woocommerce' ) . '<br />' . __( 'Leave it empty if you want to hide this admin option on frontend. ', 'wish-list-for-woocommerce' ),
101101
'type' => 'text',
102102
'id' => self::OPTION_EMAIL_ADMIN_EMAILS,
103-
'default' => '',
103+
'default' => get_option( 'admin_email' ),
104104
'placeholder' => get_option( 'admin_email' ),
105105
'class' => 'regular-input'
106106
),
@@ -111,7 +111,14 @@ function get_settings( $settings = array() ) {
111111
array(
112112
'title' => __( 'Email', 'wish-list-for-woocommerce' ),
113113
'type' => 'title',
114-
'id' => 'alg_wc_wl_social_email',
114+
'id' => 'alg_wc_wl_social_email_opts',
115+
),
116+
array(
117+
'title' => __( 'Email sharing', 'wish-list-for-woocommerce' ),
118+
'desc' => __( 'Share via Email', 'wish-list-for-woocommerce' ),
119+
'type' => 'checkbox',
120+
'id' => self::OPTION_EMAIL,
121+
'default' => 'yes',
115122
),
116123
array(
117124
'title' => __( 'Subject', 'wish-list-for-woocommerce' ),
@@ -129,7 +136,7 @@ function get_settings( $settings = array() ) {
129136
),
130137
array(
131138
'type' => 'sectionend',
132-
'id' => 'alg_wc_wl_social_email',
139+
'id' => 'alg_wc_wl_social_email_opts',
133140
),
134141
array(
135142
'title' => __( 'Share buttons', 'wish-list-for-woocommerce' ),

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

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* Wish List for WooCommerce - Core Class.
44
*
5-
* @version 3.2.2
5+
* @version 3.2.5
66
* @since 1.0.0
77
* @author WPFactory.
88
*/
@@ -21,7 +21,7 @@ final class Alg_WC_Wish_List_Core {
2121
* @since 1.0.0
2222
* @var string
2323
*/
24-
public $version = '3.2.4';
24+
public $version = '3.2.5';
2525

2626
/**
2727
* @since 1.0.0
@@ -139,7 +139,7 @@ public static function delete_meta_data() {
139139
/**
140140
* Constructor.
141141
*
142-
* @version 3.1.0
142+
* @version 3.2.5
143143
* @since 1.0.0
144144
*/
145145
function __construct() {
@@ -166,13 +166,13 @@ function __construct() {
166166
}
167167

168168
// Check if plugin is enabled on admin.
169-
if ( true === filter_var( get_option( 'alg_wc_wl_enabled', false ), FILTER_VALIDATE_BOOLEAN ) && true === apply_filters( 'alg_wc_wl_enabled', true ) ) {
169+
if ( true === filter_var( get_option( 'alg_wc_wl_enabled', 'yes' ), FILTER_VALIDATE_BOOLEAN ) && true === apply_filters( 'alg_wc_wl_enabled', true ) ) {
170170

171171
// Scripts
172172
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
173173

174174
// Handle custom style.
175-
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_Style::OPTION_STYLE_ENABLE, false ), FILTER_VALIDATE_BOOLEAN ) ) {
175+
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_Style::OPTION_STYLE_ENABLE, 'no' ), FILTER_VALIDATE_BOOLEAN ) ) {
176176
add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_custom_style' ), 20 );
177177
add_filter( 'alg_wc_wl_locate_template_params', array( $this, 'handle_button_style_params' ), 10, 3 );
178178
add_filter( 'alg_wc_wl_fa_icon_class', array( $this, 'change_font_awesome_icon_class' ), 20, 2 );
@@ -219,7 +219,7 @@ function __construct() {
219219
add_action( 'widgets_init', array( $this, 'create_widgets' ) );
220220

221221
// Email sharing
222-
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_Social::OPTION_EMAIL, true ), FILTER_VALIDATE_BOOLEAN ) ) {
222+
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_Social::OPTION_EMAIL, 'yes' ), FILTER_VALIDATE_BOOLEAN ) ) {
223223
new Alg_WC_Wish_List_Email_Sharing();
224224
}
225225

@@ -603,7 +603,7 @@ public function handle_nav_menu_item( $items, $menu, $args ) {
603603
/**
604604
* Overrides button position on single product page
605605
*
606-
* @version 1.5.0
606+
* @version 3.2.5
607607
* @since 1.5.0
608608
*
609609
* @param $position
@@ -612,7 +612,7 @@ public function handle_nav_menu_item( $items, $menu, $args ) {
612612
*/
613613
public function override_button_position_single( $position ) {
614614
$option_name = Alg_WC_Wish_List_Settings_Buttons::OPTION_DEFAULT_BTN_SINGLE_POSITION_OVERRIDE;
615-
$option = get_option( $option_name );
615+
$option = get_option( $option_name, '' );
616616
if ( ! empty( $option ) ) {
617617
$position = $option;
618618
}
@@ -623,7 +623,7 @@ public function override_button_position_single( $position ) {
623623
/**
624624
* Adds SKU to wish list
625625
*
626-
* @version 1.4.9
626+
* @version 3.2.5
627627
* @since 1.4.9
628628
*
629629
* @param $params
@@ -633,7 +633,7 @@ public function override_button_position_single( $position ) {
633633
* @return mixed
634634
*/
635635
public function add_sku_on_wish_list( $params, $final_file, $path ) {
636-
if ( false === filter_var( get_option( Alg_WC_Wish_List_Settings_List::OPTION_SHOW_SKU, false ), FILTER_VALIDATE_BOOLEAN ) ) {
636+
if ( false === filter_var( get_option( Alg_WC_Wish_List_Settings_List::OPTION_SHOW_SKU, 'no' ), FILTER_VALIDATE_BOOLEAN ) ) {
637637
return $params;
638638
}
639639
switch ( $path ) {
@@ -648,7 +648,7 @@ public function add_sku_on_wish_list( $params, $final_file, $path ) {
648648
/**
649649
* Adds product description to wish list
650650
*
651-
* @version 1.4.9
651+
* @version 3.2.5
652652
* @since 1.4.9
653653
*
654654
* @param $params
@@ -658,7 +658,7 @@ public function add_sku_on_wish_list( $params, $final_file, $path ) {
658658
* @return mixed
659659
*/
660660
public function add_description_wish_list( $params, $final_file, $path ) {
661-
if ( false === filter_var( get_option( Alg_WC_Wish_List_Settings_List::OPTION_SHOW_PRODUCT_DESCRIPTION, false ), FILTER_VALIDATE_BOOLEAN ) ) {
661+
if ( false === filter_var( get_option( Alg_WC_Wish_List_Settings_List::OPTION_SHOW_PRODUCT_DESCRIPTION, 'no' ), FILTER_VALIDATE_BOOLEAN ) ) {
662662
return $params;
663663
}
664664
switch ( $path ) {
@@ -833,14 +833,14 @@ public function alg_wc_wl_toggle_item_ajax_response( $response ) {
833833
/**
834834
* Load scripts and styles
835835
*
836-
* @version 1.3.6
836+
* @version 3.2.5
837837
* @since 1.0.0
838838
*/
839839
function enqueue_frontend_scripts() {
840840
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
841841

842842
// Balloon-css
843-
if ( filter_var( get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_TOOLTIP_ENABLE, false ), FILTER_VALIDATE_BOOLEAN ) ) {
843+
if ( filter_var( get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_TOOLTIP_ENABLE, 'no' ), FILTER_VALIDATE_BOOLEAN ) ) {
844844
Alg_WC_Wish_List_Tooltip::enqueue_scripts( $suffix );
845845
Alg_WC_Wish_List_Tooltip::add_inline_script( 'alg-wc-wish-list' );
846846
}
@@ -859,15 +859,15 @@ function enqueue_frontend_scripts() {
859859
/**
860860
* Replaces some strings based on admin settings when an item is removed or added to wish list
861861
*
862-
* @version 1.0.0
862+
* @version 3.2.5
863863
* @since 1.0.0
864864
*/
865865
public function override_toggle_item_texts( $params ) {
866-
$params['added'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ADDED_TO_WISH_LIST ) ), 'wish-list-for-woocommerce' );
867-
$params['saved'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ADDED_TO_WISH_LIST_MULTIPLE ) ), 'wish-list-for-woocommerce' );
868-
$params['removed'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_REMOVED_FROM_WISH_LIST ) ), 'wish-list-for-woocommerce' );
869-
$params['error'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ERROR ) ), 'wish-list-for-woocommerce' );
870-
$params['see_wish_list'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_SEE_YOUR_WISH_LIST ) ), 'wish-list-for-woocommerce' );
866+
$params['added'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ADDED_TO_WISH_LIST, __( '%s was successfully added to wishlist', 'wish-list-for-woocommerce' ) ) ), 'wish-list-for-woocommerce' );
867+
$params['saved'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ADDED_TO_WISH_LIST_MULTIPLE, __( 'Wishlist successfully saved.', 'wish-list-for-woocommerce' ) ) ), 'wish-list-for-woocommerce' );
868+
$params['removed'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_REMOVED_FROM_WISH_LIST, __( '%s was successfully removed from wishlist', 'wish-list-for-woocommerce' ) ) ), 'wish-list-for-woocommerce' );
869+
$params['error'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_ERROR, __( 'Sorry, Some error ocurred. Please, try again later.', 'wish-list-for-woocommerce' ) ) ), 'wish-list-for-woocommerce' );
870+
$params['see_wish_list'] = __( sanitize_text_field( get_option( Alg_WC_Wish_List_Settings_Texts::OPTION_TEXTS_SEE_YOUR_WISH_LIST, __( 'See your wishlist', 'wish-list-for-woocommerce' ) ) ), 'wish-list-for-woocommerce' );
871871

872872
return $params;
873873
}
@@ -988,7 +988,7 @@ public function handle_button_style_params( $params, $final_file, $path ) {
988988
/**
989989
* Overrides wishlist params based on admin settings
990990
*
991-
* @version 1.7.5
991+
* @version 3.2.5
992992
* @since 1.2.8
993993
*
994994
* @param $params
@@ -1000,7 +1000,7 @@ public function handle_button_style_params( $params, $final_file, $path ) {
10001000
public function override_wishlist_params( $params, $final_file, $path ) {
10011001
switch ( $path ) {
10021002
case 'wish-list.php':
1003-
$work_with_cache = filter_var( get_option( Alg_WC_Wish_List_Settings_General::OPTION_WORK_WITH_CACHE ), FILTER_VALIDATE_BOOLEAN );
1003+
$work_with_cache = filter_var( get_option( Alg_WC_Wish_List_Settings_General::OPTION_WORK_WITH_CACHE, 'no' ), FILTER_VALIDATE_BOOLEAN );
10041004
$params['work_with_cache'] = $work_with_cache;
10051005
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_List::OPTION_SHOW_PRODUCT_CATEGORY, 'no' ), FILTER_VALIDATE_BOOLEAN ) ) {
10061006
$params['show_prod_category'] = true;
@@ -1072,7 +1072,7 @@ public function handle_scripts_localization() {
10721072
/**
10731073
* Overrides any script that has been already localized.
10741074
*
1075-
* @version 1.2.6
1075+
* @version 3.2.5
10761076
* @since 1.0.0
10771077
*
10781078
* @param $object
@@ -1081,7 +1081,7 @@ public function handle_scripts_localization() {
10811081
* @return array
10821082
*/
10831083
public function override_script_localization( $object, $object_name ) {
1084-
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_Style::OPTION_STYLE_ENABLE, false ), FILTER_VALIDATE_BOOLEAN ) ) {
1084+
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_Style::OPTION_STYLE_ENABLE, 'no' ), FILTER_VALIDATE_BOOLEAN ) ) {
10851085
if ( $object_name == 'alg_wc_wl_notification' ) {
10861086
$new_object = Alg_WC_Wish_List_Customization_Notification::localize_script();
10871087
$object = array_merge( $new_object, $object );
@@ -1094,11 +1094,11 @@ public function override_script_localization( $object, $object_name ) {
10941094
/**
10951095
* Localize scripts
10961096
*
1097-
* @version 2.0.3
1097+
* @version 3.2.5
10981098
* @since 1.0.0
10991099
*/
11001100
public function localize_scripts() {
1101-
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_Style::OPTION_STYLE_ENABLE, false ), FILTER_VALIDATE_BOOLEAN ) ) {
1101+
if ( true === filter_var( get_option( Alg_WC_Wish_List_Settings_Style::OPTION_STYLE_ENABLE, 'no' ), FILTER_VALIDATE_BOOLEAN ) ) {
11021102
Alg_WC_Wish_List_Customization_Thumb_Button::localize_script( 'alg-wc-wish-list' );
11031103
}
11041104

@@ -1234,7 +1234,7 @@ private function handle_custom_actions() {
12341234
/**
12351235
* Load social networks template ( Social )
12361236
*
1237-
* @version 1.8.7
1237+
* @version 3.2.5
12381238
* @since 1.0.0
12391239
*/
12401240
public function handle_social() {
@@ -1248,7 +1248,7 @@ public function handle_social() {
12481248
}
12491249

12501250
// Check if user enabled social networks on admin
1251-
$social_is_active = filter_var( get_option( Alg_WC_Wish_List_Settings_Social::OPTION_ENABLE, true ), FILTER_VALIDATE_BOOLEAN );
1251+
$social_is_active = filter_var( get_option( Alg_WC_Wish_List_Settings_Social::OPTION_ENABLE, 'yes' ), FILTER_VALIDATE_BOOLEAN );
12521252
if ( ! $social_is_active ) {
12531253
return;
12541254
}
@@ -1257,8 +1257,8 @@ public function handle_social() {
12571257
$before = Alg_WC_Wish_List_Actions::WISH_LIST_TABLE_BEFORE;
12581258
$after = Alg_WC_Wish_List_Actions::WISH_LIST_TABLE_AFTER;
12591259

1260-
// Positions where the user selected to show network buttons
1261-
$positions = get_option( Alg_WC_Wish_List_Settings_Social::OPTION_SHARE_POSITION );
1260+
// Positions where the user selected to show network buttons.
1261+
$positions = get_option( Alg_WC_Wish_List_Settings_Social::OPTION_SHARE_POSITION, array( 'alg_wc_wl_table_before' ) );
12621262
if ( ! is_array( $positions ) ) {
12631263
return;
12641264
}
@@ -1286,14 +1286,14 @@ public function handle_social() {
12861286
$params = array(
12871287
'share_txt' => __( 'Share', 'wish-list-for-woocommerce' ),
12881288
'twitter' => array(
1289-
'active' => filter_var( get_option( Alg_WC_Wish_List_Settings_Social::OPTION_TWITTER ), FILTER_VALIDATE_BOOLEAN ),
1289+
'active' => filter_var( get_option( Alg_WC_Wish_List_Settings_Social::OPTION_TWITTER, 'yes' ), FILTER_VALIDATE_BOOLEAN ),
12901290
'url' => add_query_arg( array(
12911291
'url' => urlencode( $url ),
12921292
'text' => $title,
12931293
), 'https://twitter.com/intent/tweet' )
12941294
),
12951295
'facebook' => array(
1296-
'active' => filter_var( get_option( Alg_WC_Wish_List_Settings_Social::OPTION_FACEBOOK ), FILTER_VALIDATE_BOOLEAN ),
1296+
'active' => filter_var( get_option( Alg_WC_Wish_List_Settings_Social::OPTION_FACEBOOK, 'yes' ), FILTER_VALIDATE_BOOLEAN ),
12971297
'url' => add_query_arg( array(
12981298
'u' => urlencode( $url ),
12991299
'title' => $title,
@@ -1388,13 +1388,13 @@ function fix_fontawesome_url_option() {
13881388
}
13891389

13901390
/**
1391-
* Manages wishlist buttons
1391+
* Manages wishlist buttons.
13921392
*
1393-
* @version 1.5.5
1393+
* @version 3.2.5
13941394
* @since 1.0.0
13951395
*/
13961396
private function handle_buttons() {
1397-
$show_default_btn_single_product = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_DEFAULT_BTN_SINGLE_ENABLE, false );
1397+
$show_default_btn_single_product = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_DEFAULT_BTN_SINGLE_ENABLE, 'no' );
13981398
if ( filter_var( $show_default_btn_single_product, FILTER_VALIDATE_BOOLEAN ) !== false ) {
13991399
$default_btn_single_prod_position = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_DEFAULT_BTN_SINGLE_POSITION, 'woocommerce_single_product_summary' );
14001400
$default_btn_single_prod_priority = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_DEFAULT_BTN_SINGLE_PRIORITY, 31 );
@@ -1404,7 +1404,7 @@ private function handle_buttons() {
14041404
), filter_var( $default_btn_single_prod_priority, FILTER_VALIDATE_INT ) );
14051405
}
14061406

1407-
$show_default_btn_loop_product = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_DEFAULT_BTN_LOOP_ENABLE, false );
1407+
$show_default_btn_loop_product = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_DEFAULT_BTN_LOOP_ENABLE, 'no' );
14081408
if ( filter_var( $show_default_btn_loop_product, FILTER_VALIDATE_BOOLEAN ) !== false ) {
14091409
$default_btn_loop_prod_position = 'woocommerce_after_shop_loop_item';
14101410
$default_btn_loop_prod_priority = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_DEFAULT_BTN_LOOP_PRIORITY, 11 );
@@ -1414,15 +1414,15 @@ private function handle_buttons() {
14141414
), filter_var( $default_btn_loop_prod_priority, FILTER_VALIDATE_INT ) );
14151415
}
14161416

1417-
$show_product_page_thumb_btn = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_THUMB_BTN_SINGLE_ENABLE, true );
1417+
$show_product_page_thumb_btn = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_THUMB_BTN_SINGLE_ENABLE, 'yes' );
14181418
if ( filter_var( $show_product_page_thumb_btn, FILTER_VALIDATE_BOOLEAN ) !== false ) {
14191419
add_action( 'woocommerce_product_thumbnails', array(
14201420
Alg_WC_Wish_List_Toggle_Btn::get_class_name(),
14211421
'show_thumb_btn'
14221422
), 21 );
14231423
}
14241424

1425-
$show_loop_page_thumb_btn = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_THUMB_BTN_LOOP_ENABLE, true );
1425+
$show_loop_page_thumb_btn = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_THUMB_BTN_LOOP_ENABLE, 'yes' );
14261426
if ( filter_var( $show_loop_page_thumb_btn, FILTER_VALIDATE_BOOLEAN ) !== false ) {
14271427
$hook = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_THUMB_BTN_LOOP_POSITION, 'woocommerce_before_shop_loop_item' );
14281428
$priority = get_option( Alg_WC_Wish_List_Settings_Buttons::OPTION_THUMB_BTN_LOOP_PRIORITY, 9 );

0 commit comments

Comments
 (0)