*/ private array $elements = []; public function register(string $tag, RsvTemplateElement $element): void { $this->elements[$tag] = $element; } public function get(string $tag): ?RsvTemplateElement { return $this->elements[$tag] ?? null; } /** @return array */ public function all(): array { return $this->elements; } /** * Extends a wp_kses allowlist so the registered custom elements survive * sanitization of admin HTML. Each element contributes its tag and the * attributes it declares via symbols(). * * @param array $base A wp_kses allowed-html map to extend. * @return array */ public function kses_allowed(array $base = []): array { foreach ($this->elements as $tag => $element) { $attributes = []; foreach ($element->symbols() as $name) { $attributes[$name] = true; } $base[$tag] = $attributes; } return $base; } }