Hook can return values

This commit is contained in:
Ibnu Maksum 2024-06-26 17:38:49 +07:00
parent 710ef7e9fa
commit 5baac9d7d0
No known key found for this signature in database
GPG Key ID: 7FC82848810579E5

View File

@ -45,13 +45,14 @@ function register_hook($action, $function){
];
}
function run_hook($action){
function run_hook($action, $args = []){
global $hook_registered;
foreach($hook_registered as $hook){
if($hook['action'] == $action){
if(function_exists($hook['function'])){
call_user_func($hook['function']);
return call_user_func($hook['function'], $args);
}
}
}
return false;
}