<?php

/**
 * Initialize the custom Meta Boxes. 
 */
add_action('admin_init', 'xs_page_meta_boxes');

/**
 * Meta Boxes demo code.
 *
 * You can find all the available option types in theme-options.php.
 *
 * @return    void
 * @since     2.3.0
 */
function xs_page_meta_boxes() {

    /**
     * Create a custom meta boxes array that we pass to 
     * the OptionTree Meta Box API Class.
     */
    $page_meta_box = array(
        'id' => 'xs_meta_box',
        'title' => __('Page Options', 'option-tree-theme'),
        'desc' => '',
        'pages' => array('page'),
        'context' => 'normal',
        'priority' => 'high',
        'fields' => array(
            array(
                'label' => __('Section', 'option-tree-theme'),
                'id' => 'xs_page_section',
                'type' => 'on-off',
                'desc' => sprintf(__('If it\'s a "Section", please set this field to %s. And if it\'s "page", set it to %s', 'option-tree-theme'), '<code>on</code>', '<code>off</code>'),
                'std' => 'off'
            ),
            array(
                'label' => __('Show Title', 'option-tree-theme'),
                'id' => 'xs_page_show_title',
                'type' => 'on-off',
                'desc' => sprintf(__('Shows the "Title" when set to %s.', 'option-tree-theme'), '<code>on</code>'),
                'std' => 'on'
            ),
            array(
                'label' => __('Show Comment', 'option-tree-theme'),
                'id' => 'xs_post_show_comment',
                'type' => 'on-off',
                'desc' => sprintf(__('Shows the "Comment Box" when set to %s.', 'option-tree-theme'), '<code>on</code>'),
                'condition' => 'xs_page_section:not(on)',
                'std' => 'off'
            ),
//            array(
//                'label' => __('Sidebar', 'option-tree-theme'),
//                'id' => 'xs_post_sidebar',
//                'type' => 'sidebar-select',
//                'desc' => 'Please select sidebar. You can select no-sidebar to hide sidebar for this post.',
//                'condition' => 'xs_page_section:not(on)',
//                'std' => 'default-sidebar'
//            ),
            array(
                'label' => __('Colored Header Background', 'option-tree-theme'),
                'id' => 'xs_section_headerBG',
                'type' => 'on-off',
                'desc' => 'Section header background color style. Please turn it on, if you want colored background.',
                'condition' => 'xs_page_section:is(on)',
                'std' => 'off'
            ),
            array(
                'label' => __('Assign Curent page as', 'xs'),
                'id' => 'sections_pages',
                'type' => 'select',
                'desc' => 'Only Recent blog and speaker will be transparent. others page will be default.',
                'condition' => '',
                'operator' => 'and',
                'choices' => array(
                    array(
                        'value' => 'default',
                        'label' => __('Default Section', 'xs'),
                        'src' => ''
                    ),
                    array(
                        'value' => 'transparent',
                        'label' => __('Transparent BG', 'xs'),
                        'src' => ''
                    )
                )
            ),
            array(
                'label' => __('Section Title', 'option-tree-theme'),
                'id' => 'xs_section_title',
                'type' => 'text',
                'desc' => 'Section title. It\'s optional, if you leave blank the default title will be used.',
                'condition' => 'xs_page_section:is(on)',
                'std' => ''
            ),
            array(
                'label' => __('Sub Title Text', 'option-tree-theme'),
                'id' => 'xs_page_sub_title',
                'type' => 'text',
                'desc' => 'Section sub-title. It\'s optional, so you can leave it blank if you want.',
                'condition' => 'xs_page_section:is(on)',
                'std' => ''
            ),
            array(
                'label' => __('Short Description', 'option-tree-theme'),
                'id' => 'xs_section_desc',
                'type' => 'textarea',
                'editor_class' => 'poooop',
                'desc' => '',
                'condition' => 'xs_page_section:is(on)',
                'std' => ''
            ),
            array(
                'label' => __('SEO Keywords', 'option-tree-theme'),
                'id' => 'xs_post_seo_keywords',
                'type' => 'textarea',
                'rows' => '3',
                'condition' => 'xs_page_section:not(on)',
                'desc' => __('Custom meta keywords for this spesific post', 'option-tree-theme')
            ),
            array(
                'label' => __('SEO Description', 'option-tree-theme'),
                'id' => 'xs_post_seo_desc',
                'type' => 'textarea',
                'rows' => '3',
                'condition' => 'xs_page_section:not(on)',
                'desc' => __('Custom meta description for this spesific post', 'option-tree-theme')
            )
        )
    );

    /**
     * Register our meta boxes using the 
     * ot_register_meta_box() function.
     */
    if (function_exists('ot_register_meta_box')) {
        ot_register_meta_box($page_meta_box);
    }
}
