Make WordPress Core


Ignore:
Timestamp:
01/09/2016 02:17:02 PM (11 years ago)
Author:
swissspidy
Message:

Media: Fix wp_audio_shortcode and wp_video_shortcode attributes handling.

Although documented, the class and style attributes were simply ignored.
Adds unit tests.

Fixes #35367.

File:
1 edited

Legend:

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

    r36121 r36240  
    21642164 *     @type string $loop     The 'loop' attribute for the `<audio>` element. Default empty.
    21652165 *     @type string $autoplay The 'autoplay' attribute for the `<audio>` element. Default empty.
    2166  *     @type string $preload  The 'preload' attribute for the `<audio>` element. Default empty.
     2166 *     @type string $preload  The 'preload' attribute for the `<audio>` element. Default 'none'.
    21672167 *     @type string $class    The 'class' attribute for the `<audio>` element. Default 'wp-audio-shortcode'.
    2168  *     @type string $style    The 'style' attribute for the `<audio>` element. Default 'width: 100%'.
     2168 *     @type string $style    The 'style' attribute for the `<audio>` element. Default 'width: 100%; visibility: hidden;'.
    21692169 * }
    21702170 * @param string $content Shortcode content.
    … …  
    22012201                'loop'     => '',
    22022202                'autoplay' => '',
    2203                 'preload'  => 'none'
     2203                'preload'  => 'none',
     2204                'class'    => 'wp-audio-shortcode',
     2205                'style'    => 'width: 100%; visibility: hidden;'
    22042206        );
    22052207        foreach ( $default_types as $type ) {
    … …  
    22632265         * @param string $class CSS class or list of space-separated classes.
    22642266         */
     2267         $atts['class'] = apply_filters( 'wp_audio_shortcode_class', $atts['class'] );
     2268
    22652269        $html_atts = array(
    2266                 'class'    => apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ),
     2270                'class'    => $atts['class'],
    22672271                'id'       => sprintf( 'audio-%d-%d', $post_id, $instance ),
    22682272                'loop'     => wp_validate_boolean( $atts['loop'] ),
    22692273                'autoplay' => wp_validate_boolean( $atts['autoplay'] ),
    22702274                'preload'  => $atts['preload'],
    2271                 'style'    => 'width: 100%; visibility: hidden;',
     2275                'style'    => $atts['style'],
    22722276        );
    22732277
    … …  
    24082412                'width'    => 640,
    24092413                'height'   => 360,
     2414                'class'    => 'wp-video-shortcode',
    24102415        );
    24112416
    … …  
    24972502         * @param string $class CSS class or list of space-separated classes.
    24982503         */
     2504         $atts['class'] = apply_filters( 'wp_video_shortcode_class', $atts['class'] );
     2505
    24992506        $html_atts = array(
    2500                 'class'    => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ),
     2507                'class'    => $atts['class'],
    25012508                'id'       => sprintf( 'video-%d-%d', $post_id, $instance ),
    25022509                'width'    => absint( $atts['width'] ),
Note: See TracChangeset for help on using the changeset viewer.