PluginProbe
JetFormBuilder — Dynamic Blocks Form Builder / 3.0.5
JetFormBuilder — Dynamic Blocks Form Builder v3.0.5
3.6.5.2 3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 All 130 releases
jetformbuilder / includes / autoloader.php

autoloader.php in JetFormBuilder — Dynamic Blocks Form Builder 3.0.5, at includes/autoloader.php

76 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Jet_Form_Builder;
4
5 if ( ! defined( 'ABSPATH' ) ) {
6 exit; // Exit if accessed directly.
7 }
8
9 /**
10 * Autoloader handler class is responsible for loading the different
11 * classes needed to run the plugin.
12 */
13 class Autoloader {
14
15 /**
16 * Run autoloader.
17 *
18 * Register a function as `__autoload()` implementation.
19 *
20 * @since 1.6.0
21 * @access public
22 * @static
23 */
24 public static function run() {
25 spl_autoload_register( array( __CLASS__, 'autoload' ) );
26 }
27
28 /**
29 * Load class.
30 *
31 * For a given class name, require the class file.
32 *
33 * @param string $relative_class_name Class name.
34 *
35 * @since 1.6.0
36 * @access private
37 * @static
38 */
39 private static function load_class( $class_name ) {
40
41 $file = str_replace( '\\', DIRECTORY_SEPARATOR, $class_name );
42 $file = strtolower( str_replace( '_', '-', $file ) );
43 $filepath = JET_FORM_BUILDER_PATH . 'includes/' . $file . '.php';
44
45 if ( is_readable( $filepath ) ) {
46 require $filepath;
47 }
48 }
49
50 /**
51 * Autoload.
52 *
53 * For a given class, check if it exist and load it.
54 *
55 * @param string $class Class name.
56 *
57 * @since 1.6.0
58 * @access private
59 * @static
60 */
61 private static function autoload( $class ) {
62
63 if ( 0 !== strpos( $class, __NAMESPACE__ . '\\' ) ) {
64 return;
65 }
66
67 $relative_class_name = preg_replace( '/^' . __NAMESPACE__ . '\\\/', '', $class );
68 $final_class_name = __NAMESPACE__ . '\\' . $relative_class_name;
69
70 if ( ! class_exists( $final_class_name ) ) {
71 self::load_class( $relative_class_name );
72 }
73
74 }
75 }
76