Make WordPress Core

Ticket #42718: 42718.diff

File 42718.diff, 3.9 KB (added by birgire, 7 years ago)
  • src/wp-includes/media-template.php

    diff --git src/wp-includes/media-template.php src/wp-includes/media-template.php
    index bd0e31f..c07d59b 100644
    function wp_underscore_video_template() { 
    102102                }
    103103        endforeach;
    104104        ?><#
    105         <?php foreach ( array( 'autoplay', 'loop' ) as $attr ):
     105        <?php foreach ( array( 'autoplay', 'loop', 'muted' ) as $attr ):
    106106        ?> if ( ! _.isUndefined( data.model.<?php echo $attr ?> ) && data.model.<?php echo $attr ?> ) {
    107107                #> <?php echo $attr ?><#
    108108        }
    function wp_print_media_templates() { 
    11861186                                        <span><?php _e( 'Loop' ); ?></span>
    11871187                                </label>
    11881188
     1189                                <label class="setting checkbox-setting">
     1190                                        <input type="checkbox" data-setting="muted" />
     1191                                        <span><?php _e( 'Muted' ); ?></span>
     1192                                </label>
     1193
    11891194                                <label class="setting" data-setting="content">
    11901195                                        <span><?php _e( 'Tracks (subtitles, captions, descriptions, chapters, or metadata)' ); ?></span>
    11911196                                        <#
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 1981f3a..4e69406 100644
    function wp_get_video_extensions() { 
    24172417 *     @type string $poster   The 'poster' attribute for the `<video>` element. Default empty.
    24182418 *     @type string $loop     The 'loop' attribute for the `<video>` element. Default empty.
    24192419 *     @type string $autoplay The 'autoplay' attribute for the `<video>` element. Default empty.
     2420 *     @type string $muted    The 'muted' attribute for the `<video>` element. Default empty.
    24202421 *     @type string $preload  The 'preload' attribute for the `<video>` element.
    24212422 *                            Default 'metadata'.
    24222423 *     @type string $class    The 'class' attribute for the `<video>` element.
    function wp_video_shortcode( $attr, $content = '' ) { 
    24602461                'poster'   => '',
    24612462                'loop'     => '',
    24622463                'autoplay' => '',
     2464                'muted'    => '',
    24632465                'preload'  => 'metadata',
    24642466                'width'    => 640,
    24652467                'height'   => 360,
    function wp_video_shortcode( $attr, $content = '' ) { 
    25842586                'poster'   => esc_url( $atts['poster'] ),
    25852587                'loop'     => wp_validate_boolean( $atts['loop'] ),
    25862588                'autoplay' => wp_validate_boolean( $atts['autoplay'] ),
     2589                'muted'    => wp_validate_boolean( $atts['muted'] ),
    25872590                'preload'  => $atts['preload'],
    25882591        );
    25892592
    25902593        // These ones should just be omitted altogether if they are blank
    2591         foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a ) {
     2594        foreach ( array( 'poster', 'loop', 'autoplay', 'muted', 'preload' ) as $a ) {
    25922595                if ( empty( $html_atts[$a] ) ) {
    25932596                        unset( $html_atts[$a] );
    25942597                }
  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index 20b670f..b71e598 100644
    VIDEO; 
    810810
    811811        /**
    812812         * @ticket  35367
     813         * @ticket  42718
    813814         * @depends test_video_shortcode_body
    814815         */
    815816        function test_wp_video_shortcode_attributes() {
    VIDEO; 
    820821                $this->assertContains( 'src="https://example.com/foo.mp4', $actual );
    821822                $this->assertNotContains( 'loop', $actual );
    822823                $this->assertNotContains( 'autoplay', $actual );
     824                $this->assertNotContains( 'muted', $actual );
    823825                $this->assertContains( 'preload="metadata"', $actual );
    824826                $this->assertContains( 'width="640"', $actual );
    825827                $this->assertContains( 'height="360"', $actual );
    VIDEO; 
    830832                        'poster'   => 'https://example.com/foo.png',
    831833                        'loop'     => true,
    832834                        'autoplay' => true,
     835                        'muted'    => true,
    833836                        'preload'  => true,
    834837                        'width'    => 123,
    835838                        'height'   => 456,
    VIDEO; 
    840843                $this->assertContains( 'poster="https://example.com/foo.png', $actual );
    841844                $this->assertContains( 'loop="1"', $actual );
    842845                $this->assertContains( 'autoplay="1"', $actual );
     846                $this->assertContains( 'muted="1"', $actual );
    843847                $this->assertContains( 'preload="1"', $actual );
    844848                $this->assertContains( 'width="123"', $actual );
    845849                $this->assertContains( 'height="456"', $actual );