Make WordPress Core

Ticket #40866: 40866.1.diff

File 40866.1.diff, 2.2 KB (added by timmydcrawford, 8 years ago)
  • src/wp-includes/media.php

     
    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 mejs player from breaking.
     2550        if ( 'mediaelement' === $library && ( $is_youtube || $is_vimeo ) ) {
     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                }
     2556
     2557                if ( $is_vimeo ) {
     2558                        // Remove all query arguments from Vimeo URLs and force ssl - see #40866.
     2559                        $parsed_vimeo_url = wp_parse_url( $atts['src'] );
     2560                        $atts['src'] = 'https://' . $parsed_vimeo_url['host'] . $parsed_vimeo_url['path'];
     2561                        wp_enqueue_script( 'froogaloop' );
     2562                }
     2563        }
     2564
    25492565        /**
    25502566         * Filters the class attribute for the video shortcode output container.
    25512567         *
  • tests/phpunit/tests/media.php

     
    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         */