Skip to content

Commit

Permalink
Fix filter error
Browse files Browse the repository at this point in the history
  • Loading branch information
puleeno committed Sep 5, 2023
1 parent 3f46b41 commit c47f529
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/Core/HookManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,14 @@ public static function executeAction($hookName, ...$params)
}
}

public static function applyFilters($hookName, $value, ...$params)
public static function applyFilters($hookName, ...$params)
{
$instance = static::getInstance();
$value = count($params) > 0 ? $params[0] : null;
foreach ($instance->getFiltersByHook($hookName) as $fn) {
$value = call_user_func_array($fn, array_merge($value, $params));
$value = call_user_func_array($fn, $params);
}

return $value;
}

Expand Down
16 changes: 16 additions & 0 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use App\Common\Constants;
use App\Common\Option;
use App\Core\HookManager;

if (!function_exists('array_get')) {
function array_get($arr, $keyStr, $defaultValue = null)
Expand Down Expand Up @@ -39,3 +40,18 @@ function extractExtensionNameFromFilePath($path)
{
}
}


if (!function_exists('add_action')) {
function add_action($hookName, $fn)
{
return HookManager::addAction($hookName, $fn);
}
}

if (!function_exists('add_filter')) {
function add_filter($hookName, $fn)
{
return HookManager::addFilter($hookName, $fn);
}
}

0 comments on commit c47f529

Please sign in to comment.