-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
49 lines (42 loc) · 1.16 KB
/
init.php
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
/*
* SUSPENDED.page
*
* Core class for the SUSPENDED.page addon module.
* This class handles autoloading of classes and registration of WHMCS hooks.
*
* @docs https://suspended.page/whmcs
* @source https://github.com/Black-HOST/suspended/blob/master/init.php
*/
namespace SUSPENDED;
// load WHMCS Dependency Injector
use DI;
class CORE
{
//
public static function autoload ( $NAME )
{
// if it's not addon request skip to the next autoloader
if ( strpos( $NAME, __NAMESPACE__ ) === false )
return;
// form full path to the class filename
$_filename = strtolower( str_replace(
[ "/" . __NAMESPACE__ , "\\" ],
[ "" , "/" ],
__DIR__ . DIRECTORY_SEPARATOR . $NAME . ".php"
));
// try to load the requested class
if ( file_exists( $_filename ) )
require $_filename;
}
// hook registration
public static function hook ( $HOOK, $PRIORITY = 1 ) : void
{
DI::call( function () use ($HOOK)
{
add_hook( $HOOK, $PRIORITY, [DI::make( "\SUSPENDED\Hooks\\{$HOOK}" ), '__invoke'] );
});
}
}
// register the addon autoloader
spl_autoload_register('SUSPENDED\Core::autoload');