From c41293e1efa0dacdb8b6862804877e497e31a111 Mon Sep 17 00:00:00 2001 From: Vedanshu Jain Date: Wed, 11 Sep 2024 13:39:31 +0530 Subject: [PATCH] Add support to known class paths for conditional loading. --- plugins/woocommerce/includes/class-wc-autoloader.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/woocommerce/includes/class-wc-autoloader.php b/plugins/woocommerce/includes/class-wc-autoloader.php index 3c9c9570eee..ed18c81d9b8 100644 --- a/plugins/woocommerce/includes/class-wc-autoloader.php +++ b/plugins/woocommerce/includes/class-wc-autoloader.php @@ -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; }