<?php
/**
 * The Button Settings Section — now a redirect to Site Editor.
 *
 * @package Brandy\Customizer
 * @since   1.0.0
 */

namespace Brandy\Customizer\Panels\General;

use Brandy\Abstracts\AbstractCustomizerModuleLoader;
use Brandy\Traits\SingletonTrait;

class ButtonSettingsSection extends AbstractCustomizerModuleLoader {

	use SingletonTrait;

	public const SECTION_ID = 'button_settings';

	protected function __construct() {
		add_filter(
			'brandy_general_sections',
			function( $sections ) {
				return array_merge(
					$sections,
					array_filter(
						self::get_configurations(),
						function( $item ) {
							return 'section' === $item['configuration_type'];
						}
					)
				);
			}
		);
		parent::__construct();
	}

	/**
	 * @override
	 */
	public static function get_configurations() {
		$configurations[] = array(
			'configuration_type' => 'section',
			'id'                 => self::SECTION_ID,
			'title'              => __( 'Global Button Settings', 'brandy' ),
			'panel'              => GeneralPanel::PANEL_ID,
			'type'               => 'brandy-section',
			'description_hidden' => true,
		);
		$configurations[] = array(
			'configuration_type' => 'control',
			'id'                 => self::SECTION_ID,
			'label'              => __( 'Global Button Settings', 'brandy' ),
			'section'            => self::SECTION_ID,
			'type'               => 'brandy_settings',
			'input_attrs'        => array(
				'value' => '',
				'style' => 'display:none;',
			),
			'partial'            => false,
			'default'            => self::default_settings(),
			'transport'          => 'postMessage',
		);

		return $configurations;
	}

	public static function default_settings() {
		return array(
			'type'           => 'default',
			'color'          => 'var(--wp--preset--color--brandy-foreground)',
			'hoverColor'     => 'var(--wp--preset--color--brandy-foreground)',
			'textColor'      => 'var(--wp--preset--color--white)',
			'textHoverColor' => 'var(--wp--preset--color--white)',
		);
	}
}
