Completed
Pull Request — master (#858)
by
unknown
40:08 queued 20:01
created

uninstall()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
nc 3
nop 0
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
class Yikes_Inc_Easy_Mailchimp_Extender_Uninstaller {
3
4
	public static function uninstall() {
5
		global $wpdb;
6
		// define global switched (required for switch_to_blog())
7
		global $switched;		
8
		if ( function_exists( 'is_multisite' ) && is_multisite() ) {
9
			// users can only unisntall a plugin from the network dashboard page
10
			// Get all blog ids
11
			$blogids = $wpdb->get_col("SELECT blog_id FROM $wpdb->blogs");
12
			foreach ( $blogids as $blog_id ) {
13
				switch_to_blog( $blog_id );
14
				self::_uninstall_yikes_easy_mailchimp( $wpdb );
15
				restore_current_blog();
16
			}
17
			switch_to_blog( $old_blog );
0 ignored issues
show
Bug introduced by
The variable $old_blog does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
18
			return;
19
		}
20
		self::_uninstall_yikes_easy_mailchimp( $wpdb );
21
	}
22
	
23
	/**
24
	 * Short Description. Plugin Activation.
25
	 *
26
	 * Long Description. Creates our custom form tables on activation.
27
	 *
28
	 * @since    6.0.0
29
	 */
30
	static function _uninstall_yikes_easy_mailchimp( $wpdb ) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
31
		require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
32
33
		/* Clean up and delete our custom table from the databse */
34
		$table = $wpdb->prefix."yikes_easy_mc_forms";
35
		$sql = 'DROP TABLE IF EXISTS ' . $table;
36
37
		//Delete any options thats stored also?
38
		$wpdb->query( $sql );
39
		dbDelta($sql);
40
41
		/* Clear All Transient Data */
42
		delete_transient( 'yikes-easy-mailchimp-list-data' );
43
		delete_transient( 'yikes-easy-mailchimp-account-data' );
44
		delete_transient( 'yikes-easy-mailchimp-profile-data' );
45
		delete_transient( 'yikes-easy-mailchimp-account-activity' );
46
		delete_transient( 'yikes-mailchimp-contributor-transient' );
47
48
		/* Clear All Plugin Options */
49
		delete_option( 'yikes_easy_mailchimp_activation_date' );
50
		delete_option( 'widget_yikes_easy_mc_widget' );
51
		delete_option( 'yikes-mc-api-key' );
52
		delete_option( 'yikes-mc-api-validation' );
53
		delete_option( 'yikes-mailchimp-debug-status' );
54
		delete_option( 'yikes-mc-double-optin-message' );
55
		delete_option( 'yikes-mc-flavor' );
56
		delete_option( 'yikes-mc-lists' );
57
		delete_option( 'yikes-mc-optin' );
58
		delete_option( 'yikes-mc-optIn-checkbox' );
59
		delete_option( 'yikes-mc-recaptcha-api-key' );
60
		delete_option( 'yikes-mc-recaptcha-private-api-key' );
61
		delete_option( 'yikes-mc-recaptcha-setting' );
62
		delete_option( 'yikes-mc-single-optin-message' );
63
		delete_option( 'yikes-mc-yks-mailchimp-jquery-datepicker' );
64
		delete_option( 'yikes-mc-yks-mailchimp-optin-checkbox-text' );
65
		delete_option( 'yikes-mc-yks-mailchimp-optIn-default-list' );
66
		delete_option( 'yikes-mc-yks-mailchimp-required-text' );
67
		delete_option( 'yikes-mc-single-optin-message' );
68
		delete_option( 'yikes-mc-api-invalid-key-response' );
69
		delete_option( 'yikes-mc-recaptcha-status' );
70
		delete_option( 'yikes-mc-recaptcha-site-key' );
71
		delete_option( 'yikes-mc-recaptcha-secret-key' );
72
		delete_option( 'yikes-mc-error-messages' );
73
		delete_option( 'yikes_mc_database_version' );
74
		delete_option( 'yikes_mailchimp_activation_redirect' );
75
		delete_option( 'yikes_easy_mailchimp_extender_forms' );
76
		delete_option( 'yikes_easy_mailchimp_extender_version' );
77
	}
78
}
79