Forms: Add asset pipeline and style support for custom fields#47930
Open
enejb wants to merge 4 commits intoadd/form-fields-label-dashboardfrom
Open
Forms: Add asset pipeline and style support for custom fields#47930enejb wants to merge 4 commits intoadd/form-fields-label-dashboardfrom
enejb wants to merge 4 commits intoadd/form-fields-label-dashboardfrom
Conversation
Contributor
|
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Contributor
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Add the ability to register editor, view, and dashboard styles for custom form fields, mirroring the existing script registration pattern. This allows custom field plugins to provide CSS/SCSS styles that are automatically enqueued in the appropriate contexts. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add plugin_file parameter to register_jetpack_form_field() that auto-resolves asset paths from conventional locations (build/index.js, build/editor-style.css, build/view.js, build/view-style.css, src/dashboard.js). Dependencies and versions are loaded from build/index.asset.php when available. This simplifies field registration from verbose explicit paths to just: 'plugin_file' => __FILE__ Individual assets can be disabled (set to false) or overridden with custom paths. Also updates documentation with template-based guide for creating new fields. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Move editor style registration from wp_enqueue_style to register_block_type with editor_style parameter, ensuring styles load in block editor iframe - Add comprehensive LLM prompt template to documentation for AI-assisted field creation, covering edge cases, accessibility, and best practices - Include example prompts for star rating, signature, and date range fields Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
a02c54f to
8bbef58
Compare
e386438 to
004216f
Compare
This was referenced Apr 3, 2026
Code Coverage SummaryCannot generate coverage summary while tests are failing. 🤐 Please fix the tests, or re-run the Code coverage job if it was something being flaky. |
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.
Fixes #
Proposed changes
Adds style support and convention-over-configuration asset discovery to the custom form field registry:
editor_style,view_style, anddashboard_styleregistration alongside existing script support, with corresponding_depsand_veroptions for each.plugin_fileis provided, assets are automatically resolved from conventional paths (build/index.js,build/editor-style.css,build/view.js,build/view-style.css,src/dashboard.js,build/dashboard-style.css). Dependencies and versions are loaded frombuild/index.asset.php. Individual assets can be overridden or disabled (set tofalse).register_block_type- Editor stylesheets are registered throughregister_block_type()block args (editor_style) rather than directwp_enqueue_style, ensuring styles load correctly inside the block editor iframe.custom-fields.mdinto a template-driven format with LLM prompt template, file templates for all field components, webpack configuration, build instructions, and an emoji rating worked example.Other information
This is PR 4 of 5 in a stacked PR series adding custom field extensibility to Jetpack Forms:
Related product discussion/links
Does this pull request change what data or activity we track or use?
No changes to tracked data or activity.
Testing instructions
Style registration defaults - Confirm the registry now accepts
editor_style,view_style, anddashboard_stylearguments with corresponding_depsand_veroptions.Convention-over-configuration asset resolution - Create a test custom field plugin with
plugin_file => __FILE__and place files at the conventional paths (build/index.js,build/editor-style.css,build/view-style.css). Verify the registry auto-discovers and registers them without explicit URL configuration. Verify setting an asset tofalsedisables it.Editor styles in iframe - Register a custom field with an
editor_style. Open the block editor and confirm the stylesheet loads inside the editor iframe (inspect the iframe document for the<link>tag with handlejetpack-forms-field-{type}-editor).View style enqueuing - Add a custom field with a
view_styleto a form. View the form on the frontend and confirm the stylesheet is enqueued (check page source for the style handlejetpack-forms-field-{type}-view).Dashboard style enqueuing - Register a custom field with a
dashboard_style. Open the Jetpack Forms responses page and confirm the stylesheet is loaded.Explicit override - Register a field with both
plugin_fileand an expliciteditor_scriptURL. Verify the explicit URL takes precedence over convention-based resolution.Asset file loading - Place a
build/index.asset.phpin the plugin directory returning custom dependencies and version. Verify these are used for the editor script registration instead of defaults.