controller
9 years ago
core
9 years ago
Ga_Admin.php
9 years ago
Ga_Autoloader.php
9 years ago
Ga_Frontend.php
9 years ago
Ga_Helper.php
9 years ago
Ga_Hook.php
9 years ago
Ga_Notice.php
9 years ago
Ga_Sharethis.php
9 years ago
Ga_Stats.php
9 years ago
Ga_Autoloader.php
57 lines
| 1 | <?php |
| 2 | |
| 3 | class Ga_Autoloader { |
| 4 | |
| 5 | /** |
| 6 | * Registers clas loader. |
| 7 | */ |
| 8 | public static function register() { |
| 9 | spl_autoload_register( "Ga_Autoloader::loader" ); |
| 10 | } |
| 11 | |
| 12 | /** |
| 13 | * Class loader. |
| 14 | * |
| 15 | * @param $class_name |
| 16 | */ |
| 17 | private static function loader( $class_name ) { |
| 18 | |
| 19 | // Core classes |
| 20 | if ( preg_match( '/_Core/', $class_name ) ) { |
| 21 | $file_name = GA_PLUGIN_DIR . '/class/core/' . $class_name . '.php'; |
| 22 | if ( file_exists( $file_name ) ) { |
| 23 | require $file_name; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | // Controllers |
| 28 | if ( preg_match( '/_Controller/', $class_name ) ) { |
| 29 | $file_name = GA_PLUGIN_DIR . '/class/controller/' . $class_name . '.php'; |
| 30 | if ( file_exists( $file_name ) ) { |
| 31 | require $file_name; |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | // classes |
| 36 | $file_name = GA_PLUGIN_DIR . '/class/' . $class_name . '.php'; |
| 37 | if ( file_exists( $file_name ) ) { |
| 38 | require $file_name; |
| 39 | } |
| 40 | |
| 41 | // tools |
| 42 | $file_name_tools = GA_PLUGIN_DIR . '/tools/' . $class_name . '.php'; |
| 43 | if ( file_exists( $file_name_tools ) ) { |
| 44 | require $file_name_tools; |
| 45 | } |
| 46 | |
| 47 | // Libs |
| 48 | if ( preg_match( '/Ga_Lib/', $class_name ) ) { |
| 49 | $file_name = GA_PLUGIN_DIR . '/lib/' . $class_name . '.php'; |
| 50 | if ( file_exists( $file_name ) ) { |
| 51 | require $file_name; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | } |
| 57 |