<?php
/**
 * Custom Colour Scheme Option Class
 *
 * @package errigal
 * @since 1.1.0
 */

namespace Errigal\Customiser;

defined( 'ABSPATH' ) || exit;

use Errigal\Constant\Errigal_Custom_Colour_Scheme_Hook as Colour_Scheme_Hook;
use Errigal\Customiser\Errigal_Custom_Colour_Scheme as Colour_Scheme;
use Errigal\Shared\{
	Errigal_Utility as Utility,
	Errigal_Validator as Validator,
};

/**
 * This class is in charge of colour scheme customisation via customiser.
 *
 * @since 1.1.0
 */
class Errigal_Custom_Colour_Scheme_Option extends Errigal_Custom_Option_Base {
	/**
	 * Gets controls args.
	 *
	 * @since 1.1.0
	 *
	 * @return array
	 */
	public function get_controls_args() {
		return array(
			self::CONTROLS_TO_ADD => array(
				Colour_Scheme::ID_COLOUR_SCHEME => array(
					self::CUSTOMISE_ARGS_SETTING => array(
						self::SETTING_DEFAULT   => Colour_Scheme::DEFAULT_COLOUR_SCHEME,
						self::SETTING_TRANSPORT => self::SETTING_TRANSPORT_POST_MESSAGE,
					),
					self::CUSTOMISE_ARGS_CONTROL => array(
						self::CONTROL_PRIORITY => self::CONTROL_PRIORITY_APPEARANCE_COLOUR_SCHEME,
						self::CONTROL_LABEL    => esc_html__( 'Website Colour Scheme', 'errigal' ),
						self::CONTROL_CHOICES  => $this->get_colour_schemes(),
						self::CONTROL_TYPE     => self::CONTROL_TYPE_SELECT,
					),
				),
			),
		);
	}

	/**
	 * Gets colour schemes.
	 *
	 * @since 1.0.0
	 *
	 * @return array
	 */
	private function get_colour_schemes() {
		/**
		 * Filters colour schemes.
		 *
		 * @since 1.1.0
		 *
		 * @param array $colour_schemes Associative array of colour schemes.
		 */
		$colour_schemes = apply_filters(
			Colour_Scheme_Hook::COLOUR_SCHEMES,
			array(
				Colour_Scheme::COLOUR_SCHEME_SKY_BLUE => esc_html__( 'Sky blue', 'errigal' ),
				Colour_Scheme::COLOUR_SCHEME_MONO     => esc_html__( 'Mono', 'errigal' ),
			),
		);

		return Utility::sanitise_associative_array( $colour_schemes );
	}
}
