fix: content-create with divi returns the Visual Builder edit_url (review I-1)

DiviPage::builderUrl() is shared by DiviPage::editUrl() and the content
composer, which now returns edit_url; content-create without divi keeps
the wp-admin link. divi-write-smoke checks the builder URL and, new in
section 9, the M1/M2 gates live (raw Divi markup refused; Divi read-only
stops content-create divi and execute-ability lit/divi-insert).

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 19:19:04 +02:00
co-authored by Claude Opus 5.5
parent 5f596b8a17
commit 4fe0810049
7 changed files with 74 additions and 9 deletions
@@ -41,7 +41,8 @@ interface ContentComposer
* lit/content-create delete the draft again.
*
* @param list<mixed> $sections
* @return array{warnings: list<string>, outline: ?string}|WP_Error
* @return array{warnings: list<string>, outline: ?string, edit_url?: string}|WP_Error edit_url: where
* the new content is edited (e.g. the Divi builder) instead of the WordPress editor.
* @throws Throwable When storing failed.
*/
public function write(int $postId, string $postType, array $sections): array|WP_Error;
@@ -167,7 +167,7 @@ final class ContentCreateAbility implements Ability
$warnings = array_merge($prepared['warnings'], $layout['warnings'] ?? []);
return $this->result($postId, $postType, $input, $warnings, $layout['outline'] ?? null);
return $this->result($postId, $postType, $input, $warnings, $layout);
}
/**
@@ -220,10 +220,10 @@ final class ContentCreateAbility implements Ability
/**
* @param array<string, mixed> $input
* @param list<string> $warnings
* @param string|null $outline Divi outline of the new layout (with divi only).
* @param array<string, mixed>|null $layout What the composer wrote (with divi only): outline, edit_url.
* @return array<string, mixed>
*/
private function result(int $postId, string $postType, array $input, array $warnings, ?string $outline): array
private function result(int $postId, string $postType, array $input, array $warnings, ?array $layout): array
{
// The draft is saved – failures from here on are logged and reported as warnings only.
$change = (new PostSaveFollowUp($this->name(), $this->log, $postId, 'der Entwurf', $warnings))
@@ -234,10 +234,13 @@ final class ContentCreateAbility implements Ability
$result = $change->result(sprintf('"%s" als Entwurf angelegt (ID %d).', $title, $postId), $post)
->changed((string) $postId, $postType, 'created', $title)
->urls((string) get_preview_post_link($postId), (string) get_edit_post_link($postId, 'raw'));
->urls(
(string) get_preview_post_link($postId),
(string) ($layout['edit_url'] ?? get_edit_post_link($postId, 'raw'))
);
if (array_key_exists('divi', $input)) {
// The Divi tools lock on tree_rev (ruling P16): the next lit-divi-* call can use it right away.
$result->outline($outline)
$result->outline(isset($layout['outline']) ? (string) $layout['outline'] : null)
->with('tree_rev', Rev::of($post instanceof WP_Post ? (string) $post->post_content : ''));
}