forked from jdearaujo/Business-Card-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
callbacks.inc.php
29 lines (28 loc) · 978 Bytes
/
callbacks.inc.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
<?php
/**
* Handles hooks.
*
* @package Business-Card-Generator
*/
if ( !defined( 'ROOT' ) ) define( 'ROOT', dirname( __FILE__ ) );
require_once( ROOT.'/m.inc.php' );
if ( !function_exists( 'hook' ) ) {
/**
* Call a hook.
*
* @since 0.1
*
* @param callback $name
* @param mixed $arg,... Optional. Arguments which are passed on to the functions hooked to the action.
* @return void|mixed If it returns void, then the hook wasn't callable. Else, the response form the hook is returned.
*/
function hook( $name ) {
$args = func_get_args( );
if ( is_callable( $name ) && is_array( $args ) ) {
array_shift( $args );
return call_user_func_array( $name, $args );
}
return null; // By now, if the hook was callable, it would have been called and returned and this function would be done, but because it isn't, there must have been a problem, so we will return NULL.
}
}
?>