PluginProbe
Gutenberg / 24.1.0
Gutenberg v24.1.0
24.1.0 24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 All 404 releases
← All changes | build/scripts/block-library/playlist-track.php +27 -19 23.2.2 → 24.1.0 View file →
@@ -7,52 +7,60 @@
7 7
8 8 /**
9 9 * Renders the `core/playlist-track` block on server.
10 10 *
11 - * @since 6.9.0
11 + * @since 7.1.0
12 12 *
13 - * @param array $attributes The block attributes.
13 + * @param array $attributes The block attributes.
14 + * @param string $content The block content.
15 + * @param WP_Block|null $block The block instance.
14 16 *
15 17 * @return string Returns the Playlist Track.
16 18 */
17 -function gutenberg_render_block_core_playlist_track( $attributes ) {
19 +function gutenberg_render_block_core_playlist_track( $attributes, $content = '', $block = null ) {
18 20 if ( empty( $attributes['id'] ) ) {
19 21 return '';
20 22 }
21 23
22 24 $wrapper_attributes = get_block_wrapper_attributes();
25 + $show_images = true;
26 + if ( $block instanceof WP_Block && isset( $block->context['showImages'] ) ) {
27 + $show_images = $block->context['showImages'];
28 + }
23 29
24 - $unique_id = $attributes['uniqueId'] ?? wp_unique_id( 'playlist-track-' );
25 - $artist = $attributes['artist'] ?? '';
26 - $length = $attributes['length'] ?? '';
27 - $title = isset( $attributes['title'] ) && ! empty( $attributes['title'] ) ? $attributes['title'] : __( 'Unknown title' );
30 + $track_image = $attributes['image'] ?? null;
31 + $image = is_string( $track_image ) ? $track_image : '';
32 + $artist = $attributes['artist'] ?? '';
33 + $alt = $attributes['imageAlt'] ?? '';
34 + $length = $attributes['length'] ?? '';
35 + $title = isset( $attributes['title'] ) && ! empty( $attributes['title'] ) ? $attributes['title'] : __( 'Unknown title' );
28 36
29 - $context = wp_interactivity_data_wp_context(
30 - array(
31 - 'uniqueId' => $unique_id,
32 - )
33 - );
37 + $html = '<li ' . $wrapper_attributes . '>';
38 + $html .= '<button data-wp-on--click="actions.changeTrack" data-wp-bind--aria-current="state.isCurrentTrack" class="wp-block-playlist-track__button">';
34 39
35 - $html = '<li ' . $wrapper_attributes . '>';
36 - $html .= '<button ' . $context . 'data-wp-on--click="actions.changeTrack" data-wp-bind--aria-current="state.isCurrentTrack" class="wp-block-playlist-track__button">';
40 + if ( $show_images && $image ) {
41 + $html .= '<img class="wp-block-playlist-track__image" src="' . esc_url( $image ) . '" alt="' . esc_attr( $alt ) . '" />';
42 + }
37 43
38 44 $html .= '<span class="wp-block-playlist-track__content">';
39 45 if ( $title ) {
40 - $html .= '<span class="wp-block-playlist-track__title">' . wp_kses_post( $title ) . '</span>';
46 + $html .= '<span class="wp-block-playlist-track__title">' . esc_html( $title ) . '</span>';
41 47 }
42 48 if ( $artist ) {
43 - $html .= '<span class="wp-block-playlist-track__artist">' . wp_kses_post( $artist ) . '</span>';
49 + $html .= '<span class="wp-block-playlist-track__artist">' . esc_html( $artist ) . '</span>';
44 50 }
45 51 $html .= '</span>';
46 52
47 53 if ( $length ) {
48 54 $html .= '<span class="wp-block-playlist-track__length">';
49 - $html .= '<span class="screen-reader-text">' . esc_html__( 'Length:' ) . ' </span>';
55 + $html .= '<span class="screen-reader-text">' . esc_html__( 'Duration:' ) . ' </span>';
50 56 $html .= esc_html( $length );
51 57 $html .= '</span>';
52 58 }
53 59
54 - $html .= '<span class="screen-reader-text">' . esc_html__( 'Select to play this track' ) . '</span>';
60 + $html .= '<span class="screen-reader-text" data-wp-text="state.trackButtonActionLabel">';
61 + $html .= esc_html__( 'Play' );
62 + $html .= '</span>';
55 63 $html .= '</button>';
56 64 $html .= '</li>';
57 65
58 66 return $html;
@@ -60,9 +68,9 @@
60 68
61 69 /**
62 70 * Registers the `core/playlist-track` block on server.
63 71 *
64 - * @since 6.9.0
72 + * @since 7.1.0
65 73 */
66 74 function gutenberg_register_block_core_playlist_track() {
67 75 register_block_type_from_metadata(
68 76 __DIR__ . '/playlist-track',