PluginProbe
Custom 404 Pro / trunk
Custom 404 Pro vtrunk
3.15.2 3.15.4 3.15.5 3.15.6 3.16.0 3.15.1 3.15.0 3.14.1 3.14.0 3.13.0 trunk 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.1.5 1.1.6 1.2.0 1.3.10 1.3.12 1.3.5 All 100 releases
custom-404-pro / includes / class-uninstallclass.php

class-uninstallclass.php in Custom 404 Pro trunk, at includes/class-uninstallclass.php

57 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Handles plugin uninstall.
4 *
5 * @package Custom_404_Pro
6 */
7
8 /**
9 * Uninstall class.
10 */
11 class UninstallClass {
12
13 /**
14 * Removes all plugin data on uninstall.
15 *
16 * On Multisite, data is removed from every site in the network. On single-site
17 * installs the cleanup runs once for the current site.
18 */
19 public static function uninstall() {
20 if ( is_multisite() ) {
21 $sites = get_sites( array( 'fields' => 'ids' ) );
22 foreach ( $sites as $blog_id ) {
23 switch_to_blog( $blog_id );
24 self::cleanup_site();
25 restore_current_blog();
26 }
27 } else {
28 self::cleanup_site();
29 }
30 }
31
32 /**
33 * Removes all plugin data for the current site.
34 *
35 * Drops the logs table, deletes the settings and db-version entries from
36 * wp_options, and drops the legacy options table if the migration had not
37 * run before uninstall.
38 */
39 private static function cleanup_site() {
40 global $wpdb;
41
42 // Remove plugin settings, migration marker, and transients from wp_options.
43 delete_option( Helpers::OPTION_KEY );
44 delete_option( 'custom_404_pro_db_version' );
45 delete_transient( 'custom_404_pro_email_cooldown' );
46 wp_unschedule_hook( 'custom_404_pro_prune_logs' );
47
48 // Drop the logs table.
49 $table_logs = $wpdb->prefix . 'custom_404_pro_logs';
50 $wpdb->query( 'DROP TABLE IF EXISTS ' . $table_logs ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
51
52 // Drop the legacy options table if the migration had not run yet.
53 $table_options = $wpdb->prefix . 'custom_404_pro_options';
54 $wpdb->query( 'DROP TABLE IF EXISTS ' . $table_options ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared, WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
55 }
56 }
57