Post

dynamically include php files

Include all the php files in the directory automatically

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
 // --------------------------------------------------------------------------
 //   Include Utilities
 // --------------------------------------------------------------------------

 foreach (glob(dirname(__FILE__) . "/lib/utilities/*.php") as $filename) {
   require_once $filename;
 }

 // --------------------------------------------------------------------------
 //   Include Configuration
 // --------------------------------------------------------------------------

 foreach (glob(dirname(__FILE__) . "/lib/config/*.php") as $filename) {
   require_once $filename;
 }

 // --------------------------------------------------------------------------
 //   Include Post Types and Taxonomies
 // --------------------------------------------------------------------------

 foreach (glob(dirname(__FILE__) . "/lib/content/*.php") as $filename) {
   require_once $filename;
 }

 // --------------------------------------------------------------------------
 //   Include Tweaks
 // --------------------------------------------------------------------------

 foreach (glob(dirname(__FILE__) . "/lib/tweaks/*.php") as $filename) {
   require_once $filename;
 }
This post is licensed under CC BY 4.0 by the author.