You shouldn’t save your theme’s options one by one. In that case, you should call each of them separately, or store them in an array and then run a loop to get their values:
$options = array( 'option1', 'option2', 'option3');
foreach( $options as $option ){
// The rest of your code
}
But the proper way would always be to serialize and store all of your theme’s options in a single option. Take a look at this answer of mine, which you can find the functions to do this in the code.
Another approach would be to use a unique prefix for your options. For example, use something-
as a prefix, and then check the retrieved option for that string:
$options = get_alloptions(); // Get all options data, return array
foreach ($options as $key => $value) {
if( stristr( $key, 'something-' ) ) {
$value = maybe_unserialize($value);
$need_options[$key] = $value;
}
}
$json_file = json_encode($need_options);