/** * Register autoloader. * * @return void */ function autoload() { IG_Loader::register(IG_PB_PATH . 'core', 'IG_Pb_'); IG_Loader::register(IG_PB_PATH . 'core/gadget', 'IG_Gadget_'); // Allow autoload registration from outside do_action('ig_pb_autoload'); }
/** * Register Path to extended Parameter type * * @param string $path */ public function register_extended_parameter_path($path) { IG_Loader::register($path, 'IG_Pb_Helper_Html_'); }
} } /** * Search a file in registered paths. * * @param string $file Relative file path to search for. * * @return string */ public static function get_path($file) { // Generate alternative file name $slave = str_replace('_', '-', $file); // Filter paths to search for file self::$paths = apply_filters('ig_loader_get_path', self::$paths); foreach (array_reverse(self::$paths) as $base => $prefixes) { if (@is_file($base . '/' . $slave)) { return $base . '/' . $slave; } elseif (@is_file($base . '/' . $file)) { return $base . '/' . $file; } } return null; } } // Register class autoloader with PHP spl_autoload_register(array('IG_Loader', 'load')); } // Register base path to look for class file IG_Loader::register(dirname(__FILE__), 'IG_');
/** * Autoload shortcodes & sub shortcodes * * @param string $path */ public static function autoload_shortcodes($path) { $items = substr_count($path, '/item'); $postfix = str_repeat('Item_', $items); // autoload shortcodes IG_Loader::register($path, 'IG_' . $postfix); }