Commit b104d200b6 for wordpress.org
commit b104d200b616e92e5ba8fe82978337f6b3433af5
Author: cbravobernal <cbravobernal@git.wordpress.org>
Date: Wed Jul 24 10:59:18 2024 +0000
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
diff --git a/wp-includes/block-editor.php b/wp-includes/block-editor.php
index 00633d4d7e..e8900d1ccd 100644
--- a/wp-includes/block-editor.php
+++ b/wp-includes/block-editor.php
@@ -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.
*
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 99257cb75e..4ed66a22ee 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -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.