fix(forms): modernize CSS themes with :where() zero-specificity reset#848
Open
faisalahammad wants to merge 1 commit into
Open
fix(forms): modernize CSS themes with :where() zero-specificity reset#848faisalahammad wants to merge 1 commit into
faisalahammad wants to merge 1 commit into
Conversation
Replace heavy opinionated color themes (light/dark/red/blue/green) with minimal :where() CSS reset that has zero specificity — themes and plugins always win. - Rewrite form-basic.css with :where() selectors (~48 lines vs ~320) - Remove form-themes.css content (deprecated placeholder) - Remove theme options from admin UI (only Inherit + Basic remain) - Add migration 5.0.0 to convert theme-* selections to basic - Add defensive theme-* fallback in get_stylesheet() - Remove mc4wp-form-theme class generation - Use CSS logical properties for RTL support - Keep alert color classes at normal specificity (functional) Fixes ibericode#844
38cbb64 to
feb077f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace the 5 opinionated color themes (light/dark/red/blue/green) with a minimal
:where()CSS reset that uses zero specificity — themes and plugins always override without fighting specificity wars. Reduces CSS from ~320 lines to ~48.Fixes #844
Changes
assets/src/css/form-basic.cssBefore:
After:
Why:
:where()always has specificity 0, so theme CSS wins without!important. Honeypot hiding uses normal specificity (must not be overridable). CSS logical properties (margin-inline-end) replace directional rules for native RTL support.assets/src/css/form-themes.cssDeprecated — contains only a comment. Minified output is 0 bytes.
includes/admin/migrations/5.0.0-modernize-css.phpNew file. Converts all
mc4wp-formposts withtheme-*CSS setting tobasic, rebuildsmc4wp_form_stylesheetsoption withoutthemes.Why: Existing forms using color themes need migration to avoid broken references.
includes/forms/class-form.phpBefore:
After:
Why: Un-migrated forms (e.g. fresh zip install without running migration) still work —
theme-*values silently fall back tobasic.includes/forms/class-form-element.phpRemoved
mc4wp-form-themeclass generation block.includes/forms/class-asset-manager.phpRemoved
'themes'fromget_registered_stylesheets()— now returns only['basic'].includes/forms/views/tabs/form-appearance.phpRemoved 5 color theme
<option>entries from the CSS dropdown. Only "Inherit" and "Basic" remain.mc4wp_admin_form_css_optionsfilter preserved for third-party use.tests/FormTest.phpAdded assertions for
theme-*→basicfallback and custom stylesheet passthrough.Testing
Test 1: Basic CSS renders correctly
Result: Inputs layout correctly, no forced colors/borders.
Test 2: Inherit option works
Result: Form uses active WP theme styles.
Test 3: Existing theme- forms migrated*
Result: "Basic" selected. Frontend renders with basic reset.
Test 4: Admin UI simplified
Result: Dropdown shows only "Inherit" and "Basic" options.
Test 5: RTL checkbox spacing
Result: Checkbox margin on correct side (
margin-inline-end).