<?php

// require_once( dirname( __DIR__ ) . '/class-react-app.php' );

class DragBlock_Local_Fonts
{
	public static function local_fonts_admin_page()
	{
		// JS dependencies needed to read the file data from .woff and .woff2 files. (no needed for .ttf files)
		// wp_enqueue_script( 'inflate', plugin_dir_url( dirname( __FILE__ ) ) . 'js/lib/inflate.js', array(), '', false );
		// wp_enqueue_script( 'unbrotli', plugin_dir_url( dirname( __FILE__ ) ) . 'js/lib/unbrotli.js', array(), '', false );

		wp_enqueue_script('inflate', DRAGBLOCK_BUILD_URL . 'applications/font-library/client/font-readers/index.js', array(), DRAGBLOCK_VERSION, false);

		DragBlock_React_App::bootstrap();

		$app_nonce = esc_attr(wp_create_nonce('dragblock_font_library'));
		$app_html = "<input id=\"nonce\" type=\"hidden\" value=\"{$app_nonce}\" />";
		$app_html .= '<div id="dragblock-font-library-app"></div>';
		// Define an array of allowed HTML tags and attributes
		$allowed_html = array(
			'p' => array(
				'name' => true,
				'id' => true,
				'class' => true,
			),
			'div' => array(
				'id' => true,
			),
			'input' => array(
				'type' => true,
				'name' => true,
				'id' => true,
				'value' => true,
			),
		);
		echo wp_kses($app_html, $allowed_html);
		/*
		?>
				<input id="nonce" type="hidden" value="<?php echo esc_attr(wp_create_nonce('dragblock_font_library')); ?>" />
				<div id="dragblock-font-library-app"></div>

		<?php
		*/
	}
}
