Files
Hi-School-Slide-Manager/includes/class-hssm-autoloader.php
T

53 lines
1.2 KiB
PHP

<?php
/**
* HSSM Autoloader Class
*
* Autoloader for the Hi-School Slide Manager plugin classes
*
* @package Hi_School_Slide_Manager
* @since 1.0.0
*/
// Prevent direct access
if ( ! defined( 'ABSPATH' ) ) {
exit( 'Direct access forbidden.' );
}
/**
* HSSM Autoloader Class
*
* Handles automatic loading of plugin classes
*/
class HSSM_Autoloader {
/**
* Initialize the autoloader
*
* @since 1.0.0
*/
public static function init() {
spl_autoload_register( array( __CLASS__, 'autoload' ) );
}
/**
* Autoload classes
*
* @since 1.0.0
* @param string $class_name The class name to load
*/
public static function autoload( $class_name ) {
// Only autoload classes that start with HSSM_
if ( strpos( $class_name, 'HSSM_' ) !== 0 ) {
return;
}
// Convert class name to file path
$file_name = str_replace( '_', '-', strtolower( $class_name ) ) . '.php';
$file_path = HSSM_PLUGIN_DIR . 'includes/class-' . $file_name;
// Include the file if it exists
if ( file_exists( $file_path ) ) {
require_once $file_path;
}
}
}