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 1/5] 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 ) ); From afadf318a14415538c5af2415dcd291055c451b7 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+cbravobernal@users.noreply.github.com> Date: Mon, 16 Dec 2024 22:06:15 +0100 Subject: [PATCH 2/5] Try arguments --- src/wp-includes/class-wp-block-bindings-source.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/class-wp-block-bindings-source.php b/src/wp-includes/class-wp-block-bindings-source.php index 688f629f7a99c..9ad858b65beac 100644 --- a/src/wp-includes/class-wp-block-bindings-source.php +++ b/src/wp-includes/class-wp-block-bindings-source.php @@ -44,13 +44,12 @@ 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. + * Provide arguments that will be shown in the Block Bindings UI. * * @since 6.8.0 - * @var callable + * @var array */ - public $get_fields_list; + public $arguments; /** * The context added to the blocks needed by the source. From c659c54b8eabaacdeddb45f3f8049d8cd167a1af Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+cbravobernal@users.noreply.github.com> Date: Tue, 17 Dec 2024 15:29:29 +0100 Subject: [PATCH 3/5] Add fields to server --- src/wp-admin/edit-form-blocks.php | 8 ++++---- src/wp-admin/site-editor.php | 8 ++++---- src/wp-admin/widgets-form-blocks.php | 8 ++++---- src/wp-includes/class-wp-block-bindings-registry.php | 2 +- src/wp-includes/class-wp-customize-widgets.php | 8 ++++---- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index b476423eefdbc..d1554ab1beed3 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -116,10 +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, - 'getFieldsList' => $source->get_fields_list, + 'name' => $source->name, + 'label' => $source->label, + 'usesContext' => $source->uses_context, + 'fields' => $source->fields, ); } $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 5a5b6f62bb559..f41ab1af6d79c 100644 --- a/src/wp-admin/site-editor.php +++ b/src/wp-admin/site-editor.php @@ -142,10 +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, - 'getFieldsList' => $source->get_fields_list, + 'name' => $source->name, + 'label' => $source->label, + 'usesContext' => $source->uses_context, + 'fields' => $source->fields, ); } $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 1b102a050a52f..a0ca257f370c6 100644 --- a/src/wp-admin/widgets-form-blocks.php +++ b/src/wp-admin/widgets-form-blocks.php @@ -57,10 +57,10 @@ $filtered_sources = array(); foreach ( $registered_sources as $source ) { $filtered_sources[] = array( - 'name' => $source->name, - 'label' => $source->label, - 'usesContext' => $source->uses_context, - 'getFieldsList' => $source->get_fields_list, + 'name' => $source->name, + 'label' => $source->label, + 'usesContext' => $source->uses_context, + 'fields' => $source->fields, ); } $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 3b6da91a76273..e955d9402cacb 100644 --- a/src/wp-includes/class-wp-block-bindings-registry.php +++ b/src/wp-includes/class-wp-block-bindings-registry.php @@ -42,7 +42,7 @@ final class WP_Block_Bindings_Registry { 'label', 'get_value_callback', 'uses_context', - 'get_fields_list', + 'fields', ); /** diff --git a/src/wp-includes/class-wp-customize-widgets.php b/src/wp-includes/class-wp-customize-widgets.php index 9915adf07c2fe..a4f48e9a5d6f1 100644 --- a/src/wp-includes/class-wp-customize-widgets.php +++ b/src/wp-includes/class-wp-customize-widgets.php @@ -872,10 +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, - 'getFieldsList' => $source->get_fields_list, + 'name' => $source->name, + 'label' => $source->label, + 'usesContext' => $source->uses_context, + 'fields' => $source->fields, ); } $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) ); From ff4f66ff39e69710c38ad356189cd2a8f31af1f0 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+cbravobernal@users.noreply.github.com> Date: Tue, 17 Dec 2024 18:13:14 +0100 Subject: [PATCH 4/5] Rename to fields --- src/wp-includes/class-wp-block-bindings-source.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-wp-block-bindings-source.php b/src/wp-includes/class-wp-block-bindings-source.php index 9ad858b65beac..03d6726283d0f 100644 --- a/src/wp-includes/class-wp-block-bindings-source.php +++ b/src/wp-includes/class-wp-block-bindings-source.php @@ -44,12 +44,12 @@ final class WP_Block_Bindings_Source { private $get_value_callback; /** - * Provide arguments that will be shown in the Block Bindings UI. + * Provide fields that will be shown in the Block Bindings UI. * * @since 6.8.0 * @var array */ - public $arguments; + public $fields; /** * The context added to the blocks needed by the source. From 190f9eda2a493253bd66c83677620f3eb1cc5bf4 Mon Sep 17 00:00:00 2001 From: Carlos Bravo <37012961+cbravobernal@users.noreply.github.com> Date: Wed, 18 Dec 2024 21:36:54 +0100 Subject: [PATCH 5/5] Use args --- src/wp-admin/edit-form-blocks.php | 2 +- src/wp-admin/site-editor.php | 2 +- src/wp-admin/widgets-form-blocks.php | 2 +- src/wp-includes/class-wp-block-bindings-registry.php | 2 +- src/wp-includes/class-wp-block-bindings-source.php | 2 +- src/wp-includes/class-wp-customize-widgets.php | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/wp-admin/edit-form-blocks.php b/src/wp-admin/edit-form-blocks.php index d1554ab1beed3..bd00a1e0559c8 100644 --- a/src/wp-admin/edit-form-blocks.php +++ b/src/wp-admin/edit-form-blocks.php @@ -119,7 +119,7 @@ static function ( $classes ) { 'name' => $source->name, 'label' => $source->label, 'usesContext' => $source->uses_context, - 'fields' => $source->fields, + 'args' => $source->args, ); } $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 f41ab1af6d79c..f917a2da750e1 100644 --- a/src/wp-admin/site-editor.php +++ b/src/wp-admin/site-editor.php @@ -145,7 +145,7 @@ static function ( $classes ) { 'name' => $source->name, 'label' => $source->label, 'usesContext' => $source->uses_context, - 'fields' => $source->fields, + 'args' => $source->args, ); } $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 a0ca257f370c6..53aa43cb67d15 100644 --- a/src/wp-admin/widgets-form-blocks.php +++ b/src/wp-admin/widgets-form-blocks.php @@ -60,7 +60,7 @@ 'name' => $source->name, 'label' => $source->label, 'usesContext' => $source->uses_context, - 'fields' => $source->fields, + 'args' => $source->args, ); } $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 e955d9402cacb..055c80949d95f 100644 --- a/src/wp-includes/class-wp-block-bindings-registry.php +++ b/src/wp-includes/class-wp-block-bindings-registry.php @@ -42,7 +42,7 @@ final class WP_Block_Bindings_Registry { 'label', 'get_value_callback', 'uses_context', - 'fields', + 'args', ); /** diff --git a/src/wp-includes/class-wp-block-bindings-source.php b/src/wp-includes/class-wp-block-bindings-source.php index 03d6726283d0f..8ab83a959d3c0 100644 --- a/src/wp-includes/class-wp-block-bindings-source.php +++ b/src/wp-includes/class-wp-block-bindings-source.php @@ -49,7 +49,7 @@ final class WP_Block_Bindings_Source { * @since 6.8.0 * @var array */ - public $fields; + public $args; /** * 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 a4f48e9a5d6f1..49abdf3401e1e 100644 --- a/src/wp-includes/class-wp-customize-widgets.php +++ b/src/wp-includes/class-wp-customize-widgets.php @@ -875,7 +875,7 @@ public function enqueue_scripts() { 'name' => $source->name, 'label' => $source->label, 'usesContext' => $source->uses_context, - 'fields' => $source->fields, + 'args' => $source->args, ); } $script = sprintf( 'for ( const source of %s ) { wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) );