我想使用 foreach 循环删除动作挂钩。
这是我的功能代码
$config = array(
'remove_actions' => [
'genesis_after_header' => [
'genesis_do_nav',
'genesis_do_subnav'
],
'genesis_site_title' => [
'genesis_seo_site_title',
'4'
],
],
);
protected function remove_actions(array $config) {
foreach ($config as $hook => $functions) {
foreach ($functions as $function => $priority) {
if (! is_array($priority)) {
remove_action($hook, $function);
} else {
remove_action($hook, $function, $priority);
}
}
}
}
如何使用具有优先级的 foreach 循环移除_action 钩子