<?php
/**
 * Customiser Class
 *
 * @package errigal
 * @since 1.1.0
 */

namespace Errigal\Customiser;

defined( 'ABSPATH' ) || exit;

use Errigal\Constant\Errigal_Custom_Section as Section;
use Errigal\Customiser\Errigal_Custom_Breadcrumb as Breadcrumb;

/**
 * This class is in charge of configuring customiser options.
 *
 * @since 1.1.0
 */
class Errigal_Customiser extends Errigal_Customiser_Base {
	/**
	 * Gets sections args.
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 */
	protected function get_sections_args() {
		$sections_args = array(
			self::SECTIONS_TO_ADD    => array(
				Section::APPEARANCE    => array(
					self::SECTION_TITLE    => esc_html__( 'Appearance', 'errigal' ),
					self::SECTION_PRIORITY => Section::PRIORITY_APPEARANCE,
				),
				Section::FONT_SETTINGS => array(
					self::SECTION_PRIORITY => Section::PRIORITY_FONT_SETTINGS,
					self::SECTION_TITLE    => esc_html__( 'Font Settings', 'errigal' ),
				),
				Section::BREADCRUMB    => array(
					self::SECTION_TITLE    => Breadcrumb::get_name(),
					self::SECTION_PRIORITY => Section::PRIORITY_BREADCRUMB,
				),
				Section::POST_SETTINGS => array(
					self::SECTION_TITLE       => esc_html__( 'Post Settings', 'errigal' ),
					self::SECTION_DESCRIPTION => esc_html__( 'Go to any of your posts to preview the options below.', 'errigal' ),
					self::SECTION_PRIORITY    => Section::PRIORITY_POST_SETTINGS,
				),
				Section::FOOTER        => array(
					self::SECTION_TITLE => esc_html__( 'Footer', 'errigal' ),
				),
			),
			self::SECTIONS_TO_UPDATE => array(
				Section::WP_HOMEPAGE_SETTINGS => array(
					self::SECTION_PRIORITY => Section::PRIORITY_HOMEPAGE_SETTINGS,
				),
			),
			self::SECTIONS_TO_REMOVE => array(
				Section::WP_BACKGROUND_IMAGE,
			),
		);

		if ( is_child_theme() ) {
			return $sections_args;
		}

		$sections_args[ self::SECTIONS_TO_ADD ] = array_merge(
			array(
				Section::PRO_FEATURES => array(
					self::SECTION_PRIORITY => Section::PRIORITY_PRO_FEATURES,
					self::SECTION_TITLE    => esc_html__( 'Discover errigal PRO', 'errigal' ),
				),
			),
			$sections_args[ self::SECTIONS_TO_ADD ],
		);

		return $sections_args;
	}

	/**
	 * Gets options.
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 */
	protected function get_options() {
		$options = array(
			Section::NO_CHANGE     => array(
				new Errigal_Custom_Site_Identity_Option(),
			),
			Section::APPEARANCE    => array(
				new Errigal_Custom_Colour_Scheme_Option(),
				new Errigal_Custom_Background_Colour_Option(),
				new Errigal_Custom_Site_Header_Colour_Option(),
				new Errigal_Custom_Heading_Style_Option(),
			),
			Section::FONT_SETTINGS => array(
				new Errigal_Custom_Typography_Option(),
			),
			Section::BREADCRUMB    => array(
				new Errigal_Custom_Breadcrumb_Option(),
			),
			Section::POST_SETTINGS => array(
				new Errigal_Custom_Post_Author_Option(),
			),
			Section::FOOTER        => array(
				new Errigal_Custom_Footer_Option(),
			),
		);

		if ( is_child_theme() ) {
			return $options;
		}

		return array_merge(
			array(
				Section::PRO_FEATURES => array(
					new Errigal_Custom_Pro_Features_Option(),
				),
			),
			$options
		);
	}
}
