PluginProbe ʕ •ᴥ•ʔ
Hustle – Email Marketing, Lead Generation, Optins, Popups / 7.3.7
Hustle – Email Marketing, Lead Generation, Optins, Popups v7.3.7
7.8.13 7.8.13.1 trunk 3.0 3.1 3.1.1 3.1.2 3.1.3 3.1.4 4.3.2 4.4.4 4.4.5 4.4.5.1 4.4.5.4 4.6 4.6.1.1 4.6.1.4 4.7.0.2 4.7.0.3 4.7.0.7 4.7.0.9 4.7.1.0 4.7.1.1 4.8.0.0 5.0.0 5.0.1 5.0.1.1 5.0.1.2 5.1 5.1.1 5.1.2 5.1.3 5.1.3.1 5.1.3.2 5.1.4 5.1.5 6.0 6.0.1 6.0.2 6.0.3 6.0.4.2 6.0.5 6.0.6.1 6.0.7 6.0.8.1 6.0.9 7.0.0.1 7.0.2 7.0.3 7.0.4 7.1.0 7.1.1 7.2.0 7.2.1 7.3.0 7.3.1 7.3.3 7.3.5 7.3.6 7.3.7 7.4.0 7.4.1 7.4.11 7.4.13 7.4.13.1 7.4.2 7.4.3 7.4.4 7.4.5 7.4.5.1 7.4.5.2 7.4.6 7.4.7 7.5.0 7.6.0 7.6.1 7.6.3 7.6.4 7.6.6 7.7.0 7.7.1 7.8.0 7.8.1 7.8.10 7.8.10.1 7.8.10.2 7.8.11 7.8.12 7.8.12.1 7.8.2 7.8.3 7.8.4 7.8.5 7.8.6 7.8.7 7.8.8 7.8.9 7.8.9.1 7.8.9.2 7.8.9.3
wordpress-popup / inc / hustle-deletion.php
wordpress-popup / inc Last commit date
display-conditions 5 years ago front 5 years ago helpers 5 years ago metas 5 years ago palettes 5 years ago provider 5 years ago providers 5 years ago templates 5 years ago update 5 years ago class-hustle-admin-page-abstract.php 5 years ago class-hustle-condition-factory.php 6 years ago class-hustle-dashboard-admin.php 5 years ago class-hustle-data.php 5 years ago class-hustle-db.php 6 years ago class-hustle-module-admin.php 5 years ago class-hustle-module-collection.php 5 years ago class-hustle-module-decorator.php 5 years ago class-hustle-module-page-abstract.php 5 years ago class-hustle-notifications.php 5 years ago class-hustle-settings-admin.php 5 years ago class-hustle-upsell-page.php 5 years ago class-hustle-wp-dashboard-page.php 5 years ago hustle-collection.php 6 years ago hustle-deletion.php 5 years ago hustle-embedded-admin.php 6 years ago hustle-entries-admin.php 5 years ago hustle-entry-model.php 5 years ago hustle-general-data-protection.php 6 years ago hustle-init.php 5 years ago hustle-mail.php 5 years ago hustle-meta.php 5 years ago hustle-migration.php 5 years ago hustle-model.php 5 years ago hustle-module-model.php 5 years ago hustle-module-widget-legacy.php 5 years ago hustle-module-widget.php 5 years ago hustle-modules-common-admin-ajax.php 5 years ago hustle-popup-admin.php 6 years ago hustle-providers-admin.php 5 years ago hustle-providers.php 6 years ago hustle-settings-admin-ajax.php 5 years ago hustle-settings-page.php 5 years ago hustle-slidein-admin.php 6 years ago hustle-sshare-admin.php 5 years ago hustle-sshare-model.php 5 years ago hustle-tracking-model.php 5 years ago opt-in-geo.php 5 years ago opt-in-utils.php 5 years ago opt-in-wpmudev-api.php 6 years ago
hustle-deletion.php
238 lines
1 <?php
2
3 /**
4 * Methods for the plugin's data deletion.
5 *
6 * @since 4.0.3
7 */
8 class Hustle_Deletion {
9
10 /**
11 * Reset onboarding notification
12 *
13 * @since 4.0.3
14 */
15 public static function hustle_reset_notifications() {
16 global $wpdb;
17 // phpcs:ignore WordPress.DB.DirectDatabaseQuery.NoCaching
18 $wpdb->query( "DELETE FROM {$wpdb->usermeta} WHERE `meta_key` = 'hustle_dismissed_notifications'" );
19 }
20
21 /**
22 * Delete custom options
23 *
24 * @since 4.0.3
25 */
26 public static function hustle_delete_custom_options() {
27 delete_option( 'hustle_color_index' );
28 delete_option( 'hustle_database_version' );
29 delete_option( 'hustle_unsubscribe_nonces' );
30 delete_option( 'hustle_migrations' );
31 delete_option( 'hustle_previous_version' );
32 delete_option( 'hustle_30_migration_data' );
33 delete_option( 'hustle_settings' );
34 delete_option( 'hustle_ss_refresh_counters' );
35 delete_option( 'wpoi-county-id-map' );
36 delete_option( 'hustle_custom_nonce' );
37 delete_option( 'hustle_activated_flag' );
38 delete_option( 'hustle_new_welcome_notice_dismissed' );
39 delete_option( 'hustle_popup_migrated' );
40 delete_option( 'hustle_global_unsubscription_settings' );
41 delete_option( 'hustle_global_email_settings' );
42 delete_option( 'hustle_database_version' );
43 delete_option( 'widget_hustle_module_widget' );
44 delete_option( 'opt_in_database_version' );
45 delete_option( 'hustle_custom_palettes' );
46 delete_option( 'hustle_notice_stop_support_m2' );
47 }
48
49 /**
50 * Delete options created by Packaged Hustle Addons.
51 *
52 * @since 4.0.3
53 * @param array $addons Existing addons as $slug => Hustle_Provider_Abstract instance.
54 */
55 public static function hustle_delete_addon_options( $addons = array() ) {
56 delete_option( 'hustle_activated_providers' );
57 if ( empty( $addons ) ) {
58 $addons = array_keys( Hustle_Provider_Utils::get_registered_providers_list() );
59 }
60
61 foreach ( $addons as $slug ) {
62 delete_option( "hustle_provider_{$slug}_version" );
63 delete_option( "hustle_provider_{$slug}_settings" );
64
65 if ( 'constantcontact' === $slug || 'hubspot' === $slug ) {
66 delete_option( 'hustle_opt-in-constant_contact-token' );
67 delete_option( "hustle_opt-in-{$slug}-token" );
68 delete_option( "hustle_{$slug}_referer" );
69 delete_option( "hustle_{$slug}_current_page" );
70
71 } elseif ( 'aweber' === $slug ) {
72 // Old options.
73 delete_option( "{$slug}_access_token" );
74 delete_option( "{$slug}_access_secret" );
75 delete_option( "{$slug}_aut_code" );
76 delete_option( "{$slug}_consumer_secret" );
77 delete_option( "{$slug}_consumer_key" );
78
79 }
80 }
81
82 }
83
84 /**
85 * Clear modules.
86 *
87 * @since 4.0.3
88 */
89 public static function hustle_clear_modules() {
90 global $wpdb;
91
92 // Get max module id.
93 $max_module_id_query = "SELECT MAX(`module_id`) FROM {$wpdb->prefix}hustle_modules";
94 $max_module_id = (int) $wpdb->get_var( $max_module_id_query ); // phpcs:ignore
95
96 // Get max module meta id.
97 $max_module_meta_id_query = "SELECT MAX(`meta_id`) FROM {$wpdb->prefix}hustle_modules_meta";
98 $max_module_meta_id = (int) $wpdb->get_var( $max_module_meta_id_query ); // phpcs:ignore
99
100 // Delete module cache.
101 if ( $max_module_id && is_numeric( $max_module_id ) && $max_module_id > 0 ) {
102 for ( $i = 1; $i <= $max_module_id; $i ++ ) {
103 wp_cache_delete( $i, 'hustle_model_data' );
104 wp_cache_delete( $i, 'hustle_module_meta' );
105 }
106 }
107
108 /**
109 * Hook to reset auto increment on entries reset.
110 * This is discouraged becuase users might run into
111 * cookie conflict.
112 *
113 * @since 4.0.3
114 *
115 * @param boolen
116 */
117 $maintain_auto_increment = apply_filters( 'maintain_modules_auto_increment', true );
118
119 if ( $maintain_auto_increment ) {
120
121 // Alter auto increment for cookie compatibility.
122 $alter_modules = $wpdb->prepare(
123 "ALTER TABLE {$wpdb->prefix}hustle_modules
124 AUTO_INCREMENT = %d",
125 ++$max_module_id
126 );
127 $alter_meta = $wpdb->prepare(
128 "ALTER TABLE {$wpdb->prefix}hustle_modules_meta
129 AUTO_INCREMENT = %d",
130 ++$max_module_meta_id
131 );
132
133 $wpdb->query( "TRUNCATE {$wpdb->prefix}hustle_modules" );
134 $wpdb->query( $alter_modules );// phpcs:ignore
135
136 $wpdb->query( "TRUNCATE {$wpdb->prefix}hustle_modules_meta" );
137 $wpdb->query( $alter_meta );// phpcs:ignore
138 }
139 }
140
141 /**
142 * Clear submissions.
143 *
144 * @since 4.0.3
145 */
146 public static function hustle_clear_module_submissions() {
147 global $wpdb;
148
149 // Delete entry cache.
150 $max_entry_id_query = "SELECT MAX(`entry_id`) FROM {$wpdb->prefix}hustle_entries";
151 $max_entry_id = $wpdb->get_var( $max_entry_id_query ); // phpcs:ignore
152
153 // Get entry meta id.
154 $max_entry_meta_id_query = "SELECT MAX(`meta_id`) FROM {$wpdb->prefix}hustle_entries_meta";
155 $max_entry_meta_id = $wpdb->get_var( $max_entry_meta_id_query ); // phpcs:ignore
156
157 if ( $max_entry_id && is_numeric( $max_entry_id ) && $max_entry_id > 0 ) {
158 for ( $i = 1; $i <= $max_entry_id; $i ++ ) {
159 wp_cache_delete( $i, 'Hustle_Entry_Model' );
160 }
161 }
162
163 $wpdb->query( "TRUNCATE {$wpdb->prefix}hustle_entries" );
164
165 $wpdb->query( "TRUNCATE {$wpdb->prefix}hustle_entries_meta" );
166
167 /**
168 * Hook to reset auto increment on entries reset.
169 *
170 * This is discouraged becuase users might run into
171 * cookie conflict.
172 *
173 * @since 4.0.2
174 *
175 * @param boolen
176 */
177 $maintain_auto_increment = apply_filters( 'maintain_entries_auto_increment', true );
178
179 if ( $maintain_auto_increment ) {
180
181 // Alter auto increment for cookie compatibility.
182 $alter_entries = $wpdb->prepare(
183 "ALTER TABLE {$wpdb->prefix}hustle_entries
184 AUTO_INCREMENT = %d",
185 ++$max_entry_id
186 );
187
188 $alter_meta = $wpdb->prepare(
189 "ALTER TABLE {$wpdb->prefix}hustle_entries_meta
190 AUTO_INCREMENT = %d",
191 ++$max_entry_meta_id
192 );
193 $wpdb->query( $alter_entries );// phpcs:ignore
194 $wpdb->query( $alter_meta );// phpcs:ignore
195 }
196 wp_cache_delete( 'all_module_types', 'hustle_total_entries' );
197 wp_cache_delete( 'global_count', 'hustle_total_entries' );
198 wp_cache_delete( 'hustle_icontact_account_id', 'HUSTLE_ICONTACT_API_CACHE' );
199 wp_cache_delete( 'hustle_icontact_client_folder_id', 'HUSTLE_ICONTACT_API_CACHE' );
200 }
201
202 /**
203 * Clear views.
204 *
205 * @since 4.0.3
206 */
207 public static function hustle_clear_module_views() {
208 global $wpdb;
209 $wpdb->query( "TRUNCATE {$wpdb->prefix}hustle_tracking" );
210 }
211
212 /**
213 * Drop custom tables.
214 *
215 * @since 4.0.3
216 */
217 public static function hustle_drop_custom_tables() {
218 global $wpdb;
219 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}hustle_entries" );
220 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}hustle_entries_meta" );
221 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}hustle_modules" );
222 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}hustle_modules_meta" );
223 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}hustle_tracking" );
224 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}optin_meta" );
225 $wpdb->query( "DROP TABLE IF EXISTS {$wpdb->prefix}optins" );
226 }
227
228 /**
229 * Removes cronjobs.
230 *
231 * @since 4.3.3
232 */
233 public static function clear_cronjobs() {
234 // Remove the cron for refreshing Aweber's token.
235 wp_clear_scheduled_hook( 'hustle_aweber_token_refresh' );
236 }
237 }
238