<?php
class plugins
{
var $hooks = array();
}
?>
<?php
class plugins
{
var $hooks = array();
public function addHook($hookName, $hookFile, $hookFunction)
{
// Check if the file is already attached to the hook
if (isset($this->hooks[$hookName][$hookFile])) {
return true;
}
// Add the hook
$this->hooks[$hookName][$hookFunction] = array('file' => $hookFile, 'function' =>
$hookFunction);
return true;
}
}
?>
require_once "plugins.php"
$p = new plugins;
$p->addHook('this', 'helloWorld', 'helloWorld';
<?php
class plugins
{
var $hooks = array();
public function addHook($hookName, $hookFile, $hookFunction)
{
// Check if the file is already attached to the hook
if (isset($this->hooks[$hookName][$hookFile])) {
return true;
}
// Add the hook
$this->hooks[$hookName][$hookFunction] = array('file' => $hookFile, 'function' =>
$hookFunction);
return true;
}
public function runHook($hookName)
{
if (!is_array($this->hooks[$hookName])) {
return false;
}
foreach ($this->hooks[$hookName] as $function) {
if (!is_array($function)) {
return true;
}
if(file_exists($function->file . ".php")) {
return true;
} else {
require_once $function[$file] . ".php";
eval("{$function[$function]}"); // Run the function
}
}
}
}
?>
function helloWorld() {
echo "Hello World";
}
Copyright © 2024, NextGenUpdate.
All Rights Reserved.