From 46d267d7d0a968f3e444ac897766673d5bb02ef8 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+cbravobernal@users.noreply.github.com> Date: Tue, 10 Dec 2024 18:52:15 +0100 Subject: [PATCH] Initial commit --- src/wp-admin/edit-form-blocks.php | 7 ++++--- src/wp-admin/site-editor.php | 7 ++++--- src/wp-admin/widgets-form-blocks.php | 7 ++++--- src/wp-includes/class-wp-block-bindings-registry.php | 1 + src/wp-includes/class-wp-block-bindings-source.php | 9 +++++++++ src/wp-includes/class-wp-customize-widgets.php | 7 ++++--- 6 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index 5dbb9f33e4970..b476423eefdbc 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -116,9 +116,10 @@ static function ( $classes ) { $filtered_sources = array(); foreach ( $registered_sources as $source ) { $filtered_sources[] = array( - 'name' => $source->name, - 'label' => $source->label, - 'usesContext' => $source->uses_context, + 'name' => $source->name, + 'label' => $source->label, + 'usesContext' => $source->uses_context, + 'getFieldsList' => $source->get_fields_list, ); } $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) ); diff --git a/src/wp-admin/site-editor.php b/src/wp-admin/site-editor.php index 3207bccdf2632..5a5b6f62bb559 100644 --- a/src/wp-admin/site-editor.php +++ b/src/wp-admin/site-editor.php @@ -142,9 +142,10 @@ static function ( $classes ) { $filtered_sources = array(); foreach ( $registered_sources as $source ) { $filtered_sources[] = array( - 'name' => $source->name, - 'label' => $source->label, - 'usesContext' => $source->uses_context, + 'name' => $source->name, + 'label' => $source->label, + 'usesContext' => $source->uses_context, + 'getFieldsList' => $source->get_fields_list, ); } $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) ); diff --git a/src/wp-admin/widgets-form-blocks.php b/src/wp-admin/widgets-form-blocks.php index 0d161cf526d50..1b102a050a52f 100644 --- a/src/wp-admin/widgets-form-blocks.php +++ b/src/wp-admin/widgets-form-blocks.php @@ -57,9 +57,10 @@ $filtered_sources = array(); foreach ( $registered_sources as $source ) { $filtered_sources[] = array( - 'name' => $source->name, - 'label' => $source->label, - 'usesContext' => $source->uses_context, + 'name' => $source->name, + 'label' => $source->label, + 'usesContext' => $source->uses_context, + 'getFieldsList' => $source->get_fields_list, ); } $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) ); diff --git a/src/wp-includes/class-wp-block-bindings-registry.php b/src/wp-includes/class-wp-block-bindings-registry.php index dc065356c5ce4..3b6da91a76273 100644 --- a/src/wp-includes/class-wp-block-bindings-registry.php +++ b/src/wp-includes/class-wp-block-bindings-registry.php @@ -42,6 +42,7 @@ final class WP_Block_Bindings_Registry { 'label', 'get_value_callback', 'uses_context', + 'get_fields_list', ); /** diff --git a/src/wp-includes/class-wp-block-bindings-source.php b/src/wp-includes/class-wp-block-bindings-source.php index b71f020e28e57..688f629f7a99c 100644 --- a/src/wp-includes/class-wp-block-bindings-source.php +++ b/src/wp-includes/class-wp-block-bindings-source.php @@ -43,6 +43,15 @@ final class WP_Block_Bindings_Source { */ private $get_value_callback; + /** + * The function used to get the fields to be shown in the UI + * of Block Bindings. + * + * @since 6.8.0 + * @var callable + */ + public $get_fields_list; + /** * The context added to the blocks needed by the source. * diff --git a/src/wp-includes/class-wp-customize-widgets.php b/src/wp-includes/class-wp-customize-widgets.php index 98c6944478804..9915adf07c2fe 100644 --- a/src/wp-includes/class-wp-customize-widgets.php +++ b/src/wp-includes/class-wp-customize-widgets.php @@ -872,9 +872,10 @@ public function enqueue_scripts() { $filtered_sources = array(); foreach ( $registered_sources as $source ) { $filtered_sources[] = array( - 'name' => $source->name, - 'label' => $source->label, - 'usesContext' => $source->uses_context, + 'name' => $source->name, + 'label' => $source->label, + 'usesContext' => $source->uses_context, + 'getFieldsList' => $source->get_fields_list, ); } $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) );