Making WordPress.org

Changeset 1712


Ignore:
Timestamp:
07/07/2015 06:05:16 PM (11 years ago)
Author:
iandunn
Message:

WordPress.tv: Allow all [wpvideo] parameters to be used.

Previously the shortcode was overwritten, wiping out any parameters that had been added.

This was neccessary because one of the featured videos from WordCamp? Europe 2015 will not load in the old VideoPress? player with HD mode enabled, but adding hd=0 to the shortcode works around that problem until the new VideoPress? player can be integrated.

See ​http://wordpress.tv/2015/07/04/matt-mullenweg-keynote-qanda-wordcamp-europe-2015/
See ​https://wordpress.slack.com/archives/meta/p1436245724000263
See ​https://a8c.slack.com/archives/videopress/p1436283547005484

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.tv/public_html/wp-content/themes/wptv2/functions.php

    r1557 r1712  
    469469                remove_filter( 'the_content', array( $this, 'remove_shortcodes' ) );
    470470
    471                 preg_match_all( '/\[wpvideo +([a-zA-Z0-9,\#,\&,\/,;,",=, ]*?)\]/i', $post->post_content, $matches );
    472                 foreach ( $matches[1] as $key => $code ) {
    473 
    474                         preg_match( '/([0-9A-Za-z]+)/i', $code, $m );
    475                         $guid = $m[1];
    476 
    477                         $image = video_image_url_by_guid( $guid, 'fmt_dvd' ); //dvd image has width = 640
    478                         $video = apply_filters( 'the_content', '[wpvideo ' . $guid . ' w=605]' );
    479 
    480                         /*
    481                         // Comment out the $video= line above and uncomment the following code to enable Unisubs
    482                         $permalink = get_permalink( $post->ID );
    483                         $video = <<<HTML
    484                         <script type="text/javascript" src="http://unisubs.example.com:8000/site_media/embed.js">
    485                         ({
    486                                 "video_url": "$permalink",
    487                                 "video_config": {
    488                                         "width": 648,
    489                                         "height": 425
    490                                 }
    491                         })
    492                         </script>
    493         HTML;
    494                         $video .= apply_filters( 'the_content', '' );*/
    495                 }
    496 
     471                // VideoPress
     472                preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $shortcodes, PREG_SET_ORDER );
     473                foreach ( $shortcodes as $shortcode ) {
     474                        if ( 'wpvideo' == $shortcode[2] ) {
     475                                $attributes = shortcode_parse_atts( $shortcode[0] );
     476                                $image      = video_image_url_by_guid( rtrim( $attributes[1], ']' ), 'fmt_dvd' ); // dvd image has width = 640
     477                                $video      = sprintf( '[%s %s w="605"]', $shortcode[2], trim( $shortcode[3] ) );
     478                                $video      = apply_filters( 'the_content', $video );
     479                        }
     480                }
     481
     482                // SlideShare
    497483                preg_match_all( '|\[slideshare (.+?)]|ie', $post->post_content, $matches );
    498484                foreach ( $matches[1] as $key => $code ) {
     
    511497                }
    512498
     499                // VodPod
    513500                preg_match_all( '|\[vodpod (.+?)]|ie', $post->post_content, $matches );
    514501                foreach ( $matches[1] as $key => $code ) {
     
    521508                }
    522509
     510                // Output results
    523511                if ( $thumb ) {
    524512                        if ( ! $no_html ) {
     
    529517                        echo $video;
    530518                }
     519
    531520                add_filter( 'the_content', array( $this, 'remove_shortcodes' ) );
    532521        }
Note: See TracChangeset for help on using the changeset viewer.