PluginProbe
MailOptin – Popup, Optin Forms & Email Newsletters for Mailchimp, HubSpot, AWeber Etc. / trunk
MailOptin – Popup, Optin Forms & Email Newsletters for Mailchimp, HubSpot, AWeber Etc. vtrunk
1.2.78.3 1.2.78.2 1.2.78.1 1.2.78.0 1.2.77.3 1.2.77.2 1.2.18.0 1.2.18.1 1.2.19.0 1.2.19.1 1.2.2.1 1.2.2.2 1.2.20.0 1.2.21.0 1.2.21.1 1.2.22.1 1.2.23.0 1.2.23.1 1.2.24.0 1.2.25.0 1.2.26.0 1.2.27.0 1.2.27.1 1.2.27.2 1.2.27.3 All 194 releases
mailoptin / uninstall.php

uninstall.php in MailOptin – Popup, Optin Forms & Email Newsletters for Mailchimp, HubSpot, AWeber Etc. trunk, at uninstall.php

93 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 use MailOptin\Core\Core;
4 use MailOptin\Core\Repositories\OptinCampaignsRepository;
5
6 //if uninstall not called from WordPress exit
7 if ( ! defined('WP_UNINSTALL_PLUGIN')) {
8 exit();
9 }
10
11 // Load MailOptin file
12 include_once(dirname(__FILE__) . '/mailoptin.php');
13
14 function mailoptin_mo_uninstall_function()
15 {
16 $remove_plugin_data = \MailOptin\Core\PluginSettings\Settings::instance()->remove_plugin_data();
17
18 if ($remove_plugin_data == 'true') {
19
20 OptinCampaignsRepository::burst_all_cache();
21
22 wp_clear_scheduled_hook('mo_daily_recurring_job');
23 wp_clear_scheduled_hook('mo_hourly_recurring_job');
24
25 /** Delete plugin options */
26 delete_option(MAILOPTIN_CONNECTIONS_DB_OPTION_NAME);
27 delete_option(MAILOPTIN_SETTINGS_DB_OPTION_NAME);
28 delete_option(MO_OPTIN_CAMPAIGN_WP_OPTION_NAME);
29
30 delete_option('mo_wp_user_unsubscribers');
31 delete_option('mo_mailjet_double_optin_bucket');
32 delete_option('mo_install_date');
33 delete_option('mo_dismiss_leave_review_forever');
34 delete_option('mo_plugin_activated');
35 delete_option('mo_license_status');
36 delete_option('mo_license_expired_status');
37 delete_option('mo_license_key');
38 delete_option('mo_price_id');
39 delete_option('mo_state_repository');
40 delete_option('mo_db_ver');
41
42 delete_site_option('pand-' . md5('review-plugin-notice'));
43 delete_site_option('pand-' . md5('email-campaign-count-limit-exceeded'));
44 delete_site_option('pand-' . md5('show_woocommerce_features'));
45 delete_site_option('pand-' . md5('show_cf7_features'));
46 delete_site_option('pand-' . md5('show_ninja_forms_features'));
47 delete_site_option('pand-' . md5('show_gravity_forms_features'));
48 delete_site_option('pand-' . md5('show_wpforms_features'));
49
50 // legacy reason where we were saving this option multisite-wide
51 delete_site_option('mo_db_ver');
52 // do not remove mo_license_once_active option
53 // delete_option('mo_license_once_active');
54
55 global $wpdb;
56 $db_prefix = $wpdb->prefix;
57
58 $drop_tables = array();
59
60 $drop_tables[] = "DROP TABLE IF EXISTS {$db_prefix}" . Core::optin_campaign_meta_table_name;
61 $drop_tables[] = "DROP TABLE IF EXISTS {$db_prefix}" . Core::email_campaign_meta_table_name;
62 $drop_tables[] = "DROP TABLE IF EXISTS {$db_prefix}" . Core::campaign_log_meta_table_name;
63 $drop_tables[] = "DROP TABLE IF EXISTS {$db_prefix}" . Core::campaign_log_table_name;
64 $drop_tables[] = "DROP TABLE IF EXISTS {$db_prefix}" . Core::optin_campaigns_table_name;
65 $drop_tables[] = "DROP TABLE IF EXISTS {$db_prefix}" . Core::conversions_table_name;
66 $drop_tables[] = "DROP TABLE IF EXISTS {$db_prefix}" . Core::email_campaigns_table_name;
67 $drop_tables[] = "DROP TABLE IF EXISTS {$db_prefix}" . 'mo_optin_advance_stat';
68
69 $drop_tables = apply_filters('mo_drop_database_tables', $drop_tables, $db_prefix);
70
71 foreach ($drop_tables as $tables) {
72 $wpdb->query($tables);
73 }
74
75 // Clear any cached data that has been removed.
76 wp_cache_flush();
77 }
78 }
79
80 if ( ! is_multisite()) {
81 mailoptin_mo_uninstall_function();
82 } else {
83
84 if ( ! wp_is_large_network()) {
85 $site_ids = get_sites(['fields' => 'ids', 'number' => 0]);
86
87 foreach ($site_ids as $site_id) {
88 switch_to_blog($site_id);
89 mailoptin_mo_uninstall_function();
90 restore_current_blog();
91 }
92 }
93 }