PluginProbe
Email Log / 2.62
Email Log v2.62
2.63 2.4.8 2.4.9 2.6 2.61 2.62 trunk 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.8.1 0.9 0.9.1 0.9.2 1.1 1.5 1.5.1 1.5.2 1.5.3 1.5.4 All 61 releases
email-log / uninstall.php

uninstall.php in Email Log 2.62, at uninstall.php

74 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Uninstall page for Email Log Plugin to clean up all plugin data.
4 *
5 * This file is named uninstall.php since WordPress requires that name.
6 */
7
8 // exit if WordPress is not uninstalling the plugin.
9 if ( ! defined( 'ABSPATH' ) && ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
10 exit();
11 }
12
13 if ( is_multisite() ) {
14 // Note: if there are more than 10,000 blogs or
15 // if `wp_is_large_network` filter is set, then this may fail.
16 $sites = get_sites();
17
18 foreach ( $sites as $site ) {
19 switch_to_blog( $site->blog_id );
20 email_log_delete_db_data();
21 restore_current_blog();
22 }
23 } else {
24 email_log_delete_db_data();
25 }
26
27 /**
28 * Delete all email log data from db.
29 *
30 * The data include email log table, options, capability and add-on license data.
31 *
32 * @since 1.7
33 *
34 * @global object $wpdb
35 */
36 function email_log_delete_db_data() {
37 global $wpdb;
38
39 $remove_data_on_uninstall = false;
40
41 $option = get_option( 'email-log-core' );
42 if ( is_array( $option ) && array_key_exists( 'remove_on_uninstall', $option ) &&
43 'true' === strtolower( $option['remove_on_uninstall'] ) ) {
44
45 $remove_data_on_uninstall = true;
46 }
47
48 // This is hardcoded on purpose, since the entire plugin is not loaded during uninstall.
49 $table_name = $wpdb->prefix . 'email_log';
50
51 if ( $remove_data_on_uninstall ) {
52 if ( $wpdb->get_var( "SHOW TABLES LIKE '{$table_name}'" ) == $table_name ) { //phpcs:ignore
53 $wpdb->query( "DROP TABLE $table_name" ); //phpcs:ignore
54 }
55
56 delete_option( 'email-log-db' );
57 delete_option( 'email-log-core' );
58
59 $roles = get_editable_roles();
60 foreach ( $roles as $role_name => $role_obj ) {
61 $role = get_role( $role_name );
62
63 if ( ! is_null( $role ) ) {
64 $role->remove_cap( 'manage_email_logs' );
65 }
66 }
67 // Mask Fields addon adds this option.
68 delete_option( 'el_mask_fields' );
69
70 delete_option( 'el_bundle_license' );
71 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'el_license_%'" ); //phpcs:ignore
72 }
73 }
74