$function ); } } else { // Store the action hook in the $hooks array self::$hooks[$name][$priority][$function] = array( "function" => $function ); } return true; } /** * Do Hook */ public static function trigger($name, $arguments = "") { // Oh, no you didn't. Are you trying to run an action hook that doesn't exist? if (! isset(self::$hooks[$name])) { return $arguments; } // Set the current running hook to this self::$current_hook = $name; // Key sort our action hooks ksort(self::$hooks[$name]); foreach (self::$hooks[$name] AS $priority => $names) { if (is_array($names)) { foreach ($names AS $name) { $return = call_user_func_array($name['function'], array( &$arguments )); if ($return) { $arguments = $return; } self::$run_hooks[$name][$priority]; } } } self::$current_hook = ''; return $arguments; } /** * Remove Hook */ public static function unregister($name, $function, $priority = 10) { // If the action hook doesn't, just return true if (!isset(self::$hooks[$name][$priority][$function])) { return true; } // Remove the action hook from our hooks array unset(self::$hooks[$name][$priority][$function]); return ''; } /** * Current Hook * * Get the currently running action hook * */ public static function current() { return self::$current_hook; } /** * Has Run */ public static function has($hook, $priority = 10) { if (isset(self::$hooks[$hook][$priority])) { return true; } else { return false; } } /** * Hook Exists */ public static function exists($name) { if (isset(self::$hooks[$name])) { return true; } else { return false; } } } ?>