freigeben" (only after a fresh green report) and "Freigabe zurückziehen" (only * for a database release). Opening the tab removes check pages a dead check left behind. */ final class DiviTab implements AdminTab { public const SLUG = 'divi'; public const RELEASE_ACTION = 'lit_mcp_divi_release'; public const WITHDRAW_ACTION = 'lit_mcp_divi_withdraw'; /** * @param (Closure(): string)|null $version Installed Divi version ('' = none); null = DiviEnvironment. * @param (Closure(string): string)|null $stateKey null = ReleaseResolver::stateKey(). */ public function __construct( private ?CheckReportStore $reports = null, private ?ReleaseStore $releases = null, private ?ChangeLog $log = null, private ?AdminPostAction $action = null, private ?Closure $version = null, private ?Closure $stateKey = null ) { } public function slug(): string { return self::SLUG; } public function label(): string { return __('Divi', 'wp-lit-mcp'); } public function registerSettings(): void { } public function registerActions(): void { add_action('admin_post_' . self::RELEASE_ACTION, [$this, 'release']); add_action('admin_post_' . self::WITHDRAW_ACTION, [$this, 'withdraw']); } public function release(): void { $action = $this->action ?? new AdminPostAction(); $action->guard(); check_admin_referer(self::RELEASE_ACTION); $version = $this->version(); $report = $this->reports()->latest(); $fresh = $report !== null && $report->freshFor($version, Plugin::VERSION, $this->stateKey($version)); if ($version === '' || ! $fresh) { $action->redirect(self::SLUG, 'divi_release_refused'); return; } ($this->releases ?? new ReleaseStore())->add($version, Plugin::VERSION, get_current_user_id(), $report->id); ReleaseGate::forget(); $this->log?->record( 'lit/divi-release', 'divi', $version, sprintf('Divi %s für LIT MCP %s freigegeben (Prüfbericht %s).', $version, Plugin::VERSION, $report->id) ); $action->redirect(self::SLUG, 'divi_released'); } public function withdraw(): void { $action = $this->action ?? new AdminPostAction(); $action->guard(); check_admin_referer(self::WITHDRAW_ACTION); $version = $this->version(); if (! ($this->releases ?? new ReleaseStore())->withdraw($version, Plugin::VERSION)) { $action->redirect(self::SLUG, 'divi_withdraw_failed'); return; } ReleaseGate::forget(); $this->log?->record( 'lit/divi-release', 'divi', $version, sprintf('Freigabe von Divi %s zurückgezogen.', $version) ); $action->redirect(self::SLUG, 'divi_withdrawn'); } public function render(): void { if ($this->version() === '') { echo '
' . esc_html__( // phpcs:ignore Generic.Files.LineLength.TooLong -- WordPress.WP.I18n forbids splitting the text. 'Divi ist auf dieser Website nicht aktiv; die Divi-Freigabe ist ohne Bedeutung.', 'wp-lit-mcp' ) . '
'; return; } $removed = WriteProbe::removeOrphans(); $status = ReleaseGate::status(); $report = $this->reports()->latest(); echo '' . esc_html__( // phpcs:ignore Generic.Files.LineLength.TooLong -- WordPress.WP.I18n forbids splitting the text argument. 'LIT MCP schreibt nur mit Divi-Versionen, die geprüft sind. Nach einem Divi-Update hier die Prüfung starten und die Version freigeben; bis dahin lesen die Divi-Werkzeuge nur.', 'wp-lit-mcp' ) . '
'; if ($removed !== []) { printf( '%s
| %s | %s |
|---|---|
| %s | %s – %s |
| ' . esc_html__('Geändert in Divi', 'wp-lit-mcp') . ' |
|
' . esc_html__( // phpcs:ignore Generic.Files.LineLength.TooLong -- WordPress.WP.I18n forbids splitting the text argument. 'Freigeben geht erst nach einer vollständig grünen Prüfung dieser Divi-Version – Prüfung erneut ausführen.', 'wp-lit-mcp' ) . '
'; } } if ($status->state === ReleaseState::Released && $status->source === ReleaseStatus::SOURCE_DATABASE) { $this->actionForm(self::WITHDRAW_ACTION, __('Freigabe zurückziehen', 'wp-lit-mcp'), 'secondary'); } } private function actionForm(string $action, string $label, string $type): void { printf(''; } private function renderReport(CheckReport $report): void { printf( '%s
' . esc_html__( 'Optional: eine Divi-Seite im Visual Builder öffnen und speichern.', 'wp-lit-mcp' ) . '
'; } private function version(): string { return ($this->version ?? static fn (): string => DiviEnvironment::version() ?? '')(); } private function stateKey(string $version): string { return ($this->stateKey ?? static fn (string $v): string => ReleaseResolver::stateKey($v))($version); } private function reports(): CheckReportStore { return $this->reports ?? new CheckReportStore(); } }