Guest User

Untitled

a guest
May 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. <?php
  2. /**
  3. * Plugin autoloader. Coverts class name to path and loads it
  4. * @param string $className
  5. */
  6. function autoload($className)
  7. {
  8. if (class_exists($className))
  9. return;
  10.  
  11. if (self::$pluginAbsolutePath == NULL)
  12. self::$pluginAbsolutePath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR
  13. . 'foo' . DIRECTORY_SEPARATOR;
  14.  
  15. $medium = str_replace('bar', 'classes', strtolower($className));
  16. $path = str_replace('_', DIRECTORY_SEPARATOR, $medium);
  17.  
  18. // Putting altogether
  19. $path = self::$pluginAbsolutePath . $path . '.php';
  20.  
  21. if (file_exists($path) and is_readable($path))
  22. require_once $path;
  23. }
Add Comment
Please, Sign In to add comment