<?php
/**
 * Setup menus in WP admin.
 *
 * @package HBFWC\Admin;
 * @version 1.0.0
 */

namespace HBFWC\Admin;

defined( 'ABSPATH' ) || exit;

if ( class_exists( 'HBFWC\Admin\Admin_Menus', false ) ) {
	return new Admin_Menus();
}

/**
 * HBFWC\Admin\Admin_Menus Class.
 */
class Admin_Menus {
	/**
	 * Hook in tabs.
	 */
	public function __construct() {
		add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 );
	}

	/**
	 * Add menu items.
	 */
	public function admin_menu() {
		add_submenu_page( 'edit.php?post_type=product', __( 'Amenities', 'hotel-booking-for-woocommerce' ), __( 'Amenities', 'hotel-booking-for-woocommerce' ), 'manage_product_terms', 'amenities', array( $this, 'amenities_page' ) ); // phpcs:ignore WordPress.WP.Capabilities.Unknown
		add_submenu_page( 'edit.php?post_type=product', __( 'Rate Plans', 'hotel-booking-for-woocommerce' ), __( 'Rate Plans', 'hotel-booking-for-woocommerce' ), 'manage_product_terms', 'rate_plans', array( $this, 'rate_plans_page' ) ); // phpcs:ignore WordPress.WP.Capabilities.Unknown
		add_submenu_page( 'edit.php?post_type=product', __( 'Availability & Prices', 'hotel-booking-for-woocommerce' ), __( 'Availability & Prices', 'hotel-booking-for-woocommerce' ), 'manage_product_terms', 'availability', array( $this, 'avail_page' ) ); // phpcs:ignore WordPress.WP.Capabilities.Unknown

		do_action( 'hbfwc_add_admin_menus' );
	}

	/**
	 * Rate plans page.
	 */
	public function rate_plans_page() {
		Admin_Rate_Plans::output();
	}

	/**
	 * Amenities page.
	 */
	public function amenities_page() {
		Admin_Amenities::output();
	}

	/**
	 * Availability page.
	 */
	public function avail_page() {
		if ( hbfwc_is_pro() ) {
			\HBFWC\Pro\Admin\Admin_Availability::output();
		} else {
			Admin_Availability::output();
		}
	}
}

return new Admin_Menus();
