<?php
/**
 * Student dashboard front-end assets.
 *
 * @package TutorHelper_Bookings
 */

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

/**
 * Registers student dashboard assets.
 */
final class TutorHelper_Student_Dashboard_Frontend {

	/**
	 * Stylesheet handle.
	 *
	 * @var string
	 */
	const STYLE_HANDLE =
		'tutorhelper-student-dashboard';

	/**
	 * Register hooks.
	 *
	 * @return void
	 */
	public static function init() {
		add_action(
			'wp_enqueue_scripts',
			array(
				__CLASS__,
				'register_assets',
			)
		);
	}

	/**
	 * Register dashboard assets.
	 *
	 * @return void
	 */
	public static function register_assets() {
		$css_path =
			TUTORHELPER_BOOKINGS_PATH
			. 'assets/css/student-dashboard.css';

		wp_register_style(
			self::STYLE_HANDLE,
			TUTORHELPER_BOOKINGS_URL
				. 'assets/css/student-dashboard.css',
			array(),
			file_exists( $css_path )
				? (string) filemtime(
					$css_path
				)
				: TUTORHELPER_BOOKINGS_VERSION
		);
	}

	/**
	 * Enqueue dashboard assets.
	 *
	 * @return void
	 */
	public static function enqueue_assets() {
		if (
			! wp_style_is(
				self::STYLE_HANDLE,
				'registered'
			)
		) {
			self::register_assets();
		}

		wp_enqueue_style(
			self::STYLE_HANDLE
		);
	}
}
