fix: Admin-UX aus dem Review – Live-Gruppenfeedback, Protokollfilter, Divi-Hinweis, Rollen-Rückfrage
- Tools: „Ganze Gruppe“ und „Nur lesen“ wirken sofort auf die Zeilen (Option „wie Gruppe (…)“, gesperrte Selects mit Hinweis), der Server bleibt die Wahrheit; Markup trägt die nötigen data-Attribute. - Protokoll: Filter in eigenem Block über der Tabelle (Core blendet .tablenav .actions auf Telefonen aus); „Protokoll leeren“ nur bei Einträgen, rechtsbündig, mit Gesamtzahl über ChangeLog::count(). - Divi: Beschreibung unter „Prüfung starten“, Button primär solange ungetestet ohne frischen Bericht. - Zugriff: Rückfrage vor dem Speichern ohne Rolle oder ohne eigene Rolle. - Verbindung: HTTPS-Hinweis nicht doppelt neben der Statusliste. - Mobil: breitere Einstellungs-Spalte im Tools-Reiter. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
cc72f9b946
commit
1b73f0652a
+47
-16
@@ -68,29 +68,33 @@ final class AccessTab implements AdminTab
|
||||
)));
|
||||
|
||||
if ($roles === []) {
|
||||
self::warnOnce(
|
||||
'lit_mcp_no_roles',
|
||||
__('Keine Rolle freigegeben – niemand kann LIT MCP nutzen.', 'wp-lit-mcp')
|
||||
);
|
||||
self::warnOnce('lit_mcp_no_roles', self::noRolesWarning());
|
||||
} elseif (self::currentUserLosesAccess($roles)) {
|
||||
self::warnOnce(
|
||||
'lit_mcp_own_role',
|
||||
__(
|
||||
'Keine Ihrer Rollen ist mehr freigegeben – Sie selbst können LIT MCP nicht mehr nutzen.',
|
||||
'wp-lit-mcp'
|
||||
)
|
||||
);
|
||||
self::warnOnce('lit_mcp_own_role', self::ownRoleWarning());
|
||||
}
|
||||
|
||||
return $roles;
|
||||
}
|
||||
|
||||
private static function noRolesWarning(): string
|
||||
{
|
||||
return __('Keine Rolle freigegeben – niemand kann LIT MCP nutzen.', 'wp-lit-mcp');
|
||||
}
|
||||
|
||||
private static function ownRoleWarning(): string
|
||||
{
|
||||
return __(
|
||||
'Keine Ihrer Rollen ist mehr freigegeben – Sie selbst können LIT MCP nicht mehr nutzen.',
|
||||
'wp-lit-mcp'
|
||||
);
|
||||
}
|
||||
|
||||
public function render(): void
|
||||
{
|
||||
$allowed = $this->access->allowedRoles();
|
||||
$legend = __('Rollen mit Zugriff', 'wp-lit-mcp');
|
||||
|
||||
echo '<form method="post" action="options.php">';
|
||||
$this->openRolesForm();
|
||||
settings_fields(self::GROUP);
|
||||
// Makes an all-unchecked submission arrive as [''] instead of dropping the field.
|
||||
printf('<input type="hidden" name="%s[]" value="">', esc_attr(Access::OPTION));
|
||||
@@ -148,14 +152,41 @@ final class AccessTab implements AdminTab
|
||||
/** @param list<string> $roles */
|
||||
private static function currentUserLosesAccess(array $roles): bool
|
||||
{
|
||||
// Multisite super admins pass every capability check regardless of role.
|
||||
$own = self::ownRoles();
|
||||
|
||||
return $own !== null && array_intersect($own, $roles) === [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Roles of the current user, or null when they do not matter (multisite super admins
|
||||
* pass every capability check regardless of role).
|
||||
*
|
||||
* @return list<string>|null
|
||||
*/
|
||||
private static function ownRoles(): ?array
|
||||
{
|
||||
if (is_multisite() && is_super_admin()) {
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
$user = wp_get_current_user();
|
||||
return array_values(array_map('strval', (array) wp_get_current_user()->roles));
|
||||
}
|
||||
|
||||
return array_intersect((array) $user->roles, $roles) === [];
|
||||
/**
|
||||
* The form carries the two warnings as data attributes so the admin script can ask
|
||||
* before a save that leaves nobody, or the admin themselves, with access.
|
||||
*/
|
||||
private function openRolesForm(): void
|
||||
{
|
||||
$ask = ' ' . __('Trotzdem speichern?', 'wp-lit-mcp');
|
||||
$own = self::ownRoles();
|
||||
printf(
|
||||
'<form method="post" action="options.php" class="lit-mcp-access-form"'
|
||||
. ' data-confirm-none="%s" data-confirm-own="%s"%s>',
|
||||
esc_attr(self::noRolesWarning() . $ask),
|
||||
esc_attr(self::ownRoleWarning() . $ask),
|
||||
$own === null ? '' : sprintf(' data-own-roles="%s"', esc_attr(implode(' ', $own)))
|
||||
);
|
||||
}
|
||||
|
||||
private function renderConnections(): void
|
||||
|
||||
Reference in New Issue
Block a user