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:
@@ -64,6 +64,17 @@ class DiviThemeBuilder
|
||||
/** Actions of wp_insert_post() that name a post's ID after its row exists, earliest first (Q19). */
|
||||
private const INSERT_ACTIONS = ['clean_post_cache', 'save_post', 'wp_insert_post'];
|
||||
|
||||
/**
|
||||
* Every Theme Builder post type – the Theme Builder posts, the templates and the layouts (review M-3: one list for
|
||||
* GlobalUsages and lit/library-find-similar; ContentSchema keeps its own literal list in the WordPress layer).
|
||||
*
|
||||
* @return list<string>
|
||||
*/
|
||||
public static function postTypes(): array
|
||||
{
|
||||
return array_merge([self::THEME_BUILDER, self::TEMPLATE], array_values(self::LAYOUT_TYPES));
|
||||
}
|
||||
|
||||
/** "header", "body" or "footer" for a layout post type, else null. */
|
||||
public static function areaOf(string $postType): ?string
|
||||
{
|
||||
|
||||
@@ -66,6 +66,20 @@ class ThemeBuilderAccess
|
||||
return ($this->visible === null || ($this->visible)()) && $this->canUse() === null;
|
||||
}
|
||||
|
||||
/**
|
||||
* The Theme Builder access of a global library edit (GlobalUsages, ruling Q17 M1, review I-2): visible = Theme
|
||||
* Builder posts may be named (visible()); usable = a global edit may change them – the rights of every Theme
|
||||
* Builder write (canUse(), part of visible()) and a writable group, as the Divi tools on layouts.
|
||||
*
|
||||
* @return array{visible: bool, usable: bool}
|
||||
*/
|
||||
public function usageState(): array
|
||||
{
|
||||
$visible = $this->visible();
|
||||
|
||||
return ['visible' => $visible, 'usable' => $visible && $this->writableGate() === null];
|
||||
}
|
||||
|
||||
public function writableGate(): ?WP_Error
|
||||
{
|
||||
if ($this->writable === null || ($this->writable)()) {
|
||||
|
||||
Reference in New Issue
Block a user