feat: lit/content-create with Divi short form
New input divi (1-30 sections, short form like lit-divi-insert) builds a Divi 5 layout in one divi/placeholder. The whole description is checked before the insert (Divi's map for "no entry yet"); the draft is inserted with its normal WordPress fields only, then DiviContentComposer composes again bound to the new entry and stores it via DiviSaver::saveNew (same kses window as save(), strict DiviFlags). A refusal or failure deletes the draft. Result adds tree_rev and the outline. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Integrations\WordPress\Content;
|
||||
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
|
||||
/**
|
||||
* Builds the content of a new entry for lit/content-create from a structured description
|
||||
* (spec §6.2: "optional Divi-Inhalt in Kurzform"). Implemented by the Divi integration, so the
|
||||
* WordPress integration does not depend on Divi.
|
||||
*
|
||||
* Two steps, because the entry does not exist before the insert: check() validates the whole
|
||||
* description before anything is created (all or nothing); write() stores the content into the
|
||||
* brand-new draft, which lit/content-create inserted with its normal WordPress fields only.
|
||||
*/
|
||||
interface ContentComposer
|
||||
{
|
||||
/** Whether composing is possible on this site right now (e.g. Divi 5 active). */
|
||||
public function available(): bool;
|
||||
|
||||
/**
|
||||
* Validates the description for a new entry of $postType. Nothing is written.
|
||||
*
|
||||
* @param list<mixed> $sections
|
||||
* @return WP_Error|null Every problem of the description; null = valid.
|
||||
*/
|
||||
public function check(string $postType, array $sections): ?WP_Error;
|
||||
|
||||
/**
|
||||
* Composes the description for the new draft $postId and stores it. A WP_Error means the
|
||||
* description is invalid for this entry (nothing was written) – like a throw, it makes
|
||||
* lit/content-create delete the draft again.
|
||||
*
|
||||
* @param list<mixed> $sections
|
||||
* @return array{warnings: list<string>, outline: ?string}|WP_Error
|
||||
* @throws Throwable When storing failed.
|
||||
*/
|
||||
public function write(int $postId, string $postType, array $sections): array|WP_Error;
|
||||
}
|
||||
Reference in New Issue
Block a user