feat: Tools tab without the code-module note; direct counter only as a warning above 25
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
+8
-18
@@ -75,7 +75,7 @@ final class ToolsTab implements AdminTab
|
||||
$groups = $this->registry->grouped();
|
||||
$labels = $this->registry->labels();
|
||||
|
||||
$this->renderIntro(isset($groups['divi']));
|
||||
$this->renderIntro();
|
||||
$this->renderCounter(count($policy->directNames($this->registry->abilities())));
|
||||
|
||||
// Lets WordPress' postbox script remember which groups each user closed.
|
||||
@@ -95,7 +95,7 @@ final class ToolsTab implements AdminTab
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
private function renderIntro(bool $diviAvailable): void
|
||||
private function renderIntro(): void
|
||||
{
|
||||
echo '<p class="description">'
|
||||
. esc_html__('Lege fest, welche Tools Claude nutzen kann.', 'wp-lit-mcp') . ' '
|
||||
@@ -114,35 +114,25 @@ final class ToolsTab implements AdminTab
|
||||
printf('<dt>%s</dt><dd>%s</dd>', esc_html($term), esc_html($text));
|
||||
}
|
||||
echo '</dl>';
|
||||
|
||||
if ($diviAvailable) {
|
||||
echo '<p class="description">' . esc_html__(
|
||||
'Das Divi-Code-Modul ist immer erlaubt (nur nachrangig) und hat keine eigene Einstellung.',
|
||||
'wp-lit-mcp'
|
||||
) . '</p>';
|
||||
}
|
||||
}
|
||||
|
||||
/** Only when the direct tools get many: then the count is worth a warning, otherwise it is noise. */
|
||||
private function renderCounter(int $direct): void
|
||||
{
|
||||
$warn = $direct > self::DIRECT_WARNING_THRESHOLD;
|
||||
if ($direct <= self::DIRECT_WARNING_THRESHOLD) {
|
||||
return;
|
||||
}
|
||||
|
||||
$counter = sprintf(
|
||||
/* translators: %d: number of direct tools */
|
||||
_n('Direkt sichtbar: %d Tool', 'Direkt sichtbar: %d Tools', $direct, 'wp-lit-mcp'),
|
||||
$direct
|
||||
);
|
||||
printf(
|
||||
'<div class="notice notice-%s inline"><p><strong>%s</strong>',
|
||||
$warn ? 'warning' : 'info',
|
||||
esc_html($counter)
|
||||
);
|
||||
|
||||
if ($warn) {
|
||||
printf('<div class="notice notice-warning inline"><p><strong>%s</strong>', esc_html($counter));
|
||||
echo ' – '
|
||||
. esc_html__('Viele direkte Tools kosten in claude.ai in jeder Unterhaltung Kontext.', 'wp-lit-mcp')
|
||||
. ' '
|
||||
. esc_html__('Selten gebrauchte Tools besser auf „indirekt“ stellen.', 'wp-lit-mcp');
|
||||
}
|
||||
echo '</p></div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -216,10 +216,9 @@ final class ToolsTabTest extends TestCase
|
||||
$html = $this->render(['@group:divi' => 'disabled']);
|
||||
|
||||
// guide, site-status, media-preview (divi disabled, media-upload indirect by default).
|
||||
self::assertStringContainsString('Direkt sichtbar: 3 Tools', $html);
|
||||
// Few direct tools: no counter at all (only a warning above the threshold is shown).
|
||||
self::assertStringNotContainsString('Direkt sichtbar', $html);
|
||||
self::assertStringNotContainsString('Kontext', $html);
|
||||
self::assertLessThan(strpos($html, 'class="postbox'), strpos($html, 'Direkt sichtbar'));
|
||||
self::assertStringContainsString('<div class="notice notice-info inline"><p><strong>Direkt sichtbar: 3 Tools', $html);
|
||||
}
|
||||
|
||||
public function testWarnsWhenMoreThan25ToolsAreDirect(): void
|
||||
@@ -238,8 +237,9 @@ final class ToolsTabTest extends TestCase
|
||||
self::assertStringContainsString('<div class="notice notice-warning inline">', $warned);
|
||||
self::assertStringNotContainsString('notice-warning', $notWarned);
|
||||
self::assertStringContainsString('<h2 class="hndle">WordPress <span class="count">(26 Tools)</span>', $warned);
|
||||
self::assertStringContainsString('Direkt sichtbar: 25 Tools', $notWarned);
|
||||
self::assertStringNotContainsString('Direkt sichtbar', $notWarned);
|
||||
self::assertStringNotContainsString('Kontext', $notWarned);
|
||||
self::assertLessThan(strpos($warned, 'class="postbox'), strpos($warned, 'Direkt sichtbar'));
|
||||
}
|
||||
|
||||
public function testUnknownGroupsUseTheirIdAndEverythingIsEscaped(): void
|
||||
@@ -311,7 +311,7 @@ final class ToolsTabTest extends TestCase
|
||||
self::assertStringContainsString('id="' . $m[1] . '"', $this->select($html, 'lit/guide'));
|
||||
}
|
||||
|
||||
public function testIntroUsesPlainLanguageAndMentionsDiviOnlyWhenDiviIsAvailable(): void
|
||||
public function testIntroUsesPlainLanguageWithoutImplementationNotes(): void
|
||||
{
|
||||
$withDivi = $this->render([]);
|
||||
$withoutDivi = $this->render([], new IntegrationRegistry($this->integration('core', [['lit/guide', true, true]])));
|
||||
@@ -320,7 +320,7 @@ final class ToolsTabTest extends TestCase
|
||||
self::assertStringContainsString('Claude findet es bei Bedarf über die Tool-Suche.', $withDivi);
|
||||
self::assertStringNotContainsString('Meta-Tools', $withDivi);
|
||||
self::assertStringNotContainsString('discover', $withDivi);
|
||||
self::assertStringContainsString('Divi-Code-Modul', $withDivi);
|
||||
self::assertStringNotContainsString('Divi-Code-Modul', $withDivi);
|
||||
self::assertStringNotContainsString('Divi-Code-Modul', $withoutDivi);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user