函数文档

wp_underscore_playlist_templates()

💡 云策文档标注

概述

wp_underscore_playlist_templates() 函数用于输出播放列表使用的模板,是 WordPress 核心功能的一部分,自 3.9.0 版本引入。

关键要点

  • 函数 wp_underscore_playlist_templates() 输出播放列表的模板。
  • 该函数在 WordPress 3.9.0 版本中首次引入。
  • 与 wp_ajax_parse_media_shortcode() 函数相关,用于处理媒体短码的 AJAX 操作。

📄 原文内容

Outputs the templates used by playlists.

Source

function wp_underscore_playlist_templates() {
?>
<script type="text/html" id="tmpl-wp-playlist-current-item">
<# if ( data.thumb && data.thumb.src ) { #>
<img src="{{ data.thumb.src }}" alt="" />
<# } #>
<div class="wp-playlist-caption">
<span class="wp-playlist-item-meta wp-playlist-item-title">
<# if ( data.meta.album || data.meta.artist ) { #>
<?php
/* translators: %s: Playlist item title. */
printf( _x( '“%s”', 'playlist item title' ), '{{ data.title }}' );
?>

<# } else { #>
{{ data.title }}
<# } #>
</span>
<# if ( data.meta.album ) { #><span class="wp-playlist-item-meta wp-playlist-item-album">{{ data.meta.album }}</span><# } #>
<# if ( data.meta.artist ) { #><span class="wp-playlist-item-meta wp-playlist-item-artist">{{ data.meta.artist }}</span><# } #>
</div>
</script>
<script type="text/html" id="tmpl-wp-playlist-item">
<div class="wp-playlist-item">
<a class="wp-playlist-caption" href="
{{ data.src }}">
{{ data.index ? ( data.index + '. ' ) : '' }}
<# if ( data.caption ) { #>
{{ data.caption }}
<# } else { #>
<# if ( data.artists && data.meta.artist ) { #>
<span class="wp-playlist-item-title">
<?php
/* translators: %s: Playlist item title. */
printf( _x( '“%s”', 'playlist item title' ), '
{{{ data.title }}}' );
?>

</span>
<span class="wp-playlist-item-artist">
{{ data.meta.artist }}</span>
<# } else { #>
<span class="wp-playlist-item-title">
{{{ data.title }}}</span>
<# } #>
<# } #>
</a>
<# if ( data.meta.length_formatted ) { #>
<div class="wp-playlist-item-length">
{{ data.meta.length_formatted }}</div>
<# } #>
</div>
</script>
</pre><p class="wporg-dot-link-list"><a href="https://developer.wordpress.org/reference/files/wp-includes/media.php/">View all references</a> <a href="https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/media.php#L2968">View on Trac</a> <a href="https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/media.php#L2968-L3015">View on GitHub</a></p></section>

<section class="wp-block-wporg-code-reference-related" data-nosnippet="true"><h2 id="related" class="is-toc-heading wp-block-heading has-heading-5-font-size" tabindex="-1" ><a href="#related">Related</a></h2> <section style="margin-top:var(--wp--preset--spacing--20)" class="wp-block-wporg-code-table" id="uses"><figure class="wp-block-table "><table><thead><tr><th scope="col">Uses</th><th scope="col">Description</th></tr></thead><tbody><tr class=""><td><a href="https://developer.wordpress.org/reference/functions/_x/">_x()</a><code>wp-includes/l10n.php

Retrieves translated string with gettext context.

Used by Description
wp_ajax_parse_media_shortcode()wp-admin/includes/ajax-actions.php

Changelog

Version Description
3.9.0 Introduced.