Skip to content

Toggle settings only with the checkbox; explain each setting - #185

Merged
PDowney merged 1 commit into
mainfrom
settings-checkbox-help
Nov 28, 2026
Merged

PDowney merged 1 commit into
mainfrom
settings-checkbox-help

Conversation

@PDowney

@PDowney PDowney commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Only the checkbox changes a setting now. Before, a click on a setting's title or its description turned it on or off, and so did a drag across that text to select it. There were two causes:

  • add_settings_field() got label_for, so WordPress printed the row title as <label for>.
  • The description sat inside a <label> that wrapped the checkbox.

Checkbox fields now register without label_for and carry the option name in an option argument, so the title is plain text. Each checkbox has one label, marked screen-reader-text so it takes no space on screen, and aria-describedby points at its help. The text areas keep label_for, because a click on their title only puts the cursor in the box.

Every setting explains itself. Three paragraphs, "What it does", "Effect on your site" and "Performance", replace the one-line descriptions. They come from the new es_optimizer_get_option_help(), and every string is translatable. The text was checked against WordPress 7.0 and 7.1.5 core. For example:

  • Classic Theme Styles changes nothing on block themes.
  • Recent Comments CSS prints only on classic themes with widget support.
  • Post via Email also makes wp-mail.php refuse requests.
  • Removing the version tag is not real protection.

The domain lists show the same three parts, then their format rules under "Format:".

Internal API changes:

  • es_optimizer_get_checkbox_field_definition() and es_optimizer_register_checkbox_field() no longer take a description.
  • es_optimizer_get_option_name_from_field_args() reads option first.

Testing

  • composer check-all passes: PHPCS, PHPMD, Psalm and its taint analysis, PHPStan, Rector, and PHPUnit with 178 tests and 732 assertions. The new tests cover:
    • the field arguments;
    • one screen-reader label per checkbox;
    • aria-describedby;
    • the help following the checkbox, outside any label;
    • three non-empty parts for every option;
    • the order of the text-area help.
  • A browser check on a disposable WordPress 7.1.5 site, in Chromium, Firefox and WebKit:
    • clicks on the title and on each help paragraph, and drag-selects over the help and the title, toggle nothing;
    • a click on the box and Space toggle it;
    • each checkbox's accessible name is its title alone;
    • nothing was saved;
    • axe-core finds 0 WCAG 2.1 A/AA violations on the form.
  • Control run against main: clicking the title toggled 10 of 11 settings, and clicking the description text toggled all 11. With this branch, neither toggles anything.
  • npm run lint:md, codespell, Plugin Check's PHPCS rulesets, and msgfmt -c on the regenerated POT are clean, and gitleaks finds no leaks.

The changelog entries are under "Unreleased" in CHANGELOG.md and readme.txt. The version is unchanged; this is planned to ship with the next feature release.

🤖 Generated with Claude Code

A click on a setting's title or description, or a drag across it to
select the text, turned the setting on or off: WordPress printed the
title as a label for the checkbox, and the description sat inside a
second label. Checkboxes now register without label_for, so the title
is plain text, and carry a label for screen readers only.

Each setting now shows three short paragraphs below its control: what
it does, its effect on the site, and its performance gain or cost. They
replace the one-line descriptions and follow what each option does on
WordPress 7.0 and 7.1. The two domain lists show the same three parts,
then their format rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation security testing core i18n frontend labels Nov 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for contributing to EngineScript Site Optimizer!

Before we review:

  • Have you tested your changes with WordPress 7.0+?
  • Are your changes compatible with PHP 8.3+?
  • Have you followed WordPress coding standards?
  • Did you update the CHANGELOG.md if needed?

Security Reminder
This plugin stores per-site settings and emits browser resource hints, so please ensure:

  • All user input is properly sanitized
  • All output is properly escaped
  • No security vulnerabilities are introduced

We'll review your PR soon.

@codacy-production

codacy-production Bot commented Nov 28, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 17 complexity · 0 duplication

Metric Results
Complexity 17
Duplication 0

View in Codacy

🟢 Coverage 100.00% diff coverage · +0.11% coverage variation

Metric Results
Coverage variation ✅ +0.11% coverage variation (-1.00%)
Diff coverage ✅ 100.00% diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (fa83a1f) 871 841 96.56%
Head commit (49b2193) 900 (+29) 870 (+29) 96.67% (+0.11%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#185) 108 108 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@PDowney
PDowney merged commit d145c95 into main Nov 28, 2026
28 checks passed
@github-actions
github-actions Bot deleted the settings-checkbox-help branch November 28, 2026 02:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core documentation Improvements or additions to documentation frontend i18n security testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant