<?php

/**
 * @author : Webforia Studio
 */

namespace Retheme\Customizer;

use Retheme\Customizer_Base;

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

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

        // single section
        $this->add_single_trip_options();
        $this->add_single_trip_related();
    }

    public function set_section() {

        $this->add_section('trip', [
            'title' => __('Trip', 'jelajah-text'),
            'priority' => 90,
        ]);
    }

    public function add_trip_options() {
        $section = 'trip';

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

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'trip_archive_filter',
            'label' => __('Trip Filter', 'jelajah-text'),
            'section' => $section,
            'default' => 1,
        ]);

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

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

        $this->add_field([
            'type' => 'toggle',
            'settings' => 'post_element_readmore',
            'label' => __('Read More', 'jelajah-text'),
            'default' => true,
            'section' => $section,
        ]);
    }

    public function add_single_trip_options() {
        $section = 'trip';

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

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

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

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

    }

    public function add_single_trip_related() {

        $section = 'trip';

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

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

        $this->add_field([
            'type' => 'number',
            'settings' => 'single_trip_related_count',
            'label' => __('Related Count', 'jelajah-text'),
            'section' => $section,
            'default' => 6,
            'active_callback' => [
                [
                    'setting' => 'single_trip_related',
                    'operator' => '===',
                    'value' => true,
                ],
            ],
        ]);
    }
    // end class
}

new Trip;
