delete( $wpsco_cache_dir, true ); } } // 2. Clear scheduled cron hooks. wp_clear_scheduled_hook( 'wpsco_cache_cleanup' ); wp_clear_scheduled_hook( 'wpsco_expired_transients_cleanup' ); wp_clear_scheduled_hook( 'wpsco_cache_warming' ); wp_clear_scheduled_hook( 'wpsco_image_optimization_queue' ); // 3. Delete options only if explicit setting is configured. $wpsco_settings = get_option( 'wpsco_settings', array() ); if ( ! empty( $wpsco_settings['delete_data_on_uninstall'] ) ) { delete_option( 'wpsco_settings' ); delete_option( 'wpsco_cache_version' ); // Clean up all plugin transients. global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- Direct database query required to delete plugin transients upon uninstall. $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s OR option_name LIKE %s", $wpdb->esc_like( '_transient_wpsco_' ) . '%', $wpdb->esc_like( '_transient_timeout_wpsco_' ) . '%' ) ); } // Note: WooCommerce orders, customers, products, posts, pages, and media are strictly preserved.