PluginProbe
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 1.4.7
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v1.4.7
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 in ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor 1.4.7, at autoloader.php

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