I was building a theme options page with the settings API. I use an ajax call to compute some settings automatically from other pages / tabs. I noticed that all of the new settings default ("std") will display in their input fields but will be undefined when I make the ajax call using :
array_merge(get_option('some_options', 'fail'), get_option('some_other_options', 'fail'));
That is they will be undefined until the first time I save the new settings. All of the previously defined settings will be rendered in the resulting object, but all of the newly authored additions will be undefined.
I was wondering if the option's defaults are saved when you switch to the theme for the first time.
So when I add new options while using that theme the options defaults are not being saved. I am concerned, if that is the case, that some key values would be omitted when a user first activates this theme.
So just to be clear on what is happening.
1) I have some options to start with. -> everything is good.
2) I author some new options. -> trouble starts
3) Settings page loads. Default values are in the input fields but, when I make the call and check the database. "undefined" is returned for those new settings. All the other settings are fine.
4) Reload page. -> no change
5) Save changes.
6) Ajax call is fine, all values defined.