diff --git a/projects/plugins/jetpack/changelog/fusion-sync-jeherve-D67274-code-1632761166 b/projects/plugins/jetpack/changelog/fusion-sync-jeherve-D67274-code-1632761166 new file mode 100644 index 0000000000000..bcec6ab14e3e7 --- /dev/null +++ b/projects/plugins/jetpack/changelog/fusion-sync-jeherve-D67274-code-1632761166 @@ -0,0 +1,4 @@ +Significance: patch +Type: other + +Podcast Player Block: avoid use of extract() diff --git a/projects/plugins/jetpack/extensions/blocks/podcast-player/podcast-player.php b/projects/plugins/jetpack/extensions/blocks/podcast-player/podcast-player.php index 771728418062d..9b3af865e9948 100644 --- a/projects/plugins/jetpack/extensions/blocks/podcast-player/podcast-player.php +++ b/projects/plugins/jetpack/extensions/blocks/podcast-player/podcast-player.php @@ -299,18 +299,6 @@ function render( $name, $template_props = array(), $print = true ) { return ''; } - /* - * Optionally provided an assoc array of data to pass to template. - * IMPORTANT: It will be extracted into variables. - */ - if ( is_array( $template_props ) ) { - /* - * It ignores the `discouraging` sniffer rule for extract, since it's needed - * to make the templating system works. - */ - extract( $template_props ); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract - } - if ( $print ) { include $template_path; } else { diff --git a/projects/plugins/jetpack/extensions/blocks/podcast-player/templates/playlist-track.php b/projects/plugins/jetpack/extensions/blocks/podcast-player/templates/playlist-track.php index afdc9551cd07d..0789816e0edc8 100644 --- a/projects/plugins/jetpack/extensions/blocks/podcast-player/templates/playlist-track.php +++ b/projects/plugins/jetpack/extensions/blocks/podcast-player/templates/playlist-track.php @@ -10,21 +10,18 @@ /** * Template variables. * - * @var array $attachment - * @var array $primary_colors - * @var array $secondary_colors - * @var bool $is_active + * @var array $template_props */ -$track_title = $attachment['title']; -$track_link = empty( $attachment['link'] ) ? $attachment['src'] : $attachment['link']; -$track_duration = ! empty( $attachment['duration'] ) ? $attachment['duration'] : ''; +$track_title = $template_props['attachment']['title']; +$track_link = empty( $template_props['attachment']['link'] ) ? $template_props['attachment']['src'] : $template_props['attachment']['link']; +$track_duration = ! empty( $template_props['attachment']['duration'] ) ? $template_props['attachment']['duration'] : ''; -$class = 'jetpack-podcast-player__track ' . $secondary_colors['class']; -$style = $secondary_colors['style']; -if ( $is_active ) { - $class = 'jetpack-podcast-player__track is-active ' . $primary_colors['class']; - $style = $primary_colors['style']; +$class = 'jetpack-podcast-player__track ' . $template_props['secondary_colors']['class']; +$style = $template_props['secondary_colors']['style']; +if ( $template_props['is_active'] ) { + $class = 'jetpack-podcast-player__track is-active ' . $template_props['primary_colors']['class']; + $style = $template_props['primary_colors']['style']; } ?> @@ -37,7 +34,7 @@ class="" class="jetpack-podcast-player__track-link jetpack-podcast-player__link" href="" role="button" - + > diff --git a/projects/plugins/jetpack/extensions/blocks/podcast-player/templates/podcast-header-title.php b/projects/plugins/jetpack/extensions/blocks/podcast-player/templates/podcast-header-title.php index 4218a3e9acbd6..763aa83a1f228 100644 --- a/projects/plugins/jetpack/extensions/blocks/podcast-player/templates/podcast-header-title.php +++ b/projects/plugins/jetpack/extensions/blocks/podcast-player/templates/podcast-header-title.php @@ -10,27 +10,23 @@ /** * Template variables. * - * @var string $player_id - * @var string $title - * @var string $link - * @var array $track - * @var array $primary_colors + * @var string $template_props */ -if ( ! isset( $title ) && empty( $track['title'] ) ) { +if ( ! isset( $template_props['title'] ) && empty( $template_props['track']['title'] ) ) { return; } -$track_link = empty( $track['link'] ) ? $track['src'] : $track['link']; +$track_link = empty( $template_props['track']['link'] ) ? $template_props['track']['src'] : $template_props['track']['link']; ?> -