/** * This needs to be called before any other autoloader features are used. * * @since m2m */ public static function initialize() { if (self::$is_initialized) { return; } $instance = self::get_instance(); /** * Action hook for registering a classmap. * * The one who is adding mappings is responsible for existence of the files. * * @param string[string] $classmap class name => absolute path to a file where this class is defined * @throws InvalidArgumentException * @since m2m */ add_action('toolset_register_classmap', array($instance, 'register_classmap')); // Actually register the autoloader. // // If available (PHP >= 5.3.0), we're setting $prepend = true because this implementation is significantly // faster than other (legacy) Toolset autoloaders, especially when they don't find the class we're looking for. // This will (statistically) save a lot of execution time. if (PHP_VERSION_ID < 50300) { spl_autoload_register(array($instance, 'autoload'), true); } else { spl_autoload_register(array($instance, 'autoload'), true, true); } self::$is_initialized = true; }