PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 3.5.1
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v3.5.1
4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 All 183 releases
elementskit-lite / autoloader.php
autoloader.php
59 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace ElementsKit_Lite;
3
4 defined( 'ABSPATH' ) || exit;
5
6 /**
7 * ElementsKit_Lite autoloader.
8 * Handles dynamically loading classes only when needed.
9 *
10 * @since 1.0.0
11 */
12 class Autoloader {
13
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 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 = \ElementsKit_Lite::plugin_dir() . $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