Skip to content

Expand block bindings support using WordPress core's supported bindings list#715

Draft
Copilot wants to merge 9 commits intotrunkfrom
copilot/expand-block-bindings-support
Draft

Expand block bindings support using WordPress core's supported bindings list#715
Copilot wants to merge 9 commits intotrunkfrom
copilot/expand-block-bindings-support

Conversation

Copy link
Contributor

Copilot AI commented Feb 19, 2026

WordPress 6.7+ supports block bindings on additional blocks and attributes beyond the original four. This PR extends Remote Data Blocks to automatically support all blocks that WordPress core designates as bindable by querying the editor settings directly.

Changes

Dynamic Block Detection:

  • Query __experimentalBlockBindingsSupportedAttributes from WordPress's block editor settings in both the filter and UI components
  • Automatically support all blocks that WordPress core designates as bindable
  • No hardcoded list to maintain - stays in sync with WordPress automatically
  • Works with current blocks (paragraph, heading, image, button, details, post blocks) and future additions

Generic UI Controls:

  • Refactored BlockBindingControls to dynamically generate UI controls for any block/attribute combination
  • Removed hardcoded switch statement - now handles any bindable block generically
  • Maps attribute names to appropriate field types with sensible defaults
  • Auto-generates human-readable labels for attributes
  • Optimized with useSelect and useMemo React hooks for better performance

New attributes supported:

  • core/button - added UI controls for linkTarget, rel (in addition to existing url, text)
  • core/image - added UI control for title (in addition to existing url, alt)

Extensibility:
Custom blocks automatically work when registered with WordPress core's binding mechanisms:

// Make your block bindable through WordPress core
registerBlockType( 'my-plugin/custom-block', {
  attributes: {
    fieldName: {
      type: 'string',
      __experimentalLabel: 'Field Label', // Automatically bindable
    },
  },
} );

Implementation:

  • Query WordPress settings dynamically in addUsesContext() filter to determine supported blocks
  • Refactored BlockBindingControls to query supported attributes and generate controls dynamically
  • Added field type constants for new attributes with fallback to 'string' type
  • Added fallback support for custom blocks like remote-data-blocks/remote-html
  • Added comprehensive test coverage with mocked block editor store
  • Updated documentation to explain automatic detection mechanism

This approach ensures the plugin automatically stays compatible with current and future WordPress versions without manual updates.

Original prompt

This section details on the original issue you should resolve

<issue_title>Expand block bindings support</issue_title>
<issue_description>WordPress has expanded support for block bindings to additional blocks and attributes since our last release of Remote Data Blocks. We should make sure all of these additional blocks are supported, including dynamic blocks.

See the Bindings developer reference for a list of supported core blocks and attributes. Also, take note of the section Extending supported attributes as we should support any blocks and attributes added through these filters.

</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 19, 2026 01:24
- Add support for core/details block
- Add support for dynamic blocks: post-title, post-date, post-excerpt, post-featured-image, post-author
- Add support for additional button attributes: linkTarget and rel
- Add support for image title attribute
- Add filter to allow dynamic registration of bindable blocks
- Update BlockBindingControls to handle new blocks and attributes
- Update documentation with supported blocks and extension guide

Co-authored-by: maxschmeling <112691+maxschmeling@users.noreply.github.com>
Co-authored-by: maxschmeling <112691+maxschmeling@users.noreply.github.com>
Co-authored-by: maxschmeling <112691+maxschmeling@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for additional block bindings in Remote Data Blocks Expand block bindings support to all WordPress core blocks Feb 19, 2026
Copilot AI requested a review from maxschmeling February 19, 2026 01:29
@maxschmeling
Copy link
Contributor

@copilot this is how you get the list of supported blocks/attributes. You do not need to add another filter to register them with RDB directly.

const settings = wp.data.select('core/block-editor').getSettings();
const supportedAttributes = settings.__experimentalBlockBindingsSupportedAttributes;
// e.g. supportedAttributes['core/paragraph'] => ['content']
// e.g. supportedAttributes['core/image'] => ['id', 'url', 'title', 'alt', 'caption']

…nstead of hardcoded list

Based on feedback, replaced the hardcoded SUPPORTED_CORE_BLOCKS list with a dynamic query to WordPress's block editor settings. This ensures automatic compatibility with all blocks that WordPress designates as supporting bindings, including future additions.

- Query __experimentalBlockBindingsSupportedAttributes from block editor store
- Remove hardcoded list of supported blocks
- Keep new field type constants for UI controls
- Update tests to mock the block editor store
- Update documentation to reflect automatic detection

Co-authored-by: maxschmeling <112691+maxschmeling@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 19, 2026

@copilot this is how you get the list of supported blocks/attributes. You do not need to add another filter to register them with RDB directly.

...

Updated to use __experimentalBlockBindingsSupportedAttributes from the block editor settings instead of maintaining a hardcoded list. The plugin now queries WordPress core directly to determine which blocks support bindings, ensuring automatic compatibility with current and future WordPress versions. Changes in commit afc52aa.

Copilot AI changed the title Expand block bindings support to all WordPress core blocks Expand block bindings support using WordPress core's supported bindings list Feb 19, 2026
@maxschmeling
Copy link
Contributor

@copilot BlockBindingControls needs to handle the generic case, not just known combinations of blocks/attributes

Refactored BlockBindingControls to dynamically generate UI controls based on WordPress's supported bindings list instead of using hardcoded switch statements. This allows it to work with any block that WordPress designates as supporting bindings.

- Query __experimentalBlockBindingsSupportedAttributes to get bindable attributes for each block
- Dynamically generate controls for each supported attribute
- Map attribute names to appropriate field types with sensible defaults
- Auto-generate human-readable labels for attributes
- Add fallback support for custom blocks like remote-data-blocks/remote-html
- Remove hardcoded switch statement with specific block cases

Co-authored-by: maxschmeling <112691+maxschmeling@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 19, 2026

@copilot BlockBindingControls needs to handle the generic case, not just known combinations of blocks/attributes

Refactored to handle generic block/attribute combinations. The component now queries WordPress's supported bindings for each block and dynamically generates controls instead of using hardcoded cases. Works with any block WordPress designates as bindable. Changes in commit 02211c7.

Copilot AI and others added 3 commits February 19, 2026 06:01
- Use useSelect hook to memoize editor settings and prevent unnecessary re-renders
- Use useMemo to cache supported attributes computation
- Remove unnecessary div wrapper around controls
- Apply key prop directly to components instead of wrapper

Co-authored-by: maxschmeling <112691+maxschmeling@users.noreply.github.com>
- Add key prop to Fragment wrapper in map for proper React reconciliation
- Change @ts-ignore to @ts-expect-error for experimental API suppression

Co-authored-by: maxschmeling <112691+maxschmeling@users.noreply.github.com>
Co-authored-by: maxschmeling <112691+maxschmeling@users.noreply.github.com>
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.

Expand block bindings support

2 participants