fix: global usages follow the Theme Builder access (ruling Q17 M1)

GlobalUsages gets the Theme Builder access injected as a closure
(ThemeBuilderAccess::usageState(), wired at both construction sites through
DiviIntegration::globalUsages()). Theme Builder posts are named only while
the Theme Builder is visible to the account, otherwise only counted (also
in blocked_ids); a global edit that changes them needs canUse(), a writable
"Divi Theme Builder" group and edit_post. Without an injected access the
fail-safe default checks what canUse() checks. The duplicate
THEME_BUILDER_TYPES list gives way to DiviThemeBuilder::postTypes().

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-27 23:00:36 +02:00
co-authored by Claude Opus 5.5
parent 7590da4d96
commit 43dc3fb889
11 changed files with 271 additions and 32 deletions
+14 -2
View File
@@ -170,10 +170,22 @@ final class DiviIntegration implements Integration
$this->log,
$this->modules,
$this->diviWritable,
$this->schema
$this->schema,
$this->globalUsages()
);
}
/**
* The usages of library entries with this integration's Theme Builder access (ruling Q17 M1, review I-2):
* Theme Builder posts are named only while ThemeBuilderAccess::visible(), and a global edit that changes them
* needs the rights of every Theme Builder write (canUse(), in visible()) and a writable "Divi Theme Builder"
* group – as the Divi tools on those layouts.
*/
public function globalUsages(?\wpdb $db = null): GlobalUsages
{
return new GlobalUsages($db, $this->access->roles(), $this->themeBuilderAccess->usageState(...));
}
/** The group "Divi Theme Builder" (lit/tb-*), sharing this integration's Theme Builder access (Etappe 3b). */
public function themeBuilder(): ThemeBuilderIntegration
{
@@ -194,7 +206,7 @@ final class DiviIntegration implements Integration
$this->log,
$this->design,
new DiviComposition($this->modules, $this->design),
new GlobalEdits($this->access, new GlobalUsages(null, $this->access->roles())),
new GlobalEdits($this->access, $this->globalUsages()),
new ThemeBuilderEdits($this->themeBuilderAccess, fields: new DynamicFields($this->schema)),
new SimilarSections($this->access)
);