Lets say you are working on a plugin/theme having numerous option fields in admin setings, but you want to initialize them with default values. Not setting them with default values, can lead the wordpress debugger to throw, undefined index which is nasty. Careful that you are not storing the values in database, but only in array.

I am assuming that you are using wordpress settings API to store all the values in single array. I am not going to go deep into how to create options page, but only the core issue of initializing with default values.

Take a look at this code, and you specify the default values, and the key here is wp_parse_args() which will populate whole or only the fields listed in the array.

$defaults = array (
                'logo' => '',
                'favicon' => '',
                'footer' => '',
                'facebook-link' => '',
                'twitter-link' => '',
                'google-plus-link' => '',
                'pin-it-link' => '',
                'linkedin-link' => '',
                'homepage-image' => '',
                'homepage-title' => '',
                'homepage-text' => '',
                'homepage-link' => '',
                'menu-color' => '#caeffc',
                'header-color' => '#000',
                'menu-font-color' => '#333',
                'widgets-menus-color' => '#eee',
                'footer-color' => '#b7d3e5'
                );
                

$mytheme_options = wp_parse_args(get_option('mytheme_options'), $defaults);

 

P.S: Note that assigning default array to get option will not work $mytheme_options = get_option(‘mytheme_options’,$default), which is why you are using wp_parse_args()