WordPress.org

Make WordPress Core

Changeset 27488


Ignore:
Timestamp:
03/09/2014 11:36:57 PM (7 years ago)
Author:
wonderboymusic
Message:

Add a filter and document it: playlist_styles. Allows users to roll their own playlist themes.

Props DrewAPicture for the docs.
See #26631.

Location:
trunk/src/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media-template.php

    r27487 r27488  
    418418        <h3><?php _e( 'Playlist Settings' ); ?></h3>
    419419
     420        <?php
     421        $playlist_styles = array(
     422            'light' => _x( 'Light', 'light playlist theme' ),
     423            'dark'  => _x( 'Dark', 'dark playlist theme' )
     424        );
     425
     426        /** This filter is documented in wp-includes/media.php */
     427        $styles = apply_filters( 'playlist_styles', $playlist_styles );
     428
     429        if ( ! empty( $styles ) ): ?>
    420430        <label class="setting">
    421431            <span><?php _e( 'Style' ); ?></span>
    422432            <select class="style" data-setting="style">
    423                 <option value="light">
    424                     <?php esc_attr_e( 'Light' ); ?>
     433                <?php foreach ( $styles as $slug => $label ): ?>
     434                <option value="<?php echo esc_attr( $slug ) ?>">
     435                    <?php echo $label ?>
    425436                </option>
    426                 <option value="dark">
    427                     <?php esc_attr_e( 'Dark' ); ?>
    428                 </option>
     437                <?php endforeach ?>
    429438            </select>
    430439        </label>
     440        <?php endif; ?>
    431441
    432442        <#
  • trunk/src/wp-includes/media.php

    r27486 r27488  
    11241124    }
    11251125
    1126     if ( ! in_array( $style, array( 'light', 'dark' ), true ) ) {
     1126    $playlist_styles = array(
     1127        'light' => _x( 'Light', 'light playlist theme' ),
     1128        'dark'  => _x( 'Dark', 'dark playlist theme' )
     1129    );
     1130
     1131    /**
     1132     * Filter the available playlist styles.
     1133     *
     1134     * @since 3.9.0
     1135     *
     1136     * @param array $playlist_styles Array of playlist styles. Defaults are 'light' and 'dark'.
     1137     */
     1138    $styles = apply_filters( 'playlist_styles', $playlist_styles );
     1139
     1140    if ( ! in_array( $style, array_keys( $styles ), true ) ) {
    11271141        $style = 'light';
    11281142    }
Note: See TracChangeset for help on using the changeset viewer.