<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[28342] trunk/src/wp-includes/media.php: `audio`, `video`, and `playlist` shortcodes:</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://core.trac.wordpress.org/changeset/28342">28342</a></dd>
<dt>Author</dt> <dd>wonderboymusic</dd>
<dt>Date</dt> <dd>2014-05-07 17:35:09 +0000 (Wed, 07 May 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>`audio`, `video`, and `playlist` shortcodes:

* Convert all instances of variable variables to array properties
* Eradicate use of `extract()`
* Rename `$atts` to `$html_atts` where collision with new `$atts` (shortcode atts holder) var might occur

See <a href="http://core.trac.wordpress.org/ticket/22400">#22400</a>, <a href="http://core.trac.wordpress.org/ticket/27881">#27881</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesmediaphp">trunk/src/wp-includes/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/src/wp-includes/media.php (28341 => 28342)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/src/wp-includes/media.php  2014-05-07 04:26:07 UTC (rev 28341)
+++ trunk/src/wp-includes/media.php     2014-05-07 17:35:09 UTC (rev 28342)
</span><span class="lines">@@ -1196,7 +1196,7 @@
</span><span class="cx">                  unset( $attr['orderby'] );
</span><span class="cx">  }
</span><span class="cx"> 
</span><del>-       extract( shortcode_atts( array(
</del><ins>+        $atts = shortcode_atts( array(
</ins><span class="cx">           'type'          => 'audio',
</span><span class="cx">          'order'         => 'ASC',
</span><span class="cx">          'orderby'       => 'menu_order ID',
</span><span class="lines">@@ -1208,32 +1208,32 @@
</span><span class="cx">          'tracknumbers' => true,
</span><span class="cx">          'images'        => true,
</span><span class="cx">          'artists'       => true
</span><del>-       ), $attr, 'playlist' ) );
</del><ins>+        ), $attr, 'playlist' );
</ins><span class="cx"> 
</span><del>-       $id = intval( $id );
-       if ( 'RAND' == $order ) {
-               $orderby = 'none';
</del><ins>+        $id = intval( $atts['id'] );
+       if ( 'RAND' == $atts['order'] ) {
+               $atts['orderby'] = 'none';
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  $args = array(
</span><span class="cx">          'post_status' => 'inherit',
</span><span class="cx">          'post_type' => 'attachment',
</span><del>-               'post_mime_type' => $type,
-               'order' => $order,
-               'orderby' => $orderby
</del><ins>+                'post_mime_type' => $atts['type'],
+               'order' => $atts['order'],
+               'orderby' => $atts['orderby']
</ins><span class="cx">   );
</span><span class="cx"> 
</span><del>-       if ( ! empty( $include ) ) {
-               $args['include'] = $include;
</del><ins>+        if ( ! empty( $atts['include'] ) ) {
+               $args['include'] = $atts['include'];
</ins><span class="cx">           $_attachments = get_posts( $args );
</span><span class="cx"> 
</span><span class="cx">          $attachments = array();
</span><span class="cx">          foreach ( $_attachments as $key => $val ) {
</span><span class="cx">                  $attachments[$val->ID] = $_attachments[$key];
</span><span class="cx">          }
</span><del>-       } elseif ( ! empty( $exclude ) ) {
</del><ins>+        } elseif ( ! empty( $atts['exclude'] ) ) {
</ins><span class="cx">           $args['post_parent'] = $id;
</span><del>-               $args['exclude'] = $exclude;
</del><ins>+                $args['exclude'] = $atts['exclude'];
</ins><span class="cx">           $attachments = get_children( $args );
</span><span class="cx">  } else {
</span><span class="cx">          $args['post_parent'] = $id;
</span><span class="lines">@@ -1260,13 +1260,15 @@
</span><span class="cx">  $theme_width = empty( $content_width ) ? $default_width : ( $content_width - $outer );
</span><span class="cx">  $theme_height = empty( $content_width ) ? $default_height : round( ( $default_height * $theme_width ) / $default_width );
</span><span class="cx"> 
</span><del>-       $data = compact( 'type' );
</del><ins>+        $data = array(
+               'type' => $atts['type'],
+               // don't pass strings to JSON, will be truthy in JS
+               'tracklist' => filter_var( $atts['tracklist'], FILTER_VALIDATE_BOOLEAN ),
+               'tracknumbers' => filter_var( $atts['tracknumbers'], FILTER_VALIDATE_BOOLEAN ),
+               'images' => filter_var( $atts['images'], FILTER_VALIDATE_BOOLEAN ),
+               'artists' => filter_var( $atts['artists'], FILTER_VALIDATE_BOOLEAN ),
+       );
</ins><span class="cx"> 
</span><del>-       // don't pass strings to JSON, will be truthy in JS
-       foreach ( array( 'tracklist', 'tracknumbers', 'images', 'artists' ) as $key ) {
-               $data[$key] = filter_var( $$key, FILTER_VALIDATE_BOOLEAN );
-       }
-
</del><span class="cx">   $tracks = array();
</span><span class="cx">  foreach ( $attachments as $attachment ) {
</span><span class="cx">          $url = wp_get_attachment_url( $attachment->ID );
</span><span class="lines">@@ -1289,7 +1291,7 @@
</span><span class="cx">                          }
</span><span class="cx">                  }
</span><span class="cx"> 
</span><del>-                       if ( 'video' === $type ) {
</del><ins>+                        if ( 'video' === $atts['type'] ) {
</ins><span class="cx">                           if ( ! empty( $meta['width'] ) && ! empty( $meta['height'] ) ) {
</span><span class="cx">                                  $width = $meta['width'];
</span><span class="cx">                                  $height = $meta['height'];
</span><span class="lines">@@ -1309,12 +1311,12 @@
</span><span class="cx">                  }
</span><span class="cx">          }
</span><span class="cx"> 
</span><del>-               if ( $images ) {
-                       $id = get_post_thumbnail_id( $attachment->ID );
-                       if ( ! empty( $id ) ) {
-                               list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'full' );
</del><ins>+                if ( $atts['images'] ) {
+                       $thumb_id = get_post_thumbnail_id( $attachment->ID );
+                       if ( ! empty( $thumb_id ) ) {
+                               list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'full' );
</ins><span class="cx">                           $track['image'] = compact( 'src', 'width', 'height' );
</span><del>-                               list( $src, $width, $height ) = wp_get_attachment_image_src( $id, 'thumbnail' );
</del><ins>+                                list( $src, $width, $height ) = wp_get_attachment_image_src( $thumb_id, 'thumbnail' );
</ins><span class="cx">                           $track['thumb'] = compact( 'src', 'width', 'height' );
</span><span class="cx">                  } else {
</span><span class="cx">                          $src = wp_mime_type_icon( $attachment->ID );
</span><span class="lines">@@ -1329,8 +1331,8 @@
</span><span class="cx">  }
</span><span class="cx">  $data['tracks'] = $tracks;
</span><span class="cx"> 
</span><del>-       $safe_type = esc_attr( $type );
-       $safe_style = esc_attr( $style );
</del><ins>+        $safe_type = esc_attr( $atts['type'] );
+       $safe_style = esc_attr( $atts['style'] );
</ins><span class="cx"> 
</span><span class="cx">  ob_start();
</span><span class="cx"> 
</span><span class="lines">@@ -1343,10 +1345,10 @@
</span><span class="cx">           * @param string $type  Type of playlist. Possible values are 'audio' or 'video'.
</span><span class="cx">           * @param string $style The 'theme' for the playlist. Core provides 'light' and 'dark'.
</span><span class="cx">           */
</span><del>-               do_action( 'wp_playlist_scripts', $type, $style );
</del><ins>+                do_action( 'wp_playlist_scripts', $atts['type'], $atts['style'] );
</ins><span class="cx">   } ?>
</span><span class="cx"> <div class="wp-playlist wp-<?php echo $safe_type ?>-playlist wp-playlist-<?php echo $safe_style ?>">
</span><del>-       <?php if ( 'audio' === $type ): ?>
</del><ins>+        <?php if ( 'audio' === $atts['type'] ): ?>
</ins><span class="cx">   <div class="wp-playlist-current-item"></div>
</span><span class="cx">  <?php endif ?>
</span><span class="cx">  <<?php echo $safe_type ?> controls="controls" preload="none" width="<?php
</span><span class="lines">@@ -1482,9 +1484,10 @@
</span><span class="cx">   * @param string $content   Shortcode content.
</span><span class="cx">   * @param int    $instances Unique numeric ID of this audio shortcode instance.
</span><span class="cx">   */
</span><del>-       $html = apply_filters( 'wp_audio_shortcode_override', '', $attr, $content, $instances );
-       if ( '' !== $html )
-               return $html;
</del><ins>+        $override = apply_filters( 'wp_audio_shortcode_override', '', $attr, $content, $instances );
+       if ( '' !== $override ) {
+               return $override;
+       }
</ins><span class="cx"> 
</span><span class="cx">  $audio = null;
</span><span class="cx"> 
</span><span class="lines">@@ -1495,38 +1498,42 @@
</span><span class="cx">          'autoplay' => '',
</span><span class="cx">          'preload'  => 'none'
</span><span class="cx">  );
</span><del>-       foreach ( $default_types as $type )
</del><ins>+        foreach ( $default_types as $type ) {
</ins><span class="cx">           $defaults_atts[$type] = '';
</span><ins>+       }
</ins><span class="cx"> 
</span><span class="cx">  $atts = shortcode_atts( $defaults_atts, $attr, 'audio' );
</span><del>-       extract( $atts );
</del><span class="cx"> 
</span><span class="cx">  $primary = false;
</span><del>-       if ( ! empty( $src ) ) {
-               $type = wp_check_filetype( $src, wp_get_mime_types() );
-               if ( ! in_array( strtolower( $type['ext'] ), $default_types ) )
-                       return sprintf( '<a class="wp-embedded-audio" href="%s">%s</a>', esc_url( $src ), esc_html( $src ) );
</del><ins>+        if ( ! empty( $atts['src'] ) ) {
+               $type = wp_check_filetype( $atts['src'], wp_get_mime_types() );
+               if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) {
+                       return sprintf( '<a class="wp-embedded-audio" href="%s">%s</a>', esc_url( $atts['src'] ), esc_html( $atts['src'] ) );
+               }
</ins><span class="cx">           $primary = true;
</span><span class="cx">          array_unshift( $default_types, 'src' );
</span><span class="cx">  } else {
</span><span class="cx">          foreach ( $default_types as $ext ) {
</span><del>-                       if ( ! empty( $$ext ) ) {
-                               $type = wp_check_filetype( $$ext, wp_get_mime_types() );
-                               if ( strtolower( $type['ext'] ) === $ext )
</del><ins>+                        if ( ! empty( $atts[ $ext ] ) ) {
+                               $type = wp_check_filetype( $atts[ $ext ], wp_get_mime_types() );
+                               if ( strtolower( $type['ext'] ) === $ext ) {
</ins><span class="cx">                                   $primary = true;
</span><ins>+                               }
</ins><span class="cx">                   }
</span><span class="cx">          }
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  if ( ! $primary ) {
</span><span class="cx">          $audios = get_attached_media( 'audio', $post_id );
</span><del>-               if ( empty( $audios ) )
</del><ins>+                if ( empty( $audios ) ) {
</ins><span class="cx">                   return;
</span><ins>+               }
</ins><span class="cx"> 
</span><span class="cx">          $audio = reset( $audios );
</span><del>-               $src = wp_get_attachment_url( $audio->ID );
-               if ( empty( $src ) )
</del><ins>+                $atts['src'] = wp_get_attachment_url( $audio->ID );
+               if ( empty( $atts['src'] ) ) {
</ins><span class="cx">                   return;
</span><ins>+               }
</ins><span class="cx"> 
</span><span class="cx">          array_unshift( $default_types, 'src' );
</span><span class="cx">  }
</span><span class="lines">@@ -1551,45 +1558,49 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $class CSS class or list of space-separated classes.
</span><span class="cx">   */
</span><del>-       $atts = array(
</del><ins>+        $html_atts = array(
</ins><span class="cx">           'class'    => apply_filters( 'wp_audio_shortcode_class', 'wp-audio-shortcode' ),
</span><span class="cx">          'id'       => sprintf( 'audio-%d-%d', $post_id, $instances ),
</span><del>-               'loop'     => $loop,
-               'autoplay' => $autoplay,
-               'preload'  => $preload,
</del><ins>+                'loop'     => $atts['loop'],
+               'autoplay' => $atts['autoplay'],
+               'preload'  => $atts['preload'],
</ins><span class="cx">           'style'    => 'width: 100%; visibility: hidden;',
</span><span class="cx">  );
</span><span class="cx"> 
</span><span class="cx">  // These ones should just be omitted altogether if they are blank
</span><span class="cx">  foreach ( array( 'loop', 'autoplay', 'preload' ) as $a ) {
</span><del>-               if ( empty( $atts[$a] ) )
-                       unset( $atts[$a] );
</del><ins>+                if ( empty( $html_atts[$a] ) ) {
+                       unset( $html_atts[$a] );
+               }
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  $attr_strings = array();
</span><del>-       foreach ( $atts as $k => $v ) {
</del><ins>+        foreach ( $html_atts as $k => $v ) {
</ins><span class="cx">           $attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  $html = '';
</span><del>-       if ( 'mediaelement' === $library && 1 === $instances )
</del><ins>+        if ( 'mediaelement' === $library && 1 === $instances ) {
</ins><span class="cx">           $html .= "<!--[if lt IE 9]><script>document.createElement('audio');</script><![endif]-->\n";
</span><ins>+       }
</ins><span class="cx">   $html .= sprintf( '<audio %s controls="controls">', join( ' ', $attr_strings ) );
</span><span class="cx"> 
</span><span class="cx">  $fileurl = '';
</span><span class="cx">  $source = '<source type="%s" src="%s" />';
</span><span class="cx">  foreach ( $default_types as $fallback ) {
</span><del>-               if ( ! empty( $$fallback ) ) {
-                       if ( empty( $fileurl ) )
-                               $fileurl = $$fallback;
-                       $type = wp_check_filetype( $$fallback, wp_get_mime_types() );
-                       $url = add_query_arg( '_', $instances, $$fallback );
</del><ins>+                if ( ! empty( $atts[ $fallback ] ) ) {
+                       if ( empty( $fileurl ) ) {
+                               $fileurl = $atts[ $fallback ];
+                       }
+                       $type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() );
+                       $url = add_query_arg( '_', $instances, $atts[ $fallback ] );
</ins><span class="cx">                   $html .= sprintf( $source, $type['type'], esc_url( $url ) );
</span><span class="cx">          }
</span><span class="cx">  }
</span><span class="cx"> 
</span><del>-       if ( 'mediaelement' === $library )
</del><ins>+        if ( 'mediaelement' === $library ) {
</ins><span class="cx">           $html .= wp_mediaelement_fallback( $fileurl );
</span><ins>+       }
</ins><span class="cx">   $html .= '</audio>';
</span><span class="cx"> 
</span><span class="cx">  /**
</span><span class="lines">@@ -1674,9 +1685,10 @@
</span><span class="cx">   * @param string $content   Video shortcode content.
</span><span class="cx">   * @param int    $instances Unique numeric ID of this video shortcode instance.
</span><span class="cx">   */
</span><del>-       $html = apply_filters( 'wp_video_shortcode_override', '', $attr, $content, $instances );
-       if ( '' !== $html )
-               return $html;
</del><ins>+        $override = apply_filters( 'wp_video_shortcode_override', '', $attr, $content, $instances );
+       if ( '' !== $override ) {
+               return $override;
+       }
</ins><span class="cx"> 
</span><span class="cx">  $video = null;
</span><span class="cx"> 
</span><span class="lines">@@ -1691,57 +1703,60 @@
</span><span class="cx">          'height'   => 360,
</span><span class="cx">  );
</span><span class="cx"> 
</span><del>-       foreach ( $default_types as $type )
</del><ins>+        foreach ( $default_types as $type ) {
</ins><span class="cx">           $defaults_atts[$type] = '';
</span><ins>+       }
</ins><span class="cx"> 
</span><span class="cx">  $atts = shortcode_atts( $defaults_atts, $attr, 'video' );
</span><del>-       extract( $atts );
</del><span class="cx"> 
</span><span class="cx">  if ( is_admin() ) {
</span><span class="cx">          // shrink the video so it isn't huge in the admin
</span><del>-               if ( $width > $defaults_atts['width'] ) {
-                       $height = round( ( $height * $defaults_atts['width'] ) / $width );
-                       $width = $defaults_atts['width'];
</del><ins>+                if ( $atts['width'] > $defaults_atts['width'] ) {
+                       $atts['height'] = round( ( $atts['height'] * $defaults_atts['width'] ) / $atts['width'] );
+                       $atts['width'] = $defaults_atts['width'];
</ins><span class="cx">           }
</span><span class="cx">  } else {
</span><span class="cx">          // if the video is bigger than the theme
</span><del>-               if ( ! empty( $content_width ) && $width > $content_width ) {
-                       $height = round( ( $height * $content_width ) / $width );
-                       $width = $content_width;
</del><ins>+                if ( ! empty( $content_width ) && $atts['width'] > $content_width ) {
+                       $atts['height'] = round( ( $atts['height'] * $content_width ) / $atts['width'] );
+                       $atts['width'] = $content_width;
</ins><span class="cx">           }
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  $yt_pattern = '#^https?://(:?www\.)?(:?youtube\.com/watch|youtu\.be/)#';
</span><span class="cx"> 
</span><span class="cx">  $primary = false;
</span><del>-       if ( ! empty( $src ) ) {
-               if ( ! preg_match( $yt_pattern, $src ) ) {
-                       $type = wp_check_filetype( $src, wp_get_mime_types() );
</del><ins>+        if ( ! empty( $atts['src'] ) ) {
+               if ( ! preg_match( $yt_pattern, $atts['src'] ) ) {
+                       $type = wp_check_filetype( $atts['src'], wp_get_mime_types() );
</ins><span class="cx">                   if ( ! in_array( strtolower( $type['ext'] ), $default_types ) ) {
</span><del>-                               return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $src ), esc_html( $src ) );
</del><ins>+                                return sprintf( '<a class="wp-embedded-video" href="%s">%s</a>', esc_url( $atts['src'] ), esc_html( $atts['src'] ) );
</ins><span class="cx">                   }
</span><span class="cx">          }
</span><span class="cx">          $primary = true;
</span><span class="cx">          array_unshift( $default_types, 'src' );
</span><span class="cx">  } else {
</span><span class="cx">          foreach ( $default_types as $ext ) {
</span><del>-                       if ( ! empty( $$ext ) ) {
-                               $type = wp_check_filetype( $$ext, wp_get_mime_types() );
-                               if ( strtolower( $type['ext'] ) === $ext )
</del><ins>+                        if ( ! empty( $atts[ $ext ] ) ) {
+                               $type = wp_check_filetype( $atts[ $ext ], wp_get_mime_types() );
+                               if ( strtolower( $type['ext'] ) === $ext ) {
</ins><span class="cx">                                   $primary = true;
</span><ins>+                               }
</ins><span class="cx">                   }
</span><span class="cx">          }
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  if ( ! $primary ) {
</span><span class="cx">          $videos = get_attached_media( 'video', $post_id );
</span><del>-               if ( empty( $videos ) )
</del><ins>+                if ( empty( $videos ) ) {
</ins><span class="cx">                   return;
</span><ins>+               }
</ins><span class="cx"> 
</span><span class="cx">          $video = reset( $videos );
</span><del>-               $src = wp_get_attachment_url( $video->ID );
-               if ( empty( $src ) )
</del><ins>+                $atts['src'] = wp_get_attachment_url( $video->ID );
+               if ( empty( $atts['src'] ) ) {
</ins><span class="cx">                   return;
</span><ins>+               }
</ins><span class="cx"> 
</span><span class="cx">          array_unshift( $default_types, 'src' );
</span><span class="cx">  }
</span><span class="lines">@@ -1766,75 +1781,78 @@
</span><span class="cx">   *
</span><span class="cx">   * @param string $class CSS class or list of space-separated classes.
</span><span class="cx">   */
</span><del>-       $atts = array(
</del><ins>+        $html_atts = array(
</ins><span class="cx">           'class'    => apply_filters( 'wp_video_shortcode_class', 'wp-video-shortcode' ),
</span><span class="cx">          'id'       => sprintf( 'video-%d-%d', $post_id, $instances ),
</span><del>-               'width'    => absint( $width ),
-               'height'   => absint( $height ),
-               'poster'   => esc_url( $poster ),
-               'loop'     => $loop,
-               'autoplay' => $autoplay,
-               'preload'  => $preload,
</del><ins>+                'width'    => absint( $atts['width'] ),
+               'height'   => absint( $atts['height'] ),
+               'poster'   => esc_url( $atts['poster'] ),
+               'loop'     => $atts['loop'],
+               'autoplay' => $atts['autoplay'],
+               'preload'  => $atts['preload'],
</ins><span class="cx">   );
</span><span class="cx"> 
</span><span class="cx">  // These ones should just be omitted altogether if they are blank
</span><span class="cx">  foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a ) {
</span><del>-               if ( empty( $atts[$a] ) )
-                       unset( $atts[$a] );
</del><ins>+                if ( empty( $html_atts[$a] ) ) {
+                       unset( $html_atts[$a] );
+               }
</ins><span class="cx">   }
</span><span class="cx"> 
</span><span class="cx">  $attr_strings = array();
</span><del>-       foreach ( $atts as $k => $v ) {
</del><ins>+        foreach ( $html_atts as $k => $v ) {
</ins><span class="cx">           $attr_strings[] = $k . '="' . esc_attr( $v ) . '"';
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  $html = '';
</span><del>-       if ( 'mediaelement' === $library && 1 === $instances )
</del><ins>+        if ( 'mediaelement' === $library && 1 === $instances ) {
</ins><span class="cx">           $html .= "<!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->\n";
</span><ins>+       }
</ins><span class="cx">   $html .= sprintf( '<video %s controls="controls">', join( ' ', $attr_strings ) );
</span><span class="cx"> 
</span><span class="cx">  $fileurl = '';
</span><span class="cx">  $source = '<source type="%s" src="%s" />';
</span><span class="cx">  foreach ( $default_types as $fallback ) {
</span><del>-               if ( ! empty( $$fallback ) ) {
-                       if ( empty( $fileurl ) )
-                               $fileurl = $$fallback;
-
-                       if ( 'src' === $fallback && preg_match( $yt_pattern, $src ) ) {
</del><ins>+                if ( ! empty( $atts[ $fallback ] ) ) {
+                       if ( empty( $fileurl ) ) {
+                               $fileurl = $atts[ $fallback ];
+                       }
+                       if ( 'src' === $fallback && preg_match( $yt_pattern, $atts['src'] ) ) {
</ins><span class="cx">                           $type = array( 'type' => 'video/youtube' );
</span><span class="cx">                  } else {
</span><del>-                               $type = wp_check_filetype( $$fallback, wp_get_mime_types() );
</del><ins>+                                $type = wp_check_filetype( $atts[ $fallback ], wp_get_mime_types() );
</ins><span class="cx">                   }
</span><del>-                       $url = add_query_arg( '_', $instances, $$fallback );
</del><ins>+                        $url = add_query_arg( '_', $instances, $atts[ $fallback ] );
</ins><span class="cx">                   $html .= sprintf( $source, $type['type'], esc_url( $url ) );
</span><span class="cx">          }
</span><span class="cx">  }
</span><span class="cx"> 
</span><span class="cx">  if ( ! empty( $content ) ) {
</span><del>-               if ( false !== strpos( $content, "\n" ) )
</del><ins>+                if ( false !== strpos( $content, "\n" ) ) {
</ins><span class="cx">                   $content = str_replace( array( "\r\n", "\n", "\t" ), '', $content );
</span><del>-
</del><ins>+                }
</ins><span class="cx">           $html .= trim( $content );
</span><span class="cx">  }
</span><span class="cx"> 
</span><del>-       if ( 'mediaelement' === $library )
</del><ins>+        if ( 'mediaelement' === $library ) {
</ins><span class="cx">           $html .= wp_mediaelement_fallback( $fileurl );
</span><ins>+       }
</ins><span class="cx">   $html .= '</video>';
</span><span class="cx"> 
</span><del>-       $html = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $width, $html );
</del><ins>+        $output = sprintf( '<div style="width: %dpx; max-width: 100%%;" class="wp-video">%s</div>', $atts['width'], $html );
</ins><span class="cx"> 
</span><span class="cx">  /**
</span><span class="cx">   * Filter the output of the video shortcode.
</span><span class="cx">   *
</span><span class="cx">   * @since 3.6.0
</span><span class="cx">   *
</span><del>-        * @param string $html    Video shortcode HTML output.
</del><ins>+         * @param string $output  Video shortcode HTML output.
</ins><span class="cx">    * @param array  $atts    Array of video shortcode attributes.
</span><span class="cx">   * @param string $video   Video file.
</span><span class="cx">   * @param int    $post_id Post ID.
</span><span class="cx">   * @param string $library Media library used for the video shortcode.
</span><span class="cx">   */
</span><del>-       return apply_filters( 'wp_video_shortcode', $html, $atts, $video, $post_id, $library );
</del><ins>+        return apply_filters( 'wp_video_shortcode', $output, $atts, $video, $post_id, $library );
</ins><span class="cx"> }
</span><span class="cx"> add_shortcode( 'video', 'wp_video_shortcode' );
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>