function om_customize_register($wp_customize)
{
    require_once TEMPLATE_DIR . '/functions/theme-options.php';
    $theme_options = om_get_options_template(true);
    /***********/
    $wp_customize->remove_section('title_tagline');
    /***********/
    $wp_customize->add_section('options_notice', array('title' => __('More options', 'om_theme'), 'priority' => 10, 'description' => __('For more Options see <a href="admin.php?page=om_options">"Theme Options"</a> section', 'om_theme')));
    $wp_customize->add_setting('options_notice', array('sanitize_callback' => 'sanitize_text_field'));
    $wp_customize->add_control(new OM_Customize_Notice_Control($wp_customize, 'options_notice', array('label' => '', 'section' => 'options_notice', 'settings' => 'options_notice', 'type' => 'notice')));
    /***********/
    $wp_customize->add_section('layout', array('title' => __('Layout', 'om_theme'), 'priority' => 30));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'overall_layout', 'section' => 'layout'));
    /***********/
    $wp_customize->add_section('bg_img', array('title' => __('Background', 'om_theme'), 'description' => __('This option makes sense only if "Boxed" layout chosen above', 'om_theme'), 'priority' => 31));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'background_color', 'section' => 'bg_img'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'background_img_custom', 'section' => 'bg_img'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'background_pos', 'section' => 'bg_img'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'background_attach', 'section' => 'bg_img'));
    /***********/
    $wp_customize->add_section('header', array('title' => __('Header', 'om_theme'), 'priority' => 35));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'header_tagline', 'section' => 'header'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'social_icons_header', 'section' => 'header'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'intro_text', 'section' => 'header'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'show_header_search', 'section' => 'header'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'header_layout', 'section' => 'header'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'menu_position', 'section' => 'header'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'show_dropdown_symbol', 'section' => 'header'));
    /***********/
    $wp_customize->add_section('footer', array('title' => __('Footer', 'om_theme'), 'priority' => 36));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'subfooter_text', 'section' => 'footer'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'social_icons_footer', 'section' => 'footer'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'uncovering_footer', 'section' => 'footer'));
    /***********/
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'hightlight_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'pre_header_background_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'tagline_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'header_background_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'social_icons_color_header', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'menu_items_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'menu_items_color_hover', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'menu_sub_items_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'menu_sub_items_color_hover', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'background_main_content_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'main_text_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'side_text_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'background_footer_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'footer_titles_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'footer_main_text_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'footer_side_text_color', 'section' => 'colors'));
    om_customize_add_theme_option($wp_customize, $theme_options, array('option_id' => OM_THEME_PREFIX . 'social_icons_color_footer', 'section' => 'colors'));
    /***********/
}
function om_ajax_callback()
{
    $action = $_POST['type'];
    if (get_magic_quotes_gpc()) {
        $_POST = stripslashes_deep($_POST);
    }
    // Save All Options
    if ($action == 'options') {
        parse_str($_POST['data'], $output);
        $output = array_map('stripslashes_deep', $output);
        $options = om_get_options_template();
        foreach ($options as $option_array) {
            if (isset($option_array['id'])) {
                // Non - Headings...
                $id = $option_array['id'];
                $new_value = '';
                if (isset($output[$id])) {
                    $new_value = $output[$id];
                }
                switch ($option_array['type']) {
                    case 'checkbox':
                        if ($new_value == 'true') {
                            update_option($id, 'true');
                        } else {
                            update_option($id, 'false');
                        }
                        break;
                    case 'multicheck':
                        $option_options = $option_array['options'];
                        $tmp = array();
                        foreach ($option_options as $options_id => $options_value) {
                            $tmp[$options_id] = isset($output[$id][$options_id]);
                        }
                        update_option($id, $tmp);
                        break;
                    case 'form_fields':
                        if (!is_array(@$output[$id])) {
                            $output[$id] = array();
                        }
                        update_option($id, $output[$id]);
                        break;
                    case 'styling_presets':
                        $tmp = array();
                        if (is_array($option_array['options'])) {
                            foreach ($option_array['options'] as $k) {
                                $tmp[$k] = @$output[$k];
                            }
                        }
                        $name = $output[$id . '_new'];
                        if ($name) {
                            $output[$id] = get_option($id);
                            $output[$id][$name] = $tmp;
                            update_option($id, $output[$id]);
                        }
                        break;
                    default:
                        update_option($id, $new_value);
                        break;
                }
            }
        }
        do_action('om_options_updated');
    } elseif ($action == 'style_preset_apply') {
        $data = $_POST['data'];
        if (@$data['id'] && @$data['name']) {
            $presets = get_option($data['id']);
            $data['name'] = urldecode($data['name']);
            if (is_array(@$presets[$data['name']])) {
                foreach ($presets[$data['name']] as $k => $v) {
                    update_option($k, $v);
                }
            }
            do_action('om_options_updated');
        }
    } elseif ($action == 'style_preset_remove') {
        $data = $_POST['data'];
        if (@$data['id'] && @$data['name']) {
            $presets = get_option($data['id']);
            unset($presets[urldecode($data['name'])]);
            update_option($data['id'], $presets);
        }
    }
    die;
}