Skip to content

Conversation

@cbravobernal
Copy link
Contributor

@cbravobernal cbravobernal commented Nov 24, 2025

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.

@cbravobernal cbravobernal self-assigned this Nov 24, 2025
@cbravobernal cbravobernal requested review from Copilot and priethor and removed request for Copilot November 24, 2025 15:33
@cbravobernal cbravobernal added the [Type] Enhancement New feature or request label Nov 24, 2025
@cbravobernal cbravobernal added this to the 6.7.0 milestone Nov 24, 2025
@codecov
Copy link

codecov bot commented Nov 24, 2025

Codecov Report

❌ Patch coverage is 96.01770% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 11.51%. Comparing base (53b7351) to head (70fe014).
⚠️ Report is 1 commits behind head on trunk.

Files with missing lines Patch % Lines
...ncludes/rest-api/class-acf-rest-types-endpoint.php 76.00% 6 Missing ⚠️
assets/src/js/bindings/sources.js 90.47% 2 Missing ⚠️
assets/src/js/bindings/hooks.js 98.46% 1 Missing ⚠️
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     
Flag Coverage Δ
e2e 30.68% <64.17%> (+1.09%) ⬆️
javascript 2.53% <90.54%> (+2.27%) ⬆️
phpunit 6.63% <76.00%> (+0.57%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@cbravobernal
Copy link
Contributor Author

Codecov seems not to be reading correctly the coverage. As assets/src/js/bindings/field-processing.jsis 100% covered and is saying it is at 0 😕

@cbravobernal cbravobernal marked this pull request as ready for review December 1, 2025 12:34
@github-actions
Copy link

github-actions bot commented Dec 1, 2025

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props cbravobernal, priethor.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@cbravobernal cbravobernal modified the milestones: 6.7.0, 6.7.1 Dec 2, 2025
@priethor
Copy link
Contributor

Codecov seems not to be reading correctly the coverage. As assets/src/js/bindings/field-processing.jsis 100% covered and is saying it is at 0 😕

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)

@cbravobernal cbravobernal force-pushed the feature/add-binding-connector-site-editor branch from 42c0413 to 069d849 Compare December 10, 2025 15:20
@cbravobernal cbravobernal force-pushed the feature/add-binding-connector-site-editor branch from 069d849 to 3cd165b Compare December 10, 2025 15:50
@cbravobernal cbravobernal merged commit 5a894f5 into trunk Dec 10, 2025
9 checks passed
@cbravobernal cbravobernal deleted the feature/add-binding-connector-site-editor branch December 10, 2025 16:35
Copy link
Contributor

@priethor priethor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late to the party; works as expected 🚀

Please note that after this PR, e2e tests are broken for WP 6.2 in trunk.

Comment on lines +75 to +79
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 );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't the frameLocator wait anyway without the waitForTimeout? What's the benefit of adding these hardcoded timeouts?

};
}, [ postType ] );

return { fields, isLoading, error };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is error shown anywhere?

public function test_get_scf_fields() {
$post_type_object = array( 'slug' => 'post' );

$fields = $this->endpoint->get_scf_fields( $post_type_object );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@priethor priethor modified the milestones: 6.7.1, 6.8 Dec 10, 2025
@priethor
Copy link
Contributor

Followed up with #279 to skip bindings e2e tests in WP versions < 6.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Type] Enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants