/**
 * Makes sure that plugin options do not disappear just
 * because we're lazy (using checkboxes instead of radio buttons) :D
 *
 * @since 1.6.5.4
 */
function file_gallery_save_media_settings($options)
{
    global $file_gallery;
    $defaults = $file_gallery->false_defaults;
    $defaults = file_gallery_parse_args($options, $defaults);
    // $defaults = shortcode_atts( $defaults, $options );
    $defaults['folder'] = file_gallery_https(FILE_GALLERY_URL);
    $defaults['abspath'] = FILE_GALLERY_ABSPATH;
    return $defaults;
}
/**
 * Registers default File Gallery options when plugin is activated
 */
function _file_gallery_activate()
{
    global $file_gallery;
    file_gallery_plugins_loaded();
    file_gallery_after_setup_theme();
    file_gallery_do_settings();
    $defaults = $file_gallery->defaults;
    $options = get_option('file_gallery');
    // if options already exist, upgrade
    if ($options) {
        // preserve display options when upgrading from below 1.6.5.3
        if (!isset($options['display_acf'])) {
            if (isset($options['insert_options_states'])) {
                $states = explode(',', $options['insert_options_states']);
            } else {
                $states = array('1', '1');
            }
            if (isset($options['display_insert_fieldsets'])) {
                $display = $options['display_insert_fieldsets'];
            } else {
                $display = 1;
            }
            $defaults['insert_options_state'] = (int) $states[0];
            $defaults['insert_single_options_state'] = (int) $states[1];
            $defaults['acf_state'] = 1;
            $defaults['display_gallery_fieldset'] = $display;
            $defaults['display_single_fieldset'] = $display;
            $defaults['display_acf'] = 1;
        }
        $defaults = file_gallery_parse_args($options, $defaults);
        $defaults['folder'] = file_gallery_https(FILE_GALLERY_URL);
        $defaults['abspath'] = FILE_GALLERY_ABSPATH;
        $defaults['version'] = FILE_GALLERY_VERSION;
    } else {
        $defaults['show_on_post_type_post'] = 1;
        $defaults['show_on_post_type_page'] = 1;
    }
    update_option('file_gallery', $defaults);
    // clear any existing cache
    file_gallery_clear_cache();
}