uninstall.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. /**
  3. * Author: ExactMetrics team
  4. * Author URI: https://exactmetrics.com
  5. * Copyright 2018 ExactMetrics team
  6. * License: GPLv2 or later
  7. * License URI: http://www.gnu.org/licenses/gpl-2.0.html
  8. */
  9. // Exit if accessed directly
  10. if ( ! defined( 'ABSPATH' ) )
  11. exit();
  12. class GADWP_Uninstall {
  13. public static function uninstall() {
  14. global $wpdb;
  15. if ( is_multisite() ) { // Cleanup Network install
  16. foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
  17. switch_to_blog( $blog['blog_id'] );
  18. $sqlquery = $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'gadwp_cache_%%'" );
  19. delete_option( 'gadwp_options' );
  20. delete_option( 'exactmetrics_tracking_notice');
  21. delete_option( 'exactmetrics_usage_tracking_last_checkin');
  22. delete_option( 'exactmetrics_usage_tracking_config');
  23. wp_clear_scheduled_hook( 'exactmetrics_usage_tracking_cron' );
  24. restore_current_blog();
  25. }
  26. delete_site_option( 'gadwp_network_options' );
  27. } else { // Cleanup Single install
  28. $sqlquery = $wpdb->query( "DELETE FROM $wpdb->options WHERE option_name LIKE 'gadwp_cache_%%'" );
  29. delete_option( 'gadwp_options' );
  30. delete_option( 'exactmetrics_tracking_notice');
  31. delete_option( 'exactmetrics_usage_tracking_last_checkin');
  32. delete_option( 'exactmetrics_usage_tracking_config');
  33. wp_clear_scheduled_hook( 'exactmetrics_usage_tracking_cron' );
  34. }
  35. GADWP_Tools::unset_cookie( 'default_metric' );
  36. GADWP_Tools::unset_cookie( 'default_dimension' );
  37. GADWP_Tools::unset_cookie( 'default_view' );
  38. }
  39. }