@@ -53,7 +53,7 @@ function swiftcomplete_add_plugin_page_settings_link( $actions ) {
53
53
return $ actions ;
54
54
}
55
55
56
- if ($ settings ['w3w_enabled ' ] == true ) {
56
+ if ($ settings !== false && array_key_exists ( ' w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] == true ) {
57
57
add_action ('woocommerce_after_order_notes ' , 'display_w3w_field ' );
58
58
}
59
59
@@ -108,18 +108,18 @@ function override_default_address_fields($address_fields)
108
108
{
109
109
$ settings = get_option ('swiftcomplete_settings ' );
110
110
111
- if (array_key_exists ('billing_placeholder ' , $ settings ) && strlen ($ settings ['billing_placeholder ' ]) > 0 )
111
+ if ($ settings !== false && array_key_exists ('billing_placeholder ' , $ settings ) && strlen ($ settings ['billing_placeholder ' ]) > 0 )
112
112
$ billing_placeholder = esc_attr ($ settings ['billing_placeholder ' ]);
113
113
else
114
- $ billing_placeholder = array_key_exists ('w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] ? 'Type your address, postcode or what3words... ' : 'Type your address or postcode... ' ;
114
+ $ billing_placeholder = $ settings !== false && array_key_exists ('w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] ? 'Type your address, postcode or what3words... ' : 'Type your address or postcode... ' ;
115
115
116
- if (array_key_exists ('shipping_placeholder ' , $ settings ) && strlen ($ settings ['shipping_placeholder ' ]) > 0 )
116
+ if ($ settings !== false && array_key_exists ('shipping_placeholder ' , $ settings ) && strlen ($ settings ['shipping_placeholder ' ]) > 0 )
117
117
$ shipping_placeholder = esc_attr ($ settings ['shipping_placeholder ' ]);
118
118
else
119
- $ shipping_placeholder = array_key_exists ('w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] ? 'Type your address, postcode or what3words... ' : 'Type your address or postcode... ' ;
119
+ $ shipping_placeholder = $ settings !== false && array_key_exists ('w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] ? 'Type your address, postcode or what3words... ' : 'Type your address or postcode... ' ;
120
120
121
- $ billing_label = array_key_exists ('billing_label ' , $ settings ) && strlen ($ settings ['billing_label ' ]) > 0 ? esc_attr ($ settings ['billing_label ' ]) : 'Address Finder ' ;
122
- $ shipping_label = array_key_exists ('shipping_label ' , $ settings ) && strlen ($ settings ['shipping_label ' ]) > 0 ? esc_attr ($ settings ['shipping_label ' ]) : 'Address Finder ' ;
121
+ $ billing_label = $ settings !== false && array_key_exists ('billing_label ' , $ settings ) && strlen ($ settings ['billing_label ' ]) > 0 ? esc_attr ($ settings ['billing_label ' ]) : 'Address Finder ' ;
122
+ $ shipping_label = $ settings !== false && array_key_exists ('shipping_label ' , $ settings ) && strlen ($ settings ['shipping_label ' ]) > 0 ? esc_attr ($ settings ['shipping_label ' ]) : 'Address Finder ' ;
123
123
124
124
$ address_fields ['billing ' ]['billing_address_autocomplete ' ] = array (
125
125
'label ' => __ ($ billing_label , 'woocommerce ' ),
@@ -413,25 +413,25 @@ function add_swiftcomplete_billing()
413
413
$ settings = get_option ('swiftcomplete_settings ' );
414
414
$ api_key = '' ;
415
415
416
- if (array_key_exists ('api_key ' , $ settings ) && strlen ($ settings ['api_key ' ]) > 0 )
416
+ if ($ settings !== false && array_key_exists ('api_key ' , $ settings ) && strlen ($ settings ['api_key ' ]) > 0 )
417
417
$ api_key = $ settings ['api_key ' ];
418
418
419
419
wp_enqueue_script ('swiftcomplete_script ' , 'https://script.swiftcomplete.com/js/swiftcomplete.js ' );
420
420
wp_enqueue_script ('swiftcomplete_launch ' , plugin_dir_url (__FILE__ ) . 'addressfinder.js ' , array ('jquery ' ));
421
- wp_add_inline_script ('swiftcomplete_launch ' , sprintf ('launchAddressLookup("billing", " ' . esc_attr ($ api_key ) . '", " ' . (array_key_exists ('w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] ? 'address,what3words ' : 'address ' ) . '", " ' . (array_key_exists ('hide_fields ' , $ settings ) && $ settings ['hide_fields ' ] ? true : false ) . '", " ' . (array_key_exists ('bias_towards_lat_lon ' , $ settings ) ? esc_attr ($ settings ['bias_towards_lat_lon ' ]) : '' ) . '", " ' . (array_key_exists ('billing_placeholder ' , $ settings ) ? esc_attr ($ settings ['billing_placeholder ' ]) : '' ) . '") ' ));
421
+ wp_add_inline_script ('swiftcomplete_launch ' , sprintf ('launchAddressLookup("billing", " ' . esc_attr ($ api_key ) . '", " ' . ($ settings !== false && array_key_exists ('w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] ? 'address,what3words ' : 'address ' ) . '", " ' . ($ settings !== false && array_key_exists ('hide_fields ' , $ settings ) && $ settings ['hide_fields ' ] ? true : false ) . '", " ' . ($ settings !== false && array_key_exists ('bias_towards_lat_lon ' , $ settings ) ? esc_attr ($ settings ['bias_towards_lat_lon ' ]) : '' ) . '", " ' . ($ settings !== false && array_key_exists ('billing_placeholder ' , $ settings ) ? esc_attr ($ settings ['billing_placeholder ' ]) : '' ) . '") ' ));
422
422
}
423
423
424
424
function add_swiftcomplete_shipping ()
425
425
{
426
426
$ settings = get_option ('swiftcomplete_settings ' );
427
427
$ api_key = '' ;
428
428
429
- if (array_key_exists ('api_key ' , $ settings ) && strlen ($ settings ['api_key ' ]) > 0 )
429
+ if ($ settings !== false && array_key_exists ('api_key ' , $ settings ) && strlen ($ settings ['api_key ' ]) > 0 )
430
430
$ api_key = $ settings ['api_key ' ];
431
431
432
432
wp_enqueue_script ('swiftcomplete_script ' , 'https://script.swiftcomplete.com/js/swiftcomplete.js ' );
433
433
wp_enqueue_script ('swiftcomplete_launch ' , plugin_dir_url (__FILE__ ) . 'addressfinder.js ' , array ('jquery ' ));
434
- wp_add_inline_script ('swiftcomplete_launch ' , sprintf ('launchAddressLookup("shipping", " ' . esc_attr ($ api_key ) . '", " ' . (array_key_exists ('w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] ? 'address,what3words ' : 'address ' ) . '", " ' . (array_key_exists ('hide_fields ' , $ settings ) && $ settings ['hide_fields ' ] ? true : false ) . '", " ' . (array_key_exists ('bias_towards_lat_lon ' , $ settings ) ? esc_attr ($ settings ['bias_towards_lat_lon ' ]) : '' ) . '", " ' . (array_key_exists ('shipping_placeholder ' , $ settings ) ? esc_attr ($ settings ['shipping_placeholder ' ]) : '' ) . '") ' ));
434
+ wp_add_inline_script ('swiftcomplete_launch ' , sprintf ('launchAddressLookup("shipping", " ' . esc_attr ($ api_key ) . '", " ' . ($ settings !== false && array_key_exists ('w3w_enabled ' , $ settings ) && $ settings ['w3w_enabled ' ] ? 'address,what3words ' : 'address ' ) . '", " ' . ($ settings !== false && array_key_exists ('hide_fields ' , $ settings ) && $ settings ['hide_fields ' ] ? true : false ) . '", " ' . ($ settings !== false && array_key_exists ('bias_towards_lat_lon ' , $ settings ) ? esc_attr ($ settings ['bias_towards_lat_lon ' ]) : '' ) . '", " ' . ($ settings !== false && array_key_exists ('shipping_placeholder ' , $ settings ) ? esc_attr ($ settings ['shipping_placeholder ' ]) : '' ) . '") ' ));
435
435
}
436
436
437
437
add_action ('woocommerce_checkout_billing ' , 'add_swiftcomplete_billing ' );
0 commit comments