# wordpress-database-reset/3.22/lib/class-plugin-autoloader.php

Database Reset, version 3.22. 34 lines.

- Page: https://pluginprobe.com/plugins/wordpress-database-reset/3.22/code/lib/class-plugin-autoloader.php
- Raw: https://pluginprobe.com/plugins/wordpress-database-reset/3.22/raw/lib/class-plugin-autoloader.php
- Modified: 2015-09-26T04:28:34+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/wordpress-database-reset/3.22/code/lib/class-plugin-autoloader.php#L10-L20`.

```php
<?php

if ( ! class_exists( 'Plugin_Autoloader' ) ) :

  class Plugin_Autoloader {

    public $directory = __DIR__;

    public function __construct( $directory = '' ) {
      $this->set_directory( $directory );
      spl_autoload_register( array( $this, 'autoload' ) );
    }

    public function set_directory( $directory ) {
      if ( ! empty( $directory ) ) {
        $this->directory = $directory;
      }
    }

    public function autoload( $class ) {
      $file = $this->directory . '/class-' . strtolower( str_replace( '_', '-', $class ) ) . '.php';
      $this->get_class( $file );
    }

    private function get_class( $file ) {
      if ( file_exists( $file ) ) {
        require_once( $file );
      }
    }

  }

endif;

```
