This repository has been archived by the owner on Apr 15, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
functions.php
executable file
·95 lines (78 loc) · 2.32 KB
/
functions.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
if( !defined( 'ABSPATH' ) )
exit;
/*
|--------------------------------------------------------------------------
| Essential
|--------------------------------------------------------------------------
|
| Core functions and settings
|
*/
if ( !function_exists('autoload_folder') )
{
/**
* Autoload folder
*
* Function to load all relevant files within given folder
* and it's children
*
* @param $path string Path to given folder
* @param $extension string Files to load by extension
* @return bool|void
*/
function autoload_folder($path, $extension = '.php')
{
if (!is_dir($path))
return false;
if ($handle = opendir($path)) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && !is_dir($path . '/' . $entry) && strpos($entry, $extension) !== false) {
require_once ($path . '/' . $entry);
} else if ($entry != "." && $entry != ".." && is_dir($path . '/' . $entry)) {
autoload_folder($path . '/' . $entry);
}
}
closedir($handle);
}
}
}
/*
|--------------------------------------------------------------------------
| API
|--------------------------------------------------------------------------
|
| Load all calls registered in separate files in /api folder
|
*/
$relative_path = '/api';
foreach( array_unique([get_template_directory(), get_stylesheet_directory()]) as $folder )
{
autoload_folder($folder . $relative_path);
}
/*
|--------------------------------------------------------------------------
| Includes
|--------------------------------------------------------------------------
|
| Autoload all php files in /includes folder
|
*/
$relative_path = '/includes';
foreach( array_unique([get_template_directory(), get_stylesheet_directory()]) as $folder )
{
autoload_folder($folder . $relative_path);
}
/*
|--------------------------------------------------------------------------
| Extensions
|--------------------------------------------------------------------------
|
| Load extensions
|
*/
$relative_path = '/extensions';
foreach( array_unique([get_template_directory(), get_stylesheet_directory()]) as $folder )
{
autoload_folder($folder . $relative_path);
}