80 ) { @file_put_contents( $wp_cfg, $cfg_clean, LOCK_EX ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged } } } } } $obj_dropin = trailingslashit( WP_CONTENT_DIR ) . 'object-cache.php'; if ( file_exists( $obj_dropin ) && is_readable( $obj_dropin ) ) { $obj_head = (string) @file_get_contents( $obj_dropin, false, null, 0, 2048 ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged if ( strpos( $obj_head, 'AIO_TOOLS_OBJECT_CACHE_DROPIN' ) !== false ) { if ( isset( $GLOBALS['wp_object_cache'] ) && is_object( $GLOBALS['wp_object_cache'] ) ) { if ( method_exists( $GLOBALS['wp_object_cache'], 'flush' ) ) { @$GLOBALS['wp_object_cache']->flush(); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged } if ( method_exists( $GLOBALS['wp_object_cache'], 'disable_persistence' ) ) { @$GLOBALS['wp_object_cache']->disable_persistence(); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged } } if ( function_exists( 'wp_using_ext_object_cache' ) ) { wp_using_ext_object_cache( false ); } @unlink( $obj_dropin ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged clearstatcache( true, $obj_dropin ); if ( function_exists( 'opcache_invalidate' ) ) { @opcache_invalidate( $obj_dropin, true ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged } } } $root_htaccess = ABSPATH . '.htaccess'; if ( file_exists( $root_htaccess ) && is_writable( $root_htaccess ) ) { $ht_src = (string) @file_get_contents( $root_htaccess ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged if ( strpos( $ht_src, '# BEGIN AIO Tools Page Cache' ) !== false || strpos( $ht_src, '# BEGIN AIO Tools WebP Delivery' ) !== false ) { $ht_clean = preg_replace( '/# BEGIN AIO Tools (?:Page Cache|WebP Delivery).*?# END AIO Tools (?:Page Cache|WebP Delivery)\r?\n*/s', '', $ht_src ); if ( is_string( $ht_clean ) ) { @file_put_contents( $root_htaccess, $ht_clean, LOCK_EX ); // phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged } } if ( function_exists( 'insert_with_markers' ) ) { insert_with_markers( $root_htaccess, 'AIO Tools Browser Cache', array() ); } } // 3. Only remove database settings, usermeta, and custom log tables if explicitly opted in. $aio_options = get_option( 'aio_options', array() ); if ( ! empty( $aio_options['optDeleteDataOnUninstall'] ) ) { global $wpdb; $option_keys = array( 'aio_options', 'w2w_options', 'aio_db_version', 'aio_encryption_key', 'aio_redirect_rules', 'aio_404_logs', 'aio_blocked_ips', 'aio_webp_bulk_stats', 'aio_webp_bulk_queue', 'aio_core_integrity_issues', 'aio_dismissed_notices', ); foreach ( $option_keys as $opt_key ) { delete_option( $opt_key ); } // Remove plugin transients $wpdb->query( "DELETE FROM {$wpdb->options} WHERE option_name LIKE '\_transient\_aio\_%' OR option_name LIKE '\_transient\_timeout\_aio\_%'" ); // Remove plugin post meta $post_meta_keys = array( '_aio_webp_converted', '_aio_seo_title', '_aio_seo_desc', '_aio_seo_og_image', '_aio_seo_noindex', ); foreach ( $post_meta_keys as $pmeta_key ) { delete_metadata( 'post', 0, $pmeta_key, '', true ); } // Remove plugin user meta $user_meta_keys = array( '_aio_2fa_enabled', '_aio_2fa_secret', '_aio_2fa_backup_codes', '_aio_2fa_last_slice', 'aio_social_provider', 'aio_social_id', 'aio_social_google_id', 'aio_social_facebook_id', ); foreach ( $user_meta_keys as $meta_key ) { delete_metadata( 'user', 0, $meta_key, '', true ); } // Drop custom plugin tables $tables = array( $wpdb->prefix . 'aio_audit_logs', $wpdb->prefix . 'aio_lockouts', $wpdb->prefix . 'aio_404_logs', $wpdb->prefix . 'aio_email_logs', ); foreach ( $tables as $table ) { // phpcs:ignore WordPress.DB.DirectDatabaseQuery.SchemaChange, WordPress.DB.PreparedSQL.InterpolatedNotPrepared $wpdb->query( "DROP TABLE IF EXISTS `{$table}`" ); } }