-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Milestone
Description
For #3861 we built an algorithm that compares an invalid parameter to all possible parameters based on Levenshtein distance and makes suggestions if the Levenshtein distance is below or equal a set threshold (currently 2).
We still need to add a dictionary of pre-built "invalid parameter" => "suggestion" mappings so that we can provide meaningful suggestions that more drastically deviate from what was typed, without the need to bump the threshold higher. A too high threshold will show more meaningless suggestions.
The dictionary should just be an associative array that takes precedence over the calculated suggestion:
function get_suggestion( $target, array $options, $threshold = 2 ) {
$suggestion_map = array(
'dbpassword' => 'dbpass',
// [...]
);
if ( array_key_exists( $target, $suggestion_map ) ) {
return $suggestion_map[ $target ];
}
// [...]
}Reactions are currently unavailable