I am using following function to get the options stored in wordpress.
function get_settings( $option ) {
$options = get_option( 'my_options', my_default_options() );
return $options[ $option ];
}
In the above function my_default_options() returns an array which has default values. Now if I call the above function like:
get_settings("title"); it will work fine if the "title" exists in the default options array.
However if title does not exist in the default options array, then I get the following warning:
Notice: Undefined index:
How can I fix this notice? I tried following:
function get_settings( $option ) {
$defaults = my_default_options();
if(in_array($option, $defaults)){
$options = get_option( 'my_options', my_default_options() );
return $options[ $option ];
}
}
But it still returns same notice.