/** * @param ListenerInterface[] | array $listeners * @param string $type one of filter or action types */ protected function register(array $listeners, $type) { foreach ($listeners as $listener) { $listener = $this->listenerFactory->makeListener($type, $listener); foreach ($listener->getNames() as $name) { /** * @see WP::add_action * @see WP::add_filter */ $this->wpService->__call('add_' . strtolower($type), [$name, $listener->getCallable(), $listener->getPriority(), $listener->getArgc()]); } } }