<?php
/**
 * Add.
 *
 * @package MadeByAura\Prime\Customizer\Modules
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Customizer\Modules;

defined( 'ABSPATH' ) || die();

/**
 * Add.
 */
class Add {
	/**
	 * Add panel.
	 *
	 * @param string $id    Panel ID.
	 * @param array  $args  Arguments.
	 * @return void
	 */
	public static function panel( $id, $args = [] ) {
		$id   = 'aura_panel_' . $id;
		$args = apply_filters( "aura_theme_kirki_panel_{$id}", $args );

		\Kirki::add_panel( $id, $args );
	}

	/**
	 * Add section.
	 *
	 * @param string $id    Section ID.
	 * @param array  $args  Arguments.
	 * @return void
	 */
	public static function section( $id, $args = [] ) {
		$id   = 'aura_section_' . $id;
		$args = apply_filters( "aura_theme_kirki_section_{$id}", $args );

		\Kirki::add_section( $id, $args );
	}

	/**
	 * Add field.
	 *
	 * @param string $section   Section ID.
	 * @param string $id        Field ID.
	 * @param int    $priority  Priority.
	 * @param array  $args      Arguments.
	 * @return int $priority
	 */
	public static function field( $section, $id, $priority, $args = [] ) {
		$id = "{$section}_{$id}";

		$args = array_replace_recursive(
			[
				'settings' => 'aura_' . $id,
				'section'  => 'aura_section_' . $section,
				'priority' => absint( $priority ),
			],
			$args,
		);

		$args = apply_filters( "aura_theme_kirki_field_{$id}", $args );

		\Kirki::add_field( 'aura_theme_config', $args );

		return absint( $priority ) + 10;
	}
}
