identifier = (string)acym_rand(1000, 9000); } public function startTab(string $title, bool $selected = false, bool $clickable = true): string { if ($this->opened) { $this->endTab(); } $this->opened = true; $this->identifier = preg_replace('#[^a-z0-9]#is', '_', strtolower($title)); $this->titles[] = [ 'title' => $title, 'clickable' => $clickable, 'selected' => $selected, 'identifier' => $this->identifier, 'tabNumber' => $this->tabNumber, ]; ob_start(); return $this->identifier; } public function endTab(): void { if (!$this->opened) { return; } $this->opened = false; $this->content[] = '
'.ob_get_clean().'
'; $this->tabNumber++; } public function addCallbackElement(callable $callable, string $identifier = ''): void { $this->inBarElements[] = [ 'callable' => $callable, 'identifier' => $identifier, ]; } public function display(string $tabId): void { if ($this->opened) { $this->endTab(); } echo ''; echo '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- Content escaped from the add-on/plugin side. echo implode('', $this->content); echo '
'; } }