Add support to known class paths for conditional loading.

This commit is contained in:
Vedanshu Jain 2024-09-11 13:39:31 +05:30
parent 05930e4275
commit c41293e1ef
1 changed files with 9 additions and 0 deletions

View File

@ -20,6 +20,10 @@ class WC_Autoloader {
*/
private $include_path = '';
private static array $known_classes_paths = array(
);
/**
* The Constructor.
*/
@ -65,6 +69,11 @@ class WC_Autoloader {
public function autoload( $class ) {
$class = strtolower( $class );
if ( isset( self::$known_classes_paths[ $class ] ) ) {
$this->load_file( self::$known_classes_paths[ $class ] );
return;
}
if ( 0 !== strpos( $class, 'wc_' ) ) {
return;
}