core-web-vitals-pagespeed-booster
Last commit date
css-extractor
6 months ago
images
6 months ago
includes
6 months ago
languages
6 months ago
changelog.txt
6 months ago
core-web-vitals-pagespeed-booster.php
6 months ago
readme.txt
6 months ago
uninstall.php
6 months ago
uninstall.php
37 lines
| 1 | <?php |
| 2 | |
| 3 | defined( 'WP_UNINSTALL_PLUGIN' ) || exit; |
| 4 | |
| 5 | if ( ! defined( 'CWVPSB_CACHE_DIR' ) ) { |
| 6 | define( 'CWVPSB_CACHE_DIR', WP_CONTENT_DIR. '/cache/cwvpsb/' ); |
| 7 | } |
| 8 | |
| 9 | if ( ! defined( 'CWVPSB_IMAGE_DIR' ) ) { |
| 10 | define('CWVPSB_GRAVATARS_DIR',WP_CONTENT_DIR.'/gravatars/'); |
| 11 | } |
| 12 | $cwvpb_settings = get_option( 'cwvpsb_get_settings',false); |
| 13 | |
| 14 | if($cwvpb_settings && isset($cwvpb_settings['delete_on_uninstall']) && $cwvpb_settings['delete_on_uninstall'] == 1){ |
| 15 | global $wpdb, $table_prefix; |
| 16 | if (function_exists('is_multisite') && is_multisite()) { |
| 17 | $original_blog_id = get_current_blog_id(); |
| 18 | $blog_ids = $wpdb->get_col("SELECT blog_id FROM {$wpdb->blogs}"); //phpcs:ignore |
| 19 | |
| 20 | foreach ($blog_ids as $blog_id) { |
| 21 | switch_to_blog($blog_id); |
| 22 | $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->prefix}cwvpb_critical_urls`"); //phpcs:ignore --Reason: Direct DB call to delete table |
| 23 | delete_option('cwvpsb_get_settings'); |
| 24 | } |
| 25 | |
| 26 | switch_to_blog($original_blog_id); |
| 27 | } else { |
| 28 | $wpdb->query("DROP TABLE IF EXISTS `{$wpdb->prefix}cwvpb_critical_urls`"); //phpcs:ignore --Reason: Direct DB call to delete table |
| 29 | } |
| 30 | require_once ( ABSPATH . 'wp-admin/includes/class-wp-filesystem-base.php' ); |
| 31 | require_once ( ABSPATH . 'wp-admin/includes/class-wp-filesystem-direct.php' ); |
| 32 | $fileSystemDirect = new WP_Filesystem_Direct(false); |
| 33 | if($fileSystemDirect){ |
| 34 | $fileSystemDirect->rmdir(CWVPSB_CACHE_DIR, true); |
| 35 | $fileSystemDirect->rmdir(CWVPSB_GRAVATARS_DIR, true); |
| 36 | } |
| 37 | } |