fix: Theme Builder access needs edit_theme_options (ruling Q15)
Divi's Theme Builder page is gated by edit_theme_options; without it every TB ID answers like a missing one. Docblocks (Q16): the wp_die guard cannot restore WP_Hook nesting after a third-party wp_die inside a hook, and canEditTemplate expects IDs from Divi's list. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -15,7 +15,8 @@ defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
* Rights on Theme Builder objects (spec §4.5, E3 – never laxer than Divi): the Theme Builder at all needs
|
||||
* edit_others_posts (Divi's own TB requirement, F19/F23) and the Divi role option theme_builder (off for
|
||||
* edit_others_posts (Divi's own TB requirement, F19/F23), edit_theme_options (the gate of Divi's Theme
|
||||
* Builder page, theme-builder.php:2059-2063, ruling Q15) and the Divi role option theme_builder (off for
|
||||
* every role but administrator by default, F12); one layout or template additionally edit_post on it.
|
||||
* Without those, or with the group "Divi Theme Builder" disabled, every TB ID answers like a missing ID
|
||||
* (P12 pattern). The group's "nur lesen" stops writes (E9). Not final so abilities can be tested with a mock.
|
||||
@@ -52,6 +53,9 @@ class ThemeBuilderAccess
|
||||
if (! current_user_can('edit_others_posts')) {
|
||||
return Errors::forbidden('Keine Berechtigung für den Divi Theme Builder (edit_others_posts).');
|
||||
}
|
||||
if (! current_user_can('edit_theme_options')) {
|
||||
return Errors::forbidden('Keine Berechtigung für den Divi Theme Builder (edit_theme_options).');
|
||||
}
|
||||
|
||||
return $this->roles->refusal('theme_builder');
|
||||
}
|
||||
@@ -151,7 +155,11 @@ class ThemeBuilderAccess
|
||||
return $forWrite ? ($this->writableGate() ?? $post) : $post;
|
||||
}
|
||||
|
||||
/** Whether template $id may be named to this user (tb-list shows other IDs not at all, ruling Q8/B11). */
|
||||
/**
|
||||
* Whether template $id may be named to this user (tb-list shows other IDs not at all, ruling Q8/B11).
|
||||
* $id must come from Divi's own template list (templateIds()/liveTemplates()/detachedIds()): this checks
|
||||
* only the rights, not that $id is a template.
|
||||
*/
|
||||
public function canEditTemplate(int $id): bool
|
||||
{
|
||||
return $this->visible() && current_user_can('edit_post', $id);
|
||||
|
||||
Reference in New Issue
Block a user