feat: Divi hints point to the read tools; guides divi-structure/attrs/design-system; test: Divi read end-to-end

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
2026-09-26 12:41:42 +02:00
co-authored by Claude Opus 5.5
parent b3cd0eee62
commit f433fef8f7
15 changed files with 326 additions and 19 deletions
@@ -121,7 +121,7 @@ final class ContentUpdateAbility implements Ability
if (array_key_exists('content', $input) && PostPresenter::usesDivi($post)) {
return Errors::unsupported(
'Divi-Inhalte können nicht als Rohtext überschrieben werden; nichts wurde gespeichert.',
PostPresenter::DIVI_NOTE . ' Titel, Auszug, Felder und Begriffe hier ohne content ändern.'
PostPresenter::diviNote() . ' Titel, Auszug, Felder und Begriffe hier ohne content ändern.'
);
}
@@ -6,6 +6,7 @@ namespace LIT\MCP\Integrations\WordPress\Content;
use LIT\MCP\Abilities\JsonMap;
use LIT\MCP\Abilities\Rev;
use LIT\MCP\Integrations\Divi\Schema\DiviModules;
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
use LIT\MCP\Integrations\WordPress\Schema\FieldDefinition;
use WP_Post;
@@ -13,14 +14,36 @@ use WP_Post;
/**
* Output format of an entry for the content tools. Not final so abilities can be
* unit-tested with a mock.
*
* Layering exception: diviNote()/diviHint() call DiviModules::isAvailable() (Divi
* integration) to decide whether the Divi tools exist – the WordPress integration
* otherwise never depends on Divi. Kept because the alternative (injecting
* availability through every constructor that reaches PostPresenter) would spread the
* same one-line check across content-get, content-update and revisions-list for no
* behavioral gain; $toolsAvailable can still be passed in explicitly for tests.
*/
class PostPresenter
{
public const DIVI_NOTE = 'Divi-Werkzeuge folgen in einer späteren Version; bis dahin im Divi-Builder bearbeiten.';
/** How Divi content is read and changed with the Divi tools. */
public const DIVI_NOTE = 'Den Aufbau mit lit/divi-outline (direkt: lit-divi-outline) lesen, einzelne Knoten mit '
. 'lit/divi-node-get (direkt: lit-divi-node-get); ändern vorerst im Divi-Builder.';
public const DIVI_HINT = 'Dieser Inhalt ist mit Divi gebaut; content wird deshalb nicht ausgegeben. '
. self::DIVI_NOTE . ' Titel, Auszug, Felder und Begriffe sind über lit/content-update '
. '(direkt: lit-content-update) änderbar.';
/** Divi content on a site where the Divi 5 builder is not loaded (no Divi tools registered). */
public const DIVI_INACTIVE_NOTE = 'Der Divi-5-Builder ist auf dieser Website nicht aktiv, daher gibt es keine '
. 'Divi-Werkzeuge; Divi-Inhalte nur im Divi-Builder bearbeiten.';
/** $toolsAvailable defaults to whether the Divi integration is available (Divi 5 loaded). */
public static function diviNote(?bool $toolsAvailable = null): string
{
return ($toolsAvailable ?? DiviModules::isAvailable()) ? self::DIVI_NOTE : self::DIVI_INACTIVE_NOTE;
}
public static function diviHint(?bool $toolsAvailable = null): string
{
return 'Dieser Inhalt ist mit Divi gebaut; content wird deshalb nicht ausgegeben. '
. self::diviNote($toolsAvailable) . ' Titel, Auszug, Felder und Begriffe sind über lit/content-update '
. '(direkt: lit-content-update) änderbar.';
}
public function __construct(private ContentSchema $schema)
{
@@ -63,7 +86,7 @@ class PostPresenter
'fields' => JsonMap::of($this->fields($post)),
'featured_image' => $this->featuredImage($post),
'rev' => Rev::ofPost($post),
'hints' => $divi ? [self::DIVI_HINT] : [],
'hints' => $divi ? [self::diviHint()] : [],
]);
}
@@ -19,7 +19,7 @@ use WP_Post;
* the same detection lit/content-get uses) because a Divi/block-built revision's
* post_content is shortcode or block-comment markup, not prose – excerpt is then a
* stripped fragment of that markup rather than a real preview; hints repeats
* PostPresenter::DIVI_HINT once when any item is flagged.
* PostPresenter::diviHint() once when any item is flagged.
*/
final class RevisionsListAbility implements Ability
{
@@ -124,7 +124,7 @@ final class RevisionsListAbility implements Ability
'post_id' => (int) $post->ID,
'items' => $items,
'next_cursor' => $page['next_cursor'],
'hints' => in_array(true, array_column($items, 'divi'), true) ? [PostPresenter::DIVI_HINT] : [],
'hints' => in_array(true, array_column($items, 'divi'), true) ? [PostPresenter::diviHint()] : [],
];
}