Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 488d231c6d
Fetching contributors…

Cannot retrieve contributors at this time

executable file 49 lines (38 sloc) 1.149 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
<?php

require_once('ToppaAutoLoader.php');

class ToppaAutoLoaderWp implements ToppaAutoLoader {
    private $relativePath;
    private $className;
    private $fullPath;

    public function __construct($relativePath = null) {
        $this->relativePath = $relativePath;
        spl_autoload_register(array($this, 'loader'));
    }

    public function loader($className) {
        $this->setClassName($className);
        $this->setFullPath();
        $this->includeClass();
        return true;
    }

    public function setClassName($className) {
        $this->className = $className;
    }

    public function setFullPath() {
        $basePath = WP_PLUGIN_DIR . $this->relativePath;
        $classPath = str_replace('_', '/', $this->className) . '.php';
        $this->fullPath = $basePath . '/' . $classPath;
        return true;
    }

    public function includeClass() {
        if (class_exists($this->className, false)) {
            return 1;
        }

        else {
            return @include($this->fullPath);
        }

        return false;
    }

    public function getFullPath() {
        return $this->fullPath;
    }

}
Something went wrong with that request. Please try again.