feat: lit/divi-outline and lit/divi-node-get with tree_rev

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:14:38 +02:00
co-authored by Claude Opus 5.5
parent a54a337e0b
commit d27504a750
9 changed files with 677 additions and 1 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace LIT\MCP\Integrations\Divi\Pages;
use LIT\MCP\Abilities\Rev;
use LIT\MCP\Integrations\Divi\BlockTree\Document;
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
use WP_Post;
/**
* An entry loaded for the Divi tools: the post, its parsed tree, the path index and the
* tree_rev (hash of post_content – the optimistic lock of the Divi tools, ruling P16; the
* post-level lock stays `rev` = Rev::ofPost()).
*/
final class DiviPage
{
public function __construct(
public readonly WP_Post $post,
public readonly Document $document,
public readonly NodeIndex $index
) {
}
public function treeRev(): string
{
return Rev::of((string) $this->post->post_content);
}
/** Whether post_content is a Divi 5 layout (or empty, so a first section can be added). */
public function isDiviLayout(): bool
{
$content = (string) $this->post->post_content;
return trim($content) === '' || str_contains($content, '<!-- wp:divi/');
}
public function editUrl(): string
{
return (string) add_query_arg('et_fb', '1', (string) get_permalink($this->post));
}
}