Block Bindings: Adds sources in the editor settings to consume them in the client

Adds a new property `blockBindingsSources` to the editor settings to expose the block bindings sources registered in the server.

Props santosguillamot, cbravobernal, gziolo, artemiosans.
Fixes #61641.


Built from https://develop.svn.wordpress.org/trunk@58798


git-svn-id: http://core.svn.wordpress.org/trunk@58194 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
cbravobernal 2024-07-24 10:59:18 +00:00
parent edb05c5809
commit b104d200b6
2 changed files with 18 additions and 1 deletions

View File

@ -648,6 +648,23 @@ function get_block_editor_settings( array $custom_settings, $block_editor_contex
$editor_settings['postContentAttributes'] = $post_content_block_attributes;
}
// Expose block bindings sources in the editor settings.
$registered_block_bindings_sources = get_all_registered_block_bindings_sources();
if ( ! empty( $registered_block_bindings_sources ) ) {
// Initialize array.
$editor_settings['blockBindingsSources'] = array();
foreach ( $registered_block_bindings_sources as $source_name => $source_properties ) {
// Add source with the label to editor settings.
$editor_settings['blockBindingsSources'][ $source_name ] = array(
'label' => $source_properties->label,
);
// Add `usesContext` property if exists.
if ( ! empty( $source_properties->uses_context ) ) {
$editor_settings['blockBindingsSources'][ $source_name ]['usesContext'] = $source_properties->uses_context;
}
}
}
/**
* Filters the settings to pass to the block editor for all editor type.
*

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.7-alpha-58797';
$wp_version = '6.7-alpha-58798';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.