<?php

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

if ( ! class_exists( 'Price_Cart_Hider_Admin_Assets' ) ) {
	
	/**
	 * Price_Cart_Hider_Admin_Assets
	 */
	class Price_Cart_Hider_Admin_Assets {
		
		/**
		 * Method __construct
		 *
		 * @return void
		 */
		public function __construct() {
			add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles' ), 99 );
			add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ), 99 );
		}
		
		/**
		 * Method admin_styles
		 *
		 * @return void
		 */
		public function admin_styles() {

			$screen    = get_current_screen();
			$screen_id = $screen ? $screen->id : '';
			wp_register_style( 'pchfw_admin_styles', PCHFW_URL . '/assets/admin/css/pchfw-admin.css', array(), PCHFW_VERSION );
			if ( in_array( $screen_id, array( 'pchfw' ) ) ) {
				wp_enqueue_style( 'pchfw_admin_styles' );
			}
		}
		
		public function admin_scripts() {
			global $post;

			$screen   = get_current_screen();
			$screen_id    = $screen ? $screen->id : '';
			$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '';

			wp_register_script( 'pchfw_admin_script', PCHFW_URL . '/assets/admin/js/pchfw-admin' . $suffix . '.js', array( 'jquery' ), PCHFW_VERSION, true );

			if ( in_array( $screen_id, array( 'pchfw' ) ) ) {
				wp_enqueue_script( 'pchfw_admin_script' );
				wp_enqueue_script( 'wc-enhanced-select' );
			}
		}
	}
	new Price_Cart_Hider_Admin_Assets();
}
