feat: lit/tb-create-template – disabled templates, all or nothing

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-09-27 16:09:49 +02:00
co-authored by Claude Opus 5.5
parent 54922a9f7e
commit 42b9b384d5
10 changed files with 1165 additions and 46 deletions
@@ -124,7 +124,10 @@ class ThemeBuilderAccess
return $post;
}
/** Template $templateId for the Theme Builder tools; any other ID, or a hidden Theme Builder, is not found. */
/**
* Template $templateId for the Theme Builder tools. Any other ID, a hidden Theme Builder and a template the
* user may not edit (canEditTemplate) answer identically: not found (ruling Q18, P12 – like tb-list, Q8/B11).
*/
public function template(mixed $templateId, bool $forWrite): WP_Post|WP_Error
{
$id = PostGuard::id($templateId);
@@ -140,7 +143,7 @@ class ThemeBuilderAccess
! $post instanceof WP_Post
|| $post->post_type !== DiviThemeBuilder::TEMPLATE
|| (string) $post->post_status !== 'publish'
|| ! $this->visible()
|| ! $this->canEditTemplate($id)
) {
return Errors::notFound(
sprintf('Theme-Builder-Vorlage %d gibt es nicht.', $id),
@@ -148,10 +151,6 @@ class ThemeBuilderAccess
);
}
if (! current_user_can('edit_post', $id)) {
return Errors::forbidden(sprintf('Keine Berechtigung, Theme-Builder-Vorlage %d zu bearbeiten.', $id));
}
return $forWrite ? ($this->writableGate() ?? $post) : $post;
}