Adaptive Speed) and both copies use the // same data: when the other copy is still installed, deleting this one must not // remove the settings, history and cache that the other copy is using. foreach ( array( 'adaptive-speed/adaptive-speed.php', 'wp-adaptive/wp-adaptive.php' ) as $ctps_other ) { if ( WP_UNINSTALL_PLUGIN !== $ctps_other && is_file( WP_PLUGIN_DIR . '/' . $ctps_other ) ) { return; } } define( 'CTPS_CACHE_DIR', WP_CONTENT_DIR . '/cache/ctps/' ); require_once __DIR__ . '/includes/class-ctps-settings.php'; require_once __DIR__ . '/includes/class-ctps-assets.php'; require_once __DIR__ . '/includes/class-ctps-rum.php'; require_once __DIR__ . '/includes/class-ctps-page-cache.php'; require_once __DIR__ . '/includes/class-ctps-htaccess.php'; require_once __DIR__ . '/includes/class-ctps-log.php'; require_once __DIR__ . '/includes/class-ctps-used-css.php'; require_once __DIR__ . '/includes/class-ctps-object-cache.php'; require_once __DIR__ . '/includes/class-ctps-webp.php'; require_once __DIR__ . '/includes/class-wpa-legacy.php'; /** * Per-site data: options, post meta, generated image copies, RUM table, * transients and scheduled events of the current site. */ function ctps_uninstall_site() { global $wpdb; CTPS_Settings::flush_cache(); CTPS_Used_CSS::remove(); CTPS_Log::remove_all(); // WebP/AVIF copies created by the plugin: only those of attachments it marked // with _ctps_webp ("photo.jpg.webp" / ".avif" next to the untouched original). for ( $ctps_i = 0; $ctps_i < 5000; $ctps_i++ ) { $ctps_r = CTPS_Webp::remove_batch(); if ( empty( $ctps_r['processed'] ) || empty( $ctps_r['left'] ) ) { break; } } foreach ( array( CTPS_Settings::OPTION, CTPS_Settings::OPTION . '_backup', 'ctps_profile', 'ctps_psi_last', 'ctps_psi_history', 'ctps_preload_queue', 'ctps_snapshots', 'ctps_health', 'ctps_recovery_key', 'ctps_recovery_mailed', 'ctps_emergency', 'ctps_disabled_cleaned', 'ctps_db_backup_time', 'ctps_version', 'ctps_psi_pages', 'ctps_psi_queue', 'ctps_rum_db', 'ctps_update_cache', 'ctps_htaccess_pending', 'ctps_wizard_done', 'ctps_wizard_redirect', 'ctps_used_css', 'ctps_asset_rules', 'ctps_alerts_last', 'ctps_log_name', 'ctps_oc_resume', 'wpadapt_health_version', 'ctps_preload_backoff', 'ctps_rum_daily' ) as $ctps_opt ) { delete_option( $ctps_opt ); } delete_post_meta_by_key( '_ctps_webp' ); foreach ( array( '_ctps_no_cache', '_ctps_no_js', '_ctps_off', '_ctps_no_lazy', '_ctps_no_ucss' ) as $ctps_meta ) { delete_post_meta_by_key( $ctps_meta ); } CTPS_RUM::drop(); $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\\_transient\\_ctps\\_%' OR option_name LIKE '\\_transient\\_timeout\\_ctps\\_%'" ); // phpcs:ignore // Adaptive Speed (wpadapt_*) data. Exact names only: the "wpadapt_" prefix is also used // by unrelated plugins, so no wildcard delete. foreach ( array( 'wpadapt_asset_intelligence', 'wpadapt_asset_intelligence_latest', 'wpadapt_benchmark_baseline', 'wpadapt_diagnostic_recorder_log', 'wpadapt_diagnostic_recorder_settings', 'wpadapt_experiment_engine', 'wpadapt_experiment_history', 'wpadapt_lcp_image_intelligence_history', 'wpadapt_lcp_image_intelligence_latest', 'wpadapt_learning_history', 'wpadapt_optimization_loop_history', 'wpadapt_optimization_loop_state', 'wpadapt_rum_samples', 'wpadapt_rum_storage_v', 'wpadapt_safe_mode', 'wpadapt_test_lab_error_log_size', 'wpadapt_test_lab_reports', 'wpadapt_adaptive_settings', 'wpadapt_decisions_log', 'wpadapt_rum_guard', 'wpadapt_trial', 'wpadapt_verified', 'wpadapt_page_scan', 'wpadapt_used_css_candidate', 'wpadapt_speed_probe', 'wpadapt_early_cache', 'wpadapt_engine_lock', 'wpadapt_ucss_token', 'wpadapt_scan_token' ) as $wpadapt_opt ) { delete_option( $wpadapt_opt ); } delete_transient( 'wpadapt_early_cache_error' ); delete_option( WPADAPT_Legacy::DONE ); WPADAPT_Legacy::cleanup(); // Names used before 3.7.5. $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\\_transient\\_wpa\\_rum\\_%' OR option_name LIKE '\\_transient\\_timeout\\_wpa\\_rum\\_%' OR option_name LIKE '\\_transient\\_wpa\\_ai\\_%' OR option_name LIKE '\\_transient\\_timeout\\_wpa\\_ai\\_%'" ); // phpcs:ignore foreach ( array( 'ctps_preload_run', 'ctps_psi_daily', 'ctps_psi_next', 'ctps_report_weekly', 'ctps_purge_expired', 'ctps_send_recovery_mail', 'wpadapt_experiment_cron', 'wpadapt_rum_guard_check' ) as $wpadapt_hook ) { wp_clear_scheduled_hook( $wpadapt_hook ); } // Font downloads are scheduled with arguments: remove every instance. if ( function_exists( 'wp_unschedule_hook' ) ) { wp_unschedule_hook( 'ctps_fonts_fetch' ); } } // Server-wide files and drop-ins: once. CTPS_Object_Cache::on_uninstall(); // Early page cache: our advanced-cache.php, its config and our WP_CACHE line only. require_once __DIR__ . '/includes/class-wpa-early-cache.php'; WPADAPT_Early_Cache::disable(); CTPS_Htaccess::remove(); CTPS_Page_Cache::remove_all(); if ( is_multisite() ) { foreach ( get_sites( array( 'fields' => 'ids', 'number' => 0 ) ) as $ctps_site_id ) { switch_to_blog( (int) $ctps_site_id ); ctps_uninstall_site(); restore_current_blog(); } } else { ctps_uninstall_site(); } CTPS_Assets::remove_all(); // Old name of the removed GitHub updater cache. delete_site_transient( 'ctps_update_cache' );