equal
deleted
inserted
replaced
8 */ |
8 */ |
9 |
9 |
10 /** |
10 /** |
11 * oEmbed API endpoint controller. |
11 * oEmbed API endpoint controller. |
12 * |
12 * |
13 * Registers the API route and delivers the response data. |
13 * Registers the REST API route and delivers the response data. |
14 * The output format (XML or JSON) is handled by the REST API. |
14 * The output format (XML or JSON) is handled by the REST API. |
15 * |
15 * |
16 * @since 4.4.0 |
16 * @since 4.4.0 |
17 */ |
17 */ |
18 final class WP_oEmbed_Controller { |
18 final class WP_oEmbed_Controller { |
157 * Returns the JSON object for the proxied item. |
157 * Returns the JSON object for the proxied item. |
158 * |
158 * |
159 * @since 4.8.0 |
159 * @since 4.8.0 |
160 * |
160 * |
161 * @see WP_oEmbed::get_html() |
161 * @see WP_oEmbed::get_html() |
|
162 * @global WP_Embed $wp_embed |
|
163 * |
162 * @param WP_REST_Request $request Full data about the request. |
164 * @param WP_REST_Request $request Full data about the request. |
163 * @return object|WP_Error oEmbed response data or WP_Error on failure. |
165 * @return object|WP_Error oEmbed response data or WP_Error on failure. |
164 */ |
166 */ |
165 public function get_proxy_item( $request ) { |
167 public function get_proxy_item( $request ) { |
|
168 global $wp_embed; |
|
169 |
166 $args = $request->get_params(); |
170 $args = $request->get_params(); |
167 |
171 |
168 // Serve oEmbed data from cache if set. |
172 // Serve oEmbed data from cache if set. |
169 unset( $args['_wpnonce'] ); |
173 unset( $args['_wpnonce'] ); |
170 $cache_key = 'oembed_' . md5( serialize( $args ) ); |
174 $cache_key = 'oembed_' . md5( serialize( $args ) ); |
193 |
197 |
194 $data = _wp_oembed_get_object()->get_data( $url, $args ); |
198 $data = _wp_oembed_get_object()->get_data( $url, $args ); |
195 |
199 |
196 if ( false === $data ) { |
200 if ( false === $data ) { |
197 // Try using a classic embed, instead. |
201 // Try using a classic embed, instead. |
198 global $wp_embed; |
|
199 |
|
200 /* @var WP_Embed $wp_embed */ |
202 /* @var WP_Embed $wp_embed */ |
201 $html = $wp_embed->get_embed_handler_html( $args, $url ); |
203 $html = $wp_embed->get_embed_handler_html( $args, $url ); |
202 |
204 |
203 if ( $html ) { |
205 if ( $html ) { |
204 global $wp_scripts; |
206 global $wp_scripts; |