The WordPress coreCoreCore is the set of software required to run WordPress. The Core Development Team builds WordPress. development team builds WordPress! Follow this site for general updates, status reports, and the occasional code debate. There’s lots of ways to contribute:
Found a bugbugA bug is an error or unexpected result. Performance improvements, code optimization, and are considered enhancements, not defects. After feature freeze, only bugs are dealt with, with regressions (adverse changes from the previous version) being the highest priority.?Create a ticket in the bug tracker.
The BlockBlockBlock 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. Bindings user interface has been upgraded to improve how different data sources are displayed in the editor. Users can now easily switch between sources, as well as bind and unbind attributes with a single click.
For WordPress developers.
On the server
A new filterFilterFilters are one of the two types of Hooks https://codex.wordpress.org/Plugin_API/Hooks. They provide a way for functions to modify data of other functions. They are the counterpart to Actions. Unlike Actions, filters are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output., block_bindings_supported_attributes_{$block_type}, allows developers to customize which of a block’s attributes can be connected to a Block Bindings source.
On the editor
Developers can now register custom sources in the editor UIUIUser interface by adding a getFieldsList method to their source registration function.
This function must return an array of objects with the following properties:
label (string): Defines the label shown in the dropdown selector. Defaults to the source label if not provided.
type (string): Defines the attribute value type. It must match the attribute type it binds to; otherwise, it won’t appear in the UI.Example: An id attribute that accepts only numbers should only display fields that return numeric values.
args (object): Defines the source arguments that are applied when a user selects the field from the dropdown.
This is an example that can be tried directly in the console from the Block Editor:
wp.blocks.registerBlockBindingsSource({
name: 'state-word/haikus',
label: 'Haikus',
useContext: [ 'postId', 'postType' ],
getValues: ( { bindings } ) => {
// this getValues assumes you're on a paragraph
if ( bindings.content?.args?.haiku === 'one' ) {
return {
content:
'Six point nine arrives,\nBlock bindings bloom like spring flowers,\nEditors rejoice.',
};
}
if ( bindings.content?.args?.haiku === 'two' ) {
return {
content:
'New features unfold,\nPatterns dance with dynamic grace,\nWordPress dreams take flight.',
};
}
if ( bindings.content?.args?.haiku === 'three' ) {
return {
content:
"December's gift shines,\nSix nine brings the future near,\nCreators build more.",
};
}
return {
content: bindings.content,
};
},
getFieldsList() {
return [
{
label: 'First Haiku',
type: 'string',
args: {
haiku: 'one',
},
},
{
label: 'Second Haiku',
type: 'string',
args: {
haiku: 'two',
},
},
{
label: 'Third Haiku',
type: 'string',
args: {
haiku: 'three',
},
},
];
},
} );
After executing the code above, when inserting a paragraph, a new UI selector for the Block Binding should be available for the content attribute of the paragraph.
Additional Information
More information can be found on the related tickets, changesets, and pull requests:
TracTracAn open source project by Edgewall Software that serves as a bug tracker and project management tool for WordPress.ticketticketCreated for both bug reports and feature development on the bug tracker.: #64030
You must be logged in to post a comment.