Skip to content

Commit 3c7ac73

Browse files
committed
Add backward compat
1 parent 664bce1 commit 3c7ac73

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/wp-includes/block-bindings/post-data.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,13 @@
2020
*/
2121
function _block_bindings_post_data_get_value( array $source_args, $block_instance ) {
2222
if ( empty( $source_args['field'] ) ) {
23-
return null;
23+
// Backward compatibility for when the source argument was called `key` in Gutenberg plugin.
24+
if ( empty( $source_args['key'] ) ) {
25+
return null;
26+
}
27+
$field = $source_args['key'];
28+
} else {
29+
$field = $source_args['field'];
2430
}
2531

2632
/*
@@ -53,11 +59,11 @@ function _block_bindings_post_data_get_value( array $source_args, $block_instanc
5359
return null;
5460
}
5561

56-
if ( 'date' === $source_args['field'] ) {
62+
if ( 'date' === $field ) {
5763
return esc_attr( get_the_date( 'c', $post_id ) );
5864
}
5965

60-
if ( 'modified' === $source_args['field'] ) {
66+
if ( 'modified' === $field ) {
6167
// Only return the modified date if it is later than the publishing date.
6268
if ( get_the_modified_date( 'U', $post_id ) > get_the_date( 'U', $post_id ) ) {
6369
return esc_attr( get_the_modified_date( 'c', $post_id ) );

0 commit comments

Comments
 (0)