Skip to content

Bindings: Try to integrate SCF custom fields in the Attributes panel #169

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

Draft
wants to merge 3 commits into
base: trunk
Choose a base branch
from

Conversation

gziolo
Copy link
Member

@gziolo gziolo commented May 23, 2025

Related to #154.

This is a proof of concept that explores including registered custom SCF fields in the Attributes panel, which is currently limited to show only fields from the Post Meta binding source.

Screenshot 2025-05-23 at 14 45 34

This change alone allows connecting in the editor fields registered with SCF with all core blocks that support Block Bindings.

Approach

This prototype uses the Proxy object to override the getBlockBindingsSources method in wp.blocks global. Proxy is necessary because properties inside wp.blocks are set as readonly, so that is an elegant way to tap into the existing system.

I tried replicating the same Attributes panel by duplicating code from Gutenberg, but it uses some internal/private APIs that are difficult to mirror in a plugin. Therefore, I opted for an existing method that is used to construct the list of fields that can be connected with blocks. In the ideal world, some changes in Gutenberg would need to be applied to allow custom Block Bindings sources to define the list of fields to connect.

I haven’t explored that yet, but in the editor, users see the SCF Fields label in readonly mode without more details about the specific connected fields. It's probably caused by the fact that SCF Fields source is only registered on the server, so it doesn’t have the logic necessary to show something more specific like Post Meta does.

Demo

Screen.Recording.2025-05-23.at.14.51.20.mov

@gziolo gziolo marked this pull request as draft May 23, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant