PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.2
Timetics – Appointment Booking Calendar & Scheduling v1.0.2
1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 All 62 releases
timetics / autoloader.php

autoloader.php in Timetics – Appointment Booking Calendar & Scheduling 1.0.2, at autoloader.php

62 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Timetics;
4
5 defined( 'ABSPATH' ) || exit;
6
7 /**
8 * Etn autoloader.
9 * Handles dynamically loading classes only when needed.
10 *
11 * @since 1.0.0
12 */
13 class Autoloader {
14 /**
15 * Run autoloader.
16 * Register a function as `__autoload()` implementation.
17 *
18 * @since 1.0.0
19 * @access public
20 */
21 public static function run() {
22 spl_autoload_register( array( __CLASS__, 'autoload' ) );
23 }
24
25 /**
26 * Autoload.
27 * For a given class, check if it exist and load it.
28 *
29 * @since 1.0.0
30 * @access private
31 * @param string $class_name Class name.
32 */
33 private static function autoload( $class_name ) {
34
35 // If the class being requested does not start with our prefix
36 // we know it's not one in our project.
37 if ( 0 !== strpos( $class_name, __NAMESPACE__ ) ) {
38 return;
39 }
40
41 $file_name = strtolower(
42 preg_replace(
43 array( '/\b' . __NAMESPACE__ . '\\\/', '/([a-z])([A-Z])/', '/_/', '/\\\/' ),
44 array( '', '$1-$2', '-', DIRECTORY_SEPARATOR ),
45 $class_name
46 )
47 );
48
49 // Compile our path from the corosponding location.
50 $file = plugin_dir_path( __FILE__ ) . $file_name . '.php';
51
52 // If a file is found.
53 if ( file_exists( $file ) ) {
54 // Then load it up!
55 require_once $file;
56 }
57 }
58
59 }
60
61 Autoloader::run();
62