get_col( $wpdb->prepare( 'SELECT option_name FROM %i WHERE option_name LIKE %s', $wpdb->options, $wpdb->esc_like( 'forensix_' ) . '%' ) ); foreach ( $names as $name ) { if ( ! $remove_all && self::is_kept( (string) $name ) ) { continue; } delete_option( (string) $name ); } } /** * Deletes forensix_ transients. */ private static function delete_transients(): void { global $wpdb; // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- One-off uninstall cleanup of our own transients. $wpdb->query( $wpdb->prepare( 'DELETE FROM %i WHERE option_name LIKE %s OR option_name LIKE %s', $wpdb->options, $wpdb->esc_like( '_transient_forensix_' ) . '%', $wpdb->esc_like( '_transient_timeout_forensix_' ) . '%' ) ); } /** * Whether an option holds data that is kept by default. * * @param string $name Option name. */ private static function is_kept( string $name ): bool { foreach ( self::KEEP_OPTION_PREFIXES as $prefix ) { if ( str_starts_with( $name, $prefix ) ) { return true; } } return false; } }