Files
WP-LIT-MCP/tests/Support/FakeCustomCssStore.php
T
Jan-Niclas LoosenandClaude Sonnet 5.5 ac333a164c feat(css): globales CSS bearbeiten (lit/divi-custom-css-get und -update)
WordPress „Zusätzliches CSS“ (in Divi „Eigenes CSS“) über die Design-Pipeline: Probelauf mit Zeilen-Diff,
design_rev, Bestätigung, Snapshot, Rollback und Wiederherstellen (Bereich custom_css). Der Guard lehnt </style,
<script, expression(, javascript: und neue @import ab und warnt bei fremden Hosts; nur Neues zählt, Bestehendes
blockiert keine Änderung. Erfordert edit_css und die Divi-Rolle Theme-Anpassung.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-05 16:36:16 +01:00

40 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Support;
use Closure;
use LIT\MCP\Integrations\Divi\Design\CustomCssStore;
use RuntimeException;
/** The custom CSS of one theme in memory; $store can alter what is kept (like kses) or refuse a write. */
final class FakeCustomCssStore extends CustomCssStore
{
/** @var list<string> Every text written, in order. */
public array $writes = [];
/** @param (Closure(string): string)|null $keep What the store really keeps of a written text. */
public function __construct(
public string $css = '.a { color: red; }',
public string $stylesheet = 'Divi',
private ?Closure $keep = null,
private bool $refuse = false
) {
}
public function read(): array
{
return ['stylesheet' => $this->stylesheet, 'css' => $this->css];
}
public function write(string $css): void
{
if ($this->refuse) {
throw new RuntimeException('refused');
}
$this->writes[] = $css;
$this->css = $this->keep === null ? $css : ($this->keep)($css);
}
}