Skip to content

fix(well): only emit well-sm and well-lg for the size attribute - #86

Merged
Sinetheta merged 1 commit into
masterfrom
fix/well-size
Oct 31, 2026
Merged

Sinetheta merged 1 commit into
masterfrom
fix/well-size

Conversation

@Sinetheta

Copy link
Copy Markdown
Member

What

[bs_well size="..."] built a well-<anything> class from whatever value the attribute carried. Bootstrap 3 only defines well-sm and well-lg, so any other value produced a class that matches nothing (and, pre-escaping, was a stray user-controlled token in the markup).

bs_well now whitelists sm and lg the same way bs_tooltip already whitelists placement: those two values add the size class, anything else (including an empty attribute) falls back to the plain well.

Design notes

  • Mirrors the existing in_array pattern in inc/bs_tooltip.php rather than introducing a new helper; the comparison is strict since shortcode attributes are always strings.
  • esc_attr() on the size is dropped because the value is now one of two literal constants, not user input.
  • Scope is deliberately limited to bs_well; other shortcodes with free-form class suffixes are untouched.

Verification

TDD: the new PHPUnit cases were added first and failed on well-xl being emitted, then the fix made them pass.

  • tests/phpunit/ShortcodeWellsTest.php: added sm, invalid (xl) and empty-size cases.
  • Full PHPUnit suite: 46 tests, 93 assertions, green.
  • Playwright e2e suite: 12 passed (the editor's Well dropdown inserts size="sm", still valid).

🤖 Generated with Claude Code

Bootstrap 3 defines only `well-sm` and `well-lg`, but `[bs_well]` built
`well-<anything>` from whatever value the attribute carried. Whitelist the
two valid sizes, the way `bs_tooltip` already does for `placement`, and
fall back to the plain `well` for any other or empty value.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Sinetheta

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 2fb027e and 4038b20.

Files selected for processing: 2
  • inc/bs_well.php
  • tests/phpunit/ShortcodeWellsTest.php

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

bs_well now adds a size class only when the size is exactly sm or lg. Tests cover sm, invalid (xl), and empty size values, and verify that shortcode content remains in the output.

Changes

Well shortcode size validation

Layer / File(s) Summary
Size class handling
inc/bs_well.php, tests/phpunit/ShortcodeWellsTest.php
bs_well adds a size class only for sm or lg. Tests verify the sm class, the default class for invalid and empty sizes, and preservation of shortcode content.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · up to 4038b

No actionable merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title names the actual change: the bs_well shortcode now emits a size class only for sm or lg. It is specific, follows the fix() convention, and matches the raw summary and objectives. It does not…
Description check Passed The description explains the change. It says bs_well now accepts only sm and lg, that other values and empty attributes fall back to plain well, and that esc_attr() was dropped. It also covers the bs_…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the actual change: the bs_well shortcode now emits a size class only for sm or lg. It is specific, follows the fix() convention, and matches the raw summary and objectives. It does not mention the test additions, which is expected.

Full details: Description check

Explanation

The description explains the change. It says bs_well now accepts only sm and lg, that other values and empty attributes fall back to plain well, and that esc_attr() was dropped. It also covers the bs_tooltip pattern, the new PHPUnit cases, and the e2e run. This matches the changeset.

Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 1 functions across 2 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

PHPStan (2.3.1)

PHPStan reported 1 non-file analysis error(s); analysis is incomplete

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@Sinetheta
Sinetheta merged commit 6097d57 into master Oct 31, 2026
2 checks passed
@Sinetheta
Sinetheta deleted the fix/well-size branch October 31, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant