Feature: Add binding connector to the site editor.#253
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## trunk #253 +/- ##
============================================
+ Coverage 10.54% 11.51% +0.96%
- Complexity 4284 4285 +1
============================================
Files 279 284 +5
Lines 34576 34697 +121
============================================
+ Hits 3647 3994 +347
+ Misses 30929 30703 -226
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR adds a binding connector feature for the site editor, enabling users to connect block attributes (paragraphs, headings, images, buttons) to custom fields when creating custom templates for custom post types.
Key Changes:
- Refactored REST API endpoint for better maintainability and removed feature flag gate
- Added comprehensive JavaScript infrastructure for block bindings (store, hooks, utilities, field processing)
- Implemented site editor vs post editor context awareness with appropriate field handling
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
includes/rest-api/class-acf-rest-types-endpoint.php |
Refactored with constants, helper methods, improved validation, and added field name to REST response |
assets/src/js/bindings/utils.js |
New utility functions for field filtering, type checking, template parsing, and data formatting |
assets/src/js/bindings/store.js |
New Redux store for managing field metadata across block bindings |
assets/src/js/bindings/sources.js |
Refactored binding source with site editor support and field label placeholders |
assets/src/js/bindings/index.js |
Updated imports to include new store module |
assets/src/js/bindings/hooks.js |
Custom React hooks for site editor context, field fetching, and binding state management |
assets/src/js/bindings/field-processing.js |
Extracted field processing logic for better code organization and reusability |
assets/src/js/bindings/constants.js |
Configuration defining which field types bind to which block attributes |
assets/src/js/bindings/block-editor.js |
Refactored block controls using new hooks and utilities for cleaner code |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Codecov seems not to be reading correctly the coverage. As |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
That's expected; that test is a JS unit test, not e2e, and CI still doesn't run JS tests until #250 is merged (which also includes coverage tracking for JS tests) |
42c0413 to
069d849
Compare
069d849 to
3cd165b
Compare
| await page.waitForTimeout(2000); // Give the editor a moment to fully load | ||
|
|
||
| // Close the welcome guide modal if it appears by pressing Escape | ||
| await page.keyboard.press( 'Escape' ); | ||
| await page.waitForTimeout( 500 ); |
There was a problem hiding this comment.
Wouldn't the frameLocator wait anyway without the waitForTimeout? What's the benefit of adding these hardcoded timeouts?
| }; | ||
| }, [ postType ] ); | ||
|
|
||
| return { fields, isLoading, error }; |
| public function test_get_scf_fields() { | ||
| $post_type_object = array( 'slug' => 'post' ); | ||
|
|
||
| $fields = $this->endpoint->get_scf_fields( $post_type_object ); |
There was a problem hiding this comment.
Side note, not from this PR, but I just realized get_scf_fields doesn't take into account show_in_rest; is this expected behavior?
There was a problem hiding this comment.
As far as I remember, is on purpose, so that way showing the selector on the sidebar does not depend on them. But we could make it restrictive.
|
Followed up with #279 to skip bindings e2e tests in WP versions < 6.5 |
What
Adds the ability to connect paragraphs and images to custom fields in the site editor. Enhancing the creation of custom templates for custom post types with custom fields.
Screenshare
SCF-edit.mp4
It needs
The field group must have REST API enabled.
Fields must have Block Bindings setting enabled.