PluginProbe ʕ •ᴥ•ʔ
Checkout Field Editor (Checkout Manager) for WooCommerce / 1.7.0
Checkout Field Editor (Checkout Manager) for WooCommerce v1.7.0
1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.2 1.5.3 1.6.0 1.6.1 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.9.0 1.9.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 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.1.8 2.1.9 trunk 1.0.9 1.2.0 1.2.5 1.2.8 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.3.8
woo-checkout-field-editor-pro / includes / class-thwcfd-autoloader.php
woo-checkout-field-editor-pro / includes Last commit date
utils 3 years ago class-thwcfd-autoloader.php 3 years ago class-thwcfd.php 3 years ago
class-thwcfd-autoloader.php
83 lines
1 <?php
2 /**
3 * Auto-loads the required dependencies for this plugin.
4 *
5 * @link https://themehigh.com
6 * @since 1.5.0
7 *
8 * @package woo-checkout-field-editor-pro
9 * @subpackage woo-checkout-field-editor-pro/includes
10 */
11 if(!defined('WPINC')){ die; }
12
13 if(!class_exists('THWCFD_Autoloader')):
14
15 class THWCFD_Autoloader {
16 private $include_path = '';
17
18 private $class_path = array();
19
20 public function __construct() {
21 $this->include_path = untrailingslashit(THWCFD_PATH);
22
23 if(function_exists("__autoload")){
24 spl_autoload_register("__autoload");
25 }
26 spl_autoload_register(array($this, 'autoload'));
27 }
28
29 /** Include a class file. */
30 private function load_file( $path ) {
31 if ( $path && is_readable( $path ) ) {
32 require_once( $path );
33 return true;
34 }
35 return false;
36 }
37
38 /** Class name to file name. */
39 private function get_file_name_from_class( $class ) {
40 return 'class-' . str_replace( '_', '-', $class ) . '.php';
41 }
42
43 public function autoload( $class ) {
44 $class = strtolower( $class );
45 $file = $this->get_file_name_from_class( $class );
46 $path = '';
47 $file_path = '';
48
49 if(isset($this->class_path[$class])){
50 $file_path = $this->include_path . '/' . $this->class_path[$class];
51
52 } else {
53 if (strpos($class, 'thwcfd_admin') === 0){
54 $path = $this->include_path . '/admin/';
55
56 } elseif (strpos($class, 'thwcfd_public') === 0){
57 $path = $this->include_path . '/public/';
58
59 } elseif (strpos($class, 'thwcfd_utils') === 0){
60 $path = $this->include_path . '/includes/utils/';
61
62 } elseif (strpos($class, 'wcfe_checkout_field') === 0){
63 $path = $this->include_path . '/includes/model/fields/';
64
65 } elseif (strpos($class, 'wcfe_checkout_section') === 0){
66 $path = $this->include_path . '/includes/model/';
67
68 } else{
69 $path = $this->include_path . '/includes/';
70 }
71 $file_path = $path . $file;
72 }
73
74 if( empty($file_path) || (!$this->load_file($file_path) && strpos($class, 'thwcfd_') === 0) ) {
75 $this->load_file( $this->include_path . $file );
76 }
77 }
78 }
79
80 endif;
81
82 new THWCFD_Autoloader();
83