From 5064409f9a9c29aff586852e1898bd092b3917c1 Mon Sep 17 00:00:00 2001 From: Jan-Niclas Loosen Date: Mon, 19 Oct 2026 14:40:50 +0200 Subject: [PATCH] =?UTF-8?q?refactor:=20Detach=20=E2=80=93=20toter=20Zweig,?= =?UTF-8?q?=20benannte=20Argumente;=20VariableDetachRewrite-Docblock=20nen?= =?UTF-8?q?nt=20leftover()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 5.5 --- .../Divi/Design/DiviDesignDetachAbility.php | 38 +++++++++---------- .../Divi/Design/VariableDetachRewrite.php | 2 +- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/Integrations/Divi/Design/DiviDesignDetachAbility.php b/src/Integrations/Divi/Design/DiviDesignDetachAbility.php index c5f970a..282dbcc 100644 --- a/src/Integrations/Divi/Design/DiviDesignDetachAbility.php +++ b/src/Integrations/Divi/Design/DiviDesignDetachAbility.php @@ -256,17 +256,17 @@ final class DiviDesignDetachAbility implements Ability, RequiresDiviFeatures } return new DetachTarget( - sprintf('Variable „%s“', $label), - $postIds, - new ReferenceUsageQuery([$id]), - fn (): NodeRewrite => new VariableDetachRewrite($id, $value, $type, ($this->unfiltered)()), - $nested + subject: sprintf('Variable „%s“', $label), + postIds: $postIds, + query: new ReferenceUsageQuery([$id]), + rewrite: fn (): NodeRewrite => new VariableDetachRewrite($id, $value, $type, ($this->unfiltered)()), + presets: $nested ? static fn (PresetBook $presets): PresetBook => $presets->withVariableResolved($id, $value, $affixes) : null, - 'Presets', - $notes, - self::ARCHIVE_HINT, - $notes === [] + nestedIn: 'Presets', + notes: $notes, + doneHint: self::ARCHIVE_HINT, + complete: $notes === [] ); } @@ -278,7 +278,7 @@ final class DiviDesignDetachAbility implements Ability, RequiresDiviFeatures { $problem = match (true) { $value === '' => 'ist leer', - VariableDetachRewrite::unsafe($value, true) => 'enthält einen Verweis', + VariableDetachRewrite::unsafe($value, markupAllowed: true) => 'enthält einen Verweis', VariableDetachRewrite::unsafe($value, ($this->unfiltered)()) => 'enthält Markup (< oder >), das dieses ' . 'Konto nicht speichern darf (unfiltered_html)', default => null, @@ -336,15 +336,15 @@ final class DiviDesignDetachAbility implements Ability, RequiresDiviFeatures $nested = $postIds === null && $book->nestedUsers($id) !== []; return new DetachTarget( - sprintf('%s „%s“', $scope->label(), $label), - $postIds, + subject: sprintf('%s „%s“', $scope->label(), $label), + postIds: $postIds, // Explicit references only (R10), also for a default preset: no withGroups(), implicit uses stay. - new PresetUsageQuery([['scope' => $scope, 'id' => $id, 'default' => false]]), - static fn (): NodeRewrite => new DetachRewrite($scope, $id), - $nested ? static fn (PresetBook $presets): PresetBook => $presets->withoutNestedRef($id) : null, - 'anderen Presets', - $book->defaultId($scope) === $id ? [sprintf(self::DEFAULT_NOTE, $label, $scope->name)] : [], - self::DELETE_HINT + query: new PresetUsageQuery([['scope' => $scope, 'id' => $id, 'default' => false]]), + rewrite: static fn (): NodeRewrite => new DetachRewrite($scope, $id), + presets: $nested ? static fn (PresetBook $presets): PresetBook => $presets->withoutNestedRef($id) : null, + nestedIn: 'anderen Presets', + notes: $book->defaultId($scope) === $id ? [sprintf(self::DEFAULT_NOTE, $label, $scope->name)] : [], + doneHint: self::DELETE_HINT ); } @@ -420,7 +420,7 @@ final class DiviDesignDetachAbility implements Ability, RequiresDiviFeatures { return function (array $raw) use ($target): DesignPlan|WP_Error { $before = PresetBook::fromDivi($raw); - $after = $target->presets === null ? $before : ($target->presets)($before); + $after = ($target->presets)($before); $diff = PresetDiff::between($before, $after); if ($diff === []) { return new DesignPlan($after->data(), [], PresetDiff::summary([])); diff --git a/src/Integrations/Divi/Design/VariableDetachRewrite.php b/src/Integrations/Divi/Design/VariableDetachRewrite.php index 44c49a9..514e0c4 100644 --- a/src/Integrations/Divi/Design/VariableDetachRewrite.php +++ b/src/Integrations/Divi/Design/VariableDetachRewrite.php @@ -14,7 +14,7 @@ defined('ABSPATH') || exit; * with variable, ruling V9): every attribute value that is exactly one reference $variable({"type":"content", * "value":{"name":"",…}})$ becomes the value – for a strings variable with the reference's own before/after * around it. References embedded in a longer text stay (Divi resolves them inside the text; cutting them out would - * change the text) and are named in notes(). Other references – colors, other variables, dynamic content – stay + * change the text) and are reported through leftover() (ReportsLeftovers). Other references – colors, other variables, dynamic content – stay * untouched. Pure PHP. */ final class VariableDetachRewrite implements NodeRewrite, ReportsLeftovers