| Server IP : 103.48.194.25 / Your IP : 216.73.217.33 Web Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.33 System : Linux VMHostDefault 3.10.0-1160.42.2.el7.x86_64 #1 SMP Tue Sep 7 14:49:57 UTC 2021 x86_64 User : sieuthimay ( 1016) PHP Version : 8.2.20 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/sieuthimayasia.com/public_html/wp-content/themes/mtw-maycn/inc/ |
Upload File : |
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* MTWTeam Autoloader.
*
* @class MTW_Autoloader
* @author NamMTW
* @package MTWTeam/Classes
* @category Class
* @version 1.0.0
*/
class MTW_Autoloader {
/**
* Path to the includes directory.
*
* @var string
*/
private $include_path = '';
/**
* The Constructor.
*/
public function __construct() {
if ( function_exists( "__autoload" ) ) {
spl_autoload_register( "__autoload" );
}
spl_autoload_register( array( $this, 'autoload' ) );
$this->include_path = get_template_directory() . '/inc/widgets/';
}
/**
* Take a class name and turn it into a file name.
*
* @param string $class
* @return string
*/
private function get_file_name_from_class( $class ) {
return 'class-' . str_replace( '_', '-', $class ) . '.php';
}
/**
* Include a class file.
*
* @param string $path
* @return bool successful or not
*/
private function load_file( $path ) {
if ( $path && is_readable( $path ) ) {
include_once( $path );
return true;
}
return false;
}
/**
* Auto-load MTW classes on demand to reduce memory consumption.
*
* @param string $class
*/
public function autoload( $class ) {
$class = strtolower( $class );
$file = $this->get_file_name_from_class( $class );
$this->load_file( $this->include_path . $file );
}
}
new MTW_Autoloader();