forked from papertower/WP-Controllers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoload.php
94 lines (82 loc) · 2.85 KB
/
autoload.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
<?php
/**
* Autoload classes and functions
*/
// Register autoloader
$directory = __DIR__;
spl_autoload_register(function($class) use ($directory) {
if ( !file_exists("$directory/$class.php") ) return;
include "$directory/$class.php";
if ( class_exists($class) && method_exists($class, '_construct') ) {
call_user_func(array($class, '_construct'));
}
});
// Load all controller files
$_files = scandir($directory);
$_autoload_file = basename(__FILE__);
foreach($_files as $_file) {
if ( $_file !== $_autoload_file && ( $_class = strstr($_file, '.php', true) ) && "$_class.php" === $_file ) {
if ( !class_exists($_class) ) {
trigger_error("$_file failed to load a controller class", E_USER_WARNING);
}
}
}
if ( !function_exists('get_post_controller') ) {
/**
* Global function to call PostController::get_controller
* @see PostController::get_controller
*/
function get_post_controller($key = null, $options = array()) { return PostController::get_controller($key, $options); }
}
if ( !function_exists('get_post_controllers') ) {
/**
* Global function to call PostController::get_controllers
* @see PostController::get_controllers
*/
function get_post_controllers($args = null) { return PostController::get_controllers($args); }
}
if ( !function_exists('get_page_controller') ) {
/**
* Global function to call Page::get_controller
* @see PostController::get_controller
*/
function get_page_controller($key = null, $options = array()) { return Page::get_controller($key, $options); }
}
if ( !function_exists('get_page_controllers') ) {
/**
* Global function to call Page::get_controllers
* @see PostController::get_controllers
*/
function get_page_controllers($args = null) { return Page::get_controllers($args); }
}
if ( !function_exists('get_picture_controller') ) {
/**
* Global function to call Picture::get_controllers
* @see PostController::get_controller
*/
function get_picture_controller($key = null, $options = array()) { return Picture::get_controller($key, $options); }
}
if ( !function_exists('get_term_controller') ) {
/**
* Global function to call Term::get_controller
* @see Term::get_controller
*/
function get_term_controller($key = null, $taxonomy = null, $field = 'id', $options = array()) {
return Term::get_controller($key, $taxonomy, $field, $options);
}
}
if ( !function_exists('get_user_controller') ) {
/**
* Global function to calll User::get_controller
* @see User::get_controller
*/
function get_user_controller($key = null, $field = 'id', $options = array()) { return User::get_controller($key, $field, $options); }
}
if ( !function_exists('get_user_controllers') ) {
/**
* Global function to calll User::get_controllers
* @see User::get_controllers
*/
function get_user_controllers($args) { return User::get_controllers($args); }
}
?>