$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 ($hook_name, $arguments = "") { // Oh, no you didn't. Are you trying to run an action hook that doesn't exist? if (! isset(self::$hooks[$hook_name])) { return $arguments; } // Set the current running hook to this self::$current_hook = $hook_name; // Key sort our action hooks ksort(self::$hooks[$hook_name]); foreach (self::$hooks[$hook_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; } // ИСПРАВЛЕНИЕ: Устранение Fatal Error и Warning. // Используем $hook_name (строка) в качестве ключа. self::$run_hooks[$hook_name][$priority] = (self::$run_hooks[$hook_name][$priority] ?? 0) + 1; } } } 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; } } } ?>