https://tools.infinus.ca/wpDatabase/
{
"Version": "DB Version",
"1.2.2": "2540",
"1.5": "2541",
"1.5.1": "2541",
"1.5.1.1": "2541",
"1.5.1.2": "2541",
"1.5.1.3": "2541",
"1.5.2": "2541",
"2.0": "3441"
...
}
Ideally you'd just call this after getting db_version from your wp_options. Maybe something similar to this?
function dbVersionToWPVersion($dbVersion) {
$wp_version = ‘Unknown’;
$url = “https://tools.infinus.ca/wpDatabase/”; // this is json
$json = file_get_contents($url);
$data = json_decode($json, true);
foreach ($data as $wp_version => $db_version) {
if ($db_version == $dbVersion) {
return $wp_version;
}
}
return $dbVersion;
}