feat: settings page with connection tab, admin notices and site health test
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:
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Admin;
|
||||
|
||||
/**
|
||||
* Admin notices for administrators (Etappe-0 follow-up d). Uses only cached check
|
||||
* results so no HTTP request runs on ordinary admin page loads.
|
||||
*/
|
||||
final class AdminNotices
|
||||
{
|
||||
public function __construct(private ConnectionStatus $status)
|
||||
{
|
||||
}
|
||||
|
||||
public function register(): void
|
||||
{
|
||||
add_action('admin_notices', [$this, 'render']);
|
||||
}
|
||||
|
||||
/** @return list<string> */
|
||||
public function messages(bool $onOwnPage): array
|
||||
{
|
||||
$messages = [];
|
||||
if (! $this->status->oauthEnabled()) {
|
||||
$messages[] = __(
|
||||
'LIT MCP: Der OAuth-Server ist deaktiviert (Filter wpmedia_mcp_oauth_server_enabled).',
|
||||
'wp-lit-mcp'
|
||||
) . ' ' . __('Claude kann sich nicht verbinden.', 'wp-lit-mcp');
|
||||
}
|
||||
|
||||
$discovery = $this->status->discovery(false);
|
||||
if (is_array($discovery) && ($discovery['status'] ?? 'good') === 'critical') {
|
||||
$messages[] = __(
|
||||
'LIT MCP: Die OAuth-Discovery-Dokumente unter /.well-known/ sind nicht erreichbar.',
|
||||
'wp-lit-mcp'
|
||||
) . ' ' . __('Details unter Werkzeuge → Website-Zustand.', 'wp-lit-mcp');
|
||||
}
|
||||
|
||||
if ($onOwnPage && ! $this->status->https()) {
|
||||
$messages[] = __(
|
||||
'LIT MCP: Die Website läuft ohne HTTPS; claude.ai verbindet sich nur mit HTTPS-Websites.',
|
||||
'wp-lit-mcp'
|
||||
);
|
||||
}
|
||||
|
||||
return $messages;
|
||||
}
|
||||
|
||||
public function render(): void
|
||||
{
|
||||
if (! current_user_can('manage_options')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$screen = function_exists('get_current_screen') ? get_current_screen() : null;
|
||||
$onOwnPage = is_object($screen) && $screen->id === 'settings_page_' . SettingsPage::SLUG;
|
||||
foreach ($this->messages($onOwnPage) as $message) {
|
||||
printf('<div class="notice notice-warning"><p>%s</p></div>', esc_html($message));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user