<?php
/**
 * Custom Breadcrumb Option Class
 *
 * @package errigal
 * @since 1.2.0
 */

namespace Errigal\Customiser;

defined( 'ABSPATH' ) || exit;

use Errigal\Constant\Errigal_Navigation_Class as Navigation_Class;
use Errigal\Customiser\Errigal_Custom_Breadcrumb as Breadcrumb;
use Errigal\Shared\Errigal_Utility as Utility;

/**
 * This class is in charge of breadcrumb customisation via customiser.
 *
 * @since 1.2.0
 */
class Errigal_Custom_Breadcrumb_Option extends Errigal_Custom_Option_Base {
	/**
	 * Gets controls args.
	 *
	 * @since 1.2.0
	 *
	 * @return array
	 */
	public function get_controls_args() {
		return array(
			self::CONTROLS_TO_ADD => array(
				Breadcrumb::ID_LABEL_BREADCRUMB => array(
					self::CUSTOMISE_ARGS_CONTROL => array(
						self::CONTROL_LABEL => Breadcrumb::get_name(),
						self::CONTROL_TYPE  => self::CONTROL_TYPE_LABEL,
					),
				),
				Breadcrumb::ID_BREADCRUMB       => array(
					self::CUSTOMISE_ARGS_SETTING => array(
						self::SETTING_DEFAULT   => Breadcrumb::DEFAULT_BREADCRUMB,
						self::SETTING_TRANSPORT => self::SETTING_TRANSPORT_POST_MESSAGE,
					),
					self::CUSTOMISE_ARGS_CONTROL => array(
						self::CONTROL_LABEL => esc_html__( 'Show breadcrumbs', 'errigal' ),
						self::CONTROL_TYPE  => self::CONTROL_TYPE_CHECKBOX,
					),
					self::CUSTOMISE_ARGS_PARTIAL => array(
						self::PARTIAL_SELECTOR            => Utility::get_selector( Navigation_Class::BREADCRUMB ),
						/**
						 * Renders breadcrumb.
						 *
						 * @since 1.2.0
						 *
						 * @return void
						 */
						self::PARTIAL_RENDER_CALLBACK     => function () {
							get_template_part( 'template-parts/component/navigation/breadcrumb' );
						},
						self::PARTIAL_CONTAINER_INCLUSIVE => true,
						self::PARTIAL_FALLBACK_REFRESH    => false,
					),
				),
			),
		);
	}
}
