From 737dbdd72c4ec038fd4e0d8dcc0632b1df010dda Mon Sep 17 00:00:00 2001 From: cbravobernal Date: Fri, 17 Oct 2025 15:07:31 +0000 Subject: [PATCH] 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 --- wp-includes/block-bindings/post-data.php | 16 +++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/wp-includes/block-bindings/post-data.php b/wp-includes/block-bindings/post-data.php index 11caa1e1cd..6733738084 100644 --- a/wp-includes/block-bindings/post-data.php +++ b/wp-includes/block-bindings/post-data.php @@ -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 ) ); diff --git a/wp-includes/version.php b/wp-includes/version.php index 1cbce85acc..c09ffb73b0 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.