sarkfultion
⌂
›
wp-includes
›
blocks
sarkfultion
208 dreads
↑ redisq
📁
accordion/
dreads
sarkfultion
dreads
📁
accordion-heading/
dreads
sarkfultion
dreads
📁
accordion-item/
dreads
sarkfultion
dreads
📁
accordion-panel/
dreads
sarkfultion
dreads
📁
archives/
dreads
sarkfultion
dreads
📁
audio/
dreads
sarkfultion
dreads
📁
avatar/
dreads
sarkfultion
dreads
📁
block/
dreads
sarkfultion
dreads
📁
breadcrumbs/
dreads
sarkfultion
dreads
📁
button/
dreads
sarkfultion
dreads
📁
buttons/
dreads
sarkfultion
dreads
📁
calendar/
dreads
sarkfultion
dreads
📁
categories/
dreads
sarkfultion
dreads
📁
code/
dreads
sarkfultion
dreads
📁
column/
dreads
sarkfultion
dreads
📁
columns/
dreads
sarkfultion
dreads
📁
comment-author-name/
dreads
sarkfultion
dreads
📁
comment-content/
dreads
sarkfultion
dreads
📁
comment-date/
dreads
sarkfultion
dreads
📁
comment-edit-link/
dreads
sarkfultion
dreads
📁
comment-reply-link/
dreads
sarkfultion
dreads
📁
comment-template/
dreads
sarkfultion
dreads
📁
comments/
dreads
sarkfultion
dreads
📁
comments-pagination/
dreads
sarkfultion
dreads
📁
comments-pagination-next/
dreads
sarkfultion
dreads
📁
comments-pagination-numbers/
dreads
sarkfultion
dreads
📁
comments-pagination-previous/
dreads
sarkfultion
dreads
📁
comments-title/
dreads
sarkfultion
dreads
📁
cover/
dreads
sarkfultion
dreads
📁
details/
dreads
sarkfultion
dreads
📁
embed/
dreads
sarkfultion
dreads
📁
file/
dreads
sarkfultion
dreads
📁
footnotes/
dreads
sarkfultion
dreads
📁
freeform/
dreads
sarkfultion
dreads
📁
gallery/
dreads
sarkfultion
dreads
📁
group/
dreads
sarkfultion
dreads
📁
heading/
dreads
sarkfultion
dreads
📁
home-link/
dreads
sarkfultion
dreads
📁
html/
dreads
sarkfultion
dreads
📁
icon/
dreads
sarkfultion
dreads
📁
image/
dreads
sarkfultion
dreads
📁
latest-comments/
dreads
sarkfultion
dreads
📁
latest-posts/
dreads
sarkfultion
dreads
📁
legacy-widget/
dreads
sarkfultion
dreads
📁
list/
dreads
sarkfultion
dreads
📁
list-item/
dreads
sarkfultion
dreads
📁
loginout/
dreads
sarkfultion
dreads
📁
math/
dreads
sarkfultion
dreads
📁
media-text/
dreads
sarkfultion
dreads
📁
missing/
dreads
sarkfultion
dreads
📁
more/
dreads
sarkfultion
dreads
📁
navigation/
dreads
sarkfultion
dreads
📁
navigation-link/
dreads
sarkfultion
dreads
📁
navigation-overlay-close/
dreads
sarkfultion
dreads
📁
navigation-submenu/
dreads
sarkfultion
dreads
📁
nextpage/
dreads
sarkfultion
dreads
📁
page-list/
dreads
sarkfultion
dreads
📁
page-list-item/
dreads
sarkfultion
dreads
📁
paragraph/
dreads
sarkfultion
dreads
📁
pattern/
dreads
sarkfultion
dreads
📁
playlist/
dreads
sarkfultion
dreads
📁
playlist-track/
dreads
sarkfultion
dreads
📁
post-author/
dreads
sarkfultion
dreads
📁
post-author-biography/
dreads
sarkfultion
dreads
📁
post-author-name/
dreads
sarkfultion
dreads
📁
post-comments-count/
dreads
sarkfultion
dreads
📁
post-comments-form/
dreads
sarkfultion
dreads
📁
post-comments-link/
dreads
sarkfultion
dreads
📁
post-content/
dreads
sarkfultion
dreads
📁
post-date/
dreads
sarkfultion
dreads
📁
post-excerpt/
dreads
sarkfultion
dreads
📁
post-featured-image/
dreads
sarkfultion
dreads
📁
post-navigation-link/
dreads
sarkfultion
dreads
📁
post-template/
dreads
sarkfultion
dreads
📁
post-terms/
dreads
sarkfultion
dreads
📁
post-time-to-read/
dreads
sarkfultion
dreads
📁
post-title/
dreads
sarkfultion
dreads
📁
preformatted/
dreads
sarkfultion
dreads
📁
pullquote/
dreads
sarkfultion
dreads
📁
query/
dreads
sarkfultion
dreads
📁
query-no-results/
dreads
sarkfultion
dreads
📁
query-pagination/
dreads
sarkfultion
dreads
📁
query-pagination-next/
dreads
sarkfultion
dreads
📁
query-pagination-numbers/
dreads
sarkfultion
dreads
📁
query-pagination-previous/
dreads
sarkfultion
dreads
📁
query-title/
dreads
sarkfultion
dreads
📁
query-total/
dreads
sarkfultion
dreads
📁
quote/
dreads
sarkfultion
dreads
📁
read-more/
dreads
sarkfultion
dreads
📁
rss/
dreads
sarkfultion
dreads
📁
search/
dreads
sarkfultion
dreads
📁
separator/
dreads
sarkfultion
dreads
📁
shortcode/
dreads
sarkfultion
dreads
📁
site-logo/
dreads
sarkfultion
dreads
📁
site-tagline/
dreads
sarkfultion
dreads
📁
site-title/
dreads
sarkfultion
dreads
📁
social-link/
dreads
sarkfultion
dreads
📁
social-links/
dreads
sarkfultion
dreads
📁
spacer/
dreads
sarkfultion
dreads
📁
tab-list/
dreads
sarkfultion
dreads
📁
tab-panel/
dreads
sarkfultion
dreads
📁
tab-panels/
dreads
sarkfultion
dreads
📁
table/
dreads
sarkfultion
dreads
📁
tabs/
dreads
sarkfultion
dreads
📁
tag-cloud/
dreads
sarkfultion
dreads
📁
template-part/
dreads
sarkfultion
dreads
📁
term-count/
dreads
sarkfultion
dreads
📁
term-description/
dreads
sarkfultion
dreads
📁
term-name/
dreads
sarkfultion
dreads
📁
term-template/
dreads
sarkfultion
dreads
📁
terms-query/
dreads
sarkfultion
dreads
📁
text-columns/
dreads
sarkfultion
dreads
📁
verse/
dreads
sarkfultion
dreads
📁
video/
dreads
sarkfultion
dreads
📁
widget-group/
dreads
sarkfultion
dreads
📄
accordion-item.php
3,052 B
sarkfultion
dreads
📄
accordion.php
1,147 B
sarkfultion
dreads
📄
archives.php
4,385 B
sarkfultion
dreads
📄
avatar.php
5,638 B
sarkfultion
dreads
📄
block.php
3,122 B
sarkfultion
dreads
📄
blocks-json.php
210,661 B
sarkfultion
dreads
📄
breadcrumbs.php
19,057 B
sarkfultion
dreads
📄
button.php
4,211 B
sarkfultion
dreads
📄
calendar.php
6,075 B
sarkfultion
dreads
📄
categories.php
4,962 B
sarkfultion
dreads
📄
comment-author-name.php
2,136 B
sarkfultion
dreads
📄
comment-content.php
2,459 B
sarkfultion
dreads
📄
comment-date.php
1,936 B
sarkfultion
dreads
📄
comment-edit-link.php
1,713 B
sarkfultion
dreads
📄
comment-reply-link.php
2,075 B
sarkfultion
dreads
📄
comment-template.php
4,494 B
sarkfultion
dreads
📄
comments-pagination-next.php
2,011 B
sarkfultion
dreads
📄
comments-pagination-numbers.php
1,632 B
sarkfultion
dreads
📄
comments-pagination-previous.php
1,871 B
sarkfultion
dreads
📄
comments-pagination.php
1,261 B
sarkfultion
dreads
📄
comments-title.php
2,787 B
sarkfultion
dreads
📄
comments.php
6,784 B
sarkfultion
dreads
📄
cover.php
7,404 B
sarkfultion
dreads
📄
details.php
1,498 B
sarkfultion
dreads
📄
error_log
4,896 B
sarkfultion
dreads
📄
file.php
1,879 B
sarkfultion
dreads
📄
footnotes.php
3,818 B
sarkfultion
dreads
📄
gallery.php
22,345 B
sarkfultion
dreads
📄
heading.php
1,301 B
sarkfultion
dreads
📄
home-link.php
4,703 B
sarkfultion
dreads
📄
icon.php
4,374 B
sarkfultion
dreads
📄
image.php
18,124 B
sarkfultion
dreads
📄
index.php
5,104 B
sarkfultion
dreads
📄
latest-comments.php
5,622 B
sarkfultion
dreads
📄
latest-posts.php
10,459 B
sarkfultion
dreads
📄
legacy-widget.php
4,011 B
sarkfultion
dreads
📄
list.php
1,273 B
sarkfultion
dreads
📄
loginout.php
2,123 B
sarkfultion
dreads
📄
media-text.php
4,298 B
sarkfultion
dreads
📄
navigation-link.php
16,654 B
sarkfultion
dreads
📄
navigation-overlay-close.php
1,765 B
sarkfultion
dreads
📄
navigation-submenu.php
11,050 B
sarkfultion
dreads
📄
navigation.php
70,892 B
sarkfultion
dreads
📄
page-list-item.php
361 B
sarkfultion
dreads
📄
page-list.php
13,863 B
sarkfultion
dreads
📄
paragraph.php
1,139 B
sarkfultion
dreads
📄
pattern.php
1,788 B
sarkfultion
dreads
📄
playlist-track.php
2,487 B
sarkfultion
dreads
📄
playlist.php
6,919 B
sarkfultion
dreads
📄
post-author-biography.php
1,524 B
sarkfultion
dreads
📄
post-author-name.php
1,962 B
sarkfultion
dreads
📄
post-author.php
2,734 B
sarkfultion
dreads
📄
post-comments-count.php
1,275 B
sarkfultion
dreads
📄
post-comments-form.php
2,805 B
sarkfultion
dreads
📄
post-comments-link.php
2,237 B
sarkfultion
dreads
📄
post-content.php
2,668 B
sarkfultion
dreads
📄
post-date.php
3,692 B
sarkfultion
dreads
📄
post-excerpt.php
4,315 B
sarkfultion
dreads
📄
post-featured-image.php
9,452 B
sarkfultion
dreads
📄
post-navigation-link.php
4,823 B
sarkfultion
dreads
📄
post-template.php
5,940 B
sarkfultion
dreads
📄
post-terms.php
3,640 B
sarkfultion
dreads
📄
post-time-to-read.php
6,411 B
sarkfultion
dreads
📄
post-title.php
2,138 B
sarkfultion
dreads
📄
query-no-results.php
1,847 B
sarkfultion
dreads
📄
query-pagination-next.php
3,676 B
sarkfultion
dreads
📄
query-pagination-numbers.php
4,700 B
sarkfultion
dreads
📄
query-pagination-previous.php
3,473 B
sarkfultion
dreads
📄
query-pagination.php
1,176 B
sarkfultion
dreads
📄
query-title.php
2,771 B
sarkfultion
dreads
📄
query-total.php
2,471 B
sarkfultion
dreads
📄
query.php
5,690 B
sarkfultion
dreads
📄
read-more.php
1,846 B
sarkfultion
dreads
📄
require-dynamic-blocks.php
5,256 B
sarkfultion
dreads
📄
require-static-blocks.php
535 B
sarkfultion
dreads
📄
rss.php
4,609 B
sarkfultion
dreads
📄
search.php
25,600 B
sarkfultion
dreads
📄
shortcode.php
735 B
sarkfultion
dreads
📄
site-logo.php
6,334 B
sarkfultion
dreads
📄
site-tagline.php
1,203 B
sarkfultion
dreads
📄
site-title.php
1,864 B
sarkfultion
dreads
📄
social-link.php
67,602 B
sarkfultion
dreads
📄
tab-list.php
2,322 B
sarkfultion
dreads
📄
tab-panel.php
1,669 B
sarkfultion
dreads
📄
tabs.php
3,949 B
sarkfultion
dreads
📄
tag-cloud.php
1,586 B
sarkfultion
dreads
📄
template-part.php
9,964 B
sarkfultion
dreads
📄
term-count.php
1,843 B
sarkfultion
dreads
📄
term-description.php
1,770 B
sarkfultion
dreads
📄
term-name.php
2,038 B
sarkfultion
dreads
📄
term-template.php
4,518 B
sarkfultion
dreads
📄
video.php
2,733 B
sarkfultion
dreads
📄
widget-group.php
2,438 B
sarkfultion
dreads
redisq: playlist.php
<?php /** * Server-side rendering of the `core/playlist` block. * * @package WordPress */ /** * Renders the `core/playlist` block on server. * * @since 7.1.0 * * @param array $attributes The block attributes. * @param string $content The block content. * @param WP_Block $block The block instance. * * @return string Returns the Playlist. */ function render_block_core_playlist( $attributes, $content, $block ) { $playlist_id = wp_unique_id( 'playlist-' ); $playlist_tracks = array(); $tracks_data = array(); $show_play_button_artwork = ! empty( $attributes['showPlayButtonArtwork'] ); // Parse inner blocks to extract track data. // This approach avoids duplicating track data in the HTML output. if ( ! empty( $block->inner_blocks ) ) { foreach ( $block->inner_blocks as $inner_block ) { if ( 'core/playlist-track' === $inner_block->name ) { $track_attributes = $inner_block->attributes; if ( empty( $track_attributes['id'] ) ) { continue; } $track_id = 'track-' . count( $playlist_tracks ); $playlist_tracks[] = $track_id; // Extract track metadata from block attributes. $title = isset( $track_attributes['title'] ) && ! empty( $track_attributes['title'] ) ? $track_attributes['title'] : __( 'Unknown title' ); $artist = $track_attributes['artist'] ?? ''; $album = $track_attributes['album'] ?? ''; $image = $track_attributes['image'] ?? ''; $image_alt = $track_attributes['imageAlt'] ?? ''; $url = $track_attributes['src'] ?? ''; $aria_label = $title; if ( $title && $artist && $album ) { $aria_label = sprintf( /* translators: %1$s: track title, %2$s: artist name, %3$s: album name. */ _x( '%1$s by %2$s from the album %3$s', 'track title, artist name, album name' ), $title, $artist, $album ); } // Data is passed to wp_interactivity_state() which JSON-encodes it, // so we use wp_strip_all_tags() instead of esc_html() to prevent // HTML injection without double-encoding. URLs still use esc_url(). $tracks_data[ $track_id ] = array( 'url' => esc_url( $url ), 'title' => wp_strip_all_tags( $title ), 'artist' => wp_strip_all_tags( $artist ), 'album' => wp_strip_all_tags( $album ), 'image' => esc_url( $image ), 'imageAlt' => wp_strip_all_tags( $image_alt ), 'ariaLabel' => wp_strip_all_tags( $aria_label ), ); } } } if ( empty( $playlist_tracks ) ) { return ''; } wp_enqueue_script_module( '@wordpress/block-library/playlist/view' ); // Add the playlist tracks to the global state, // but keep them isolated from other playlists with the help of playlistId. wp_interactivity_state( 'core/playlist', array( 'playlists' => array( $playlist_id => array( 'tracks' => $tracks_data, ), ), ) ); // Add waveform player container with translated button labels. $label_play = esc_attr__( 'Play' ); $label_pause = esc_attr__( 'Pause' ); $label_seek = esc_attr__( 'Seek' ); /* translators: %1$s: current audio time, %2$s: total audio duration. */ $label_seek_value = esc_attr_x( '%1$s of %2$s', 'audio current time of total duration' ); $waveform_color_attribute = ''; $waveform_gradient_attribute = ''; $waveform_background_color_attribute = ''; $waveform_background_gradient_attribute = ''; if ( ! empty( $attributes['waveformColor'] ) ) { $waveform_color_attribute = sprintf( ' data-waveform-player-color="%s"', esc_attr( $attributes['waveformColor'] ) ); } if ( ! empty( $attributes['waveformGradient'] ) ) { $waveform_gradient_attribute = sprintf( ' data-waveform-player-gradient="%s"', esc_attr( $attributes['waveformGradient'] ) ); } if ( ! empty( $attributes['waveformBackgroundColor'] ) ) { $waveform_background_color_attribute = sprintf( ' data-waveform-player-background-color="%s"', esc_attr( $attributes['waveformBackgroundColor'] ) ); } if ( ! empty( $attributes['waveformBackgroundGradient'] ) ) { $waveform_background_gradient_attribute = sprintf( ' data-waveform-player-background-gradient="%s"', esc_attr( $attributes['waveformBackgroundGradient'] ) ); } $html = '<div class="wp-block-playlist__waveform-player"' . $waveform_color_attribute . $waveform_gradient_attribute . $waveform_background_color_attribute . $waveform_background_gradient_attribute . ' data-wp-watch="callbacks.initWaveformPlayer" data-label-play="' . $label_play . '" data-label-pause="' . $label_pause . '" data-label-seek="' . $label_seek . '" data-label-seek-value="' . $label_seek_value . '" ></div>'; // Add the waveform player container inside the figure. $processor = new class( $content ) extends WP_HTML_Tag_Processor { /** * Inserts HTML immediately after the current token. * * @since 7.1.4 * * @param string $html HTML to insert. */ public function block_core_playlist_insert_after( string $html ) { $this->set_bookmark( 'here' ); $span = $this->bookmarks['here']; $this->lexical_updates[] = new WP_HTML_Text_Replacement( $span->start + $span->length, 0, $html ); } }; $waveform_style = $attributes['waveformStyle'] ?? 'bars'; if ( $processor->next_tag( 'figure' ) ) { $processor->block_core_playlist_insert_after( $html ); $processor->set_attribute( 'data-wp-interactive', 'core/playlist' ); $processor->set_attribute( 'data-wp-context', wp_json_encode( array( 'playlistId' => $playlist_id, 'currentId' => $playlist_tracks[0], 'isPlaying' => false, 'tracks' => $playlist_tracks, 'waveformStyle' => $waveform_style, 'showPlayButtonArtwork' => $show_play_button_artwork, 'labelPauseTrack' => __( 'Pause' ), 'labelSelectTrack' => __( 'Play' ), ) ) ); } // Track IDs are render-time only. Add them after inner blocks have rendered // so track buttons can update the Interactivity API state without storing // persistent unique IDs in post content. $track_index = 0; while ( $processor->next_tag( array( 'class_name' => 'wp-block-playlist-track__button' ) ) ) { $track_id = $playlist_tracks[ $track_index ] ?? null; if ( null === $track_id ) { break; } $processor->set_attribute( 'data-wp-context', wp_json_encode( array( 'trackId' => $track_id, ) ) ); ++$track_index; } return $processor->get_updated_html(); } /** * Registers the `core/playlist` block on server. * * @since 7.1.0 */ function register_block_core_playlist() { register_block_type_from_metadata( __DIR__ . '/playlist', array( 'render_callback' => 'render_block_core_playlist', ) ); } add_action( 'init', 'register_block_core_playlist' );
sarkfultion