<?php
namespace SmartSlotAppointmentScheduler;
use SmartSlotAppointmentScheduler\Schedule_Settings;
use SmartSlotAppointmentScheduler\Schedule_Posttype;

if (! defined('ABSPATH')) {
	exit;
}

if (!class_exists('\SmartSlotAppointmentScheduler\Register_Submenu')) {
	/**
	 * Class to register the Submenu page under custom posttype.
	 */
	class Register_Submenu {

		public static function init() {
			add_action('admin_menu', [self::class, 'register_custom_admin_page']);
		}

		/**
		 * submenu page for Settings.
		 */
		public static function register_custom_admin_page() {
			add_submenu_page(
				'edit.php?post_type=' . Schedule_Posttype::SLUG,
				'Settings',
				'Settings',
				'manage_options',
				'schedule-settings',
				[__CLASS__, 'settings_html'],
			);
		}

		/**
		 * Load settings page content
		 * @return void
		 */
		public static function settings_html() {
			Schedule_Settings::settings_page();
		}
	}

		add_action('init', ['\\SmartSlotAppointmentScheduler\\Register_Submenu', 'init'], 11);
}
