wordpress-popup
Last commit date
assets
1 month ago
free
1 month ago
inc
1 month ago
languages
1 month ago
lib
5 months ago
vendor
1 month ago
views
1 month ago
humans.txt
2 years ago
license.txt
5 years ago
popover.php
1 month ago
readme.txt
1 month ago
uninstall.php
5 months ago
uninstall.php
92 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Hustle Uninstall methods |
| 4 | * Called when plugin is deleted |
| 5 | * |
| 6 | * @since 4.0.3 |
| 7 | * @package Hustle |
| 8 | */ |
| 9 | |
| 10 | // If uninstall.php is not called by WordPress, die. |
| 11 | if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) { |
| 12 | die; |
| 13 | } |
| 14 | |
| 15 | // Require helper file for uninstallation. |
| 16 | if ( ! class_exists( 'Hustle_Deletion' ) ) { |
| 17 | require_once __DIR__ . '/inc/hustle-deletion.php'; |
| 18 | } |
| 19 | |
| 20 | // Get Hustle settings for the main site. |
| 21 | $hustle_settings = get_option( 'hustle_settings', array() ); |
| 22 | |
| 23 | $reset_main_site_settings = ! empty( $hustle_settings['data'] ) |
| 24 | && ! empty( $hustle_settings['data']['reset_settings_uninstall'] ) |
| 25 | && '1' === $hustle_settings['data']['reset_settings_uninstall']; |
| 26 | |
| 27 | if ( ! is_multisite() || |
| 28 | empty( $hustle_settings['data']['reset_all_sites'] ) |
| 29 | || '1' !== $hustle_settings['data']['reset_all_sites'] ) { |
| 30 | hustle_reset_settings( $reset_main_site_settings ); |
| 31 | } else { |
| 32 | $sites = get_sites(); |
| 33 | |
| 34 | foreach ( $sites as $site ) { |
| 35 | $site_id = $site->blog_id; |
| 36 | |
| 37 | // Switch to blog before deleting settings. |
| 38 | switch_to_blog( $site_id ); |
| 39 | hustle_reset_settings( $reset_main_site_settings ); |
| 40 | restore_current_blog(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Remove all Hustle settings for the current blog |
| 46 | * |
| 47 | * @param bool $reset_main_site_settings Should reset settings or not. |
| 48 | */ |
| 49 | function hustle_reset_settings( $reset_main_site_settings ) { |
| 50 | Hustle_Deletion::clear_cronjobs(); |
| 51 | |
| 52 | if ( ! is_main_site() || $reset_main_site_settings ) { |
| 53 | Hustle_Deletion::hustle_reset_notifications(); |
| 54 | Hustle_Deletion::hustle_delete_custom_options(); |
| 55 | Hustle_Deletion::hustle_delete_addon_options( hustle_addon_slugs() ); |
| 56 | Hustle_Deletion::hustle_clear_modules(); |
| 57 | Hustle_Deletion::hustle_clear_module_submissions(); |
| 58 | Hustle_Deletion::hustle_clear_module_views(); |
| 59 | Hustle_Deletion::hustle_drop_custom_tables(); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Delete slug params |
| 65 | * |
| 66 | * @since 1.4 |
| 67 | */ |
| 68 | function hustle_addon_slugs() { |
| 69 | $addon_slugs = array( |
| 70 | 'activecampaign', |
| 71 | 'aweber', |
| 72 | 'campaignmonitor', |
| 73 | 'constantcontact', |
| 74 | 'convertkit', |
| 75 | 'e_newsletter', |
| 76 | 'getresponse', |
| 77 | 'hubspot', |
| 78 | 'icontact', |
| 79 | 'infusionsoft', |
| 80 | 'mad_mimi', |
| 81 | 'mailchimp', |
| 82 | 'mailerlite', |
| 83 | 'mautic', |
| 84 | 'sendgrid', |
| 85 | 'sendinblue', |
| 86 | 'sendy', |
| 87 | 'zapier', |
| 88 | ); |
| 89 | |
| 90 | return $addon_slugs; |
| 91 | } |
| 92 |