WordPress.org

Make WordPress Core

Ticket #40866: 40866.3.diff

File 40866.3.diff, 2.2 KB (added by westonruter, 2 years ago)

Tweak comments; condense conditional

  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 81d83d8cc0..c4d51c7ba6 100644
    function wp_video_shortcode( $attr, $content = '' ) { 
    25462546                wp_enqueue_script( 'wp-mediaelement' );
    25472547        }
    25482548
     2549        // Mediaelement has issues with some url formatting for Vimeo and YouTube, update src to prevent the ME.js 2.22.0 player from breaking.
     2550        if ( 'mediaelement' === $library ) {
     2551                if ( $is_youtube ) {
     2552                        // Remove feature query arg and force ssl for YouTube links - see #40866.
     2553                        $atts['src'] = remove_query_arg( 'feature', $atts['src'] );
     2554                        $atts['src'] = preg_replace( '|^http://|i', 'https://', $atts['src'] );
     2555                } elseif ( $is_vimeo ) {
     2556                        // Remove all query arguments from Vimeo URLs and force ssl - see #40866.
     2557                        $parsed_vimeo_url = wp_parse_url( $atts['src'] );
     2558                        $atts['src'] = 'https://' . $parsed_vimeo_url['host'] . $parsed_vimeo_url['path'];
     2559                }
     2560        }
     2561
    25492562        /**
    25502563         * Filters the class attribute for the video shortcode output container.
    25512564         *
  • tests/phpunit/tests/media.php

    diff --git tests/phpunit/tests/media.php tests/phpunit/tests/media.php
    index bccab12d3e..a9badf876d 100644
    VIDEO; 
    724724        }
    725725
    726726        /**
     727         * @ticket 40866
     728         */
     729        function test_wp_video_shortcode_youtube_remove_feature() {
     730                $actual = wp_video_shortcode( array(
     731                        'src' => 'https://www.youtube.com/watch?v=i_cVJgIz_Cs&feature=youtu.be',
     732                ) );
     733
     734                $this->assertNotContains( 'feature=youtu.be', $actual );
     735        }
     736
     737        /**
     738         * @ticket 40866
     739         */
     740        function test_wp_video_shortcode_youtube_force_ssl() {
     741                $actual = wp_video_shortcode( array(
     742                        'src' => 'http://www.youtube.com/watch?v=i_cVJgIz_Cs',
     743                ) );
     744
     745                $this->assertContains( 'src="https://www.youtube.com/watch?v=i_cVJgIz_Cs', $actual );
     746        }
     747
     748        /**
     749         * @ticket 40866
     750         */
     751        function test_wp_video_shortcode_vimeo_force_ssl_remove_query_args() {
     752                $actual = wp_video_shortcode( array(
     753                        'src' => 'http://vimeo.com/190372437?blah=meh',
     754                ) );
     755
     756                $this->assertContains( 'src="https://vimeo.com/190372437', $actual );
     757                $this->assertNotContains( 'blah=meh', $actual );
     758        }
     759
     760        /**
    727761         * Test [video] shortcode processing
    728762         *
    729763         */