<?php 

// This is GLOB for front end Style and Js
function wpsection_enqueue_assets() {   
  $plugin_path = WPSECTION_PLUGIN_PATH ;
  // Enqueue all CSS files in the assets/css directory
  foreach ( glob( $plugin_path . 'assets/css/*.css' ) as $css_file ) {
    wp_enqueue_style( basename( $css_file, '.css' ), WPSECTION_PLUGIN_URL . 'assets/css/' . basename( $css_file ), array(), WPSECTION_VERSION );
  }
  // Enqueue all JavaScript files in the assets/js directory
  foreach ( glob( $plugin_path . 'assets/js/*.js' ) as $js_file ) {
    wp_enqueue_script( basename( $js_file, '.js' ), WPSECTION_PLUGIN_URL . 'assets/js/' . basename( $js_file ), array( 'jquery' ), WPSECTION_VERSION, false );
  }
}
add_action( 'wp_enqueue_scripts', 'wpsection_enqueue_assets' );


// This is GLOB for Admin Style and Js
function wpsection_enqueue_admin_assets() {
  $plugin_path = WPSECTION_PLUGIN_PATH;
  // Enqueue all CSS files in the assets/css/admin directory
  foreach ( glob( $plugin_path . 'assets/admin/css/*.css' ) as $css_file ) {
    wp_enqueue_style( basename( $css_file, '.css' ), WPSECTION_PLUGIN_URL . 'assets/admin/css/' . basename( $css_file ), array(), filemtime( $css_file ) );
  }
  // Enqueue all JavaScript files in the assets/js/admin directory
  foreach ( glob( $plugin_path . 'assets/admin/js/*.js' ) as $js_file ) {
    wp_enqueue_script( basename( $js_file, '.js' ), WPSECTION_PLUGIN_URL . 'assets/admin/js/' . basename( $js_file ), array( 'jquery' ), filemtime( $js_file ), false );
  }
}
add_action( 'admin_enqueue_scripts', 'wpsection_enqueue_admin_assets' );


// This code is for the Elemntor Dashboard CSS and Js
add_action(
	'elementor/editor/before_enqueue_styles',
	function () {
		wp_enqueue_style('wpsection-elemntor', WPSECTION_PLUGIN_URL . 'assets/css/elemntor.css', true);
	    wp_enqueue_script( 'wpsection-script', WPSECTION_PLUGIN_URL . 'assets/js/elemntor.js', array( 'jquery' ), '1.0.0', true );
}			
);



