<!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" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { 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, #msg p { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul { overflow: auto; }
#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>
<title>[12027] trunk/wp-includes: Use oEmbed for youtube.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12027">12027</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2009-10-13 22:36:24 +0000 (Tue, 13 Oct 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use oEmbed for youtube. Props Viper007Bond. see <a href="http://trac.wordpress.org/ticket/10337">#10337</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludescapabilitiesphp">trunk/wp-includes/capabilities.php</a></li>
<li><a href="#trunkwpincludesclassoembedphp">trunk/wp-includes/class-oembed.php</a></li>
<li><a href="#trunkwpincludesdefaultembedsphp">trunk/wp-includes/default-embeds.php</a></li>
<li><a href="#trunkwpincludesformattingphp">trunk/wp-includes/formatting.php</a></li>
<li><a href="#trunkwpincludesmediaphp">trunk/wp-includes/media.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludescapabilitiesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/capabilities.php (12026 => 12027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/capabilities.php        2009-10-13 22:04:54 UTC (rev 12026)
+++ trunk/wp-includes/capabilities.php        2009-10-13 22:36:24 UTC (rev 12027)
</span><span class="lines">@@ -962,7 +962,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Whether author of supplied post has capability or role.
</span><span class="cx">  *
</span><del>- * @since 2.9
</del><ins>+ * @since 2.9.0
</ins><span class="cx">  *
</span><span class="cx">  * @param int|object $post Post ID or post object.
</span><span class="cx">  * @param string $capability Capability or role name.
</span></span></pre></div>
<a id="trunkwpincludesclassoembedphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/class-oembed.php (12026 => 12027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/class-oembed.php        2009-10-13 22:04:54 UTC (rev 12026)
+++ trunk/wp-includes/class-oembed.php        2009-10-13 22:36:24 UTC (rev 12027)
</span><span class="lines">@@ -37,12 +37,14 @@
</span><span class="cx">                 // The WP_Embed class disables discovery for non-unfiltered_html users,
</span><span class="cx">                 // so only providers in this array will be used for them.
</span><span class="cx">                 $this-&gt;providers = apply_filters( 'oembed_providers', array(
</span><ins>+                        'http://*.youtube.com/watch*' =&gt; 'http://www.youtube.com/oembed',
+                        'http://youtube.com/watch*'   =&gt; 'http://www.youtube.com/oembed',
</ins><span class="cx">                         'http://blip.tv/file/*'       =&gt; 'http://blip.tv/oembed/',
</span><span class="cx">                         'http://*.flickr.com/*'       =&gt; 'http://www.flickr.com/services/oembed/',
</span><ins>+                        'http://www.hulu.com/watch/*' =&gt; 'http://www.hulu.com/api/oembed.{format}',
</ins><span class="cx">                         'http://*.viddler.com/*'      =&gt; 'http://lab.viddler.com/services/oembed/',
</span><span class="cx">                         'http://qik.com/*'            =&gt; 'http://qik.com/api/oembed.{format}',
</span><span class="cx">                         'http://*.revision3.com/*'    =&gt; 'http://revision3.com/api/oembed/',
</span><del>-                        'http://www.hulu.com/watch/*' =&gt; 'http://www.hulu.com/api/oembed.{format}',
</del><span class="cx"> 
</span><span class="cx">                         // Vimeo uses the discovery &lt;link&gt;, so leave this commented to use it as a discovery test
</span><span class="cx">                         //'http://www.vimeo.com/*'      =&gt; 'http://www.vimeo.com/api/oembed.{format}',
</span></span></pre></div>
<a id="trunkwpincludesdefaultembedsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/default-embeds.php (12026 => 12027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/default-embeds.php        2009-10-13 22:04:54 UTC (rev 12026)
+++ trunk/wp-includes/default-embeds.php        2009-10-13 22:36:24 UTC (rev 12027)
</span><span class="lines">@@ -8,32 +8,6 @@
</span><span class="cx">  */
</span><span class="cx"> 
</span><span class="cx"> /**
</span><del>- * The YouTube.com embed handler callback. YouTube does not support oEmbed and we want to provide extra customization.
- *
- * @see WP_Embed::register_handler()
- * @see WP_Embed::shortcode()
- *
- * @param array $matches The regex matches from the provided regex when calling {@link wp_embed_register_handler()}.
- * @param array $attr Embed attributes.
- * @param string $url The original URL that was matched by the regex.
- * @param array $rawattr The original unmodified attributes.
- * @return string The embed HTML.
- */
-function wp_embed_handler_youtube( $matches, $attr, $url, $rawattr ) {
-        // If the user supplied a fixed width AND height, use it
-        if ( !empty($rawattr['width']) &amp;&amp; !empty($rawattr['height']) ) {
-                $width  = (int) $rawattr['width'];
-                $height = (int) $rawattr['height'];
-        } else {
-                list( $width, $height ) = wp_expand_dimensions( 425, 344, $attr['width'], $attr['height'] );
-        }
-
-        return apply_filters( 'embed_youtube', '&lt;object width=&quot;' . esc_attr($width) . '&quot; height=&quot;' . esc_attr($height) . '&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/' . esc_attr($matches[3]) . '&amp;amp;hl=en&amp;amp;fs=1&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot;&gt;&lt;/param&gt;&lt;param name=&quot;allowscriptaccess&quot; value=&quot;always&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/' . esc_attr($matches[3]) . '&amp;amp;hl=en&amp;amp;fs=1&quot; type=&quot;application/x-shockwave-flash&quot; allowscriptaccess=&quot;always&quot; allowfullscreen=&quot;true&quot; width=&quot;' . esc_attr($width) . '&quot; height=&quot;' . esc_attr($height) . '&quot;&gt;&lt;/embed&gt;&lt;/object&gt;', $matches, $attr, $url, $rawattr );
-}
-wp_embed_register_handler( 'youtube', '#http://(www.youtube|youtube|[A-Za-z]{2}.youtube)\.com/(watch\?v=|w/\?v=|\?v=)([\w-]+)(.*?)#i', 'wp_embed_handler_youtube' );
-
-
-/**
</del><span class="cx">  * The Google Video embed handler callback. Google Video does not support oEmbed.
</span><span class="cx">  *
</span><span class="cx">  * @see WP_Embed::register_handler()
</span></span></pre></div>
<a id="trunkwpincludesformattingphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/formatting.php (12026 => 12027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/formatting.php        2009-10-13 22:04:54 UTC (rev 12026)
+++ trunk/wp-includes/formatting.php        2009-10-13 22:36:24 UTC (rev 12027)
</span><span class="lines">@@ -2358,7 +2358,6 @@
</span><span class="cx">                 case 'medium_size_h':
</span><span class="cx">                 case 'large_size_w':
</span><span class="cx">                 case 'large_size_h':
</span><del>-                //case 'embed_size_w':
</del><span class="cx">                 case 'embed_size_h':
</span><span class="cx">                 case 'default_post_edit_rows':
</span><span class="cx">                 case 'mailserver_port':
</span><span class="lines">@@ -2375,6 +2374,11 @@
</span><span class="cx">                         $value = absint( $value );
</span><span class="cx">                         break;
</span><span class="cx"> 
</span><ins>+                case 'embed_size_w':
+                        if ( '' !== $value )
+                                $value = absint( $value );
+                        break;
+
</ins><span class="cx">                 case 'posts_per_page':
</span><span class="cx">                 case 'posts_per_rss':
</span><span class="cx">                         $value = (int) $value;
</span></span></pre></div>
<a id="trunkwpincludesmediaphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/media.php (12026 => 12027)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/media.php        2009-10-13 22:04:54 UTC (rev 12026)
+++ trunk/wp-includes/media.php        2009-10-13 22:36:24 UTC (rev 12027)
</span><span class="lines">@@ -1134,6 +1134,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Register an embed handler. This function should probably only be used for sites that do not support oEmbed.
</span><span class="cx">  *
</span><ins>+ * @since 2.9.0
</ins><span class="cx">  * @see WP_Embed::register_handler()
</span><span class="cx">  */
</span><span class="cx"> function wp_embed_register_handler( $id, $regex, $callback, $priority = 10 ) {
</span><span class="lines">@@ -1144,6 +1145,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Unregister a previously registered embed handler.
</span><span class="cx">  *
</span><ins>+ * @since 2.9.0
</ins><span class="cx">  * @see WP_Embed::unregister_handler()
</span><span class="cx">  */
</span><span class="cx"> function wp_embed_unregister_handler( $id, $priority = 10 ) {
</span><span class="lines">@@ -1154,6 +1156,8 @@
</span><span class="cx"> /**
</span><span class="cx">  * Create default array of embed parameters.
</span><span class="cx">  *
</span><ins>+ * @since 2.9.0
+ *
</ins><span class="cx">  * @return array Default embed parameters.
</span><span class="cx">  */
</span><span class="cx"> function wp_embed_defaults() {
</span><span class="lines">@@ -1177,6 +1181,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Based on a supplied width/height example, return the biggest possible dimensions based on the max width/height.
</span><span class="cx">  *
</span><ins>+ * @since 2.9.0
</ins><span class="cx">  * @uses wp_constrain_dimensions() This function passes the widths and the heights.
</span><span class="cx">  *
</span><span class="cx">  * @param int $example_width The width of an example embed.
</span><span class="lines">@@ -1197,6 +1202,7 @@
</span><span class="cx"> /**
</span><span class="cx">  * Attempts to fetch the embed HTML for a provided URL using oEmbed.
</span><span class="cx">  *
</span><ins>+ * @since 2.9.0
</ins><span class="cx">  * @see WP_oEmbed
</span><span class="cx">  *
</span><span class="cx">  * @uses _wp_oembed_get_object()
</span><span class="lines">@@ -1211,3 +1217,20 @@
</span><span class="cx">         $oembed = _wp_oembed_get_object();
</span><span class="cx">         return $oembed-&gt;get_html( $url, $args );
</span><span class="cx"> }
</span><ins>+
+/**
+ * Adds a URL format and oEmbed provider URL pair.
+ *
+ * @since 2.9.0
+ * @see WP_oEmbed
+ *
+ * @uses _wp_oembed_get_object()
+ *
+ * @param string $format The format of URL that this provider can handle. Use asterisks as wildcards.
+ * @param string $provider The URL to the oEmbed provider.
+ */
+function wp_oembed_add_provider( $format, $provider ) {
+        require_once( 'class-oembed.php' );
+        $oembed = _wp_oembed_get_object();
+        $oembed-&gt;providers[$format] = $provider;
+}
</ins></span></pre>
</div>
</div>

</body>
</html>