[wp-trac] [WordPress Trac] #62705: Block Bindings: Expose UI options for the source from the server
WordPress Trac
noreply at wordpress.org
Fri Dec 20 11:20:32 UTC 2024
#62705: Block Bindings: Expose UI options for the source from the server
-----------------------------+---------------------
Reporter: cbravobernal | Owner: (none)
Type: feature request | Status: new
Priority: normal | Milestone: 6.8
Component: Editor | Version: 6.5
Severity: normal | Resolution:
Keywords: has-patch | Focuses:
-----------------------------+---------------------
Comment (by cbravobernal):
What I've seen in most of approaches of Block Bindings is that
´$source_args['key']´ is the variable guiding the frontend rendered
content.
In post meta, the list is showing all the different values that ´key´ may
have. And interacting with them within the UI will set that ´key´ value.
Taking that into account, an example of what the user may need with dates
could be this one:
{{{
array(
'label' => __( 'Current dates', 'custom-bindings' ),
'get_value_callback' => function ( array $source_args,
$block_instance ) {
switch ( $source_args['key'] ) {
case 'y_m_d':
return gmdate( 'Y M D' );
case 'y_m_d_h_i_s':
return gmdate( 'Y M D h i s' );
default:
return gmdate( 'Y M D h i s' );
}
},
'args' => array(
'y_m_d' => array(
'type' => 'string',
'label' => __( 'Y M D', 'custom-bindings'
),
'value' => gmdate( 'Y M D' ),
),
'y_m_d_h_i_s' => array(
'type' => 'string',
'label' => __( 'Y M D h i s', 'custom-
bindings' ),
'value' => gmdate( 'Y M D h i s' ),
),
),
),
}}}
I think we should define what we want on that UI, should we instead choose
between different ´args´? Should we just focus on allowing defining just
`args`keys?
In the last case, ´label´ would show the format, and value would show an
example of what will be rendered on the frontend.
[[Image(https://private-user-
images.githubusercontent.com/37012961/397721788-89c17078-eb37-4f41-ac37-bf23a86305f9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzQ2OTM2NzMsIm5iZiI6MTczNDY5MzM3MywicGF0aCI6Ii8zNzAxMjk2MS8zOTc3MjE3ODgtODljMTcwNzgtZWIzNy00ZjQxLWFjMzctYmYyM2E4NjMwNWY5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDEyMjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQxMjIwVDExMTYxM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTMwNDVlMmZiMzM0YWQxYmI5YTc4MDk1Njc5ZDRmNTRiOGExZDI4OTcwZjNlZTYwNDZlMGI2ZmNlNjM4MzM1M2QmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.O7Ltfisu9PpmuqT329mmrtE273VaCR5dz5rdH8-3RAo)]]
> Could we assume the default is string?
I think we could assume it. In a future, as you mention, could accept
number, bool, dateformat, etc.
I agree with all the requirements you mention. I think the debate should
be if we want to allow setting different args via the UI, or we just want
to focus on the `arg` key value. If we want to set different args, we may
need to update the internals of post meta right now.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/62705#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list