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