feat: adapter-level Divi release lock, content-create and site status
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -6,8 +6,10 @@ namespace LIT\MCP\Integrations\Divi\ThemeBuilder;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\Release\Call;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviAdapter;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviLocked;
|
||||
use LIT\MCP\Integrations\Divi\Release\Manifest;
|
||||
use LIT\MCP\Integrations\Divi\Release\Mirror;
|
||||
use LIT\MCP\Integrations\Divi\Release\ReleaseGate;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
@@ -229,9 +231,13 @@ class DiviThemeBuilder implements DiviAdapter
|
||||
return $found !== null;
|
||||
}
|
||||
|
||||
/** @throws RuntimeException */
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
*/
|
||||
public function insertLayout(string $area, string $title): int
|
||||
{
|
||||
ReleaseGate::assertWritable();
|
||||
$type = self::LAYOUT_TYPES[$area] ?? throw new RuntimeException('unknown Theme Builder area ' . $area);
|
||||
$this->assertCanWrite('et_theme_builder_insert_layout');
|
||||
$id = $this->guarded(
|
||||
@@ -253,9 +259,11 @@ class DiviThemeBuilder implements DiviAdapter
|
||||
* @param array{title: string, layouts: array<string, array{id: int, enabled: bool}>, use_on: list<string>,
|
||||
* exclude_from: list<string>} $template
|
||||
* @throws RuntimeException
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
*/
|
||||
public function storeTemplate(int $themeBuilderId, array $template): int
|
||||
{
|
||||
ReleaseGate::assertWritable();
|
||||
$this->assertCanWrite('et_theme_builder_store_template', 'et_');
|
||||
$payload = [
|
||||
'title' => $template['title'],
|
||||
@@ -285,9 +293,11 @@ class DiviThemeBuilder implements DiviAdapter
|
||||
* template unused (stage3b README finding 10) – detachedIds() finds it, callers unmarkUnused() on reattach.
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
*/
|
||||
public function attach(int $themeBuilderId, int $templateId): void
|
||||
{
|
||||
ReleaseGate::assertWritable();
|
||||
$existing = get_post_meta($themeBuilderId, self::TEMPLATE_LIST, false);
|
||||
if (is_array($existing) && in_array((string) $templateId, array_map('strval', $existing), true)) {
|
||||
return;
|
||||
@@ -304,8 +314,10 @@ class DiviThemeBuilder implements DiviAdapter
|
||||
}
|
||||
}
|
||||
|
||||
/** @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written. */
|
||||
public function detach(int $themeBuilderId, int $templateId): void
|
||||
{
|
||||
ReleaseGate::assertWritable();
|
||||
delete_post_meta($themeBuilderId, self::TEMPLATE_LIST, (string) $templateId);
|
||||
}
|
||||
|
||||
@@ -316,9 +328,11 @@ class DiviThemeBuilder implements DiviAdapter
|
||||
* @param list<string> $useOn
|
||||
* @param list<string> $excludeFrom
|
||||
* @throws RuntimeException
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
*/
|
||||
public function setConditions(int $templateId, array $useOn, array $excludeFrom): void
|
||||
{
|
||||
ReleaseGate::assertWritable();
|
||||
foreach ([self::USE_ON => $useOn, self::EXCLUDE_FROM => $excludeFrom] as $key => $conditions) {
|
||||
delete_post_meta($templateId, $key);
|
||||
foreach (array_values(array_unique($conditions)) as $condition) {
|
||||
@@ -329,9 +343,13 @@ class DiviThemeBuilder implements DiviAdapter
|
||||
}
|
||||
}
|
||||
|
||||
/** @throws RuntimeException */
|
||||
/**
|
||||
* @throws RuntimeException
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
*/
|
||||
public function setEnabled(int $templateId, bool $enabled): void
|
||||
{
|
||||
ReleaseGate::assertWritable();
|
||||
$value = $enabled ? '1' : '0';
|
||||
update_post_meta($templateId, self::ENABLED, $value);
|
||||
if ((string) get_post_meta($templateId, self::ENABLED, true) !== $value) {
|
||||
@@ -339,9 +357,14 @@ class DiviThemeBuilder implements DiviAdapter
|
||||
}
|
||||
}
|
||||
|
||||
/** Removes Divi's "unused" mark (F19), as Divi's own save does for every listed post. */
|
||||
/**
|
||||
* Removes Divi's "unused" mark (F19), as Divi's own save does for every listed post.
|
||||
*
|
||||
* @throws DiviLocked When Divi is not released (spec §5.5) – before anything is written.
|
||||
*/
|
||||
public function unmarkUnused(int $postId): void
|
||||
{
|
||||
ReleaseGate::assertWritable();
|
||||
delete_post_meta($postId, self::UNUSED);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user