WordPress / wp-movies-demo

Demo of the Interactivity API
https://wpmovies.dev
GNU General Public License v2.0
195 stars 42 forks source link

Use block bindings instead of custom blocks for some actors / movies data. #72

Closed cbravobernal closed 1 week ago

cbravobernal commented 2 weeks ago

Before block bindings, all the movies and actors data were coming from post-meta in form of custom blocks.

This PR replaces them with block bindings. We want this project to be an example of all developer tools WordPress is now providing.

In a future, ideally, most of this data should not be custom sources, but just meta data with paragraphs connected to that post metadata. But the custom fields are protected (unprotecting them would imply some big changes on the database) and also have some tweaks (date formatting and that stuff, which is not yet solved in post-meta bound cases).

I will keep iterating these blocks with future developments!

cbravobernal commented 2 weeks ago

I didn't want to unprotect the data, as, for this case, is provided by an external source, which could be a good pattern too (we can set userCanEditBinding to false, though).

Also, is easier to follow simple examples like this one rather than creating an "inteligent" source that provides the data depending on any option or variable.

Current movies and actors posts only contains the description of them, no the rest of the data, that's another reason I went this way.

SantosGuillamot commented 2 weeks ago

In my opinion, we shouldn't promote creating a custom source for each block when they could be abstracted. That's why we use source_args. It's true that in some cases we are formatting the value, but I am not sure if that's reason enough. Maybe it is a good use case to use the new filter as an example?

I would also like to migrate the movie-data block and use bindings for language, budget, and revenue. If we have to create a new source for each meta field we want to connect to, it doesn't seem scalable.

Having said that, this is just my opinion, I'd love to hear more thoughts.

cbravobernal commented 1 week ago

Let's close this one and think about moving to public post metadata.

gziolo commented 1 week ago

Good call. Let’s rethink the approach so it serves as the example of how much you can simplify development by using the API shipped with WordPress 6.7.