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
@@ -25,7 +25,11 @@ defined('ABSPATH') || exit;
*/
final class LibraryIntegration implements Integration
{
/** @param (Closure(): bool)|null $diviWritable Whether lit/divi-insert is enabled (audit M2); null = always. */
/**
* @param (Closure(): bool)|null $diviWritable Whether lit/divi-insert is enabled (audit M2); null = always.
* @param GlobalUsages|null $usages The usages with the Theme Builder access (DiviIntegration::globalUsages(),
* review I-2); null = GlobalUsages' own fail-safe Theme Builder check.
*/
public function __construct(
private LibraryAccess $access,
private DiviPageLoader $loader,
@@ -35,7 +39,8 @@ final class LibraryIntegration implements Integration
private ChangeLog $log,
private DiviModules $modules,
private ?Closure $diviWritable = null,
private ?ContentSchema $schema = null
private ?ContentSchema $schema = null,
private ?GlobalUsages $usages = null
) {
}
@@ -61,7 +66,7 @@ final class LibraryIntegration implements Integration
$this->access,
$this->loader,
$this->design,
new GlobalUsages(null, $this->access->roles())
$this->usages ?? new GlobalUsages(null, $this->access->roles())
),
new LibrarySaveAbility(
$this->access,