Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed Dec 10, 2024
1 parent 0d42819 commit 46d267d
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 12 deletions.
7 changes: 4 additions & 3 deletions src/wp-admin/edit-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
7 changes: 4 additions & 3 deletions src/wp-admin/site-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
7 changes: 4 additions & 3 deletions src/wp-admin/widgets-form-blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
1 change: 1 addition & 0 deletions src/wp-includes/class-wp-block-bindings-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ final class WP_Block_Bindings_Registry {
'label',
'get_value_callback',
'uses_context',
'get_fields_list',
);

/**
Expand Down
9 changes: 9 additions & 0 deletions src/wp-includes/class-wp-block-bindings-source.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down
7 changes: 4 additions & 3 deletions src/wp-includes/class-wp-customize-widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down

0 comments on commit 46d267d

Please sign in to comment.