Add a filter and document it: `playlist_styles`. Allows users to roll their own playlist themes.
Props DrewAPicture for the docs. See #26631. Built from https://develop.svn.wordpress.org/trunk@27488 git-svn-id: http://core.svn.wordpress.org/trunk@27332 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
634fac6e2c
commit
d2c0cdc5de
|
@ -417,17 +417,27 @@ function wp_print_media_templates() {
|
|||
<script type="text/html" id="tmpl-playlist-settings">
|
||||
<h3><?php _e( 'Playlist Settings' ); ?></h3>
|
||||
|
||||
<?php
|
||||
$playlist_styles = array(
|
||||
'light' => _x( 'Light', 'light playlist theme' ),
|
||||
'dark' => _x( 'Dark', 'dark playlist theme' )
|
||||
);
|
||||
|
||||
/** This filter is documented in wp-includes/media.php */
|
||||
$styles = apply_filters( 'playlist_styles', $playlist_styles );
|
||||
|
||||
if ( ! empty( $styles ) ): ?>
|
||||
<label class="setting">
|
||||
<span><?php _e( 'Style' ); ?></span>
|
||||
<select class="style" data-setting="style">
|
||||
<option value="light">
|
||||
<?php esc_attr_e( 'Light' ); ?>
|
||||
</option>
|
||||
<option value="dark">
|
||||
<?php esc_attr_e( 'Dark' ); ?>
|
||||
<?php foreach ( $styles as $slug => $label ): ?>
|
||||
<option value="<?php echo esc_attr( $slug ) ?>">
|
||||
<?php echo $label ?>
|
||||
</option>
|
||||
<?php endforeach ?>
|
||||
</select>
|
||||
</label>
|
||||
<?php endif; ?>
|
||||
|
||||
<#
|
||||
var playlist = 'playlist-edit' === data.controller.id, emptyModel = _.isEmpty(data.model);
|
||||
|
|
|
@ -1123,7 +1123,21 @@ function wp_get_playlist( $attr, $type ) {
|
|||
$orderby = 'none';
|
||||
}
|
||||
|
||||
if ( ! in_array( $style, array( 'light', 'dark' ), true ) ) {
|
||||
$playlist_styles = array(
|
||||
'light' => _x( 'Light', 'light playlist theme' ),
|
||||
'dark' => _x( 'Dark', 'dark playlist theme' )
|
||||
);
|
||||
|
||||
/**
|
||||
* Filter the available playlist styles.
|
||||
*
|
||||
* @since 3.9.0
|
||||
*
|
||||
* @param array $playlist_styles Array of playlist styles. Defaults are 'light' and 'dark'.
|
||||
*/
|
||||
$styles = apply_filters( 'playlist_styles', $playlist_styles );
|
||||
|
||||
if ( ! in_array( $style, array_keys( $styles ), true ) ) {
|
||||
$style = 'light';
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue