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.9.7 6.9.8 6.9.9 7.0.0 7.0.1 7.0.2 7.0.3 7.0.4 7.0.5 7.0.6 7.0.7
media-cleaner / uninstall.php
media-cleaner Last commit date
app 1 month ago classes 1 month ago common 1 month ago languages 1 year ago logs 6 years ago media-cleaner.php 1 month ago readme.txt 1 month ago uninstall.php 1 month ago
uninstall.php
60 lines
1 <?php
2 if ( !defined( 'WP_UNINSTALL_PLUGIN' ) ) {
3 die;
4 }
5
6 // Get option to check if clean uninstall is enabled
7 $options = get_option( 'wpmc_options', [] );
8 $clean_uninstall = isset( $options['clean_uninstall'] ) ? $options['clean_uninstall'] : false;
9
10 if ( $clean_uninstall ) {
11 global $wpdb;
12 $table_scan = $wpdb->prefix . 'mclean_scan';
13 $table_exists = $wpdb->get_var( $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $table_scan ) ) ) === $table_scan;
14 $quarantined = 0;
15 if ( $table_exists ) {
16 $has_run_id = $wpdb->get_var( "SHOW COLUMNS FROM $table_scan LIKE 'run_id'" ) === 'run_id';
17 if ( $has_run_id ) {
18 $tracked_run_id = max( 0, (int) get_option( 'wpmc_active_run_id', 0 ) );
19 if ( $tracked_run_id < 1 ) {
20 $tracked_run_id = max( 0, (int) $wpdb->get_var( "SELECT MAX(run_id) FROM $table_scan" ) );
21 }
22 $quarantined = (int) $wpdb->get_var( $wpdb->prepare(
23 "SELECT COUNT(*) FROM $table_scan WHERE run_id = %d AND deleted = 1",
24 $tracked_run_id
25 ) );
26 }
27 else {
28 $quarantined = (int) $wpdb->get_var( "SELECT COUNT(*) FROM $table_scan WHERE deleted = 1" );
29 }
30 }
31 if ( $quarantined > 0 ) {
32 wp_die(
33 sprintf(
34 __( 'Media Cleaner still has %d item(s) in its trash. Restore them or empty the trash before uninstalling so no files are stranded.', 'media-cleaner' ),
35 $quarantined
36 ),
37 __( 'Media Cleaner uninstall blocked', 'media-cleaner' ),
38 array( 'response' => 409, 'back_link' => true )
39 );
40 }
41
42 delete_transient( 'wpmc_progress' );
43
44 // Remove all wpmc options
45 $option_pattern = $wpdb->esc_like( 'wpmc_' ) . '%';
46 $db_options = $wpdb->get_results( $wpdb->prepare( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE %s", $option_pattern ) );
47 foreach ( $db_options as $option ) {
48 delete_option( $option->option_name );
49 }
50
51 // Remove database tables
52 $table_refs = $wpdb->prefix . "mclean_refs";
53 $table_legacy = $wpdb->prefix . "wpmcleaner";
54 $table_runs = $wpdb->prefix . 'mclean_runs';
55 $table_work = $wpdb->prefix . 'mclean_work';
56 $table_operations = $wpdb->prefix . 'mclean_operations';
57 $table_duplicates = $wpdb->prefix . 'mclean_duplicates';
58 $wpdb->query( "DROP TABLE IF EXISTS $table_scan, $table_refs, $table_legacy, $table_runs, $table_work, $table_operations, $table_duplicates" );
59 }
60