예제 #1
0
/**
 * Sanitize and validate form input. Accepts an array, return a sanitized array.
 *
 * @see catchbox_theme_options_init()
 * @todo set up Reset Options action
 *
 * @since Catch Box 1.0
 */
function catchbox_theme_options_validate($input)
{
    $output = $defaults = catchbox_get_default_theme_options();
    // favicon url
    if (isset($input['fav_icon'])) {
        $output['fav_icon'] = esc_url_raw($input['fav_icon']);
    }
    // web clicp icon url
    if (isset($input['web_clip'])) {
        $output['web_clip'] = esc_url_raw($input['web_clip']);
    }
    // Color scheme must be in our array of color scheme options
    if (isset($input['color_scheme']) && array_key_exists($input['color_scheme'], catchbox_color_schemes())) {
        $output['color_scheme'] = $input['color_scheme'];
    }
    // Our defaults for the link color may have changed, based on the color scheme.
    $output['link_color'] = $defaults['link_color'] = catchbox_get_default_link_color($output['color_scheme']);
    // Link color must be 3 or 6 hexadecimal characters
    if (isset($input['link_color']) && preg_match('/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'])) {
        $output['link_color'] = '#' . strtolower(ltrim($input['link_color'], '#'));
    }
    // Theme layout must be in our array of theme layout options
    if (isset($input['theme_layout']) && array_key_exists($input['theme_layout'], catchbox_layouts())) {
        $output['theme_layout'] = $input['theme_layout'];
    }
    // Theme layout must be in our array of theme layout options
    if (isset($input['content_layout']) && array_key_exists($input['content_layout'], catchbox_content_layout())) {
        $output['content_layout'] = $input['content_layout'];
    }
    // excerpt length
    if (isset($input['excerpt_length'])) {
        $output['excerpt_length'] = absint($input['excerpt_length']);
    }
    // feed url
    if (isset($input['feed_url'])) {
        $output['feed_url'] = esc_url_raw($input['feed_url']);
    }
    // Disable Header Search
    if (isset($input['disable_header_search'])) {
        // Our checkbox value is either 0 or 1
        $output['disable_header_search'] = $input['disable_header_search'];
    }
    // Custom CSS
    if (isset($input['custom_css'])) {
        $output['custom_css'] = wp_kses_stripslashes($input['custom_css']);
    }
    if (function_exists('catchbox_themeoption_invalidate_caches')) {
        catchbox_themeoption_invalidate_caches();
    }
    return apply_filters('catchbox_theme_options_validate', $output, $input, $defaults);
}
/**
 * Implements Catch Kathmandu theme options into Theme Customizer.
 *
 * @param $wp_customize Theme Customizer object
 * @return void
 *
 * @since Catch Box 3.6.7
 */
function catchbox_customize_register($wp_customize)
{
    $options = catchbox_get_theme_options();
    $defaults = catchbox_get_default_theme_options();
    //print_r($options);
    //Custom Controls
    require get_template_directory() . '/inc/customizer/customizer-custom-controls.php';
    $theme_slug = 'catchbox_theme_';
    $settings_page_tabs = array('theme_options' => array('id' => 'theme_options', 'title' => __('Theme Options', 'catch-box'), 'description' => __('Basic theme Options', 'catch-box'), 'sections' => array('favicon' => array('id' => 'favicon', 'title' => __('Favicon', 'catch-box'), 'description' => ''), 'web_clip_icon_options' => array('id' => 'web_clip_icon_options', 'title' => __('Webclip Icon Options', 'catch-box'), 'description' => __('Web Clip Icon for Apple devices. Recommended Size - Width 144px and Height 144px height, which will support High Resolution Devices like iPad Retina', 'catch-box')), 'color_scheme' => array('id' => 'color_scheme', 'title' => __('Color Scheme', 'catch-box'), 'description' => ''), 'link_color' => array('id' => 'link_color', 'title' => __('Link Color', 'catch-box'), 'description' => ''), 'theme_layout' => array('id' => 'theme_layout', 'title' => __('Default Layout', 'catch-box'), 'description' => ''), 'content_layout' => array('id' => 'content_layout', 'title' => __('Content Layout', 'catch-box'), 'description' => ''), 'excerpt_length' => array('id' => 'excerpt_length', 'title' => __('Excerpt Length in Words', 'catch-box'), 'description' => ''), 'feed_url' => array('id' => 'feed_url', 'title' => __('Feed Redirect URL', 'catch-box'), 'description' => ''), 'site_title_above' => array('id' => 'site_title_above', 'title' => __('Move Site Title and Tagline?', 'catch-box'), 'description' => ''), 'search_display_text' => array('id' => 'search_display_text', 'title' => __('Default Display Text in Search', 'catch-box'), 'description' => ''), 'disable_header_search' => array('id' => 'disable_header_search', 'title' => __('Disable Search in Header?', 'catch-box'), 'description' => ''), 'enable_menus' => array('id' => 'enable_menus', 'title' => __('Enable Secondary & Footer Menu in Mobile Devices?', 'catch-box'), 'description' => ''), 'custom_css' => array('id' => 'custom_css', 'title' => __('Custom CSS Styles', 'catch-box'), 'description' => ''), 'scrollup' => array('id' => 'scrollup', 'title' => __('Scroll Up Options', 'catch-box'), 'description' => ''))), 'featured_slider' => array('id' => 'featured_slider', 'title' => __('Featured Slider', 'catch-box'), 'description' => __('Featured Slider', 'catch-box'), 'sections' => array('slider_options' => array('id' => 'slider_options', 'title' => __('Slider Options', 'catch-box'), 'description' => ''), 'slider_effect_options' => array('id' => 'slider_effect_options', 'title' => __('Slider Effect Options', 'catch-box'), 'description' => ''))), 'social_links' => array('id' => 'social_links', 'title' => __('Social Links', 'catch-box'), 'description' => __('Add your social links here', 'catch-box'), 'sections' => array('predefined_social_icons' => array('id' => 'predefined_social_icons', 'title' => __('Predefined Social Icons', 'catch-box'), 'description' => ''))), 'webmaster_tools' => array('id' => 'webmaster_tools', 'title' => __('Webmaster Tools', 'catch-box'), 'description' => sprintf(__('Webmaster Tools falls under Plugins Territory according to Theme Review Guidelines in WordPress.org. This feature will be depreciated in future versions from Catch Box free version. If you want this feature, then you can add <a href="%s">Catch Web Tools</a>  plugin.', 'catch-box'), esc_url('https://wordpress.org/plugins/catch-web-tools/')), 'sections' => array('webmaster_tools' => array('id' => 'webmaster_tools', 'title' => __('Webmaster Tools', 'catch-box'), 'description' => sprintf(__('Webmaster Tools falls under Plugins Territory according to Theme Review Guidelines in WordPress.org. This feature will be depreciated in future versions from Catch Box free version. If you want this feature, then you can add <a href="%s">Catch Web Tools</a>  plugin.', 'catch-box'), esc_url('https://wordpress.org/plugins/catch-web-tools/'))))));
    //Add Panels and sections
    foreach ($settings_page_tabs as $panel) {
        $wp_customize->add_panel($theme_slug . $panel['id'], array('priority' => 200, 'capability' => 'edit_theme_options', 'title' => $panel['title'], 'description' => $panel['description']));
        // Loop through tabs for sections
        foreach ($panel['sections'] as $section) {
            $params = array('title' => $section['title'], 'description' => $section['description'], 'panel' => $theme_slug . $panel['id']);
            if (isset($section['active_callback'])) {
                $params['active_callback'] = $section['active_callback'];
            }
            $wp_customize->add_section($theme_slug . $section['id'], $params);
        }
    }
    foreach (catchbox_color_schemes() as $option) {
        $catchbox_color_schemes[$option['value']] = $option['label'];
    }
    foreach (catchbox_layouts() as $option) {
        $catchbox_theme_layout[$option['value']] = $option['label'];
    }
    foreach (catchbox_content_layout() as $option) {
        $catchbox_content_layout[$option['value']] = $option['label'];
    }
    $settings_parameters = array('fav_icon' => array('id' => 'fav_icon', 'title' => __('Fav Icon', 'catch-box'), 'description' => '', 'field_type' => 'image', 'sanitize' => 'catchbox_sanitize_image', 'panel' => 'theme_options', 'section' => 'favicon', 'default' => '', 'active_callback' => 'catchbox_is_site_icon_active'), 'web_clip' => array('id' => 'web_clip', 'title' => __('Web Clip Icon', 'catch-box'), 'description' => '', 'field_type' => 'image', 'sanitize' => 'catchbox_sanitize_image', 'panel' => 'theme_options', 'section' => 'web_clip_icon_options', 'default' => '', 'active_callback' => 'catchbox_is_site_icon_active'), 'color_scheme' => array('id' => 'color_scheme', 'title' => __('Color Scheme', 'catch-box'), 'description' => '', 'field_type' => 'radio', 'sanitize' => 'catchbox_sanitize_select', 'panel' => 'theme_options', 'section' => 'color_scheme', 'default' => $defaults['color_scheme'], 'choices' => $catchbox_color_schemes), 'link_color' => array('id' => 'link_color', 'title' => __('Link Color', 'catch-box'), 'description' => '', 'field_type' => 'color', 'sanitize' => 'sanitize_hex_color', 'panel' => 'theme_options', 'section' => 'link_color', 'default' => $defaults['link_color']), 'theme_layout' => array('id' => 'theme_layout', 'title' => __('Default Layout', 'catch-box'), 'description' => '', 'field_type' => 'radio', 'sanitize' => 'catchbox_sanitize_select', 'panel' => 'theme_options', 'section' => 'theme_layout', 'default' => $defaults['theme_layout'], 'choices' => $catchbox_theme_layout), 'content_layout' => array('id' => 'content_layout', 'title' => __('Content Layout', 'catch-box'), 'description' => '', 'field_type' => 'radio', 'sanitize' => 'catchbox_sanitize_select', 'panel' => 'theme_options', 'section' => 'content_layout', 'default' => $defaults['content_layout'], 'choices' => $catchbox_content_layout), 'excerpt_length' => array('id' => 'excerpt_length', 'title' => __('Excerpt Length in Words', 'catch-box'), 'description' => '', 'field_type' => 'number', 'sanitize' => 'catchbox_sanitize_number_range', 'panel' => 'theme_options', 'section' => 'excerpt_length', 'default' => $defaults['excerpt_length'], 'input_attrs' => array('style' => 'width: 45px;', 'min' => 0, 'max' => 999999, 'step' => 1)), 'feed_url' => array('id' => 'feed_url', 'title' => __('Feed Redirect url', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'feed_url', 'default' => '', 'active_callback' => 'catchbox_is_feed_url_present'), 'site_title_above' => array('id' => 'site_title_above', 'title' => __('Check to move above the Header/Logo Image', 'catch-box'), 'field_type' => 'checkbox', 'sanitize' => 'catchbox_sanitize_checkbox', 'panel' => 'theme_options', 'section' => 'site_title_above', 'default' => $defaults['site_title_above']), 'search_display_text' => array('id' => 'search_display_text', 'title' => __('Default Display Text in Search', 'catch-box'), 'description' => '', 'field_type' => 'text', 'sanitize' => 'sanitize_text_field', 'panel' => 'theme_options', 'section' => 'search_display_text', 'default' => $defaults['search_display_text']), 'disable_header_search' => array('id' => 'disable_header_search', 'title' => __('Check to Disable', 'catch-box'), 'field_type' => 'checkbox', 'sanitize' => 'catchbox_sanitize_checkbox', 'panel' => 'theme_options', 'section' => 'disable_header_search', 'default' => $defaults['disable_header_search']), 'enable_menus' => array('id' => 'enable_menus', 'title' => __('Check to Enable', 'catch-box'), 'field_type' => 'checkbox', 'sanitize' => 'catchbox_sanitize_checkbox', 'panel' => 'theme_options', 'section' => 'enable_menus', 'default' => $defaults['enable_menus']), 'custom_css' => array('id' => 'custom_css', 'title' => __('Custom CSS Styles', 'catch-box'), 'description' => '', 'field_type' => 'textarea', 'sanitize' => 'catchbox_sanitize_custom_css', 'panel' => 'theme_options', 'section' => 'custom_css', 'default' => ''), 'disable_scrollup' => array('id' => 'disable_scrollup', 'title' => __('Check to disable scroll up', 'catch-box'), 'description' => '', 'field_type' => 'checkbox', 'sanitize' => 'catchbox_sanitize_checkbox', 'panel' => 'theme_options', 'section' => 'scrollup', 'default' => $defaults['disable_scrollup']), 'exclude_slider_post' => array('id' => 'exclude_slider_post', 'title' => __('Check to Exclude Slider posts from Homepage posts', 'catch-box'), 'field_type' => 'checkbox', 'sanitize' => 'catchbox_sanitize_checkbox', 'panel' => 'featured_slider', 'section' => 'slider_options', 'default' => $defaults['exclude_slider_post']), 'slider_qty' => array('id' => 'slider_qty', 'title' => __('Number of Slides', 'catch-box'), 'description' => __('Customizer page needs to be refreshed after saving if number of slides is changed', 'catch-box'), 'field_type' => 'number', 'sanitize' => 'catchbox_sanitize_number_range', 'panel' => 'featured_slider', 'section' => 'slider_options', 'default' => $defaults['slider_qty'], 'input_attrs' => array('style' => 'width: 45px;', 'min' => 0, 'max' => 20, 'step' => 1)), 'transition_effect' => array('id' => 'transition_effect', 'title' => __('Transition Effect', 'catch-box'), 'description' => '', 'field_type' => 'select', 'sanitize' => 'catchbox_sanitize_select', 'panel' => 'featured_slider', 'section' => 'slider_effect_options', 'default' => $defaults['transition_effect'], 'choices' => array('fade' => __('fade', 'catch-box'), 'wipe' => __('wipe', 'catch-box'), 'scrollUp' => __('scrollUp', 'catch-box'), 'scrollDown' => __('scrollDown', 'catch-box'), 'scrollLeft' => __('scrollLeft', 'catch-box'), 'scrollRight' => __('scrollRight', 'catch-box'), 'blindX' => __('blindX', 'catch-box'), 'blindY' => __('blindY', 'catch-box'), 'blindZ' => __('blindZ', 'catch-box'), 'cover' => __('cover', 'catch-box'), 'shuffle' => __('shuffle', 'catch-box'))), 'transition_delay' => array('id' => 'transition_delay', 'title' => __('Transition Delay (in seconds)', 'catch-box'), 'description' => '', 'field_type' => 'number', 'sanitize' => 'catchbox_sanitize_number_range', 'panel' => 'featured_slider', 'section' => 'slider_effect_options', 'default' => $defaults['transition_delay'], 'input_attrs' => array('style' => 'width: 45px;', 'min' => 0, 'max' => 999999999, 'step' => 1)), 'transition_duration' => array('id' => 'transition_duration (in seconds)', 'title' => __('Transition Length', 'catch-box'), 'description' => '', 'field_type' => 'number', 'sanitize' => 'catchbox_sanitize_number_range', 'panel' => 'featured_slider', 'section' => 'slider_effect_options', 'default' => $defaults['transition_duration'], 'input_attrs' => array('style' => 'width: 45px;', 'min' => 0, 'max' => 999999999, 'step' => 1)), 'social_facebook' => array('id' => 'social_facebook', 'title' => __('Facebook', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_twitter' => array('id' => 'social_twitter', 'title' => __('Twitter', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_googleplus' => array('id' => 'social_googleplus', 'title' => __('Google+', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_linkedin' => array('id' => 'social_linkedin', 'title' => __('LinkedIn', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_pinterest' => array('id' => 'social_pinterest', 'title' => __('Pinterest', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_youtube' => array('id' => 'social_youtube', 'title' => __('Youtube', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_rss' => array('id' => 'social_rss', 'title' => __('RSS', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_deviantart' => array('id' => 'social_deviantart', 'title' => __('deviantART', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_tumblr' => array('id' => 'social_tumblr', 'title' => __('Tumblr', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_vimeo' => array('id' => 'social_vimeo', 'title' => __('Vimeo', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_dribbble' => array('id' => 'social_dribbble', 'title' => __('Dribbble', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_myspace' => array('id' => 'social_myspace', 'title' => __('MySpace', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_aim' => array('id' => 'social_aim', 'title' => __('Aim', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_flickr' => array('id' => 'social_flickr', 'title' => __('Flickr', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'sanitize_email', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_slideshare' => array('id' => 'social_slideshare', 'title' => __('Slideshare', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_instagram' => array('id' => 'social_instagram', 'title' => __('Flickr', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_skype' => array('id' => 'social_skype', 'title' => __('Skype', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'sanitize_text_field', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_soundcloud' => array('id' => 'social_soundcloud', 'title' => __('Soundcloud', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_email' => array('id' => 'social_email', 'title' => __('Email', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'sanitize_email', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_xing' => array('id' => 'social_xing', 'title' => __('Xing', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'social_meetup' => array('id' => 'social_meetup', 'title' => __('Meetup', 'catch-box'), 'description' => '', 'field_type' => 'url', 'sanitize' => 'esc_url_raw', 'panel' => 'social_links', 'section' => 'predefined_social_icons', 'default' => ''), 'tracker_header' => array('id' => 'tracker_header', 'title' => __('Code to display on Header', 'catch-box'), 'description' => __('Here you can put scripts from Google, Facebook etc. which will load on Header', 'catch-box'), 'field_type' => 'textarea', 'sanitize' => 'wp_kses_stripslashes', 'panel' => 'webmaster_tools', 'section' => 'webmaster_tools', 'active_callback' => 'catchbox_is_header_code_present', 'default' => ''), 'tracker_footer' => array('id' => 'tracker_footer', 'title' => __('Code to display on Footer', 'catch-box'), 'description' => __('Here you can put scripts from Google, Facebook etc. which will load on Footer', 'catch-box'), 'field_type' => 'textarea', 'sanitize' => 'wp_kses_stripslashes', 'panel' => 'webmaster_tools', 'section' => 'webmaster_tools', 'active_callback' => 'catchbox_is_footer_code_present', 'default' => ''));
    foreach ($settings_parameters as $option) {
        if ('image' == $option['field_type']) {
            $wp_customize->add_setting($theme_slug . 'options[' . $option['id'] . ']', array('type' => 'option', 'sanitize_callback' => $option['sanitize'], 'default' => $option['default']));
            $wp_customize->add_control(new WP_Customize_Image_Control($wp_customize, $theme_slug . 'options[' . $option['id'] . ']', array('label' => $option['title'], 'section' => $theme_slug . $option['section'], 'settings' => $theme_slug . 'options[' . $option['id'] . ']', 'active_callback' => $option['active_callback'])));
        } else {
            if ('checkbox' == $option['field_type']) {
                $wp_customize->add_setting($theme_slug . 'options[' . $option['id'] . ']', array('type' => 'option', 'sanitize_callback' => $option['sanitize'], 'default' => $option['default']));
                $params = array('label' => $option['title'], 'settings' => $theme_slug . 'options[' . $option['id'] . ']', 'name' => $theme_slug . 'options[' . $option['id'] . ']', 'section' => $theme_slug . $option['section']);
                if (isset($option['active_callback'])) {
                    $params['active_callback'] = $option['active_callback'];
                }
                $wp_customize->add_control(new CatchBox_Customize_Checkbox($wp_customize, $theme_slug . 'options[' . $option['id'] . ']', $params));
            } else {
                //Normal Loop
                $wp_customize->add_setting($theme_slug . 'options[' . $option['id'] . ']', array('default' => $option['default'], 'type' => 'option', 'sanitize_callback' => $option['sanitize']));
                // Add setting control
                $params = array('label' => $option['title'], 'settings' => $theme_slug . 'options[' . $option['id'] . ']', 'type' => $option['field_type'], 'description' => $option['description'], 'section' => $theme_slug . $option['section']);
                if (isset($option['active_callback'])) {
                    $params['active_callback'] = $option['active_callback'];
                }
                if (isset($option['choices'])) {
                    $params['choices'] = $option['choices'];
                }
                if (isset($option['active_callback'])) {
                    $params['active_callback'] = $option['active_callback'];
                }
                if (isset($option['input_attrs'])) {
                    $params['input_attrs'] = $option['input_attrs'];
                }
                $wp_customize->add_control($theme_slug . 'options[' . $option['id'] . ']', $params);
            }
        }
    }
    if (!isset($options['slider_qty']) || !is_numeric($options['slider_qty'])) {
        $options['slider_qty'] = 4;
    }
    //Add featured post elements with respect to no of featured sliders
    for ($i = 1; $i <= $options['slider_qty']; $i++) {
        $wp_customize->add_setting($theme_slug . 'options[featured_slider][' . $i . ']', array('type' => 'option', 'sanitize_callback' => 'catchbox_sanitize_post_id'));
        $wp_customize->add_control($theme_slug . 'options[featured_slider][' . $i . ']', array('label' => sprintf(__('#%s Featured Post ID', 'catch-box'), $i), 'section' => $theme_slug . 'slider_options', 'settings' => $theme_slug . 'options[featured_slider][' . $i . ']', 'type' => 'text', 'input_attrs' => array('style' => 'width: 100px;')));
    }
    // Reset all settings to default
    $wp_customize->add_section('catchbox_reset_all_settings', array('description' => __('Caution: Reset all settings to default. Refresh the page after save to view full effects.', 'catch-box'), 'priority' => 700, 'title' => __('Reset all settings', 'catch-box')));
    $wp_customize->add_setting('catchbox_theme_options[reset_all_settings]', array('capability' => 'edit_theme_options', 'sanitize_callback' => 'catchbox_reset_all_settings', 'transport' => 'postMessage'));
    $wp_customize->add_control('catchbox_theme_options[reset_all_settings]', array('label' => __('Check to reset all settings to default', 'catch-box'), 'section' => 'catchbox_reset_all_settings', 'settings' => 'catchbox_theme_options[reset_all_settings]', 'type' => 'checkbox'));
    // Reset all settings to default end
    //Important Links
    $wp_customize->add_section('important_links', array('priority' => 999, 'title' => __('Important Links', 'catch-box')));
    /**
     * Has dummy Sanitizaition function as it contains no value to be sanitized
     */
    $wp_customize->add_setting('important_links', array('sanitize_callback' => 'catchbox_sanitize_important_link'));
    $wp_customize->add_control(new CatchBox_Important_Links($wp_customize, 'important_links', array('label' => __('Important Links', 'catch-box'), 'section' => 'important_links', 'settings' => 'important_links', 'type' => 'important_links')));
    //Important Links End
}
/**
 * Sanitize and validate form input. Accepts an array, return a sanitized array.
 *
 * @see catchbox_theme_options_init()
 * @todo set up Reset Options action
 *
 * @since Catch Box 1.0
 */
function catchbox_theme_options_validate($input)
{
    $options_validated = $defaults = catchbox_get_default_theme_options();
    //print_r($input);
    //die();
    // favicon url
    if (isset($input['fav_icon'])) {
        $options_validated['fav_icon'] = esc_url_raw($input['fav_icon']);
    }
    // web clicp icon url
    if (isset($input['web_clip'])) {
        $options_validated['web_clip'] = esc_url_raw($input['web_clip']);
    }
    // Color scheme must be in our array of color scheme options
    if (isset($input['color_scheme']) && array_key_exists($input['color_scheme'], catchbox_color_schemes())) {
        $options_validated['color_scheme'] = $input['color_scheme'];
    }
    // Our defaults for the link color may have changed, based on the color scheme.
    $options_validated['link_color'] = $defaults['link_color'] = catchbox_get_default_link_color($options_validated['color_scheme']);
    // Link color must be 3 or 6 hexadecimal characters
    if (isset($input['link_color']) && preg_match('/^#?([a-f0-9]{3}){1,2}$/i', $input['link_color'])) {
        $options_validated['link_color'] = '#' . strtolower(ltrim($input['link_color'], '#'));
    }
    // Theme layout must be in our array of theme layout options
    if (isset($input['theme_layout']) && array_key_exists($input['theme_layout'], catchbox_layouts())) {
        $options_validated['theme_layout'] = $input['theme_layout'];
    }
    // Theme layout must be in our array of theme layout options
    if (isset($input['content_layout']) && array_key_exists($input['content_layout'], catchbox_content_layout())) {
        $options_validated['content_layout'] = $input['content_layout'];
    }
    // excerpt length
    if (isset($input['excerpt_length'])) {
        $options_validated['excerpt_length'] = absint($input['excerpt_length']);
    }
    // feed url
    if (isset($input['feed_url'])) {
        $options_validated['feed_url'] = esc_url_raw($input['feed_url']);
    }
    // Move Site Title
    if (isset($input['site_title_above'])) {
        // Our checkbox value is either 0 or 1
        $options_validated['site_title_above'] = $input['site_title_above'];
    }
    // data validation for Search Settings
    if (isset($input['search_display_text'])) {
        $options_validated['search_display_text'] = sanitize_text_field($input['search_display_text']);
    }
    // Disable Header Search
    if (isset($input['disable_header_search'])) {
        // Our checkbox value is either 0 or 1
        $options_validated['disable_header_search'] = $input['disable_header_search'];
    }
    // Enable Seconday and Footer Menu
    if (isset($input['enable_menus'])) {
        // Our checkbox value is either 0 or 1
        $options_validated['enable_menus'] = $input['enable_menus'];
    }
    // Custom CSS
    if (isset($input['custom_css'])) {
        $options_validated['custom_css'] = wp_kses_stripslashes($input['custom_css']);
    }
    // data validation for scroll up
    if (isset($input['disable_scrollup'])) {
        // Our checkbox value is either 0 or 1
        $options_validated['disable_scrollup'] = $input['disable_scrollup'];
    }
    if (isset($input['slider_qty'])) {
        $options_validated['slider_qty'] = absint($input['slider_qty']) ? $input['slider_qty'] : 4;
    }
    if (isset($input['featured_slider'])) {
        $options_validated['featured_slider'] = array();
    }
    if (isset($input['slider_qty'])) {
        for ($i = 1; $i <= $input['slider_qty']; $i++) {
            if (!empty($input['featured_slider'][$i]) && intval($input['featured_slider'][$i])) {
                $options_validated['featured_slider'][$i] = absint($input['featured_slider'][$i]);
            }
        }
    }
    if (isset($input['exclude_slider_post'])) {
        // Our checkbox value is either 0 or 1
        $options_validated['exclude_slider_post'] = $input['exclude_slider_post'];
    }
    if (!empty($input['transition_effect'])) {
        $options_validated['transition_effect'] = wp_filter_nohtml_kses($input['transition_effect']);
    }
    // data validation for transition delay
    if (!empty($input['transition_delay']) && is_numeric($input['transition_delay'])) {
        $options_validated['transition_delay'] = $input['transition_delay'];
    }
    // data validation for transition length
    if (!empty($input['transition_duration']) && is_numeric($input['transition_duration'])) {
        $options_validated['transition_duration'] = $input['transition_duration'];
    }
    //Facebook
    if (isset($input['social_facebook'])) {
        $options_validated['social_facebook'] = esc_url_raw($input['social_facebook']);
    }
    //Twitter
    if (isset($input['social_twitter'])) {
        $options_validated['social_twitter'] = esc_url_raw($input['social_twitter']);
    }
    //Youtube
    if (isset($input['social_youtube'])) {
        $options_validated['social_youtube'] = esc_url_raw($input['social_youtube']);
    }
    //Google+
    if (isset($input['social_google'])) {
        $options_validated['social_google'] = esc_url_raw($input['social_google']);
    }
    //RSS
    if (isset($input['social_rss'])) {
        $options_validated['social_rss'] = esc_url_raw($input['social_rss']);
    }
    //Linkedin
    if (isset($input['social_linkedin'])) {
        $options_validated['social_linkedin'] = esc_url_raw($input['social_linkedin']);
    }
    //Pinterest
    if (isset($input['social_pinterest'])) {
        $options_validated['social_pinterest'] = esc_url_raw($input['social_pinterest']);
    }
    //Deviantart
    if (isset($input['social_deviantart'])) {
        $options_validated['social_deviantart'] = esc_url_raw($input['social_deviantart']);
    }
    //Tumblr
    if (isset($input['social_tumblr'])) {
        $options_validated['social_tumblr'] = esc_url_raw($input['social_tumblr']);
    }
    //Viemo
    if (isset($input['social_viemo'])) {
        $options_validated['social_viemo'] = esc_url_raw($input['social_viemo']);
    }
    //Dribble
    if (isset($input['social_dribbble'])) {
        $options_validated['social_dribbble'] = esc_url_raw($input['social_dribbble']);
    }
    //Myspace
    if (isset($input['social_myspace'])) {
        $options_validated['social_myspace'] = esc_url_raw($input['social_myspace']);
    }
    //Aim
    if (isset($input['social_aim'])) {
        $options_validated['social_aim'] = esc_url_raw($input['social_aim']);
    }
    //Flickr
    if (isset($input['social_flickr'])) {
        $options_validated['social_flickr'] = esc_url_raw($input['social_flickr']);
    }
    //Slideshare
    if (isset($input['social_slideshare'])) {
        $options_validated['social_slideshare'] = esc_url_raw($input['social_slideshare']);
    }
    //Instagram
    if (isset($input['social_instagram'])) {
        $options_validated['social_instagram'] = esc_url_raw($input['social_instagram']);
    }
    //Skype
    if (isset($input['social_skype'])) {
        $options_validated['social_skype'] = sanitize_text_field($input['social_skype']);
    }
    //Soundcloud
    if (isset($input['social_soundcloud'])) {
        $options_validated['social_soundcloud'] = esc_url_raw($input['social_soundcloud']);
    }
    //Email
    if (isset($input['social_email'])) {
        $options_validated['social_email'] = sanitize_email($input['social_email']);
    }
    //Xing
    if (isset($input['social_xing'])) {
        $options_validated['social_xing'] = esc_url_raw($input['social_xing']);
    }
    //Meetup
    if (isset($input['social_meetup'])) {
        $options_validated['social_meetup'] = esc_url_raw($input['social_meetup']);
    }
    // data validation for tracking code
    if (isset($input['tracker_header'])) {
        $options_validated['tracker_header'] = wp_kses_stripslashes($input['tracker_header']);
    }
    if (isset($input['tracker_footer'])) {
        $options_validated['tracker_footer'] = wp_kses_stripslashes($input['tracker_footer']);
    }
    //Clearing the theme option cache
    if (function_exists('catchbox_themeoption_invalidate_caches')) {
        catchbox_themeoption_invalidate_caches();
    }
    return $options_validated;
}