PluginProbe
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF / 2.0.0
Robin Image Optimizer – Unlimited Image Optimization, WebP & AVIF v2.0.0
2.0.7 2.0.6 2.0.5 trunk 1.3.7 1.4.0 1.4.1 1.4.2 1.4.6 1.5.0 1.5.3 1.5.6 1.5.8 1.6.5 1.6.6 1.6.9 1.7.0 1.7.4 1.8.1 1.8.2 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 All 26 releases
robin-image-optimizer / uninstall.php
uninstall.php
85 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // if uninstall.php is not called by WordPress, die
4 if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
5 die;
6 }
7
8 // remove plugin options
9 global $wpdb;
10
11 if ( is_multisite() ) {
12 $wpdb->query( "DELETE FROM {$wpdb->sitemeta}options WHERE option_name LIKE 'wbcr_io_%';" );
13
14 $blogs = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
15 if ( ! empty( $blogs ) ) {
16 foreach ( $blogs as $id ) {
17
18 switch_to_blog( $id );
19
20 $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE 'wio_%';" );
21 $io_db_table = $wpdb->prefix . 'rio_process_queue';
22 $wpdb->query( "DROP TABLE IF EXISTS {$io_db_table};" );
23 restore_current_blog();
24 }
25 }
26 } else {
27 $io_db_table = $wpdb->prefix . 'rio_process_queue';
28 $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE 'wbcr_io_%';" );
29 $wpdb->query( "DELETE FROM {$wpdb->postmeta} WHERE meta_key LIKE 'wio_%';" );
30 $wpdb->query( "DROP TABLE IF EXISTS {$io_db_table};" );
31 }
32
33 // REMOVE Backup dir
34 // --------------------------------------------------------------------------
35 require_once __DIR__ . '/includes/functions.php';
36
37 $wp_upload_dir = wp_upload_dir();
38
39 if ( isset( $wp_upload_dir['error'] ) && $wp_upload_dir['error'] !== false ) {
40 return;
41 }
42
43 $wp_upload_dir_path = wp_normalize_path( trailingslashit( $wp_upload_dir['basedir'] ) );
44
45 // REMOVE BACKUP DIR
46 // --------------------------------------------------------------------------
47 $backup_dir = $wp_upload_dir_path . 'wio_backup';
48
49 if ( file_exists( $backup_dir ) ) {
50 wrio_rmdir( $backup_dir );
51 }
52
53 // --------------------------------------------------------------------------
54
55 // REMOVE WebP DIR
56 // This directory is left over from old plugin version. From version 1.3.6,
57 // webp images are saved to same directory in which the image was stored,
58 // from which a copy was made in webp format.
59 // --------------------------------------------------------------------------
60 $webp_dir_path = $wp_upload_dir_path . 'wrio-webp-uploads';
61
62 if ( file_exists( $webp_dir_path ) ) {
63 wrio_rmdir( $webp_dir_path );
64
65 return true;
66 }
67
68 // REMOVE LOG DIR
69 // --------------------------------------------------------------------------
70 $log_dir_path = $wp_upload_dir_path . 'wrio';
71
72 if ( file_exists( $log_dir_path ) ) {
73 wrio_rmdir( $log_dir_path );
74 }
75 // --------------------------------------------------------------------------
76
77 // REMOVE OLD LOG FILE
78 // This file was used up to version 1.3.3. Another error logging structure is being used.
79 $old_log_file_path = $wp_upload_dir_path . 'wio.log';
80
81 if ( file_exists( $old_log_file_path ) ) {
82 @unlink( $old_log_file_path );
83 }
84 // --------------------------------------------------------------------------
85