From ca434a539841b5987717cb1094f27d6fe9dcf972 Mon Sep 17 00:00:00 2001 From: retrofox Date: Tue, 21 Apr 2020 17:38:01 -0300 Subject: [PATCH 1/4] podcast-player: handle dual-behaviour of render --- .../blocks/podcast-player/podcast-player.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/extensions/blocks/podcast-player/podcast-player.php b/extensions/blocks/podcast-player/podcast-player.php index 7ddca2111236..6575ded6dc57 100644 --- a/extensions/blocks/podcast-player/podcast-player.php +++ b/extensions/blocks/podcast-player/podcast-player.php @@ -55,7 +55,7 @@ function register_block() { /** * Podcast Player block registration/dependency declaration. * - * @param array $attributes Array containing the Podcast Player block attributes. + * @param array|object $attributes Podcast Player block attributes / WP_Block instance. * @return string */ function render_block( $attributes ) { @@ -79,7 +79,19 @@ function render_block( $attributes ) { return '

' . esc_html( $player_data->get_error_message() ) . '

'; } - return render_player( $player_data, $attributes ); + /* + * Get the block attributes checking if `$attributes` + * is an array and it has defined a property. + * + * It handles the dual-behavior of argument + * of the callback_render() function, which + * was recently introduced by this Pull Request: + * https://github.com/WordPress/gutenberg/pull/21467 + */ + $block_attributes = ! is_array( $attributes ) && isset( $attributes->attributes ) + ? $attributes->attributes + : $attributes; + return render_player( $player_data, $block_attributes ); } /** From 3fc7cf6e3c4f9d7cc6b587e425c3016310f4c6cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dami=C3=A1n=20Su=C3=A1rez?= Date: Wed, 22 Apr 2020 09:09:15 -0300 Subject: [PATCH 2/4] Update extensions/blocks/podcast-player/podcast-player.php Co-Authored-By: Konstantin Obenland --- extensions/blocks/podcast-player/podcast-player.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/blocks/podcast-player/podcast-player.php b/extensions/blocks/podcast-player/podcast-player.php index 6575ded6dc57..83f2733fc96f 100644 --- a/extensions/blocks/podcast-player/podcast-player.php +++ b/extensions/blocks/podcast-player/podcast-player.php @@ -88,9 +88,9 @@ function render_block( $attributes ) { * was recently introduced by this Pull Request: * https://github.com/WordPress/gutenberg/pull/21467 */ - $block_attributes = ! is_array( $attributes ) && isset( $attributes->attributes ) - ? $attributes->attributes - : $attributes; + if ( ! empty( $attributes->attributes ) ) { + $attributes = $attributes->attributes; + } return render_player( $player_data, $block_attributes ); } From cf9902c94ed1cc9295c0064e07da4290c4930f25 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 22 Apr 2020 13:44:13 -0300 Subject: [PATCH 3/4] podcast-player: update passing $attributes var --- extensions/blocks/podcast-player/podcast-player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/blocks/podcast-player/podcast-player.php b/extensions/blocks/podcast-player/podcast-player.php index 83f2733fc96f..10beed41d00e 100644 --- a/extensions/blocks/podcast-player/podcast-player.php +++ b/extensions/blocks/podcast-player/podcast-player.php @@ -91,7 +91,7 @@ function render_block( $attributes ) { if ( ! empty( $attributes->attributes ) ) { $attributes = $attributes->attributes; } - return render_player( $player_data, $block_attributes ); + return render_player( $player_data, $attributes ); } /** From debd4954d41ce86d73fc4e072def7dcb873d0730 Mon Sep 17 00:00:00 2001 From: retrofox Date: Wed, 22 Apr 2020 13:46:26 -0300 Subject: [PATCH 4/4] podcast-player: improve jsdoc --- extensions/blocks/podcast-player/podcast-player.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/blocks/podcast-player/podcast-player.php b/extensions/blocks/podcast-player/podcast-player.php index 10beed41d00e..c26a1ae5b83b 100644 --- a/extensions/blocks/podcast-player/podcast-player.php +++ b/extensions/blocks/podcast-player/podcast-player.php @@ -55,7 +55,7 @@ function register_block() { /** * Podcast Player block registration/dependency declaration. * - * @param array|object $attributes Podcast Player block attributes / WP_Block instance. + * @param array|WP_Block $attributes Podcast Player block attributes / WP_Block instance. * @return string */ function render_block( $attributes ) {