-
Notifications
You must be signed in to change notification settings - Fork 0
/
append.php
40 lines (33 loc) · 1.18 KB
/
append.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
<?php
/**
* Run any appends located in the /usr/local/hestia/plugins directory based on priority naming schema
*/
$folderPath = "/usr/local/hestia/plugins";
$appendsArray = array();
// Scan the plugins directory for any append files
$iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($folderPath));
foreach( $iterator as $file ) {
if ( $file->getExtension() == "php") {
$fileKey = pathinfo( $file->getFilename(), PATHINFO_FILENAME );
if ( strpos( $fileKey, 'append' ) === 0 && strpos( $filePath, '.disabled/append' ) === false ) {
$appendsArray[$fileKey] = $file->getPathname();
}
}
}
// Sort our append arrays by key, default 'append' to append_10.
foreach( $appendsArray as $key => $value ) {
if ( $key == "append" ) {
$appendsArray["append_10"] = $value;
unset( $appendsArray[$key] );
}
}
// Sort numerically by the priority number
usort( $appendsArray, function( $a, $b ) {
$a = explode( '_', $a )[1];
$b = explode( '_', $b )[1];
return $a - $b;
});
// Load and execute the append files in the order they were sorted
foreach( $appendsArray as $key => $value ) {
require_once( $value );
}