| Server IP : 121.121.20.254 / Your IP : 216.73.216.145 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/inetpub/wwwroot/KnowledgeBase/wp-content/plugins/admin-menu-editor/includes/ |
Upload File : |
<?php
namespace YahnisElsts\AdminMenuEditor;
/**
* A basic PSR-4 autoloader.
*/
class AmeAutoloader {
protected $prefixes;
/**
* @param array<string,string> $namespacePrefixes
*/
public function __construct($namespacePrefixes) {
//Ensure that each prefix ends with a backslash and each path ends
//with a forward slash.
$this->prefixes = array();
foreach ($namespacePrefixes as $prefix => $path) {
$prefix = trim($prefix, '\\') . '\\';
$path = rtrim($path, '/\\') . '/';
$this->prefixes[$prefix] = $path;
}
}
public function register() {
spl_autoload_register([$this, 'loadClass']);
}
public function loadClass($class) {
foreach ($this->prefixes as $prefix => $baseDirectory) {
//Does the full class name start with this namespace prefix?
$len = strlen($prefix);
if ( strncmp($prefix, $class, $len) !== 0 ) {
continue;
}
$relativeClassName = substr($class, $len);
//Replace the prefix with the base directory, replace namespace separators
//with directory separators, and append the ".php" extension.
$fileName = $baseDirectory . str_replace('\\', '/', $relativeClassName) . '.php';
if ( file_exists($fileName) ) {
require $fileName;
}
}
}
}