Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Bindings: Prepare the ground to define fieldsList on the server. #7987

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from

Conversation

cbravobernal
Copy link
Contributor

What?

Ignore this PR at this moment. I'm just experimenting if it is possible to add sources to the UI just by defining them on the server side. It will need a PR in Core to be landed.

Something like:

register_block_bindings_source(
			'bbe/now-date',
			array(
				'label'              => __( 'Current date', 'custom-bindings' ),
				'get_value_callback' => function ( array $source_args, $block_instance ) {
					return gmdate( 'Y-m-d H:i:s' );
				},
				'get_fields_list'    =>
					array(
						array(
							'id'    => 'date1',
							'label' => __( 'Date (Y-m-d)', 'custom-bindings' ),
							'value' => 'Y-m-d',
						),
						array(
							'id'    => 'date2',
							'label' => __( 'Date (d/m/Y)', 'custom-bindings' ),
							'value' => 'd/m/Y',
						),
					),
			)
		);


To return:
Screenshot 2024-12-10 at 18 50 15

@cbravobernal cbravobernal changed the title Block Bindings: Prepare the ground to defgine fieldsList on the server. Block Bindings: Prepare the ground to define fieldsList on the server. Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant