/** * 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; }
public function register_utils() { if (!$this->is_section_loaded(self::TOOLSET_AUTOLOADER)) { // This needs to happen very very early require_once TOOLSET_COMMON_PATH . '/utility/autoloader.php'; Toolset_Common_Autoloader::initialize(); $this->add_section_loaded(self::TOOLSET_AUTOLOADER); } if (!$this->is_section_loaded(self::TOOLSET_UTILS)) { $this->add_section_loaded(self::TOOLSET_UTILS); require_once TOOLSET_COMMON_PATH . '/utility/utils.php'; } // Although this is full of DDL prefixes, we need to actually port before using it. if (!$this->is_section_loaded(self::TOOLSET_DIALOGS)) { $this->add_section_loaded(self::TOOLSET_DIALOGS); require_once TOOLSET_COMMON_PATH . '/utility/dialogs/toolset.dialog-boxes.class.php'; } if (!$this->is_section_loaded(self::TOOLSET_HELP_VIDEOS)) { $this->add_section_loaded(self::TOOLSET_HELP_VIDEOS); require_once TOOLSET_COMMON_PATH . '/utility/help-videos/toolset-help-videos.php'; } $this->apply_filters_on_sections_loaded('toolset_register_utility_section'); }