-
Notifications
You must be signed in to change notification settings - Fork 42
Generate formidableforms.css from default styles for stylelint coverage #3364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Crabcyborg
merged 4 commits into
master
from
fix/issue-6684-formidableforms-css-stylelint
Sep 18, 2026
+71
−3
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
b84deec
Generate default formidableforms.css for stylelint coverage
vivi-the-going-merry[bot] 854e91c
Use FrmStyle::save_settings() to generate the default stylesheet
vivi-the-going-merry[bot] b0d9b32
Fix wp-env invocation and verify the file actually lands on disk
vivi-the-going-merry[bot] 738e0be
Silence formatting-only stylelint errors on the generated stylesheet,…
vivi-the-going-merry[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| <?php | ||
| /** | ||
| * Writes css/formidableforms.css so stylelint has a real generated file to | ||
| * check instead of an ignored one, using the plugin's own static-file | ||
| * generator (FrmStyle::save_settings(), the same method a real save of the | ||
| * Styles settings triggers) rather than reimplementing its render logic. | ||
| * | ||
| * Usage: wp eval 'require FrmAppHelper::plugin_path() . "/bin/generate-default-stylesheet.php";' | ||
| * (not `wp eval-file` directly - wp-env's cli container's working | ||
| * directory is the WordPress root, not this plugin's checkout, and the | ||
| * mounted plugin folder name isn't guaranteed.) | ||
| */ | ||
|
|
||
| if ( ! defined( 'WP_CLI' ) || ! WP_CLI ) { | ||
| return; | ||
| } | ||
|
|
||
| ( new FrmStyle() )->save_settings(); | ||
|
|
||
| // save_settings() writes wherever add_css_to_uploads_dir() resolves to, | ||
| // which can be outside this checkout (wp_upload_dir()) depending on file | ||
| // mod permissions - confirm the file actually landed where stylelint | ||
| // will look, rather than letting a silent miss pass as a green run. | ||
| $target = FrmStyle::get_generated_css_file_path( FrmStyle::add_css_to_uploads_dir() ) . '/' . FrmStylesController::get_file_name(); | ||
|
|
||
| if ( ! is_file( $target ) || ! filesize( $target ) ) { | ||
| WP_CLI::error( "No stylesheet generated at $target" ); | ||
| } | ||
|
|
||
| // Several of the style templates gate a selector's only declarations behind | ||
| // a single `! empty( $defaults[...] )` check with no fallback (e.g. a | ||
| // font-family rule that only prints when a custom font is set) - under the | ||
| // stock defaults that selector renders with nothing between its braces. | ||
| // That's inert in real output either way, but stylelint's block-no-empty | ||
| // has no way to tell "false setting produced this on purpose" from "typo'd | ||
| // selector" without evaluating the template's PHP, so strip empty rules | ||
| // (including any block left empty once its only content is removed, e.g. a | ||
| // media query whose sole rule was itself emptied) before lint sees the file. | ||
| $css = file_get_contents( $target ); | ||
| do { | ||
| $before = $css; | ||
| $css = preg_replace( '/[^{}]*\{\}/', '', $css ); | ||
| } while ( $css !== $before ); | ||
| file_put_contents( $target, $css ); | ||
|
|
||
| WP_CLI::success( "Generated $target" ); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invalid call to a static method. This would lead to a run time error.