fix: tb-assign reattaches only templates no Theme Builder post lists (audit L4)
"Detached" now means for lit/tb-assign what lit/tb-list shows as detached: DiviThemeBuilder::isListedAnywhere() looks for any _et_template row (live, draft or Theme Builder library post). A template another Theme Builder post lists is refused with or without reattach; nothing is written. 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:
@@ -23,7 +23,8 @@ defined('ABSPATH') || exit;
|
||||
* (ruling Q3/B3). A live template changes the website at once, so it is a dry run first and needs confirm: true
|
||||
* (ruling Q9/B22), listing both lists before/after and overlaps (identical and possible, B9) with other live
|
||||
* templates for the resulting lists. reattach: true puts a template a stale Theme Builder save removed back on the
|
||||
* live list (only on the user's request, B19) – always disabled, Divi's "unused" marks removed from it and its
|
||||
* live list (only on the user's request, B19; only one no Theme Builder post lists – tb-list's detached, audit L4)
|
||||
* – always disabled, Divi's "unused" marks removed from it and its
|
||||
* layouts, which must still be published (B10). Templates have no revisions: the previous conditions are in the
|
||||
* answer and the change log; a failed write restores them (and undoes the reattach).
|
||||
*/
|
||||
@@ -144,13 +145,30 @@ final class TbAssignAbility implements Ability
|
||||
return $this->write($template, $useOn['ids'], $excludeFrom['ids'], $reattach);
|
||||
}
|
||||
|
||||
/** A detached template needs reattach: true, a live Theme Builder post and published layouts (B10). */
|
||||
/**
|
||||
* A detached template needs reattach: true, a live Theme Builder post and published layouts (B10). Detached
|
||||
* means what tb-list shows as detached: no Theme Builder post lists it – a template of a Theme Builder library
|
||||
* item or draft is none (audit L4).
|
||||
*/
|
||||
private function reattachRefusal(Template $template, bool $reattach): ?WP_Error
|
||||
{
|
||||
if ($template->attached) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if ($this->access->store()->isListedAnywhere($template->id)) {
|
||||
return Errors::invalidInput(
|
||||
sprintf(
|
||||
'Vorlage %d ist keine entfernte Vorlage (siehe detached in lit/tb-list); nichts wurde gespeichert.',
|
||||
$template->id
|
||||
),
|
||||
[
|
||||
'template_id' => 'nur Vorlagen der Website (templates) oder entfernte Vorlagen (detached) aus '
|
||||
. 'lit/tb-list',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if (! $reattach) {
|
||||
$marked = $template->markedUnused === null
|
||||
? ''
|
||||
|
||||
Reference in New Issue
Block a user