feat: jedes Divi-Tool und lit/content-create erklärt seine Divi-Fähigkeiten (RequiresDiviFeatures, DeclaresRequirements, FeatureSets); Tabelle Tool → Fähigkeiten als Test
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
e387d8d29e
commit
fdbda8012c
@@ -12,6 +12,8 @@ use LIT\MCP\Abilities\Rollback;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\Abilities\WriteFailed;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||||
use LIT\MCP\Integrations\Divi\Release\RequiresDiviFeatures;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
|
||||
@@ -27,7 +29,7 @@ defined('ABSPATH') || exit;
|
||||
* published, e.g. in the trash (ruling Q16), never needs the layouts and works despite a Theme Builder draft (with
|
||||
* DRAFT_WARNING, ruling Q20). Overlaps name only templates the user may edit, the others as a count (ruling Q21).
|
||||
*/
|
||||
final class TbActivateAbility implements Ability
|
||||
final class TbActivateAbility implements Ability, RequiresDiviFeatures
|
||||
{
|
||||
public const REASON = 'Die Vorlage konnte nicht umgeschaltet werden.';
|
||||
|
||||
@@ -97,6 +99,12 @@ final class TbActivateAbility implements Ability
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Switches _et_enabled of a listed template (Theme Builder functions); the right is a Divi role. */
|
||||
public function diviFeatures(array $input): array
|
||||
{
|
||||
return [DiviFeature::ThemeBuilderRead, DiviFeature::ThemeBuilderWrite, DiviFeature::Roles];
|
||||
}
|
||||
|
||||
public function permission(array $input): bool|WP_Error
|
||||
{
|
||||
$template = $this->access->changeableTemplate($input, ($input['enabled'] ?? null) === false);
|
||||
|
||||
@@ -12,6 +12,8 @@ use LIT\MCP\Abilities\Rollback;
|
||||
use LIT\MCP\Abilities\ToolResult;
|
||||
use LIT\MCP\Abilities\WriteFailed;
|
||||
use LIT\MCP\ChangeLog\ChangeLog;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||||
use LIT\MCP\Integrations\Divi\Release\RequiresDiviFeatures;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
|
||||
@@ -30,7 +32,7 @@ defined('ABSPATH') || exit;
|
||||
* Divi's "unused" marks a reattach removed (review M-12 c): the template is detached again, but Divi no longer
|
||||
* trashes it after seven days – harmless, it stays under detached in lit/tb-list.
|
||||
*/
|
||||
final class TbAssignAbility implements Ability
|
||||
final class TbAssignAbility implements Ability, RequiresDiviFeatures
|
||||
{
|
||||
public const REASON = 'Die Bedingungen der Vorlage konnten nicht gespeichert werden.';
|
||||
|
||||
@@ -103,6 +105,12 @@ final class TbAssignAbility implements Ability
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Reads and writes templates and their conditions (Theme Builder functions); the right is a Divi role. */
|
||||
public function diviFeatures(array $input): array
|
||||
{
|
||||
return [DiviFeature::ThemeBuilderRead, DiviFeature::ThemeBuilderWrite, DiviFeature::Roles];
|
||||
}
|
||||
|
||||
public function permission(array $input): bool|WP_Error
|
||||
{
|
||||
$template = $this->access->changeableTemplate($input);
|
||||
|
||||
@@ -17,6 +17,9 @@ use LIT\MCP\Integrations\Divi\Pages\DiviComposition;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviSaver;
|
||||
use LIT\MCP\Integrations\Divi\Pages\LayoutBuilder;
|
||||
use LIT\MCP\Integrations\Divi\Pages\SaveScope;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||||
use LIT\MCP\Integrations\Divi\Release\FeatureSets;
|
||||
use LIT\MCP\Integrations\Divi\Release\RequiresDiviFeatures;
|
||||
use RuntimeException;
|
||||
use Throwable;
|
||||
use WP_Error;
|
||||
@@ -33,7 +36,7 @@ defined('ABSPATH') || exit;
|
||||
* (TemplateBuild). Refused while the Theme Builder has an unsaved draft (E7). Never enables anything (F1, Q5):
|
||||
* Divi stores it with enabled '0' and a template that reads back enabled or as default is rolled back.
|
||||
*/
|
||||
final class TbCreateTemplateAbility implements Ability
|
||||
final class TbCreateTemplateAbility implements Ability, RequiresDiviFeatures
|
||||
{
|
||||
public const SOURCES = ['new', 'global', 'default', 'hidden'];
|
||||
|
||||
@@ -127,6 +130,29 @@ final class TbCreateTemplateAbility implements Ability
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates layouts and the template (Theme Builder functions); layouts with nodes are composed and saved like a
|
||||
* page (PageRead, PageWrite, Catalog, DesignRead, DynamicSources) – only when an area names nodes.
|
||||
*/
|
||||
public function diviFeatures(array $input): array
|
||||
{
|
||||
$features = [DiviFeature::ThemeBuilderRead, DiviFeature::ThemeBuilderWrite, DiviFeature::Roles];
|
||||
foreach (Template::AREAS as $area) {
|
||||
$spec = $input[$area] ?? null;
|
||||
if (is_array($spec) && is_array($spec['nodes'] ?? null) && $spec['nodes'] !== []) {
|
||||
return FeatureSets::merge($features, [
|
||||
DiviFeature::PageRead,
|
||||
DiviFeature::PageWrite,
|
||||
DiviFeature::Catalog,
|
||||
DiviFeature::DesignRead,
|
||||
DiviFeature::DynamicSources,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
return $features;
|
||||
}
|
||||
|
||||
public function permission(array $input): bool|WP_Error
|
||||
{
|
||||
return $this->access->canCreate() ?? $this->access->draftRefusal() ?? true;
|
||||
|
||||
@@ -7,6 +7,8 @@ namespace LIT\MCP\Integrations\Divi\ThemeBuilder;
|
||||
use LIT\MCP\Abilities\Ability;
|
||||
use LIT\MCP\Abilities\Annotations;
|
||||
use LIT\MCP\Abilities\Errors;
|
||||
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
|
||||
use LIT\MCP\Integrations\Divi\Release\RequiresDiviFeatures;
|
||||
use LIT\MCP\Integrations\WordPress\PostGuard;
|
||||
use WP_Error;
|
||||
|
||||
@@ -22,7 +24,7 @@ defined('ABSPATH') || exit;
|
||||
* reads like a missing one – P12) – active ones only as a count (hidden_live, ruling Q21); layout titles only for
|
||||
* layouts the user may edit; condition labels name objects by the stored ID only, never by title.
|
||||
*/
|
||||
final class TbListAbility implements Ability
|
||||
final class TbListAbility implements Ability, RequiresDiviFeatures
|
||||
{
|
||||
public const DETACHED_LIMIT = 50;
|
||||
|
||||
@@ -97,6 +99,12 @@ final class TbListAbility implements Ability
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Templates, layouts and conditions come from Divi's Theme Builder functions; the right is a Divi role. */
|
||||
public function diviFeatures(array $input): array
|
||||
{
|
||||
return [DiviFeature::ThemeBuilderRead, DiviFeature::Roles];
|
||||
}
|
||||
|
||||
public function permission(array $input): bool|WP_Error
|
||||
{
|
||||
return $this->access->canUse() ?? true;
|
||||
|
||||
Reference in New Issue
Block a user