feat: declarative and operation-based menu item editing
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:
@@ -112,24 +112,34 @@ final class Errors
|
||||
|
||||
/**
|
||||
* A write failed and could not be rolled back completely – something may have been saved.
|
||||
* $state and $hint replace the post-oriented defaults for writes that are not about a post
|
||||
* (e.g. menus); $extra is merged into the error details.
|
||||
*
|
||||
* @param array<string, mixed> $extra
|
||||
*/
|
||||
public static function partialWrite(string $reason, ?int $postId = null, ?int $revisionId = null): WP_Error
|
||||
{
|
||||
$state = $postId === null
|
||||
public static function partialWrite(
|
||||
string $reason,
|
||||
?int $postId = null,
|
||||
?int $revisionId = null,
|
||||
?string $state = null,
|
||||
?string $hint = null,
|
||||
array $extra = []
|
||||
): WP_Error {
|
||||
$state ??= $postId === null
|
||||
? 'Möglicherweise wurde trotzdem ein Entwurf angelegt.'
|
||||
: sprintf('Eintrag %d ist möglicherweise teilweise geändert bzw. angelegt worden', $postId)
|
||||
. ($revisionId === null ? '.' : sprintf(' (Stand vorher: Revision %d).', $revisionId));
|
||||
$details = array_filter(
|
||||
$details = array_merge($extra, array_filter(
|
||||
['post_id' => $postId, 'revision_id' => $revisionId],
|
||||
static fn (?int $id): bool => $id !== null
|
||||
);
|
||||
));
|
||||
|
||||
return self::make(
|
||||
'partial_write',
|
||||
trim('Speichern fehlgeschlagen: ' . $reason) . ' Die Änderung konnte nicht vollständig zurückgenommen '
|
||||
. 'werden. ' . $state,
|
||||
'Den Aufruf nicht einfach wiederholen. Zuerst den aktuellen Stand prüfen (lit-content-get, bei einem '
|
||||
. 'neuen Entwurf lit-content-query) und ggf. über lit-revisions-list den vorherigen Stand '
|
||||
$hint ?? 'Den Aufruf nicht einfach wiederholen. Zuerst den aktuellen Stand prüfen (lit-content-get, bei '
|
||||
. 'einem neuen Entwurf lit-content-query) und ggf. über lit-revisions-list den vorherigen Stand '
|
||||
. 'wiederherstellen; dem Nutzer Bescheid geben.',
|
||||
500,
|
||||
$details
|
||||
|
||||
Reference in New Issue
Block a user