Have you tried just using SetCVar and use the return value and the event if necessary to continue the code process.
https://wow.gamepedia.com/API_C_CVar.SetCVar
The other option is to use the static variable NUM_LE_EXPANSION_LEVELS that is set to 1 for Classic and use that as a guide for Classic based functionality access and make any necessary changes using an if statement block, if you were hoping to have one source code base for both versions.