-
Notifications
You must be signed in to change notification settings - Fork 1
/
class-lpac-uninstall.php
182 lines (167 loc) · 6.09 KB
/
class-lpac-uninstall.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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
<?php
/**
* Fired when the plugin is uninstalled.
*
* When populating this file, consider the following flow
* of control:
*
* - This method should be static
* - Check if the $_REQUEST content actually is the plugin name
* - Run an admin referrer check to make sure it goes through authentication
* - Verify the output of $_GET makes sense
* - Repeat with other user roles. Best directly by using the links/query string parameters.
* - Repeat things for multisite. Once for a single site in the network, once sitewide.
*
*
* For more information, see the following discussion:
* https://github.com/tommcfarlin/WordPress-Plugin-Boilerplate/pull/123#issuecomment-28541913
*
* @link https://uriahsvictor.com
* @since 1.0.0
*
* @package Lpac
*/
class Lpac_Uninstall {
/**
* Remove plugin settings.
*
* @since 1.0.0
* @since 1.1.0 Turned into class to support freemius.
*/
public static function remove_plugin_settings() {
/**
* If the free version and PRO version exist then don't delete the settings.
* This ensures that users do not accidentally delete their settings when installing PRO plugin.
*/
if ( ! function_exists( 'get_plugins' ) ) {
include ABSPATH . '/wp-admin/includes/plugin.php';
}
$plugins = get_plugins();
if ( array_key_exists( 'map-location-picker-at-checkout-for-woocommerce/lpac.php', $plugins ) && array_key_exists( 'map-location-picker-at-checkout-for-woocommerce-pro/lpac.php', $plugins ) ) {
return;
}
$should_delete_settings = get_option( 'lpac_delete_settings_on_uninstall' );
if ( $should_delete_settings !== 'yes' ) {
return;
}
$option_keys = array(
// General Settings
'lpac_enabled',
'lpac_google_maps_api_key',
'lpac_force_map_use',
'lpac_allow_clicking_on_map_icons',
'lpac_force_places_autocomplete',
'lpac_force_places_autocomplete_notice_text',
'kikote_dissect_customer_address',
// Display Settings
'lpac_map_starting_coordinates',
'lpac_map_instructions_text',
'lpac_general_map_zoom_level',
'lpac_map_background_color',
'lpac_checkout_map_orientation',
'lpac_checkout_page_map_height',
'lpac_checkout_page_map_width',
'lpac_display_map_on_order_received_page',
'lpac_order_received_page_map_height',
'lpac_order_received_page_map_width',
'lpac_display_map_on_view_order_page',
'lpac_view_order_page_map_height',
'lpac_view_order_page_map_width',
'lpac_order_received_page_map_id',
'lpac_view_order_page_map_id',
'lpac_checkout_page_map_id',
'lpac_checkout_page_map_default_view',
'kikote_disabled_map_controls',
// Store Locations
'lpac_store_locations_cords',
'lpac_store_locations_labels',
'lpac_store_locations_icons',
'lpac_autofill_billing_fields',
'lpac_email_delivery_map_emails',
'lpac_email_delivery_map_link_location',
'lpac_email_delivery_map_link_type',
'lpac_enable_delivery_map_link_in_email',
'lpac_map_directions_provider',
'lpac_delete_settings_on_uninstall',
'lpac_wc_shipping_zones',
'lpac_wc_shipping_zones_show_hide',
'lpac_wc_shipping_classes',
'lpac_wc_shipping_classes_show_hide',
'lpac_enable_save_address_feature',
'lpac_wc_shipping_methods',
'lpac_hide_troubleshooting_admin_checkout_notice',
'lpac_dequeue_google_maps',
'lpac_hide_map_for_guests',
'lpac_wc_shipping_methods',
'lpac_map_min_cart_amount',
'lpac_map_max_cart_amount',
'lpac_map_show_for_coupons',
'lpac_map_anchor_points',
'lpac_admin_view_order_map_id',
'lpac_installed_at_version',
'lpac_first_install_date',
'lpac_remove_address_plus_code',
'lpac_enable_places_autocomplete',
'lpac_places_autocomplete_fields',
'lpac_places_autocomplete_hide_map',
'lpac_auto_detect_location',
'lpac_export_date_from',
'lpac_export_date_to',
'lpac_places_autocomplete_country_restrictions',
'lpac_places_autocomplete_type',
// Cost by Distance Settings
'lpac_enable_shipping_cost_by_distance_feature',
'lpac_distance_matrix_api_key',
'lpac_distance_matrix_store_origin_cords',
'lpac_distance_matrix_cost_per_unit',
'lpac_distance_matrix_distance_unit',
'lpac_show_distance_unit_cost_in_checkout',
'lpac_distance_matrix_travel_mode',
'lpac_distance_matrix_shipping_methods',
'lpac_limit_shipping_distance',
'lpac_max_shipping_distance',
'lpac_max_free_shipping_distance',
'lpac_distance_cost_no_shipping_method_available_text',
'lpac_distance_cost_no_shipping_method_selected_error',
'lpac_enable_cost_by_store_distance',
'lpac_enable_cost_by_distance_range',
'lpac_cost_by_distance_range_rangelist',
'lpac_cost_by_store_distance_delivery_prices',
// Cost by Region Settings
'lpac_shipping_cost_by_region_enabled',
'lpac_shipping_regions',
'lpac_shipping_regions_shipping_methods',
'lpac_show_shipping_regions_on_checkout_map',
'lpac_show_shipping_regions_cost_on_checkout_map',
'lpac_show_shipping_regions_name_on_checkout_map',
'lpac_shipping_regions_default_background_color',
'lpac_regions_min_max_order_total',
'lpac_order_total_insufficient_text',
'lpac_order_total_limit_passed_text',
'lpac_ship_only_to_drawn_regions',
'lpac_no_shipping_method_available_text',
'lpac_no_shipping_method_selected_error',
// Cost by Store Location
'lpac_enable_cost_by_store_location',
'lpac_cost_by_store_location_delivery_prices',
'lpac_cost_by_store_location_shipping_methods',
'lpac_migrated__add_address_to_store_locations',
'lpac_show_selected_store_in_emails',
// Misc
'lpac_store_locations',
'lpac_show_store_locations_on_map',
'lpac_enable_store_location_selector',
'lpac_store_select_label',
'lpac_debug_shipping_distance',
'lpac_map_marker_icon',
);
foreach ( $option_keys as $key ) {
delete_option( $key );
}
delete_metadata( 'user', 0, 'lpac_dismissed_notices', '', true );
delete_metadata( 'user', 0, 'lpac_user_preferred_store_location_id', '', true );
delete_metadata( 'post', 0, 'kikote_map_builder_shortcode_settings', '', true );
$lpac_directory = wp_upload_dir()['basedir'] . '/lpac';
( new WP_Filesystem_Direct( '' ) )->delete( $lpac_directory, true, 'd' );
}
}