private static function _load_modules()
{
ksort(self::$_modules);
self::$_modules = apply_filters('wplib_modules', self::$_modules);
$called_class = get_called_class();
$module_classes = isset(self::$_module_classes[$called_class]) ? self::$_module_classes[$called_class] : array();
$module_names = isset(self::$_module_names[$called_class]) ? self::$_module_names[$called_class] : array();
$abspath_regex = '#^' . preg_quote(ABSPATH) . '(.+' . preg_quote(DIRECTORY_SEPARATOR) . '.+\\.php)$#';
foreach (self::$_modules as $priority) {
foreach ($priority as $module_name => $filepath) {
if (isset(self::$_loaded_include_files[$filepath])) {
/*
* Already loaded
*/
continue;
}
if (self::is_development() && !$filepath || !WPLib::is_found($filepath)) {
self::trigger_error(sprintf(__("File for Module %s not found: %s", 'wplib'), $module_name, $filepath), E_USER_ERROR);
}
if (!$filepath) {
continue;
}
/**
* Set self::$_file_loading so 'shutdown' hook can report which file caused the load error.
*/
self::$_file_loading = $filepath;
require_once $filepath;
self::$_file_loading = false;
$classes = get_declared_classes();
$module_path = preg_replace($abspath_regex, '~/$1', $filepath);
$module_classes[$module_class = end($classes)] = self::maybe_make_abspath_relative($module_path);
if ($module_name = self::get_module_name($module_class)) {
$module_names[$module_name] = $module_class;
}
$register_templates = array($module_class, '_register_templates');
if (is_callable($register_templates)) {
call_user_func($register_templates);
}
/**
* Find all autoloading files defined by the above module.
*/
static::_find_autoload_files();
}
}
self::$_module_classes[$called_class] = $module_classes;
self::$_module_names[$called_class] = $module_names;
self::$_modules = array();
}