| Conditions | 3 |
| Paths | 3 |
| Total Lines | 23 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | function SimpleCalendar_Autoload( $class ) { |
||
| 26 | |||
| 27 | // Do not load unless in plugin domain. |
||
| 28 | $namespace = 'SimpleCalendar'; |
||
| 29 | if ( strpos( $class, $namespace ) !== 0 ) { |
||
|
|
|||
| 30 | return; |
||
| 31 | } |
||
| 32 | |||
| 33 | // Converts Class_Name (class convention) to class-name (file convention). |
||
| 34 | $class_name = implode( '-', array_map( 'lcfirst', explode( '_', strtolower( $class ) ) ) ); |
||
| 35 | |||
| 36 | // Remove the root namespace. |
||
| 37 | $unprefixed = substr( $class_name, strlen( $namespace ) ); |
||
| 38 | |||
| 39 | // Build the file path. |
||
| 40 | $file_path = str_replace( '\\', DIRECTORY_SEPARATOR, $unprefixed ); |
||
| 41 | $file = dirname( __FILE__ ) . '/' . $file_path . '.php'; |
||
| 42 | |||
| 43 | if ( file_exists( $file ) ) { |
||
| 44 | require $file; |
||
| 45 | } |
||
| 46 | |||
| 47 | } |
||
| 48 | |||
| 53 |