<?php

/**
 * Initialize the custom theme options.
 */
add_action('admin_init', 'custom_tab_options');

/**
 * Build the custom settings & update OptionTree.
 */
function custom_tab_options() {

    /* OptionTree is not loaded yet */
    /*
      if (! function_exists('ot_settings_id' ) ) {
      return false;
      }
     */

    /**
     * Get a copy of the saved settings array.
     */
    $saved_settings = get_option('tab_options', array());

    /**
     * Custom settings array that will eventually be
     * passes to the OptionTree Settings API Class.
     */
    $custom_settings = array(
        'contextual_help' => array(
            'sidebar' => ''
        ),
        'sections' => array(
            array('id' => 'sec_schedule',
                'title' => __('Event Schedule', 'xs')
            ),
            array('id' => 'sec_video',
                'title' => __('Promotional Video', 'xs')
            ),
            array('id' => 'sec_gallery',
                'title' => __('Event Gallery', 'xs')
            ),
            array('id' => 'sec_executive',
                'title' => __('Executive Presence', 'xs')
            )
        ),
        'settings' => array(
            array('id' => 'titevsh',
                'label' => __('Event Schedule', 'xs'),
                'desc' => __('', 'xs'),
                'std' => '',
                'type' => 'title-only',
                'section' => 'sec_schedule',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => 'ot-title no-top',
                'condition' => '',
                'operator' => 'and'
            ),
            array(
                'id' => 'show_schedule',
                'label' => __('Show this tab', 'xs'),
                'desc' => '',
                'std' => 'on',
                'type' => 'on-off',
                'section' => 'sec_schedule',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'schedule_group',
                'label' => __('Schedule Group', 'xs'),
                'desc' => __('Please select a parent schedule group.', 'xs'),
                'std' => '',
                'type' => 'taxonomy_select',
                'section' => 'sec_schedule',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => 'xs_schedules',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'schedule_title',
                'label' => __('Title', 'xs'),
                'desc' => __('%sSchedule%s will be colored.', 'xs'),
                'std' => 'Event %sSchedule%s',
                'type' => 'text',
                'section' => 'sec_schedule',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'schedule_sub_title',
                'label' => __('Sub Title', 'xs'),
                'desc' => __('', 'xs'),
                'std' => 'Daily Activities',
                'type' => 'text',
                'section' => 'sec_schedule',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
             array('id' => 'schedule_icon',
                'label' => __('Tab Icon', 'xs'),
                'desc' => __('add icon like fa-clock-o. from font awesome icons name', 'xs'),
                'std' => 'fa-clock-o',
                'type' => 'text',
                'section' => 'sec_schedule',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'schedule_desc',
                'label' => __('Short Description', 'xs'),
                'desc' => __('', 'xs'),
                'std' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla hendrerit vitae nulla at ultricies. Suspendisse consequat tempor mi, eu tristique mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dignissim convallis dolor at viverra. Nullam consequat nulla enim, eu vulputate magna varius quis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.',
                'type' => 'textarea',
                'section' => 'sec_schedule',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'titvideo',
                'label' => __('Promotional Video', 'xs'),
                'desc' => __('', 'xs'),
                'std' => '',
                'type' => 'title-only',
                'section' => 'sec_video',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => 'ot-title no-top',
                'condition' => '',
                'operator' => 'and'
            ),
            array(
                'id' => 'show_video',
                'label' => __('Show this tab', 'xs'),
                'desc' => '',
                'std' => 'on',
                'type' => 'on-off',
                'section' => 'sec_video',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'video_title',
                'label' => __('Title', 'xs'),
                'desc' => __('%sVideo%s will be colored.', 'xs'),
                'std' => 'Promotional %sVideo%s',
                'type' => 'text',
                'section' => 'sec_video',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'video_sub_title',
                'label' => __('Sub Title', 'xs'),
                'desc' => __('', 'xs'),
                'std' => 'Watch The Video',
                'type' => 'text',
                'section' => 'sec_video',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'tab_video_icon',
                'label' => __('Tab Icon', 'xs'),
                'desc' => __('add icon like fa-play-circle. from font awesome icons name', 'xs'),
                'std' => 'fa-play-circle',
                'type' => 'text',
                'section' => 'sec_video',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'video_url',
                'label' => __('Video URL <small>( Youtube Embed url)</small>', 'xs'),
                'desc' => __('Use an embeded video url (ex: http://www.youtube.com/embed/0h0lN556Hi0). Or, Leave it url blank to use the text content.', 'xs'),
                'std' => '',
                'type' => 'text',
                'section' => 'sec_video',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'video_textarea',
                'label' => __('Text Content', 'xs'),
                'desc' => __('If you left the above url blank, this content\'ll be used.', 'xs'),
                'std' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla hendrerit vitae nulla at ultricies. Suspendisse consequat tempor mi, eu tristique mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dignissim convallis dolor at viverra. Nullam consequat nulla enim, eu vulputate magna varius quis. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.',
                'type' => 'textarea',
                'section' => 'sec_video',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'titgal',
                'label' => __('Event Gallery', 'xs'),
                'desc' => __('', 'xs'),
                'std' => '',
                'type' => 'title-only',
                'section' => 'sec_gallery',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => 'ot-title no-top',
                'condition' => '',
                'operator' => 'and'
            ),
            array(
                'id' => 'show_gallery',
                'label' => __('Show this tab', 'xs'),
                'desc' => '',
                'std' => 'on',
                'type' => 'on-off',
                'section' => 'sec_gallery',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'gal_title',
                'label' => __('Title', 'xs'),
                'desc' => __('%sGallery%s will be colored.', 'xs'),
                'std' => 'Event %sGallery%s',
                'type' => 'text',
                'section' => 'sec_gallery',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'gal_sub_title',
                'label' => __('Sub Title', 'xs'),
                'desc' => __('', 'xs'),
                'std' => 'Pics From Our Past Events',
                'type' => 'text',
                'section' => 'sec_gallery',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'tab_gal_icon',
                'label' => __('Tab Icon', 'xs'),
                'desc' => __('add icon like fa-picture-o. from font awesome icons name', 'xs'),
                'std' => 'fa-picture-o',
                'type' => 'text',
                'section' => 'sec_gallery',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'gal_desc',
                'label' => __('Short Description', 'xs'),
                'desc' => __('', 'xs'),
                'std' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla hendrerit vitae nulla at ultricies. Suspendisse consequat tempor mi, eu tristique mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dignissim convallis dolor at viverra.',
                'type' => 'textarea',
                'section' => 'sec_gallery',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'gal_gal',
                'label' => __('Image Gallery', 'xs'),
                'desc' => __('', 'xs'),
                'std' => '',
                'type' => 'gallery',
                'section' => 'sec_gallery',
                'rows' => '2',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'titex',
                'label' => __('Executive Presence', 'xs'),
                'desc' => __('', 'xs'),
                'std' => '',
                'type' => 'title-only',
                'section' => 'sec_executive',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => 'ot-title no-top',
                'condition' => '',
                'operator' => 'and'
            ),
            array(
                'id' => 'show_exe',
                'label' => __('Show this tab', 'xs'),
                'desc' => '',
                'std' => 'on',
                'type' => 'on-off',
                'section' => 'sec_executive',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'exe_title',
                'label' => __('Title', 'xs'),
                'desc' => __('%sPresence%s will be colored.', 'xs'),
                'std' => 'Executive %sPresence%s',
                'type' => 'text',
                'section' => 'sec_executive',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'exe_sub_title',
                'label' => __('Sub Title', 'xs'),
                'desc' => __('', 'xs'),
                'std' => 'Invited Personalities',
                'type' => 'text',
                'section' => 'sec_executive',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'tab_exe_icon',
                'label' => __('Tab Icon', 'xs'),
                'desc' => __('add icon like fa-star. from font awesome icons name', 'xs'),
                'std' => 'fa-star',
                'type' => 'text',
                'section' => 'sec_executive',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'exe_desc',
                'label' => __('Short Description', 'xs'),
                'desc' => __('', 'xs'),
                'std' => 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla hendrerit vitae nulla at ultricies. Suspendisse consequat tempor mi, eu tristique mi. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse dignissim convallis dolor at viverra.',
                'type' => 'textarea',
                'section' => 'sec_executive',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and'
            ),
            array('id' => 'exe_executives',
                'label' => __('Executives', 'xs'),
                'desc' => __('', 'xs'),
                'std' => '',
                'type' => 'list-item',
                'section' => 'sec_executive',
                'rows' => '',
                'post_type' => '',
                'taxonomy' => '',
                'min_max_step' => '',
                'class' => '',
                'condition' => '',
                'operator' => 'and',
                'settings' => array(
                    array('id' => 'job',
                        'label' => __('Job Title', 'xs'),
                        'desc' => '',
                        'std' => '',
                        'type' => 'text',
                        'rows' => '',
                        'post_type' => '',
                        'taxonomy' => '',
                        'min_max_step' => '',
                        'class' => '',
                        'condition' => '',
                        'operator' => 'and'
                    )
                )
            )
        )
    );

    /* allow settings to be filtered before saving */
    $custom_settings = apply_filters('tab_options' . '_args', $custom_settings);

    /* settings are not the same update the DB */
    if ($saved_settings !== $custom_settings) {
        update_option('tab_options', $custom_settings);
    }

    /* Lets OptionTree know the UI Builder is being overridden */
    global $ot_has_custom_tab_options;
    $ot_has_custom_tab_options = true;
}
