<!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>[35436] trunk: Embeds: Who put this REST API infrastructure in my WordPress?</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" style="font-size: 105%">
<dt style="float: left; width: 6em; font-weight: bold">Revision</dt> <dd><a style="font-weight: bold" href="https://core.trac.wordpress.org/changeset/35436">35436</a><script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","description":"Review this Commit","action":{"@type":"ViewAction","url":"https://core.trac.wordpress.org/changeset/35436","name":"Review Commit"}}</script></dd>
<dt style="float: left; width: 6em; font-weight: bold">Author</dt> <dd>pento</dd>
<dt style="float: left; width: 6em; font-weight: bold">Date</dt> <dd>2015-10-29 22:50:13 +0000 (Thu, 29 Oct 2015)</dd>
</dl>

<pre style='padding-left: 1em; margin: 2em 0; border-left: 2px solid #ccc; line-height: 1.25; font-size: 105%; font-family: sans-serif'>Embeds: Who put this REST API infrastructure in my WordPress?

Well, while it's here, we probably should make use of it. The oEmbed endpoint now uses the REST API infrastructure, instead of providing its own.

Props swissspidy.

Fixes <a href="https://core.trac.wordpress.org/ticket/34207">#34207</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunksrcwpincludesclasswpoembedcontrollerphp">trunk/src/wp-includes/class-wp-oembed-controller.php</a></li>
<li><a href="#trunksrcwpincludesclasswpphp">trunk/src/wp-includes/class-wp.php</a></li>
<li><a href="#trunksrcwpincludesdefaultfiltersphp">trunk/src/wp-includes/default-filters.php</a></li>
<li><a href="#trunksrcwpincludesembedfunctionsphp">trunk/src/wp-includes/embed-functions.php</a></li>
<li><a href="#trunktestsphpunittestsoembedcontrollerphp">trunk/tests/phpunit/tests/oembed/controller.php</a></li>
<li><a href="#trunktestsphpunittestsoembeddiscoveryphp">trunk/tests/phpunit/tests/oembed/discovery.php</a></li>
<li><a href="#trunktestsphpunittestsoembedheadersphp">trunk/tests/phpunit/tests/oembed/headers.php</a></li>
<li><a href="#trunktestsphpunittestsoembedtemplatephp">trunk/tests/phpunit/tests/oembed/template.php</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunksrcwpincludesclasswpoembedcontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp-oembed-controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp-oembed-controller.php      2015-10-29 21:28:39 UTC (rev 35435)
+++ trunk/src/wp-includes/class-wp-oembed-controller.php        2015-10-29 22:50:13 UTC (rev 35436)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -10,36 +10,18 @@
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * oEmbed API endpoint controller.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Parses the oEmbed API requests and delivers
- * XML and JSON responses.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Registers the API route and delivers the response data.
+ * The output format (XML or JSON) is handled by the REST API.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 4.4.0
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> final class WP_oEmbed_Controller {
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Hook into the query parsing to detect oEmbed requests.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Register the oEmbed REST API route.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * If an oEmbed request is made, trigger the output.
-        *
</del><span class="cx" style="display: block; padding: 0 10px">          * @since 4.4.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         *
-        * @param WP_Query $wp_query The WP_Query instance (passed by reference).
</del><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function parse_query( $wp_query ) {
-               if ( false === $wp_query->get( 'oembed', false ) ) {
-                       return;
-               }
-
-               if ( false === $wp_query->get( 'url', false ) ) {
-                       status_header( 400 );
-                       return get_status_header_desc( 400 );
-                       exit;
-               }
-
-               $url = esc_url_raw( get_query_var( 'url' ) );
-
-               $format = wp_oembed_ensure_format( get_query_var( 'format' ) );
-
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function register_routes() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 /**
</span><span class="cx" style="display: block; padding: 0 10px">                 * Filter the maxwidth oEmbed parameter.
</span><span class="cx" style="display: block; padding: 0 10px">                 *
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -48,30 +30,40 @@
</span><span class="cx" style="display: block; padding: 0 10px">                 * @param int $maxwidth Maximum allowed width. Default 600.
</span><span class="cx" style="display: block; padding: 0 10px">                 */
</span><span class="cx" style="display: block; padding: 0 10px">                $maxwidth = apply_filters( 'oembed_default_width', 600 );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $maxwidth = absint( get_query_var( 'maxwidth', $maxwidth ) );
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $callback = get_query_var( '_jsonp', false );
-
-               $request = array(
-                       'url'      => $url,
-                       'format'   => $format,
-                       'maxwidth' => $maxwidth,
-                       'callback' => $callback,
-               );
-
-               echo $this->dispatch( $request );
-               exit;
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         register_rest_route( 'oembed/1.0/', '/embed', array(
+                       array(
+                               'methods'  => WP_REST_Server::READABLE,
+                               'callback' => array( $this, 'get_item' ),
+                               'args'     => array(
+                                       'url'      => array(
+                                               'required'          => true,
+                                               'sanitize_callback' => 'esc_url_raw',
+                                       ),
+                                       'format'   => array(
+                                               'default'           => 'json',
+                                               'sanitize_callback' => 'wp_oembed_ensure_format',
+                                       ),
+                                       'maxwidth' => array(
+                                               'default'           => $maxwidth,
+                                               'sanitize_callback' => 'absint',
+                                       ),
+                               ),
+                       ),
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * Handle the whole request and print the response.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * Callback for the API endpoint.
</ins><span class="cx" style="display: block; padding: 0 10px">          *
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         * Returns the JSON object for the post.
+        *
</ins><span class="cx" style="display: block; padding: 0 10px">          * @since 4.4.0
</span><span class="cx" style="display: block; padding: 0 10px">         *
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-         * @param array $request The request arguments.
-        * @return string The oEmbed API response.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+  * @param WP_REST_Request $request Full data about the request.
+        * @return WP_Error|array oEmbed response data or WP_Error on failure.
</ins><span class="cx" style="display: block; padding: 0 10px">          */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public function dispatch( $request ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public function get_item( $request ) {
</ins><span class="cx" style="display: block; padding: 0 10px">                 $post_id = url_to_postid( $request['url'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -86,79 +78,10 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $data = get_oembed_response_data( $post_id, $request['maxwidth'] );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( false === $data ) {
-                       status_header( 404 );
-                       return get_status_header_desc( 404 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         if ( ! $data ) {
+                       return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) );
</ins><span class="cx" style="display: block; padding: 0 10px">                 }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                if ( 'json' === $request['format'] ) {
-                       return $this->json_response( $data, $request );
-               }
-
-               return $this->xml_response( $data );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         return $data;
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
-       /**
-        * Print the oEmbed JSON response.
-        *
-        * @since 4.4.0
-        *
-        * @param array $data     The oEmbed response data.
-        * @param array $request  The request arguments.
-        * @return string The JSON response data.
-        */
-       public function json_response( $data, $request ) {
-               if ( ! is_string( $request['callback'] ) || preg_match( '/[^\w\.]/', $request['callback'] ) ) {
-                       $request['callback'] = false;
-               }
-
-               $result = wp_json_encode( $data );
-
-               // Bail if the result couldn't be JSON encoded.
-               if ( ! $result || ! is_array( $data ) || empty( $data ) ) {
-                       status_header( 501 );
-                       return get_status_header_desc( 501 );
-               }
-
-               if ( ! headers_sent() ) {
-                       $content_type = $request['callback'] ? 'application/javascript' : 'application/json';
-                       header( 'Content-Type: ' . $content_type . '; charset=' . get_option( 'blog_charset' ) );
-                       header( 'X-Content-Type-Options: nosniff' );
-               }
-
-               if ( $request['callback'] ) {
-                       return '/**/' . $request['callback'] . '(' . $result . ')';
-               }
-
-               return $result;
-       }
-
-       /**
-        * Print the oEmbed XML response.
-        *
-        * @since 4.4.0
-        *
-        * @param array $data The oEmbed response data.
-        * @return string The XML response data.
-        */
-       public function xml_response( $data ) {
-               if ( ! class_exists( 'SimpleXMLElement' ) ) {
-                       status_header( 501 );
-                       return get_status_header_desc( 501 );
-               }
-
-               $result = _oembed_create_xml( $data );
-
-               // Bail if there's no XML.
-               if ( ! $result ) {
-                       status_header( 501 );
-                       return get_status_header_desc( 501 );
-               }
-
-               if ( ! headers_sent() ) {
-                       header( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ) );
-               }
-
-               return $result;
-       }
</del><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunksrcwpincludesclasswpphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/class-wp.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/class-wp.php        2015-10-29 21:28:39 UTC (rev 35435)
+++ trunk/src/wp-includes/class-wp.php  2015-10-29 22:50:13 UTC (rev 35436)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -15,7 +15,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">         * @access public
</span><span class="cx" style="display: block; padding: 0 10px">         * @var array
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'title', 'embed', 'oembed', 'format', 'url', '_jsonp', 'maxwidth' );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ public $public_query_vars = array('m', 'p', 'posts', 'w', 'cat', 'withcomments', 'withoutcomments', 's', 'search', 'exact', 'sentence', 'calendar', 'page', 'paged', 'more', 'tb', 'pb', 'author', 'order', 'orderby', 'year', 'monthnum', 'day', 'hour', 'minute', 'second', 'name', 'category_name', 'tag', 'feed', 'author_name', 'static', 'pagename', 'page_id', 'error', 'comments_popup', 'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview', 'robots', 'taxonomy', 'term', 'cpage', 'post_type', 'title', 'embed' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        /**
</span><span class="cx" style="display: block; padding: 0 10px">         * Private query variables.
</span></span></pre></div>
<a id="trunksrcwpincludesdefaultfiltersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/default-filters.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/default-filters.php 2015-10-29 21:28:39 UTC (rev 35435)
+++ trunk/src/wp-includes/default-filters.php   2015-10-29 22:50:13 UTC (rev 35436)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -439,31 +439,32 @@
</span><span class="cx" style="display: block; padding: 0 10px"> add_filter( 'media_send_to_editor', 'image_media_send_to_editor', 10, 3 );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> // Embeds
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'parse_query',          'wp_oembed_parse_query'                );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'rest_api_init',          'wp_oembed_register_route'              );
+add_filter( 'rest_pre_serve_request', '_oembed_rest_pre_serve_request', 10, 4 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'wp_head',              'wp_oembed_add_discovery_links'        );
-add_action( 'wp_head',              'wp_oembed_add_host_js'                );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'wp_head',                'wp_oembed_add_discovery_links'         );
+add_action( 'wp_head',                'wp_oembed_add_host_js'                 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'embed_head',           'print_emoji_detection_script'         );
-add_action( 'embed_head',           'print_emoji_styles'                   );
-add_action( 'embed_head',           'print_embed_styles'                   );
-add_action( 'embed_head',           'wp_print_head_scripts',         20    );
-add_action( 'embed_head',           'wp_print_styles',               20    );
-add_action( 'embed_head',           'wp_no_robots'                         );
-add_action( 'embed_head',           'rel_canonical'                        );
-add_action( 'embed_head',           'locale_stylesheet'                    );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'embed_head',             'print_emoji_detection_script'          );
+add_action( 'embed_head',             'print_emoji_styles'                    );
+add_action( 'embed_head',             'print_embed_styles'                    );
+add_action( 'embed_head',             'wp_print_head_scripts',          20    );
+add_action( 'embed_head',             'wp_print_styles',                20    );
+add_action( 'embed_head',             'wp_no_robots'                          );
+add_action( 'embed_head',             'rel_canonical'                         );
+add_action( 'embed_head',             'locale_stylesheet'                     );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_action( 'embed_footer',         'print_embed_scripts'                  );
-add_action( 'embed_footer',         'wp_print_footer_scripts',       20    );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_action( 'embed_footer',           'print_embed_scripts'                   );
+add_action( 'embed_footer',           'wp_print_footer_scripts',        20    );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_filter( 'excerpt_more',         'wp_embed_excerpt_more',         20    );
-add_filter( 'the_excerpt_embed',    'wptexturize'                          );
-add_filter( 'the_excerpt_embed',    'convert_chars'                        );
-add_filter( 'the_excerpt_embed',    'wpautop'                              );
-add_filter( 'the_excerpt_embed',    'shortcode_unautop'                    );
-add_filter( 'the_excerpt_embed',    'wp_embed_excerpt_attachment'          );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_filter( 'excerpt_more',           'wp_embed_excerpt_more',          20    );
+add_filter( 'the_excerpt_embed',      'wptexturize'                           );
+add_filter( 'the_excerpt_embed',      'convert_chars'                         );
+add_filter( 'the_excerpt_embed',      'wpautop'                               );
+add_filter( 'the_excerpt_embed',      'shortcode_unautop'                     );
+add_filter( 'the_excerpt_embed',      'wp_embed_excerpt_attachment'           );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-add_filter( 'oembed_dataparse',     'wp_filter_oembed_result',       10, 3 );
-add_filter( 'oembed_response_data', 'get_oembed_response_data_rich', 10, 4 );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+add_filter( 'oembed_dataparse',       'wp_filter_oembed_result',        10, 3 );
+add_filter( 'oembed_response_data',   'get_oembed_response_data_rich',  10, 4 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> unset( $filter, $action );
</span></span></pre></div>
<a id="trunksrcwpincludesembedfunctionsphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/src/wp-includes/embed-functions.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/src/wp-includes/embed-functions.php 2015-10-29 21:28:39 UTC (rev 35435)
+++ trunk/src/wp-includes/embed-functions.php   2015-10-29 22:50:13 UTC (rev 35436)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -328,17 +328,13 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- * Parses an oEmbed API query.
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Registers the oEmbed REST API route.
</ins><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 4.4.0
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">- *
- * @see WP_oEmbed_Controller::parse_query()
- *
- * @param WP_Query $wp_query The current WP_Query instance.
</del><span class="cx" style="display: block; padding: 0 10px">  */
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-function wp_oembed_parse_query( $wp_query ) {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+function wp_oembed_register_route() {
</ins><span class="cx" style="display: block; padding: 0 10px">         $controller = new WP_oEmbed_Controller();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $controller->parse_query( $wp_query );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $controller->register_routes();
</ins><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -421,7 +417,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @return string The oEmbed endpoint URL.
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> function get_oembed_endpoint_url( $permalink = '', $format = 'json' ) {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $url = add_query_arg( array( 'oembed' => 'true' ), home_url( '/' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $url = rest_url( 'oembed/1.0/embed' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        if ( 'json' === $format ) {
</span><span class="cx" style="display: block; padding: 0 10px">                $format = false;
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -545,18 +541,9 @@
</span><span class="cx" style="display: block; padding: 0 10px">                'max' => 600
</span><span class="cx" style="display: block; padding: 0 10px">        ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        if ( $width < $min_max_width['min'] ) {
-               $width = $min_max_width['min'];
-       } elseif ( $width > $min_max_width['max'] ) {
-               $width = $min_max_width['max'];
-       }
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ $width  = min( max( $min_max_width['min'], $width ), $min_max_width['max'] );
+       $height = max( ceil( $width / 16 * 9 ), 200 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        $height = ceil( $width / 16 * 9 );
-
-       if ( 200 > $height ) {
-               $height = 200;
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         $data = array(
</span><span class="cx" style="display: block; padding: 0 10px">                'version'       => '1.0',
</span><span class="cx" style="display: block; padding: 0 10px">                'provider_name' => get_bloginfo( 'name' ),
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -647,6 +634,61 @@
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * Hooks into the REST API output to print XML instead of JSON.
+ *
+ * This is only done for the oEmbed API endpoint,
+ * which supports both formats.
+ *
+ * @access private
+ * @since 4.4.0
+ *
+ * @param bool                      $served  Whether the request has already been served.
+ * @param WP_HTTP_ResponseInterface $result  Result to send to the client. Usually a WP_REST_Response.
+ * @param WP_REST_Request           $request Request used to generate the response.
+ * @param WP_REST_Server            $server  Server instance.
+ * @return true
+ */
+function _oembed_rest_pre_serve_request( $served, $result, $request, $server ) {
+       $params = $request->get_params();
+
+       if ( '/oembed/1.0/embed' !== $request->get_route() || 'GET' !== $request->get_method() ) {
+               return $served;
+       }
+
+       if ( ! isset( $params['format'] ) || 'xml' !== $params['format'] ) {
+               return $served;
+       }
+
+       // Embed links inside the request.
+       $data = $server->response_to_data( $result, false );
+
+       if ( 404 === $result->get_status() ) {
+               $data = $data[0];
+       }
+
+       if ( ! class_exists( 'SimpleXMLElement' ) ) {
+               status_header( 501 );
+               die( get_status_header_desc( 501 ) );
+       }
+
+       $result = _oembed_create_xml( $data );
+
+       // Bail if there's no XML.
+       if ( ! $result ) {
+               status_header( 501 );
+               return get_status_header_desc( 501 );
+       }
+
+       if ( ! headers_sent() ) {
+               $server->send_header( 'Content-Type', 'text/xml; charset=' . get_option( 'blog_charset' ) );
+       }
+
+       echo $result;
+
+       return true;
+}
+
+/**
</ins><span class="cx" style="display: block; padding: 0 10px">  * Creates an XML string from a given array.
</span><span class="cx" style="display: block; padding: 0 10px">  *
</span><span class="cx" style="display: block; padding: 0 10px">  * @since 4.4.0
</span></span></pre></div>
<a id="trunktestsphpunittestsoembedcontrollerphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/oembed/controller.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/oembed/controller.php   2015-10-29 21:28:39 UTC (rev 35435)
+++ trunk/tests/phpunit/tests/oembed/controller.php     2015-10-29 22:50:13 UTC (rev 35436)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -2,20 +2,135 @@
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px"> /**
</span><span class="cx" style="display: block; padding: 0 10px">  * @group oembed
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ * @group restapi
</ins><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class Test_oEmbed_Controller extends WP_UnitTestCase {
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        /**
+        * @var WP_REST_Server
+        */
+       protected $server;
+
+       public function setUp() {
+               parent::setUp();
+
+               /** @var WP_REST_Server $wp_rest_server */
+               global $wp_rest_server;
+               $this->server = $wp_rest_server = new Spy_REST_Server();
+
+               do_action( 'rest_api_init', $this->server );
+       }
+
+       function test_wp_oembed_ensure_format() {
+               $this->assertEquals( 'json', wp_oembed_ensure_format( 'json' ) );
+               $this->assertEquals( 'xml', wp_oembed_ensure_format( 'xml' ) );
+               $this->assertEquals( 'json', wp_oembed_ensure_format( 123 ) );
+               $this->assertEquals( 'json', wp_oembed_ensure_format( 'random' ) );
+               $this->assertEquals( 'json', wp_oembed_ensure_format( array() ) );
+       }
+
+       function test_oembed_create_xml() {
+               $actual = _oembed_create_xml( array(
+                       'foo'  => 'bar',
+                       'bar'  => 'baz',
+                       'ping' => 'pong',
+               ) );
+
+               $expected = '<oembed><foo>bar</foo><bar>baz</bar><ping>pong</ping></oembed>';
+
+               $this->assertStringEndsWith( $expected, trim( $actual ) );
+
+               $actual = _oembed_create_xml( array(
+                       'foo'  => array(
+                               'bar' => 'baz',
+                       ),
+                       'ping' => 'pong',
+               ) );
+
+               $expected = '<oembed><foo><bar>baz</bar></foo><ping>pong</ping></oembed>';
+
+               $this->assertStringEndsWith( $expected, trim( $actual ) );
+
+               $actual = _oembed_create_xml( array(
+                       'foo'   => array(
+                               'bar' => array(
+                                       'ping' => 'pong',
+                               ),
+                       ),
+                       'hello' => 'world',
+               ) );
+
+               $expected = '<oembed><foo><bar><ping>pong</ping></bar></foo><hello>world</hello></oembed>';
+
+               $this->assertStringEndsWith( $expected, trim( $actual ) );
+
+               $actual = _oembed_create_xml( array(
+                       array(
+                               'foo' => array(
+                                       'bar',
+                               ),
+                       ),
+                       'helloworld',
+               ) );
+
+               $expected = '<oembed><oembed><foo><oembed>bar</oembed></foo></oembed><oembed>helloworld</oembed></oembed>';
+
+               $this->assertStringEndsWith( $expected, trim( $actual ) );
+       }
+
+       public function test_route_availability() {
+               // Check the route was registered correctly.
+               $filtered_routes = $this->server->get_routes();
+               $this->assertArrayHasKey( '/oembed/1.0/embed', $filtered_routes );
+               $route = $filtered_routes['/oembed/1.0/embed'];
+               $this->assertCount( 1, $route );
+               $this->assertArrayHasKey( 'callback', $route[0] );
+               $this->assertArrayHasKey( 'methods', $route[0] );
+               $this->assertArrayHasKey( 'args', $route[0] );
+       }
+
+       function test_request_with_wrong_method() {
+               $request = new WP_REST_Request( 'POST', '/oembed/1.0/embed' );
+
+               $response = $this->server->dispatch( $request );
+               $data     = $response->get_data();
+
+               $this->assertEquals( 'rest_no_route', $data[0]['code'] );
+       }
+
+       function test_request_without_url_param() {
+               $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+
+               $response = $this->server->dispatch( $request );
+               $data     = $response->get_data();
+
+               $this->assertEquals( 'rest_missing_callback_param', $data[0]['code'] );
+               $this->assertEquals( 'url', $data[0]['data']['params'][0] );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         function test_request_with_bad_url() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $request = array(
-                       'url'      => '',
-                       'format'   => 'json',
-                       'maxwidth' => 600,
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+               $request->set_param( 'url', 'http://google.com/' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $legacy_controller = new WP_oEmbed_Controller();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $response = $this->server->dispatch( $request );
+               $data     = $response->get_data();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( get_status_header_desc( 404 ), $legacy_controller->dispatch( $request ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( 'oembed_invalid_url', $data[0]['code'] );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+        function test_request_invalid_format() {
+               $post_id = $this->factory()->post->create();
+
+               $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+               $request->set_param( 'url', get_permalink( $post_id ) );
+               $request->set_param( 'format', 'random' );
+
+               $response = $this->server->dispatch( $request );
+               $data     = $response->get_data();
+
+               $this->assertInternalType( 'array', $data );
+               $this->assertNotEmpty( $data );
+       }
+
</ins><span class="cx" style="display: block; padding: 0 10px">         function test_request_json() {
</span><span class="cx" style="display: block; padding: 0 10px">                $user = self::factory()->user->create_and_get( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'display_name' => 'John Doe',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -25,21 +140,16 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'post_title'  => 'Hello World',
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                // WP_Query arguments.
-               $request = array(
-                       'url'      => get_permalink( $post->ID ),
-                       'format'   => 'json',
-                       'maxwidth' => 400,
-                       'callback' => '',
-                       'oembed'   => true,
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+               $request->set_param( 'url', get_permalink( $post->ID ) );
+               $request->set_param( 'maxwidth', 400 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $legacy_controller = new WP_oEmbed_Controller();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $response = $this->server->dispatch( $request );
+               $data     = $response->get_data();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $data = json_decode( $legacy_controller->dispatch( $request ), true );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertInternalType( 'array', $data );
+               $this->assertNotEmpty( $data );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( is_array( $data ) );
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->assertArrayHasKey( 'version', $data );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'provider_name', $data );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'provider_url', $data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -59,64 +169,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( $data['width'] <= $request['maxwidth'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_request_jsonp() {
-               $user = self::factory()->user->create_and_get( array(
-                       'display_name' => 'John Doe',
-               ) );
-               $post = self::factory()->post->create_and_get( array(
-                       'post_author' => $user->ID,
-                       'post_title'  => 'Hello World',
-               ) );
-
-               $request = array(
-                       'url'      => get_permalink( $post->ID ),
-                       'format'   => 'json',
-                       'maxwidth' => 600,
-                       'callback' => 'mycallback',
-               );
-
-               $legacy_controller = new WP_oEmbed_Controller();
-
-               $data = $legacy_controller->dispatch( $request );
-
-               $this->assertEquals( 0, strpos( $data, '/**/mycallback(' ) );
-       }
-
-       function test_request_jsonp_invalid_callback() {
-               $user = self::factory()->user->create_and_get( array(
-                       'display_name' => 'John Doe',
-               ) );
-               $post = self::factory()->post->create_and_get( array(
-                       'post_author' => $user->ID,
-                       'post_title'  => 'Hello World',
-               ) );
-
-               $request = array(
-                       'url'      => get_permalink( $post->ID ),
-                       'format'   => 'json',
-                       'maxwidth' => 600,
-                       'callback' => array( 'foo', 'bar' ),
-               );
-
-               $legacy_controller = new WP_oEmbed_Controller();
-
-               $data = $legacy_controller->dispatch( $request );
-
-               $this->assertFalse( strpos( $data, '/**/' ) );
-       }
-
-       function test_request_json_invalid_data() {
-               $request = array(
-                       'callback' => '',
-               );
-
-               $legacy_controller = new WP_oEmbed_Controller();
-
-               $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( null, $request ) );
-               $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( 123, $request ) );
-               $this->assertEquals( get_status_header_desc( 501 ), $legacy_controller->json_response( array(), $request ) );
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         function test_request_xml() {
</span><span class="cx" style="display: block; padding: 0 10px">                $user = self::factory()->user->create_and_get( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'display_name' => 'John Doe',
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -126,22 +178,17 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'post_title'  => 'Hello World',
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $request = array(
-                       'url'     => get_permalink( $post->ID ),
-                       'format'   => 'xml',
-                       'maxwidth' => 400,
-                       'callback' => '',
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+               $request->set_param( 'url', get_permalink( $post->ID ) );
+               $request->set_param( 'format', 'xml' );
+               $request->set_param( 'maxwidth', 400 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $legacy_controller = new WP_oEmbed_Controller();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $response = $this->server->dispatch( $request );
+               $data     = $response->get_data();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $data = $legacy_controller->dispatch( $request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertInternalType( 'array', $data );
+               $this->assertNotEmpty( $data );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $data = simplexml_load_string( $data );
-               $this->assertInstanceOf( 'SimpleXMLElement', $data );
-
-               $data = (array) $data;
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->assertArrayHasKey( 'version', $data );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'provider_name', $data );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertArrayHasKey( 'provider_url', $data );
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -161,14 +208,6 @@
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( $data['width'] <= $request['maxwidth'] );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_request_xml_invalid_data() {
-               $legacy_controller = new WP_oEmbed_Controller();
-
-               $this->assertEquals( get_status_header_desc( 501 ),  $legacy_controller->xml_response( null ) );
-               $this->assertEquals( get_status_header_desc( 501 ),  $legacy_controller->xml_response( 123 ) );
-               $this->assertEquals( get_status_header_desc( 501 ),  $legacy_controller->xml_response( array() ) );
-       }
-
</del><span class="cx" style="display: block; padding: 0 10px">         /**
</span><span class="cx" style="display: block; padding: 0 10px">         * @group multisite
</span><span class="cx" style="display: block; padding: 0 10px">         */
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -178,97 +217,95 @@
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $child = self::factory()->blog->create();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                 switch_to_blog( $child );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $post = self::factory()->post->create_and_get( array(
</span><span class="cx" style="display: block; padding: 0 10px">                        'post_title' => 'Hello Child Blog',
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $request = array(
-                       'url'      => get_permalink( $post->ID ),
-                       'format'   => 'json',
-                       'maxwidth' => 600,
-                       'callback' => '',
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+               $request->set_param( 'url', get_permalink( $post->ID ) );
+               $request->set_param( 'maxwidth', 400 );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $legacy_controller = new WP_oEmbed_Controller();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $response = $this->server->dispatch( $request );
+               $data     = $response->get_data();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $data = json_decode( $legacy_controller->dispatch( $request ), true );
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->assertInternalType( 'array', $data );
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertNotEmpty( $data );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                restore_current_blog();
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_get_oembed_endpoint_url() {
-               $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url() );
-               $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'json' ) );
-               $this->assertEquals( home_url() . '/?oembed=true', get_oembed_endpoint_url( '', 'xml' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_rest_pre_serve_request() {
+               $user = $this->factory()->user->create_and_get( array(
+                       'display_name' => 'John Doe',
+               ) );
+               $post = $this->factory()->post->create_and_get( array(
+                       'post_author' => $user->ID,
+                       'post_title'  => 'Hello World',
+               ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $post_id     = self::factory()->post->create();
-               $url         = get_permalink( $post_id );
-               $url_encoded = urlencode( $url );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+               $request->set_param( 'url', get_permalink( $post->ID ) );
+               $request->set_param( 'format', 'xml' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( home_url() . '/?oembed=true&url=' . $url_encoded, get_oembed_endpoint_url( $url ) );
-               $this->assertEquals( home_url() . '/?oembed=true&url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $response = $this->server->dispatch( $request );
+               $output   = get_echo( '_oembed_rest_pre_serve_request', array( true, $response, $request, $this->server ) );
+
+               $xml = simplexml_load_string( $output );
+               $this->assertInstanceOf( 'SimpleXMLElement', $xml );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_wp_oembed_ensure_format() {
-               $this->assertEquals( 'json', wp_oembed_ensure_format( 'json' ) );
-               $this->assertEquals( 'xml', wp_oembed_ensure_format( 'xml' ) );
-               $this->assertEquals( 'json', wp_oembed_ensure_format( 123 ) );
-               $this->assertEquals( 'json', wp_oembed_ensure_format( 'random' ) );
-               $this->assertEquals( 'json', wp_oembed_ensure_format( array() ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_rest_pre_serve_request_wrong_format() {
+               $post = $this->factory()->post->create_and_get();
+
+               $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+               $request->set_param( 'url', get_permalink( $post->ID ) );
+               $request->set_param( 'format', 'json' );
+
+               $response = $this->server->dispatch( $request );
+
+               $this->assertTrue( _oembed_rest_pre_serve_request( true, $response, $request, $this->server ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_oembed_create_xml() {
-               $actual = _oembed_create_xml( array(
-                       'foo'  => 'bar',
-                       'bar'  => 'baz',
-                       'ping' => 'pong',
-               ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_rest_pre_serve_request_wrong_method() {
+               $post = $this->factory()->post->create_and_get();
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $expected = '<oembed><foo>bar</foo><bar>baz</bar><ping>pong</ping></oembed>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $request = new WP_REST_Request( 'HEAD', '/oembed/1.0/embed' );
+               $request->set_param( 'url', get_permalink( $post->ID ) );
+               $request->set_param( 'format', 'xml' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertStringEndsWith( $expected, trim( $actual ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $response = $this->server->dispatch( $request );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $actual = _oembed_create_xml( array(
-                       'foo'  => array(
-                               'bar' => 'baz',
-                       ),
-                       'ping' => 'pong',
-               ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertTrue( _oembed_rest_pre_serve_request( true, $response, $request, $this->server ) );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $expected = '<oembed><foo><bar>baz</bar></foo><ping>pong</ping></oembed>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_get_oembed_endpoint_url() {
+               $this->assertEquals( home_url() . '/?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url() );
+               $this->assertEquals( home_url() . '/?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'json' ) );
+               $this->assertEquals( home_url() . '/?rest_route=/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertStringEndsWith( $expected, trim( $actual ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $post_id     = $this->factory()->post->create();
+               $url         = get_permalink( $post_id );
+               $url_encoded = urlencode( $url );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $actual = _oembed_create_xml( array(
-                       'foo'   => array(
-                               'bar' => array(
-                                       'ping' => 'pong',
-                               ),
-                       ),
-                       'hello' => 'world',
-               ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( home_url() . '/?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded, get_oembed_endpoint_url( $url ) );
+               $this->assertEquals( home_url() . '/?rest_route=%2Foembed%2F1.0%2Fembed&url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) );
+       }
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $expected = '<oembed><foo><bar><ping>pong</ping></bar></foo><hello>world</hello></oembed>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_get_oembed_endpoint_url_pretty_permalinks() {
+               update_option( 'permalink_structure', '/%postname%' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertStringEndsWith( $expected, trim( $actual ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url() );
+               $this->assertEquals( home_url() . '/wp-json/oembed/1.0/embed', get_oembed_endpoint_url( '', 'xml' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $actual = _oembed_create_xml( array(
-                       array(
-                               'foo' => array(
-                                       'bar',
-                               ),
-                       ),
-                       'helloworld',
-               ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $post_id     = $this->factory()->post->create();
+               $url         = get_permalink( $post_id );
+               $url_encoded = urlencode( $url );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $expected = '<oembed><oembed><foo><oembed>bar</oembed></foo></oembed><oembed>helloworld</oembed></oembed>';
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( home_url() . '/wp-json/oembed/1.0/embed?url=' . $url_encoded, get_oembed_endpoint_url( $url ) );
+               $this->assertEquals( home_url() . '/wp-json/oembed/1.0/embed?url=' . $url_encoded . '&format=xml', get_oembed_endpoint_url( $url, 'xml' ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertStringEndsWith( $expected, trim( $actual ) );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         update_option( 'permalink_structure', '' );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsoembeddiscoveryphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/oembed/discovery.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/oembed/discovery.php    2015-10-29 21:28:39 UTC (rev 35435)
+++ trunk/tests/phpunit/tests/oembed/discovery.php      2015-10-29 22:50:13 UTC (rev 35436)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -5,26 +5,18 @@
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_oEmbed_Discovery extends WP_UnitTestCase {
</span><span class="cx" style="display: block; padding: 0 10px">        function test_add_oembed_discovery_links_non_singular() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                ob_start();
-               wp_oembed_add_discovery_links();
-               $actual = ob_get_clean();
-               $this->assertSame( '', $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertSame( '', get_echo( 'wp_oembed_add_discovery_links' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function test_add_oembed_discovery_links_to_post() {
</span><span class="cx" style="display: block; padding: 0 10px">                $post_id = self::factory()->post->create();
</span><span class="cx" style="display: block; padding: 0 10px">                $this->go_to( get_permalink( $post_id ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->assertQueryTrue( 'is_single', 'is_singular' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                ob_start();
-               wp_oembed_add_discovery_links();
-               $actual = ob_get_clean();
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
</span><span class="cx" style="display: block; padding: 0 10px">                $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $expected, $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function test_add_oembed_discovery_links_to_page() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -32,17 +24,12 @@
</span><span class="cx" style="display: block; padding: 0 10px">                        'post_type' => 'page'
</span><span class="cx" style="display: block; padding: 0 10px">                ));
</span><span class="cx" style="display: block; padding: 0 10px">                $this->go_to( get_permalink( $post_id ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->assertQueryTrue( 'is_page', 'is_singular' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                ob_start();
-               wp_oembed_add_discovery_links();
-               $actual = ob_get_clean();
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
</span><span class="cx" style="display: block; padding: 0 10px">                $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $expected, $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function test_add_oembed_discovery_links_to_attachment() {
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -53,16 +40,11 @@
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->go_to( get_permalink( $attachment_id ) );
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->assertQueryTrue( 'is_attachment', 'is_singular', 'is_single' );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                ob_start();
-               wp_oembed_add_discovery_links();
-               $actual = ob_get_clean();
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $expected = '<link rel="alternate" type="application/json+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink() ) ) . '" />' . "\n";
</span><span class="cx" style="display: block; padding: 0 10px">                $expected .= '<link rel="alternate" type="text/xml+oembed" href="' . esc_url( get_oembed_endpoint_url( get_permalink(), 'xml' ) ) . '" />' . "\n";
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertEquals( $expected, $actual );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertEquals( $expected, get_echo( 'wp_oembed_add_discovery_links' ) );
</ins><span class="cx" style="display: block; padding: 0 10px">         }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsoembedheadersphp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/oembed/headers.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/oembed/headers.php      2015-10-29 21:28:39 UTC (rev 35435)
+++ trunk/tests/phpunit/tests/oembed/headers.php        2015-10-29 22:50:13 UTC (rev 35436)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -7,60 +7,27 @@
</span><span class="cx" style="display: block; padding: 0 10px">  * @group oembed-headers
</span><span class="cx" style="display: block; padding: 0 10px">  */
</span><span class="cx" style="display: block; padding: 0 10px"> class Tests_oEmbed_HTTP_Headers extends WP_UnitTestCase {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-        function test_request_json_response_headers() {
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+ function test_rest_pre_serve_request_headers() {
</ins><span class="cx" style="display: block; padding: 0 10px">                 if ( ! function_exists( 'xdebug_get_headers' ) ) {
</span><span class="cx" style="display: block; padding: 0 10px">                        $this->markTestSkipped( 'xdebug is required for this test' );
</span><span class="cx" style="display: block; padding: 0 10px">                }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $post = self::factory()->post->create_and_get( array(
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $post = $this->factory()->post->create_and_get( array(
</ins><span class="cx" style="display: block; padding: 0 10px">                         'post_title'  => 'Hello World',
</span><span class="cx" style="display: block; padding: 0 10px">                ) );
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $request = array(
-                       'url'      => get_permalink( $post->ID ),
-                       'format'   => 'json',
-                       'maxwidth' => 600,
-                       'callback' => '',
-               );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $request = new WP_REST_Request( 'GET', '/oembed/1.0/embed' );
+               $request->set_param( 'url', get_permalink( $post->ID ) );
+               $request->set_param( 'format', 'xml' );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $legacy_controller = new WP_oEmbed_Controller();
-               $legacy_controller->dispatch( $request );
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $server   = new WP_REST_Server();
+               $response = $server->dispatch( $request );
+               $output   = get_echo( '_oembed_rest_pre_serve_request', array( true, $response, $request, $server ) );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $headers = xdebug_get_headers();
</del><ins style="background-color: #dfd; text-decoration:none; display:block; padding: 0 10px">+         $this->assertNotEmpty( $output );
</ins><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( in_array( 'Content-Type: application/json; charset=' . get_option( 'blog_charset' ), $headers ) );
-               $this->assertTrue( in_array( 'X-Content-Type-Options: nosniff', $headers ) );
-
-               $request['callback'] = 'foobar';
-
-               $legacy_controller->dispatch( $request );
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $headers = xdebug_get_headers();
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                $this->assertTrue( in_array( 'Content-Type: application/javascript; charset=' . get_option( 'blog_charset' ), $headers ) );
-               $this->assertTrue( in_array( 'X-Content-Type-Options: nosniff', $headers ) );
-       }
-
-       function test_request_xml_response_headers() {
-               if ( ! function_exists( 'xdebug_get_headers' ) ) {
-                       $this->markTestSkipped( 'xdebug is required for this test' );
-               }
-
-               $post = self::factory()->post->create_and_get( array(
-                       'post_title'  => 'Hello World',
-               ) );
-
-               $request = array(
-                       'url'      => get_permalink( $post->ID ),
-                       'format'   => 'xml',
-                       'maxwidth' => 600,
-               );
-
-               $legacy_controller = new WP_oEmbed_Controller();
-               $legacy_controller->dispatch( $request );
-
-               $headers = xdebug_get_headers();
-
</del><span class="cx" style="display: block; padding: 0 10px">                 $this->assertTrue( in_array( 'Content-Type: text/xml; charset=' . get_option( 'blog_charset' ), $headers ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> }
</span></span></pre></div>
<a id="trunktestsphpunittestsoembedtemplatephp"></a>
<div class="modfile"><h4 style="background-color: #eee; color: inherit; margin: 1em 0; padding: 1.3em; font-size: 115%">Modified: trunk/tests/phpunit/tests/oembed/template.php</h4>
<pre class="diff"><span>
<span class="info" style="display: block; padding: 0 10px; color: #888">--- trunk/tests/phpunit/tests/oembed/template.php     2015-10-29 21:28:39 UTC (rev 35435)
+++ trunk/tests/phpunit/tests/oembed/template.php       2015-10-29 22:50:13 UTC (rev 35436)
</span><span class="lines" style="display: block; padding: 0 10px; color: #888">@@ -249,9 +249,7 @@
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">        function test_add_host_js() {
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                ob_start();
</del><span class="cx" style="display: block; padding: 0 10px">                 wp_oembed_add_host_js();
</span><del style="background-color: #fdd; text-decoration:none; display:block; padding: 0 10px">-                ob_end_clean();
</del><span class="cx" style="display: block; padding: 0 10px"> 
</span><span class="cx" style="display: block; padding: 0 10px">                $this->assertTrue( wp_script_is( 'wp-embed' ) );
</span><span class="cx" style="display: block; padding: 0 10px">        }
</span></span></pre>
</div>
</div>

</body>
</html>