Make WordPress Core

Ticket #40590: 40590-4.diff

File 40590-4.diff, 3.1 KB (added by birgire, 8 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 8965da9..1812672 100644
    function wp_get_video_extensions() { 
    24952495 * WordPress mp4s in a post.
    24962496 *
    24972497 * @since 3.6.0
     2498 * @since ?.?.? The `controls` attribute was added.
    24982499 *
    24992500 * @global int $content_width
    25002501 * @staticvar int $instance
    function wp_get_video_extensions() { 
    25122513 *                            Default 'metadata'.
    25132514 *     @type string $class    The 'class' attribute for the `<video>` element.
    25142515 *                            Default 'wp-video-shortcode'.
     2516 *     @type string $controls The 'controls' attribute for the `<video>` element. Default true.
    25152517 * }
    25162518 * @param string $content Shortcode content.
    25172519 * @return string|void HTML content to display video.
    function wp_video_shortcode( $attr, $content = '' ) { 
    25552557                'width'    => 640,
    25562558                'height'   => 360,
    25572559                'class'    => 'wp-video-shortcode',
     2560                'controls' => true,
    25582561        );
    25592562
    25602563        foreach ( $default_types as $type ) {
    function wp_video_shortcode( $attr, $content = '' ) { 
    26762679                'loop'     => wp_validate_boolean( $atts['loop'] ),
    26772680                'autoplay' => wp_validate_boolean( $atts['autoplay'] ),
    26782681                'preload'  => $atts['preload'],
     2682                'controls' => wp_validate_boolean( $atts['controls'] ) ? 'controls' : '',
    26792683        );
    26802684
    26812685        // These ones should just be omitted altogether if they are blank
    2682         foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a ) {
     2686        foreach ( array( 'poster', 'loop', 'autoplay', 'preload', 'controls' ) as $a ) {
    26832687                if ( empty( $html_atts[ $a ] ) ) {
    26842688                        unset( $html_atts[ $a ] );
    26852689                }
    function wp_video_shortcode( $attr, $content = '' ) { 
    26942698        if ( 'mediaelement' === $library && 1 === $instance ) {
    26952699                $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n";
    26962700        }
    2697         $html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) );
     2701        $html .= sprintf( '<video %s>', join( ' ', $attr_strings ) );
    26982702
    26992703        $fileurl = '';
    27002704        $source  = '<source type="%s" src="%s" />';
  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index 1fe2228..bfe427f 100644
    VIDEO; 
    874874        }
    875875
    876876        /**
    877          * @ticket  35367
     877         * @ticket 35367
     878         * @ticket 40590
    878879         * @depends test_video_shortcode_body
    879880         */
    880881        function test_wp_video_shortcode_attributes() {
    VIDEO; 
    891892                $this->assertContains( 'width="640"', $actual );
    892893                $this->assertContains( 'height="360"', $actual );
    893894                $this->assertContains( 'class="wp-video-shortcode"', $actual );
     895                $this->assertContains( 'controls="controls"', $actual );
    894896
    895897                $actual = wp_video_shortcode(
    896898                        array(
    VIDEO; 
    902904                                'width'    => 123,
    903905                                'height'   => 456,
    904906                                'class'    => 'foobar',
     907                                'controls' => false,
    905908                        )
    906909                );
    907910
    VIDEO; 
    913916                $this->assertContains( 'width="123"', $actual );
    914917                $this->assertContains( 'height="456"', $actual );
    915918                $this->assertContains( 'class="foobar"', $actual );
     919                $this->assertNotContains( 'controls="controls"', $actual );
    916920        }
    917921
    918922        /**