Skip to content

Allow binding Date block to date_picker fields #206

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 1 commit into
base: trunk
Choose a base branch
from

Conversation

ockham
Copy link
Contributor

@ockham ockham commented Aug 4, 2025

As of WordPress/gutenberg#70585, the Date block can be used with Block Bindings.

This PR allows connecting it to SCF's date_picker field.

date-block-binding-scf

@ockham ockham self-assigned this Aug 4, 2025
@ockham
Copy link
Contributor Author

ockham commented Aug 4, 2025

Note that if the Date block is inserted and its datetime attribute is bound to an ACF date_picker field as seen in the animated gif in the PR description, it will currently show the wrong date on the frontend. The reason is that the datetime attribute is set to the current timestamp upon insertion (the reason for this is to distinguish the block from its deprecated version, which didn't have a datetime attribute, and would instead automatically "bind" to the containing post's publish date).

However, the Date block's datetime attribute isn't listed as bindable yet. While the Date block itself contains logic to provide backwards-compatibility, that code is currently only invoked if the attribute is not set at all.

We'll probably need to amend the latter logic to accommodate for cases where the attribute is set, but to the "wrong" (i.e. fallback) value, and needs to be overridden by Block Bindings.

Edit: Filed WordPress/gutenberg#71047 to address this.


In the long run, we'll need to find a way to avoid requiring complex orchestrations like this for anyone who wants to extend Block Bindings (by adding more block attributes as bindable), including Gutenberg. Here's a related Core Trac ticket.

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