<?php

/**
 * Control for post
 *
 * @since 1.0.0
 */

namespace Kubelio\Customizer;

if (! defined('ABSPATH')) {
	exit;
}

class Post {

	use Helper;
	public function __construct() {
		add_action('after_setup_theme', array($this, 'register_fields'));
	}

	/**
	 * Register Post related customizer fields
	 */
	public function register_fields() {
		$this->set_section();

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

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

	public function set_section() {

		$this->add_section(
			'post',
			array(
				'title'    => esc_html__('Post', 'kubelio'),
				'priority' => 80,
			)
		);
	}

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

		$this->add_field([
			'type'    => 'headline',
			'label'   => esc_html__('Post Loops', 'kubelio'),
			'settings' => 'headline_' . uniqid(),
			'section' => $section,
		]);

		$this->add_field(
			array(
				'type'     => 'toggle',
				'settings' => 'post_category',
				'label'    => esc_html__('Categories', 'kubelio'),
				'default'  => true,
				'section'  => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'toggle',
				'settings' => 'post_content',
				'label'    => esc_html__('Excerpt', 'kubelio'),
				'default'  => true,
				'section'  => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'divider',
				'settings' => 'divider_' . uniqid(),
				'section' => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'multicheck',
				'settings' => 'post_meta',
				'label'    => esc_html__('Post Meta', 'kubelio'),
				'section'  => $section,
				'default'  => array(
					'meta-date',
					'meta-comment',
				),
				'multiple' => 999,
				'choices'  => array(
					'meta-author'  => esc_html__('Author', 'kubelio'),
					'meta-date'    => esc_html__('Date', 'kubelio'),
					'meta-comment' => esc_html__('Comment', 'kubelio'),
				),
			)
		);
	}

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

		$this->add_field([
			'type'    => 'headline',
			'label'   => esc_html__('Single Post', 'kubelio'),
			'settings' => 'headline_' . uniqid(),
			'section' => $section,
		]);

		$this->add_field(
			array(
				'type'     => 'toggle',
				'settings' => 'single_category',
				'label'    => esc_html__('Categories', 'kubelio'),
				'default'  => true,
				'section'  => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'toggle',
				'settings' => 'single_thumbnail',
				'label'    => esc_html__('Featured Image', 'kubelio'),
				'default'  => true,
				'section'  => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'toggle',
				'settings' => 'single_sharebox',
				'label'    => esc_html__('Social Share Box', 'kubelio'),
				'default'  => true,
				'section'  => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'toggle',
				'settings' => 'single_tag',
				'label'    => esc_html__('Tags', 'kubelio'),
				'default'  => true,
				'section'  => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'toggle',
				'settings' => 'single_authorbox',
				'label'    => esc_html__('Author Info Box', 'kubelio'),
				'default'  => true,
				'section'  => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'toggle',
				'settings' => 'single_comment',
				'label'    => esc_html__('Comments', 'kubelio'),
				'default'  => true,
				'section'  => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'divider',
				'settings' => 'divider_' . uniqid(),
				'section' => $section,
			)
		);

		$this->add_field(
			array(
				'type'     => 'multicheck',
				'settings' => 'single_meta',
				'label'    => esc_html__('Post Meta', 'kubelio'),
				'section'  => $section,
				'default'  => array(
					'meta-date',
					'meta-comment',
				),
				'multiple' => 999,
				'choices'  => array(
					'meta-author'  => esc_html__('Author', 'kubelio'),
					'meta-date'    => esc_html__('Date', 'kubelio'),
					'meta-comment' => esc_html__('Comment', 'kubelio'),
				),
			)
		);
	}

	// end class
}
