Editing custom fields from connected blocks

WordPress 6.5 introduced the Block Bindings API, which, among other things, allows users to easily connect blocks to custom fields. For example, users can directly connect paragraph content without the need to create a custom blockBlock Block is the abstract term used to describe units of markup that, composed together, form the content or layout of a webpage using the WordPress editor. The idea combines concepts of what in the past may have achieved with shortcodes, custom HTML, and embed discovery into a single consistent API and user experience., and it will show the selected post metaMeta Meta is a term that refers to the inside workings of a group. For us, this is the team that works on internal WordPress sites like WordCamp Central and Make WordPress. value.

Until now, when this connection existed, the UIUI User interface to edit the paragraph was locked, preventing users from modifying its value.

WordPress 6.6 introduces the possibility of editing the value of the custom fieldCustom Field Custom Field, also referred to as post meta, is a feature in WordPress. It allows users to add additional information when writing a post, eg contributors’ names, auth. WordPress stores this information as metadata. Users can display this meta data by using template tags in their WordPress themes. directly from the block when they are connected.

You can see the potential of it in this quick demo:

As can be seen in the video, whenever a block attribute is connected to the Post Meta source, it automatically connects to the custom field value while editing.

Among improvements to the UI to clarify when a block is connected, it comes with some functionalities that are worth mentioning as well:

Custom fields can be updated from a query loopLoop The Loop is PHP code used by WordPress to display posts. Using The Loop, WordPress processes each post to be displayed on the current page, and formats it according to how it matches specified criteria within The Loop tags. Any HTML or PHP code in the Loop will be processed on each post. https://codex.wordpress.org/The_Loop.

While using blocks in the query loop, if they are connected to Post Meta, they are also editable.

When multiple blocks are connected to the same custom field, their value is synced

Users can only edit the custom fields from posts where they have permission

Right now, this is restricted to coreCore Core is the set of software required to run WordPress. The Core Development Team builds WordPress. sources like Post Meta or Pattern Overrides, but the idea is to open the relevant APIs to be used by any external source as well.

Read more about this iteration for Block Bindings at #60956

Props to @juanmaguitar for review

#6-6, #block-bindings