feat(admin): Prüfroute je Profil und Reiter „Compatibility“
Die generische CheckRoute (POST lit-mcp/v1/<id>-check, für Divi weiter /divi-check) ersetzt DiviCheckRoute: Lock je Profil mit Besitzer-Token, Bericht je Profil, Rücksprung auf den neuen Reiter und Hook lit_mcp_compat_changed (Divi lädt darauf seinen Freigabe-Status neu). Der Reiter „Compatibility“ zeigt je Plugin Zustand (Wort und Icon), Hinweis zur Stufe, Fähigkeiten, getestete und freigegebene Versionen und den letzten Bericht, mit Prüfen, Freigeben und Zurückziehen (Recht manage_options, Allowlist der Profil-ID, Nonce je Profil). Freigeben serverseitig nur mit frischem grünem Bericht. Der Load-Hook lit_mcp_compat_profile_load bereitet den Abbau des DiviTab vor, der bis dahin parallel läuft. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
7d6a97a54e
commit
85f4138b36
+49
-13
@@ -4,6 +4,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Admin;
|
||||
|
||||
use Closure;
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
/**
|
||||
@@ -30,12 +32,15 @@ final class SettingsPage
|
||||
* @param string $logoUrl Loosen-IT logo shown top right of the page ('' = none).
|
||||
* @param string $assetsUrl URL of the plugin's assets/ directory ('' = no own CSS/JS).
|
||||
* @param string $version Asset version for cache busting.
|
||||
* @param (Closure(string): ?string)|null $profileLabel Label of a compatibility profile by ID, null = unknown;
|
||||
* names the profile in the compat_* notices.
|
||||
*/
|
||||
public function __construct(
|
||||
private array $baseTabs,
|
||||
private string $logoUrl = '',
|
||||
private string $assetsUrl = '',
|
||||
private string $version = ''
|
||||
private string $version = '',
|
||||
private ?Closure $profileLabel = null
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -74,6 +79,7 @@ final class SettingsPage
|
||||
public function removableQueryArgs(array $args): array
|
||||
{
|
||||
$args[] = 'lit_mcp_notice';
|
||||
$args[] = 'lit_mcp_profile';
|
||||
|
||||
return $args;
|
||||
}
|
||||
@@ -107,6 +113,10 @@ final class SettingsPage
|
||||
'Tab „Protokoll“: jede Änderung des Assistenten mit Benutzer, Ergebnis und Zeitpunkt.',
|
||||
'wp-lit-mcp'
|
||||
),
|
||||
__('Passt es zu Divi, Pods & Co.?', 'wp-lit-mcp') => __(
|
||||
'Tab „Compatibility“: Fremd-Plugins prüfen, Versionen freigeben und sehen, was gesperrt ist.',
|
||||
'wp-lit-mcp'
|
||||
),
|
||||
];
|
||||
$content = '';
|
||||
foreach ($items as $title => $text) {
|
||||
@@ -163,7 +173,7 @@ final class SettingsPage
|
||||
public function currentTab(): string
|
||||
{
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only tab switch.
|
||||
$requested = isset($_GET['tab']) ? sanitize_key(wp_unslash((string) $_GET['tab'])) : '';
|
||||
$requested = is_string($_GET['tab'] ?? null) ? sanitize_key(wp_unslash($_GET['tab'])) : '';
|
||||
|
||||
$tabs = $this->tabs();
|
||||
|
||||
@@ -236,23 +246,26 @@ final class SettingsPage
|
||||
);
|
||||
}
|
||||
|
||||
/** "<Label>: " for a compat_* notice naming a known profile; the ID from the address bar only looks the label up. */
|
||||
private function noticeProfile(string $key): string
|
||||
{
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display only.
|
||||
$id = is_string($_GET['lit_mcp_profile'] ?? null) ? sanitize_key(wp_unslash($_GET['lit_mcp_profile'])) : '';
|
||||
$label = str_starts_with($key, 'compat_') && $id !== '' && $this->profileLabel !== null
|
||||
? ($this->profileLabel)($id)
|
||||
: null;
|
||||
|
||||
return $label === null ? '' : $label . ': ';
|
||||
}
|
||||
|
||||
private function renderNotice(): void
|
||||
{
|
||||
// phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display only.
|
||||
$key = isset($_GET['lit_mcp_notice']) ? sanitize_key(wp_unslash((string) $_GET['lit_mcp_notice'])) : '';
|
||||
$key = is_string($_GET['lit_mcp_notice'] ?? null) ? sanitize_key(wp_unslash($_GET['lit_mcp_notice'])) : '';
|
||||
$notice = match ($key) {
|
||||
'revoked' => ['success', __('Verbindung widerrufen.', 'wp-lit-mcp')],
|
||||
'revoke_failed' => ['error', __('Die Verbindung konnte nicht widerrufen werden.', 'wp-lit-mcp')],
|
||||
'cleared' => ['success', __('Protokoll geleert.', 'wp-lit-mcp')],
|
||||
'divi_checked' => ['success', __('Divi-Prüfung abgeschlossen; das Ergebnis steht unten.', 'wp-lit-mcp')],
|
||||
'divi_check_running' => [
|
||||
'warning',
|
||||
__('Es läuft bereits eine Divi-Prüfung; bitte in ein paar Minuten erneut versuchen.', 'wp-lit-mcp'),
|
||||
],
|
||||
'divi_check_failed' => [
|
||||
'error',
|
||||
__('Die Divi-Prüfung ist abgebrochen; Details stehen im PHP-Error-Log.', 'wp-lit-mcp'),
|
||||
],
|
||||
'divi_released' => ['success', __('Die Divi-Version ist für LIT MCP freigegeben.', 'wp-lit-mcp')],
|
||||
'divi_release_refused' => [
|
||||
'error',
|
||||
@@ -270,6 +283,29 @@ final class SettingsPage
|
||||
'error',
|
||||
__('Für die installierte Divi-Version gibt es auf dieser Website keine Freigabe.', 'wp-lit-mcp'),
|
||||
],
|
||||
'compat_checked' => ['success', __('Prüfung abgeschlossen; das Ergebnis steht unten.', 'wp-lit-mcp')],
|
||||
'compat_check_running' => [
|
||||
'warning',
|
||||
__('Es läuft bereits eine Prüfung; bitte in ein paar Minuten erneut versuchen.', 'wp-lit-mcp'),
|
||||
],
|
||||
'compat_check_failed' => [
|
||||
'error',
|
||||
__('Die Prüfung ist abgebrochen; Details stehen im PHP-Error-Log.', 'wp-lit-mcp'),
|
||||
],
|
||||
'compat_released' => ['success', __('Die Version ist für LIT MCP freigegeben.', 'wp-lit-mcp')],
|
||||
'compat_release_refused' => [
|
||||
'error',
|
||||
__(
|
||||
// phpcs:ignore Generic.Files.LineLength.TooLong -- WordPress.WP.I18n forbids splitting the text argument.
|
||||
'Freigabe nicht möglich: Der letzte Prüfbericht ist nicht grün oder passt nicht mehr zur installierten Version oder zur Plugin-Version. Bitte die Prüfung erneut ausführen.',
|
||||
'wp-lit-mcp'
|
||||
),
|
||||
],
|
||||
'compat_withdrawn' => ['success', __('Freigabe zurückgezogen.', 'wp-lit-mcp')],
|
||||
'compat_withdraw_failed' => [
|
||||
'error',
|
||||
__('Für die installierte Version gibt es auf dieser Website keine Freigabe.', 'wp-lit-mcp'),
|
||||
],
|
||||
default => null,
|
||||
};
|
||||
|
||||
@@ -277,7 +313,7 @@ final class SettingsPage
|
||||
printf(
|
||||
'<div class="notice notice-%s is-dismissible"><p>%s</p></div>',
|
||||
esc_attr($notice[0]),
|
||||
esc_html($notice[1])
|
||||
esc_html($this->noticeProfile($key) . $notice[1])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user