fix: neutral hint form for remaining client-facing tool mentions, Limits bounds accessor
Fix round 1 (task 10 review): - FieldValidator's "unknown field" validation error (reaches the client via validation_failed's fields) and PostPresenter's DIVI_HINT (surfaced in the result's hints array) still named lit-content-types/lit-content-update as plain lit-<name>; converted both to the neutral "lit/<name> (direkt: lit-<name>)" form like the other hints from task 10. Re-grepped src/ for any other client-facing error/field/hints text naming a direct-by-default tool as lit-<name> (descriptions/schemas excluded per Q11c) - none left. - Added Limits::bounds() (field => [min, max]) and made LimitsTab use it for the number inputs' min/max instead of a second, hardcoded copy of the same bounds. - LimitsTab now shows a description note when the configured upload_mb exceeds wp_max_upload_size() (PHP's upload_max_filesize/post_max_size), since WordPress would refuse a larger upload before this limit ever applies. 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:
+29
-5
@@ -40,16 +40,18 @@ final class LimitsTab implements AdminTab
|
||||
public function render(): void
|
||||
{
|
||||
$values = (new Limits())->all();
|
||||
$fields = [
|
||||
'upload_mb' => [__('Maximale Upload-/Download-Größe (MB)', 'wp-lit-mcp'), 1, 100],
|
||||
'log_retention_days' => [__('Protokoll aufbewahren (Tage)', 'wp-lit-mcp'), 1, 3650],
|
||||
'snapshot_count' => [__('Anzahl Designsystem-Snapshots (ab Etappe 4)', 'wp-lit-mcp'), 1, 100],
|
||||
$bounds = Limits::bounds();
|
||||
$labels = [
|
||||
'upload_mb' => __('Maximale Upload-/Download-Größe (MB)', 'wp-lit-mcp'),
|
||||
'log_retention_days' => __('Protokoll aufbewahren (Tage)', 'wp-lit-mcp'),
|
||||
'snapshot_count' => __('Anzahl Designsystem-Snapshots (ab Etappe 4)', 'wp-lit-mcp'),
|
||||
];
|
||||
|
||||
echo '<form method="post" action="options.php">';
|
||||
settings_fields(self::GROUP);
|
||||
echo '<table class="form-table"><tbody>';
|
||||
foreach ($fields as $key => [$label, $min, $max]) {
|
||||
foreach ($labels as $key => $label) {
|
||||
[$min, $max] = $bounds[$key];
|
||||
printf(
|
||||
'<tr><th scope="row"><label for="lit-mcp-%1$s">%2$s</label></th><td>'
|
||||
. '<input id="lit-mcp-%1$s" type="number" min="%3$d" max="%4$d" name="%5$s[%1$s]" value="%6$d">'
|
||||
@@ -63,7 +65,29 @@ final class LimitsTab implements AdminTab
|
||||
);
|
||||
}
|
||||
echo '</tbody></table>';
|
||||
$this->maybeRenderUploadSizeNotice($values['upload_mb']);
|
||||
submit_button();
|
||||
echo '</form>';
|
||||
}
|
||||
|
||||
/**
|
||||
* PHP's own upload_max_filesize/post_max_size (via wp_max_upload_size()) can be lower than
|
||||
* what is configured here – WordPress itself would then refuse a large upload/download before
|
||||
* this limit ever applies. A warning only, since the two are independent knobs.
|
||||
*/
|
||||
private function maybeRenderUploadSizeNotice(int $uploadMb): void
|
||||
{
|
||||
$serverMaxMb = (int) floor(wp_max_upload_size() / (1024 * 1024));
|
||||
if ($serverMaxMb <= 0 || $uploadMb <= $serverMaxMb) {
|
||||
return;
|
||||
}
|
||||
|
||||
$message = sprintf(
|
||||
/* translators: 1: configured limit in MB, 2: server limit in MB */
|
||||
__('%1$d MB übersteigt das Server-Limit von %2$d MB (upload_max_filesize/post_max_size).', 'wp-lit-mcp'),
|
||||
$uploadMb,
|
||||
$serverMaxMb
|
||||
);
|
||||
printf('<p class="description">%s</p>', esc_html($message));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user