PluginProbe
Database Reset / trunk
Database Reset vtrunk
2.3.2 3.0 3.0.1 3.0.2 3.1 3.15 3.16 3.17 3.18 3.19 3.20 3.21 3.22 3.23 3.24 3.25 trunk 1.0 1.2 1.2.1 1.2.2 1.3 1.4 2.0 2.1 All 27 releases
wordpress-database-reset / lib / class-plugin-autoloader.php

class-plugin-autoloader.php in Database Reset trunk, at lib/class-plugin-autoloader.php

34 lines 738 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! class_exists( 'Plugin_Autoloader' ) ) :
4
5 class Plugin_Autoloader {
6
7 public $directory = __DIR__;
8
9 public function __construct( $directory = '' ) {
10 $this->set_directory( $directory );
11 spl_autoload_register( array( $this, 'autoload' ) );
12 }
13
14 public function set_directory( $directory ) {
15 if ( ! empty( $directory ) ) {
16 $this->directory = $directory;
17 }
18 }
19
20 public function autoload( $class ) {
21 $file = $this->directory . '/class-' . strtolower( str_replace( '_', '-', $class ) ) . '.php';
22 $this->get_class( $file );
23 }
24
25 private function get_class( $file ) {
26 if ( file_exists( $file ) ) {
27 require_once( $file );
28 }
29 }
30
31 }
32
33 endif;
34