<?php
/**
 * Menus.
 *
 * @package MadeByAura\Prime\Hooks
 * @author  MadeByAura.com
 */

namespace MadeByAura\Prime\Hooks;

use MadeByAura\Prime\Base;
use MadeByAura\Prime\Helpers\SingletonTrait;

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

/**
 * Menus.
 */
class Menus {
	use SingletonTrait;

	/**
	 * Constructor.
	 */
	protected function __construct() {
		// Add JavaScript object for the nav accordion.
		add_filter( 'aura_theme_app_js_object', [ __CLASS__, 'add_menu_widget_js_object' ] );
		// Add mobile nav modal.
		add_action( 'wp_footer', [ __CLASS__, 'add_mobile_nav_modal' ] );
	}

	/**
	 * Add JavaScript object for the nav accordion.
	 *
	 * @param array $obj  JavaScript object.
	 * @return array $obj
	 */
	public static function add_menu_widget_js_object( $obj ) {
		$obj['navAccordion'] = [
			'openText'  => esc_js( __( 'Open sub menu', 'aura-prime' ) ),
			'closeText' => esc_js( __( 'Close sub menu', 'aura-prime' ) ),
		];

		return $obj;
	}

	/**
	 * Add mobile nav modal.
	 */
	public static function add_mobile_nav_modal() {
		Base::view(
			'views/modal',
			[
				'id'     => 'menu',
				'type'   => false,
				'header' => false,
			],
		);
	}
}
