예제 #1
0
 function cyberchimps_core_setup_theme()
 {
     // Set directory path
     $directory = get_template_directory();
     // Load core functions file
     require_once $directory . '/cyberchimps/functions.php';
     // Load core hooks file
     require_once $directory . '/cyberchimps/inc/hooks.php';
     // Load element files before meta and options
     require_once $directory . '/elements/init.php';
     // Load santize before options-init and options core
     require_once $directory . '/cyberchimps/options/options-sanitize.php';
     // Load core options file
     require_once $directory . '/cyberchimps/options/options-init.php';
     // Load default core settings
     require_once $directory . '/cyberchimps/options/options-core.php';
     // Load core hooks file
     require_once $directory . '/cyberchimps/inc/cc-custom-background.php';
     //Load pro features if a pro theme. Load prior to meta boxes so that filters work
     if (cyberchimps_theme_check() == 'pro') {
         require_once $directory . '/elements/setup/features.php';
     }
     // Load new meta box class
     require_once $directory . '/cyberchimps/options/meta-box-class/my-meta-box-class.php';
     // Load new meta box options
     require_once $directory . '/cyberchimps/options/meta-box-class/meta-box.php';
     // Load theme upsell.
     require_once $directory . '/cyberchimps/options/theme-upsell.php';
     // Core Translations can be filed in the /inc/languages/ directory
     load_theme_textdomain('cyberchimps_core', $directory . '/cyberchimps/lib/languages');
     load_theme_textdomain('cyberchimps_elements', $directory . '/elements/lib/languages');
     // Add support for the Aside Post Formats
     add_theme_support('post-formats', array('aside', 'gallery', 'link', 'image', 'quote', 'status', 'video', 'audio', 'chat'));
     // Add default posts and comments RSS feed links to head
     add_theme_support('automatic-feed-links');
     // Enable support for Post Thumbnails
     add_theme_support('post-thumbnails');
     // add theme support for backgrounds
     $defaults = array('default-color' => apply_filters('default_background_color', ''), 'default-image' => apply_filters('default_background_image', ''), 'wp-head-callback' => 'cyberchimps_custom_background_cb');
     $defaults = apply_filters('cyberchimps_background_default_args', $defaults);
     add_theme_support('custom-background', $defaults);
     // This theme uses wp_nav_menu() in one location.
     register_nav_menus(array('primary' => __('Primary Menu', 'cyberchimps_core')));
     //set up defaults
     $option_defaults = cyberchimps_get_default_values();
     if (!get_option('cyberchimps_options') && isset($_GET['activated'])) {
         update_option('cyberchimps_options', $option_defaults);
     } elseif (get_option('cyberchimps_options') && isset($_GET['activated'])) {
         $options = get_option('cyberchimps_options');
         $options['header_section_order'] = $option_defaults['header_section_order'];
         $options['theme_backgrounds'] = $option_defaults['theme_backgrounds'];
         update_option('cyberchimps_options', $options);
     }
 }
예제 #2
0
/**
 * Set up the theme.  If it's not a cyberchimps theme, just continue on.
 * @return null
 */
function gd_quicksetup_setup_cyberchimps_theme()
{
    // Make sure we're using a cyberchimps theme
    if (!function_exists('cyberchimps_get_default_values')) {
        return;
    }
    // Get $_POST data back
    $data = get_option('gd_quicksetup_last_post');
    if (empty($data)) {
        return;
    }
    // Get default options
    $option_defaults = get_option('cyberchimps_options');
    if (empty($option_defaults)) {
        $option_defaults = cyberchimps_get_default_values();
    }
    // Set up social buttons
    if (!isset($option_defaults['theme_backgrounds']) || empty($option_defaults['theme_backgrounds'])) {
        $option_defaults['theme_backgrounds'] = 'default';
    }
    $option_defaults['blog_section_order'] = array('blog_post_page');
    $option_defaults['social_twitter'] = '';
    $option_defaults['social_facebook'] = '';
    $option_defaults['social_google'] = '';
    // Add user selected social networks
    foreach ((array) $data['type'] as $k => $v) {
        if (!$data['enabled'][$k] || 'false' === $_POST['enabled'][$k]) {
            continue;
        }
        if ('contact' === $v) {
            if (!empty($data['contact_twitter'][$k])) {
                $option_defaults['social_twitter'] = '1';
                $option_defaults['twitter_url'] = 'http://twitter.com/' . ltrim(stripslashes_deep($data['contact_twitter'][$k], '@'));
            }
            if (!empty($data['contact_facebook'][$k])) {
                $option_defaults['social_facebook'] = '1';
                $option_defaults['facebook_url'] = stripslashes_deep($data['contact_facebook'][$k]);
            }
            if (!empty($data['contact_googleplus'][$k])) {
                $option_defaults['social_google'] = '1';
                $option_defaults['google_url'] = stripslashes_deep($data['contact_googleplus'][$k]);
            }
            if (!empty($data['contact_email'][$k])) {
                $option_defaults['profile_picture'] = 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($data['contact_email'][$k]))) . '.jpg?s=250&r=g';
            }
            break;
        }
    }
    // Header section
    $option_defaults['header_section_order'] = array('cyberchimps_logo');
    // Toggle blog description off
    $option_defaults['description_toggle'] = '';
    // Turn off footer widgets
    $option_defaults['footer_show_toggle'] = '';
    // Save options
    update_option('cyberchimps_options', $option_defaults);
    // Set all posts of type "page" to full width, except for business card
    if ('gdbizcard' === wp_get_theme()->get_stylesheet()) {
        return;
    }
    $posts = get_posts(array('post_type' => 'page', 'post_status' => 'any', 'numberposts' => -1));
    foreach ((array) $posts as $post) {
        update_post_meta($post->ID, 'cyberchimps_page_sidebar', 'full_width');
    }
}
예제 #3
0
function cyberchimps_customize($wp_customize)
{
    //set up defaults if they don't exist. Useful if theme is set up through live preview
    $option_defaults = cyberchimps_get_default_values();
    if (!get_option('cyberchimps_options')) {
        update_option('cyberchimps_options', $option_defaults);
    }
    /**
     * Class Cyberchimps_Form
     *
     * Creates a form input type with the option to add description and placeholders
     */
    class Cyberchimps_Form extends WP_Customize_Control
    {
        public function render_content()
        {
            switch ($this->type) {
                case 'textarea':
                    ?>
					<label>
						<span class="customize-control-title"><?php 
                    echo esc_html($this->label);
                    ?>
</span>
						<textarea value="<?php 
                    echo esc_attr($this->value());
                    ?>
" <?php 
                    $this->link();
                    ?>
 style="width: 97%; height: 200px;"></textarea>
					</label>
					<?php 
                    break;
            }
        }
    }
    class Cyberchimps_Typography_Size extends WP_Customize_Control
    {
        public $type = 'select';
        public function render_content()
        {
            ?>
			<label>
				<span class="customize-control-title"><?php 
            echo esc_html($this->label);
            ?>
</span>
				<select <?php 
            $this->link();
            ?>
>
					<?php 
            foreach ($this->choices as $value => $label) {
                echo '<option value="' . esc_attr($label) . 'px"' . selected($this->value(), $value, false) . '>' . $label . 'px</option>';
            }
            ?>
				</select>
			</label>
		<?php 
        }
    }
    /********** Class for background image option starts *************/
    class Cyberchimps_Background_Image extends WP_Customize_Control
    {
        public $type = 'radio';
        public function render_content()
        {
            ?>
			<style>
				.images-radio-subcontainer img {
					margin-top: 5px;
					padding: 2px;
					border: 5px solid #eee;
				}

				.images-radio-subcontainer img.of-radio-img-selected {
					border: 5px solid #5DA7F2;
				}

				.images-radio-subcontainer img:hover {
					cursor: pointer;
					border: 5px solid #5DA7F2;
				}
			</style>
			<script>
				jQuery(function ($) {
					$('.of-radio-img-img').click(function () {
						$(this).parent().parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected');
						$(this).addClass('of-radio-img-selected');
					});
				});
			</script>

			<span class="customize-control-title"><?php 
            echo esc_html($this->label);
            ?>
</span>
			<em>
				<small><?php 
            _e('make sure you have removed the image above before selecting one of these', 'cyberchimps_core');
            ?>
</small>
			</em>
			<?php 
            foreach ($this->choices as $value => $label) {
                //if get theme mod background image has a value then we need to set cyberchimps bg to none
                $test_bg = $this->value();
                $test_bg = get_theme_mod('background_image') ? 'none' : $test_bg;
                $name = '_customize-radio-' . $this->id;
                $selected = $test_bg == $value ? 'of-radio-img-selected' : '';
                ?>
				<div class="images-radio-subcontainer">
					<label>
						<input type="radio" value="<?php 
                echo esc_attr($value);
                ?>
" name="<?php 
                echo esc_attr($name);
                ?>
" <?php 
                $this->link();
                checked($test_bg, $value);
                ?>
 style="display:none;"/>
						<img src="<?php 
                echo esc_html($label);
                ?>
" class="of-radio-img-img <?php 
                echo esc_attr($selected);
                ?>
"/><br/>
					</label>
				</div>
			<?php 
            }
        }
    }
    /********** Class for background image option ends *************/
    /********** Class for skin color selection option starts *************/
    class Cyberchimps_skin_selector extends WP_Customize_Control
    {
        public $type = 'radio';
        public function render_content()
        {
            ?>
			<style>
				.images-skin-subcontainer, .images-radio-subcontainer {
					display: inline-block;
				}
				
				#customize-control-cyberchimps_background em {
					display: block;
				}

				.images-skin-subcontainer img {
					margin-top: 5px;
					padding: 2px;
					border: 5px solid #eee;
					height: 80px;
					width: 80px;
				}

				.images-skin-subcontainer img.of-radio-img-selected {
					border: 5px solid #5DA7F2;
				}

				.images-skin-subcontainer img:hover {
					cursor: pointer;
					border: 5px solid #5DA7F2;
				}
			</style>
			<script>
				jQuery(function ($) {
					$('.of-radio-img-img').click(function () {
						$(this).parent().parent().parent().find('.of-radio-img-img').removeClass('of-radio-img-selected');
						$(this).addClass('of-radio-img-selected');
					});

					// Script to show hide the Google Text Font input depending on the value of the Text select
					var font = $('#customize-control-typography_face select').val();
					if (font != 'Google Fonts') {
						$('#customize-control-google_font_field').hide();
					}
					else {
						$('#customize-control-google_font_field').show();
					}
					$('#customize-control-typography_face select').change(function () {
						var font_change = $(this).val();
						if (font_change != 'Google Fonts') {
							$('#customize-control-google_font_field').hide();
						}
						else {
							$('#customize-control-google_font_field').show();
						}
					});

					// Script to hide show the Google Heading Font input depending on value of the Heading select
					var text = $('#customize-control-font_family_headings select').val();
					if (text != 'Google Fonts') {
						$('#customize-control-google_font_headings').hide();
					}
					else {
						$('#customize-control-google_font_headings').show();
					}
					$('#customize-control-font_family_headings select').change(function () {
						var text_change = $(this).val();
						if (text_change != 'Google Fonts') {
							$('#customize-control-google_font_headings').hide();
						}
						else {
							$('#customize-control-google_font_headings').show();
						}
					});

				});
			</script>

			<span class="customize-control-title"><?php 
            echo esc_html($this->label);
            ?>
</span>
			<?php 
            foreach ($this->choices as $value => $label) {
                //if get theme mod background image has a value then we need to set cyberchimps bg to none
                $test_skin = $this->value();
                $name = '_customize-radio-' . $this->id;
                $selected = $test_skin == $value ? 'of-radio-img-selected' : '';
                ?>
				<div class="images-skin-subcontainer">
					<label>
						<input type="radio" value="<?php 
                echo esc_attr($value);
                ?>
" name="<?php 
                echo esc_attr($name);
                ?>
" <?php 
                $this->link();
                checked($test_skin, $value);
                ?>
 style="display:none;"/>
						<img src="<?php 
                echo esc_html($label);
                ?>
" class="of-radio-img-img <?php 
                echo esc_attr($selected);
                ?>
"/>
					</label>
				</div>
			<?php 
            }
        }
    }
    /********** Class for skin color selection option ends *************/
    $wp_customize->add_section('cyberchimps_design_section', array('title' => 'Design', 'priority' => 35));
    // website width
    $wp_customize->add_setting('cyberchimps_options[max_width]', array('default' => 1020, 'type' => 'option'));
    $wp_customize->add_control('max_width', array('label' => __('Max Width', 'cyberchimps_core'), 'section' => 'cyberchimps_design_section', 'type' => 'text', 'settings' => 'cyberchimps_options[max_width]'));
    // theme skin
    // First check that there is more than one skin to show, otherwise hide the options as requested by WP
    $choices = apply_filters('cyberchimps_skin_color', array('default' => get_template_directory_uri() . '/inc/css/skins/images/default.png'));
    if (count($choices) > 1) {
        $wp_customize->add_setting('cyberchimps_options[cyberchimps_skin_color]', array('default' => array('default' => get_template_directory_uri() . '/inc/css/skins/images/default.png'), 'type' => 'option'));
        $wp_customize->add_control(new Cyberchimps_skin_selector($wp_customize, 'skin_color', array('label' => __('Skin Color', 'cyberchimps_core'), 'section' => 'cyberchimps_design_section', 'settings' => 'cyberchimps_options[cyberchimps_skin_color]', 'choices' => $choices)));
    }
    // text color
    $wp_customize->add_setting('cyberchimps_options[text_colorpicker]', array('default' => '', 'type' => 'option'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'text_colorpicker', array('label' => __('Text Color', 'cyberchimps_core'), 'section' => 'cyberchimps_design_section', 'settings' => 'cyberchimps_options[text_colorpicker]')));
    // link color
    $wp_customize->add_setting('cyberchimps_options[link_colorpicker]', array('default' => '', 'type' => 'option'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'link_colorpicker', array('label' => __('Link Color', 'cyberchimps_core'), 'section' => 'cyberchimps_design_section', 'settings' => 'cyberchimps_options[link_colorpicker]')));
    // link hover color
    $wp_customize->add_setting('cyberchimps_options[link_hover_colorpicker]', array('default' => '', 'type' => 'option'));
    $wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'link_hover_colorpicker', array('label' => __('Link Hover Color', 'cyberchimps_core'), 'section' => 'cyberchimps_design_section', 'settings' => 'cyberchimps_options[link_hover_colorpicker]')));
    // Custom CSS
    if ('pro' == cyberchimps_theme_check()) {
        $wp_customize->add_setting('cyberchimps_options[custom_css]', array('default' => '', 'type' => 'option'));
        // Content area
        $wp_customize->add_control(new Cyberchimps_Form($wp_customize, 'custom_css', array('section' => 'cyberchimps_design_section', 'settings' => 'cyberchimps_options[custom_css]', 'type' => 'textarea')));
    }
    // new typography section
    $wp_customize->add_section('cyberchimps_typography_section', array('title' => 'Typography', 'priority' => 40));
    // typography sizes
    $wp_customize->add_setting('cyberchimps_options[typography_options][size]', array('default' => '14px', 'type' => 'option'));
    $wp_customize->add_control(new Cyberchimps_Typography_Size($wp_customize, 'typography_size', array('label' => __('Typography Size', 'cyberchimps_core'), 'section' => 'cyberchimps_typography_section', 'type' => 'select', 'settings' => 'cyberchimps_options[typography_options][size]', 'choices' => apply_filters('cyberchimps_typography_sizes', ''))));
    // typography style
    $wp_customize->add_setting('cyberchimps_options[typography_options][style]', array('default' => 'normal', 'type' => 'option'));
    $wp_customize->add_control('typography_style', array('label' => __('Typography Style', 'cyberchimps_core'), 'section' => 'cyberchimps_typography_section', 'type' => 'select', 'settings' => 'cyberchimps_options[typography_options][style]', 'choices' => apply_filters('cyberchimps_typography_styles', '')));
    // typography face
    /* Default font faces */
    $faces = array('Arial, Helvetica, sans-serif' => 'Arial', 'Arial Black, Gadget, sans-serif' => 'Arial Black', 'Comic Sans MS, cursive' => 'Comic Sans MS', 'Courier New, monospace' => 'Courier New', 'Georgia, serif' => 'Georgia', '"HelveticaNeue-Light", "Helvetica Neue Light",
		"Helvetica Neue",Helvetica, Arial, "Lucida Grande",
		sans-serif' => 'Helvetica Neue', 'Impact, Charcoal, sans-serif' => 'Impact', 'Lucida Console, Monaco, monospace' => 'Lucida Console', 'Lucida Sans Unicode, Lucida Grande, sans-serif' => 'Lucida Sans Unicode', '"Open Sans", sans-serif' => 'Open Sans', 'Palatino Linotype, Book Antiqua, Palatino, serif' => 'Palatino Linotype', 'Tahoma, Geneva, sans-serif' => 'Tahoma', 'Times New Roman, Times, serif' => 'Times New Roman', 'Trebuchet MS, sans-serif' => 'Trebuchet MS', 'Verdana, Geneva, sans-serif' => 'Verdana', 'Symbol' => 'Symbol', 'Webdings' => 'Webdings', 'Wingdings, Zapf Dingbats' => 'Wingdings', 'MS Sans Serif, Geneva, sans-serif' => 'MS Sans Serif', 'MS Serif, New York, serif' => 'MS Serif', 'Google Fonts' => 'Google Fonts');
    // Font family for text
    $wp_customize->add_setting('cyberchimps_options[typography_options][face]', array('default' => 'Arial', 'type' => 'option'));
    $wp_customize->add_control('typography_face', array('label' => __('Typography Face', 'cyberchimps_core'), 'section' => 'cyberchimps_typography_section', 'type' => 'select', 'settings' => 'cyberchimps_options[typography_options][face]', 'choices' => apply_filters('cyberchimps_typography_faces', $faces)));
    // Google Font family for text
    $wp_customize->add_setting('cyberchimps_options[google_font_field]', array('default' => 'Arial', 'type' => 'option'));
    $wp_customize->add_control('google_font_field', array('label' => __('Enter Google font', 'cyberchimps_core'), 'section' => 'cyberchimps_typography_section', 'type' => 'text', 'settings' => 'cyberchimps_options[google_font_field]'));
    // Font family for headings
    $wp_customize->add_setting('cyberchimps_options[font_family_headings][face]', array('default' => 'Arial', 'type' => 'option'));
    $wp_customize->add_control('font_family_headings', array('label' => __('Font Family for headings', 'cyberchimps_core'), 'section' => 'cyberchimps_typography_section', 'type' => 'select', 'settings' => 'cyberchimps_options[font_family_headings][face]', 'choices' => apply_filters('cyberchimps_typography_faces', $faces)));
    // Google Font family for headings
    $wp_customize->add_setting('cyberchimps_options[google_font_headings]', array('default' => 'Arial', 'type' => 'option'));
    $wp_customize->add_control('google_font_headings', array('label' => __('Google font for headings', 'cyberchimps_core'), 'section' => 'cyberchimps_typography_section', 'type' => 'text', 'settings' => 'cyberchimps_options[google_font_headings]'));
    // background image
    $wp_customize->add_setting('cyberchimps_background', array('default' => 'none', 'type' => 'theme_mod'));
    $wp_customize->add_control(new Cyberchimps_Background_Image($wp_customize, 'cyberchimps_background', array('label' => 'CyberChimps ' . __('Background Image', 'cyberchimps_core'), 'section' => 'background_image', 'settings' => 'cyberchimps_background', 'choices' => apply_filters('cyberchimps_background_image', ''))));
}
예제 #4
0
/**
 * Validate options
 *
 * Validate theme options before updating to database.
 */
function cyberchimps_options_validate($input)
{
    global $wp_filesystem;
    /*
     * Import functionality
     *
     * Both the copy/paste and file upload options are active. First it checks for file, if any file is uploaded then
     * it processes that. Otherwise it checks if anything is sent with the textarea for the import.
     */
    // Check if any file is uplaoded
    if (isset($_FILES['import_file']) && $_FILES['import_file']['name']) {
        // Initialise WP filesystem.
        WP_Filesystem(request_filesystem_credentials('options.php', '', false, false, null));
        // Get the text of the uploaded file and trim it to remove space from either end.
        $import_file_text = trim($wp_filesystem->get_contents($_FILES['import_file']['tmp_name']));
        if ($import_file_text) {
            $string = stripslashes($import_file_text);
            // check string is serialized and unserialize it
            if (is_serialized($string)) {
                $try = unserialize($string);
            }
            // make sure $try is set with the unserialized data
            if ($try) {
                add_settings_error('cyberchimps_options', 'imported_success', __('Options Imported', 'cyberchimps_core'), 'updated fade');
                return $try;
            } else {
                add_settings_error('cyberchimps_options', 'imported_failed', __('Invalid Data for Import', 'cyberchimps_core'), 'error fade');
            }
        }
    } else {
        if (isset($_POST['import'])) {
            if (trim($_POST['import'])) {
                $string = stripslashes(trim($_POST['import']));
                // check string is serialized and unserialize it
                if (is_serialized($string)) {
                    $try = unserialize($string);
                }
                // make sure $try is set with the unserialized data
                if ($try) {
                    add_settings_error('cyberchimps_options', 'imported_success', __('Options Imported', 'cyberchimps_core'), 'updated fade');
                    return $try;
                } else {
                    add_settings_error('cyberchimps_options', 'imported_failed', __('Invalid Data for Import', 'cyberchimps_core'), 'error fade');
                }
            }
        }
    }
    /*
     * Restore Defaults.
     *
     * In the event that the user clicked the "Restore Defaults"
     * button, the options defined in the theme's options.php
     * file will be added to the option for the active theme.
     */
    if (isset($_POST['reset'])) {
        add_settings_error('cyberchimps_options', 'restore_defaults', __('Default options restored.', 'cyberchimps_core'), 'updated fade');
        return cyberchimps_get_default_values();
    } else {
        $clean = array();
        $options = cyberchimps_get_fields();
        foreach ($options as $option) {
            if (!isset($option['id'])) {
                continue;
            }
            if (!isset($option['type'])) {
                continue;
            }
            $id = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($option['id']));
            // Set upload to false if it wasn't sent in the $_POST
            if ('info' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set upload to false if it wasn't sent in the $_POST
            if ('upload' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set radio to false if it wasn't sent in the $_POST
            if ('radio' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set toggle to false if it wasn't sent in the $_POST
            if ('toggle' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set checkbox to false if it wasn't sent in the $_POST
            if ('checkbox' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set checkbox to false if it wasn't sent in the $_POST
            if ('images' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set each item in the multicheck to false if it wasn't sent in the $_POST
            if ('multicheck' == $option['type'] && !isset($input[$id])) {
                foreach ($option['options'] as $key => $value) {
                    $input[$id][$key] = false;
                }
            }
            // Catch any other id's that have not been set and set them to false. For some themes we remove options and we don't want them causing a problem
            if (!isset($input[$id])) {
                $input[$id] = false;
            }
            // For a value to be submitted to database it must pass through a sanitization filter
            if (has_filter('cyberchimps_sanitize_' . $option['type'])) {
                $clean[$id] = apply_filters('cyberchimps_sanitize_' . $option['type'], $input[$id], $option);
            }
        }
        do_action('cyberchimps_options_before_save', $input);
        add_settings_error('cyberchimps_options', 'save_options', __('Options saved.', 'cyberchimps_core'), 'updated fade');
        return $clean;
    }
}
예제 #5
0
/**
 * Validate options
 *
 * Validate theme options before updating to database.
 */
function cyberchimps_options_validate($input)
{
    // Theme option import functionality
    if (isset($_POST['import'])) {
        if (trim($_POST['import'])) {
            $string = stripslashes(trim($_POST['import']));
            $try = unserialize($string);
            if ($try) {
                add_settings_error('cyberchimps_options', 'imported_success', __('Options Imported', 'cyberchimps'), 'updated fade');
                return $try;
            } else {
                add_settings_error('cyberchimps_options', 'imported_failed', __('Invalid Data for Import', 'cyberchimps'), 'error fade');
            }
        }
    }
    /*
     * Restore Defaults.
     *
     * In the event that the user clicked the "Restore Defaults"
     * button, the options defined in the theme's options.php
     * file will be added to the option for the active theme.
     */
    if (isset($_POST['reset'])) {
        add_settings_error('cyberchimps_options', 'restore_defaults', __('Default options restored.', 'cyberchimps'), 'updated fade');
        $defaults = cyberchimps_get_default_values();
        /* get the admin array */
        $admin_array = cyberchimps_get_option('admin');
        /* if it exists then add it to the defaults array */
        if ($admin_array) {
            $defaults['admin'] = $admin_array;
        }
        return $defaults;
    } else {
        // Update general setting options
        if (isset($_POST['blogname'])) {
            update_option('blogname', wp_unslash($_POST['blogname']));
        }
        if (isset($_POST['blogdescription'])) {
            update_option('blogdescription', wp_unslash($_POST['blogdescription']));
        }
        $clean = array();
        $options = cyberchimps_get_fields();
        foreach ($options as $option) {
            if (!isset($option['id'])) {
                continue;
            }
            if (!isset($option['type'])) {
                continue;
            }
            $id = preg_replace('/[^a-zA-Z0-9._\\-]/', '', strtolower($option['id']));
            // Set upload to false if it wasn't sent in the $_POST
            if ('info' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set upload to false if it wasn't sent in the $_POST
            if ('upload' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set radio to false if it wasn't sent in the $_POST
            if ('radio' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set toggle to false if it wasn't sent in the $_POST
            if ('toggle' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set checkbox to false if it wasn't sent in the $_POST
            if ('checkbox' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set checkbox to false if it wasn't sent in the $_POST
            if ('images' == $option['type'] && !isset($input[$id])) {
                $input[$id] = false;
            }
            // Set each item in the multicheck to false if it wasn't sent in the $_POST
            if ('multicheck' == $option['type'] && !isset($input[$id])) {
                foreach ($option['options'] as $key => $value) {
                    $input[$id][$key] = false;
                }
            }
            // For a value to be submitted to database it must pass through a sanitization filter
            if (has_filter('cyberchimps_sanitize_' . $option['type'])) {
                $clean[$id] = apply_filters('cyberchimps_sanitize_' . $option['type'], $input[$id], $option);
            }
        }
        $clean['admin'] = array();
        if (isset($input['admin'])) {
            $clean['admin'] = $input['admin'];
        } else {
            $clean['admin'] = cyberchimps_get_option('admin');
        }
        add_settings_error('cyberchimps_options', 'save_options', __('Options saved.', 'cyberchimps'), 'updated fade');
        return $clean;
    }
}