In this case, you can use my tiny ValueResolver library, for example:
$default = ValueResolver::resolve(get_option('your_name'), '<whatever your default value is>');
and do not forget to use the namespace use LapaLabs\ValueResolver\Resolver\ValueResolver;
There is also the possibility of type casting, for example, if the value of the variable must be integer , so use this:
$id = ValueResolver::toInteger('6 apples', 1); // returns 6 $id = ValueResolver::toInteger('There are no apples', 1); // returns 1 (used default value)
Learn more about docs for more examples.
source share