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:
@@ -90,7 +90,11 @@ final class DiviContentComposer implements ContentComposer
|
||||
|
||||
$saved = $this->saver->saveNew($postId, Serializer::document($layout['document']));
|
||||
|
||||
return ['warnings' => array_merge($warnings, $saved), 'outline' => (string) $outline['text']];
|
||||
return [
|
||||
'warnings' => array_merge($warnings, $saved),
|
||||
'outline' => (string) $outline['text'],
|
||||
'edit_url' => DiviPage::builderUrl($postId),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,12 @@ final class DiviPage
|
||||
|
||||
public function editUrl(): string
|
||||
{
|
||||
return (string) add_query_arg('et_fb', '1', (string) get_permalink($this->post));
|
||||
return self::builderUrl($this->post);
|
||||
}
|
||||
|
||||
/** The entry opened in the Divi Visual Builder – the edit_url of every Divi write (review I-1). */
|
||||
public static function builderUrl(WP_Post|int $post): string
|
||||
{
|
||||
return (string) add_query_arg('et_fb', '1', (string) get_permalink($post));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 : ''));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user