<?php

/**
 * @author : Webforia Studio
 */

namespace Retheme\Customizer;

use Retheme\Customizer_Base;

class Post extends Customizer_Base {
    public function __construct() {
        $this->set_section();

        // archive section
        $this->add_post_options();

        // single section
        $this->add_single_options();
        $this->add_single_related();
    }

    public function set_section() {

        $this->add_section('post', [
            'title' => __('Post', 'jelajah-text'),
            'priority' => 80,
        ]);
    }

    public function add_post_options() {
        $section = 'post';

        $this->add_header([
            'label' => __('Post Loops', 'jelajah-text'),
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'post_element_category',
            'label' => __('Post Categories', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'post_element_thumbnail',
            'label' => __('Featured Image', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'post_element_content',
            'label' => __('Post Excerpt', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_divinder([
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'multicheck',
            'settings' => 'post_meta',
            'label' => __('Post Meta', 'jelajah-text'),
            'section' => $section,
            'default' => [
                'meta-date',
                'meta-view'
            ],
            'multiple' => 999,
            'choices' => [
                'meta-author' => __('Author', 'jelajah-text'),
                'meta-date' => __('Date', 'jelajah-text'),
                'meta-view' => __('View', 'jelajah-text'),
                'meta-comment' => __('Comment', 'jelajah-text'),
            ],
        ]);
    }

    public function add_single_options() {
        $section = 'post';

        $this->add_header([
            'label' => __('Post Single', 'jelajah-text'),
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'single_element_category',
            'label' => __('Post Categories', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'single_element_thumbnail',
            'label' => __('Featured Image', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'single_element_sharebox',
            'label' => __('Share Box', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'single_element_tag',
            'label' => __('Post Tags', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'single_element_authorbox',
            'label' => __('Author Box', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'single_element_comment',
            'label' => __('Comments', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);

        $this->add_divinder([
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'multicheck',
            'settings' => 'single_meta',
            'label' => __('Post Meta', 'jelajah-text'),
            'section' => $section,
            'default' => [
                'meta-date',
                'meta-view',
                'meta-comment',
            ],
            'multiple' => 999,
            'choices' => [
                'meta-author' => __('Author', 'jelajah-text'),
                'meta-date' => __('Date', 'jelajah-text'),
                'meta-comment' => __('Comment', 'jelajah-text'),
            ],
        ]);
    }

    public function add_single_related() {

        $section = 'post';

        $this->add_divinder([
            'section' => $section,
        ]);

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'single_related',
            'label' => __('Posts Related', 'jelajah-text'),
            'section' => $section,
            'default' => 1,
        ]);

        $this->add_field([
            'type' => 'number',
            'settings' => 'single_related_count',
            'label' => __('Posts Related Count', 'jelajah-text'),
            'section' => $section,
            'default' => 6,
            'active_callback' => [
                [
                    'setting' => 'single_related',
                    'operator' => '===',
                    'value' => true,
                ],
            ],
        ]);
    }

    // end class
}

new Post;
