AMP
6 years ago
Elementor
3 years ago
Ends
3 years ago
Includes
3 years ago
Plugins
4 years ago
Providers
3 years ago
ThirdParty
4 years ago
AutoLoader.php
6 years ago
Compatibility.php
6 years ago
Core.php
3 years ago
CoreLegacy.php
4 years ago
DisablerLegacy.php
6 years ago
Loader.php
6 years ago
RestAPI.php
3 years ago
Shortcode.php
3 years ago
index.html
7 years ago
simple_html_dom.php
4 years ago
RestAPI.php
50 lines
| 1 | <?php |
| 2 | |
| 3 | namespace EmbedPress; |
| 4 | |
| 5 | use Embera\Embera; |
| 6 | use WP_Error as WP_ErrorAlias; |
| 7 | use WP_REST_Request; |
| 8 | use WP_REST_Response; |
| 9 | |
| 10 | (defined('ABSPATH') && defined('EMBEDPRESS_IS_LOADED')) or die("No direct script access allowed."); |
| 11 | |
| 12 | /** |
| 13 | * Entity responsible for maintaining and registering all hooks that power the plugin. |
| 14 | * |
| 15 | * @package EmbedPress |
| 16 | * @author EmbedPress <help@embedpress.com> |
| 17 | * @copyright Copyright (C) 2020 WPDeveloper. All rights reserved. |
| 18 | * @license GPLv3 or later |
| 19 | * @since 1.0.0 |
| 20 | */ |
| 21 | class RestAPI |
| 22 | { |
| 23 | /** |
| 24 | * @param WP_REST_Request $request |
| 25 | * |
| 26 | * @return WP_REST_Response | WP_ErrorAlias |
| 27 | */ |
| 28 | public static function oembed($request) |
| 29 | { |
| 30 | $url = esc_url_raw($request->get_param('url')); |
| 31 | $playlist_id = $request->get_param( 'list'); |
| 32 | if ( !empty( $playlist_id) ) { |
| 33 | $url .= "&list=$playlist_id"; |
| 34 | } |
| 35 | |
| 36 | $atts = $request->get_params(); |
| 37 | |
| 38 | |
| 39 | if (empty($url)) { |
| 40 | return new WP_ErrorAlias('embedpress_invalid_url', 'Invalid Embed URL', ['status' => 404]); |
| 41 | } |
| 42 | |
| 43 | $urlInfo = Shortcode::parseContent( $url, true, $atts); |
| 44 | if (empty($urlInfo)) { |
| 45 | return new WP_ErrorAlias('embedpress_invalid_url', 'Invalid Embed URL', ['status' => 404]); |
| 46 | } |
| 47 | return new WP_REST_Response($urlInfo, 200); |
| 48 | } |
| 49 | } |
| 50 |