diff --git a/assets/img/loosen-it-logo.svg b/assets/img/loosen-it-logo.svg new file mode 100644 index 0000000..8206141 --- /dev/null +++ b/assets/img/loosen-it-logo.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/Admin/SettingsPage.php b/src/Admin/SettingsPage.php index f635023..39cf16b 100644 --- a/src/Admin/SettingsPage.php +++ b/src/Admin/SettingsPage.php @@ -14,8 +14,11 @@ final class SettingsPage /** @var array */ private array $tabs = []; - /** @param list $tabs The first tab is the default. */ - public function __construct(array $tabs) + /** + * @param list $tabs The first tab is the default. + * @param string $logoUrl Loosen-IT logo shown top right of the page ('' = none). + */ + public function __construct(array $tabs, private string $logoUrl = '') { foreach ($tabs as $tab) { $this->tabs[$tab->slug()] = $tab; @@ -78,7 +81,9 @@ final class SettingsPage } $current = $this->currentTab(); - echo '

' . esc_html__('LIT MCP', 'wp-lit-mcp') . '

'; + echo '
'; + $this->renderLogo(); + echo '

' . esc_html__('LIT MCP', 'wp-lit-mcp') . '

'; $this->renderNotice(); echo '
'; } + private function renderLogo(): void + { + if ($this->logoUrl === '') { + return; + } + + printf( + '' + . '', + esc_url($this->logoUrl) + ); + } + private function renderNotice(): void { // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- display only. diff --git a/src/Plugin.php b/src/Plugin.php index 4de2e5d..eeb8a72 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -90,7 +90,7 @@ final class Plugin new ToolsTab($registry, $policy), new LogTab($changeLog, $limits), new LimitsTab(), - ]); + ], plugins_url('assets/img/loosen-it-logo.svg', self::$pluginFile)); if (is_admin()) { self::$settingsPage->register(); (new AdminNotices($status))->register(); diff --git a/tests/Unit/Admin/SettingsPageTest.php b/tests/Unit/Admin/SettingsPageTest.php index 4c20024..26e578f 100644 --- a/tests/Unit/Admin/SettingsPageTest.php +++ b/tests/Unit/Admin/SettingsPageTest.php @@ -57,6 +57,23 @@ final class SettingsPageTest extends TestCase self::assertSame(['verbindung', 'zugriff'], $page->tabSlugs()); } + public function testRendersTheLogoTopRightOnlyWhenGiven(): void + { + Functions\when('current_user_can')->justReturn(true); + Functions\when('esc_url')->returnArg(); + + ob_start(); + (new SettingsPage([$this->tab('verbindung', 'Verbindung')], 'https://example.test/logo.svg'))->render(); + $withLogo = (string) ob_get_clean(); + ob_start(); + (new SettingsPage([$this->tab('verbindung', 'Verbindung')]))->render(); + $withoutLogo = (string) ob_get_clean(); + + self::assertStringContainsString('Loosen-IT LogojustReturn(true);