Block Bindings: Use field instead of key in post-data source.
After the UI refactor, source args can contain anything, and using whatever fits better for each source is encouraged. Instead of using a `post-meta` based key argument. `post-data` will use `field` as an argument, which fits better to post related use cases. Props cbravobernal, bernhard-reiter. Fixes #64112. Built from https://develop.svn.wordpress.org/trunk@60955 git-svn-id: http://core.svn.wordpress.org/trunk@60291 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -14,13 +14,19 @@
|
||||
* @access private
|
||||
*
|
||||
* @param array $source_args Array containing arguments used to look up the source value.
|
||||
* Example: array( "key" => "foo" ).
|
||||
* Example: array( "field" => "foo" ).
|
||||
* @param WP_Block $block_instance The block instance.
|
||||
* @return mixed The value computed for the source.
|
||||
*/
|
||||
function _block_bindings_post_data_get_value( array $source_args, $block_instance ) {
|
||||
if ( empty( $source_args['key'] ) ) {
|
||||
return null;
|
||||
if ( empty( $source_args['field'] ) ) {
|
||||
// Backward compatibility for when the source argument was called `key` in Gutenberg plugin.
|
||||
if ( empty( $source_args['key'] ) ) {
|
||||
return null;
|
||||
}
|
||||
$field = $source_args['key'];
|
||||
} else {
|
||||
$field = $source_args['field'];
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -53,11 +59,11 @@ function _block_bindings_post_data_get_value( array $source_args, $block_instanc
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( 'date' === $source_args['key'] ) {
|
||||
if ( 'date' === $field ) {
|
||||
return esc_attr( get_the_date( 'c', $post_id ) );
|
||||
}
|
||||
|
||||
if ( 'modified' === $source_args['key'] ) {
|
||||
if ( 'modified' === $field ) {
|
||||
// Only return the modified date if it is later than the publishing date.
|
||||
if ( get_the_modified_date( 'U', $post_id ) > get_the_date( 'U', $post_id ) ) {
|
||||
return esc_attr( get_the_modified_date( 'c', $post_id ) );
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.9-alpha-60954';
|
||||
$wp_version = '6.9-alpha-60955';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user