WordPress / WordPress/secure-custom-fields
Guidance on extending SCF with custom fields using JavaScript libraries
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 131
- Forks
- 64
- Avg merge
- 10m
- Merged PRs (30d)
- 1
Description
Hi 👋
First of all, thank you for the work on Secure Custom Fields — I’m currently experimenting with it in a personal fork and really enjoying the developer experience so far, and i think when a finish this, send a pull request to add this fields to the main fork.
I’m exploring the idea of creating some new custom field types that I believe could be useful for real-world projects, for example:
- A Likert scale field
- A QR code field (generated from user input)
- A field that uses html5-qrcode to scan QR codes directly from the camera
- A field to save a signature
- A field to add a button to call funcitons on PHP or AJAX
I followed the contributing guide and development setup here:
https://github.com/WordPress/secure-custom-fields/blob/trunk/docs/contributing/index.md#development-setup
So far, I’ve been able to:
- Create and register a custom field class successfully
- Have the field appear correctly in the admin UI
However, I’ve run into some questions regarding JavaScript assets and third-party libraries, and I’d like to understand the intended architecture before going further.
Questions
1. Field-specific scripts
How are field-specific scripts supposed to be enqueued?
I haven’t yet found a clear example of where or how SCF expects custom field JS to be registered/enqueued (especially for input/admin context).
2. Webpack & ES module imports
Is it expected (or supported) to extend the existing webpack setup to allow imports like:
import { Html5QrcodeScanner } from "html5-qrcode";
Or is SCF intentionally avoiding direct npm/ESM imports inside field scripts?
3. Third-party libraries
Is there any guideline or recommendation regarding:
- Including third-party JS libraries (bundled or vendored)?
- Whether fields should rely only on vanilla JS or WordPress-provided packages?
I want to make sure I’m aligning with the project’s philosophy and best practices before continuing or proposing anything upstream.
Any guidance, pointers to existing patterns, or clarification would be greatly appreciated.
Thanks again for the project and for your time 🙌
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with docs/contributing/index.md, especially the development setup section, then inspect the existing custom field registration and asset-loading patterns mentioned by the issue. The work is complete when SCF's supported approach for field-specific scripts, webpack or ES module imports, and third-party JavaScript libraries is clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php, webpack, wordpress
- Domain
- developer-experience, documentation, tooling
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100