You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Added
Block Bindings sources declared in PHP (experimental): a class marked #[BlockBinding('acme/event')] is registered with register_block_bindings_source(), each public method marked #[BindingField] being a field a block chooses with "args": {"field": "remaining_seats"} (an __invoke() source receives every call). A field receives a BindingContext — the post or term of the block context, right in a query loop, the arguments, the bound attribute, post() and meta(Event::class) for typed meta — and any dependency the container resolves. Every source answers through one resolver, so none can forget its checks: nothing of a post the visitor cannot see (unpublished, password, read_post) or of a non-public term, text escaped where WordPress writes it as HTML, url fields sanitized, an HtmlString filtered like post content, a field that throws logged and the block keeping its content (thrown in debug mode), each value computed once per request. A declaration WordPress would reject or leave silently empty (name, missing or unsupported return type, field declared twice) is reported at discovery. pollora:make:binding generates a source
A server-rendered block becomes bindable by listing attributes under pollora.bindings in its block.json: the attributes are added to block_bindings_supported_attributes_{block} and the Blade view receives the bound value in $attributes. A block without render, or an attribute the block does not declare, is reported
Block Bindings sources for typed meta, formatted by their declared type: pollora/post-meta and pollora/term-meta (a term from the block context or the queried term) read a #[Meta] exposed in REST under a key that is not protected, as core/post-meta does; pollora/author-meta reads a user meta marked #[Meta(public: true)] only; pollora/option reads the options listed in block-bindings.options (none by default). A date shows in the site's format and language (format for another), a number with the site's separators (decimals), a boolean as Yes/No (true, false for other words), an enum by its label(), an array as a list, format: raw gives the stored value (a date in ISO 8601) and fallback the text of an empty meta
The editor side of Pollora's binding sources: the block's "Attributes" panel offers the fields of every #[BlockBinding] class (only on the post types it names) and, for pollora/post-meta, term-meta and author-meta, the meta of the post type being edited that the source may show (an attachment also to number attributes, for an image ID); pollora/option offers the listed options. A bound block shows its value in the editor, computed on the server by the same resolver as the page, escaped the same way and formatted in the site's language whatever the user's, through POST /wp-json/pollora/v1/block-bindings/resolve: one request for the blocks waiting for a value, allowed to who can edit the post (edit_posts without one). The values are read-only; the field's label shows while a value loads or when there is none. The script is resources/js/block-bindings.js, printed inline after wp-blocks with no build
#[Meta(media: true)] on an int property marks an attachment ID: bound to an image, it gives the URL (size), the alternative text, the title or the caption depending on the attribute; its input control is Media. #[Meta(public: true)] marks a meta anyone may see