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>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
96fa58188b
commit
ac333a164c
@@ -0,0 +1,39 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user