/** * WP_oEmbed_Controller class, used to provide an oEmbed endpoint. * * @package WordPress * @subpackage Embeds * @since 4.4.0 */ /** * oEmbed API endpoint controller. * * Registers the REST API route and delivers the response data. * The output format (XML or JSON) is handled by the REST API. * * @since 4.4.0 */ #[AllowDynamicProperties] final class WP_oEmbed_Controller { /** * Register the oEmbed REST API route. * * @since 4.4.0 */ public function register_routes() { /** * Filters the maxwidth oEmbed parameter. * * @since 4.4.0 * * @param int $maxwidth Maximum allowed width. Default 600. */ $maxwidth = apply_filters( 'oembed_default_width', 600 ); register_rest_route( 'oembed/1.0', '/embed', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_item' ), 'permission_callback' => '__return_true', 'args' => array( 'url' => array( 'description' => __( 'The URL of the resource for which to fetch oEmbed data.' ), 'required' => true, 'type' => 'string', 'format' => 'uri', ), 'format' => array( 'default' => 'json', 'sanitize_callback' => 'wp_oembed_ensure_format', ), 'maxwidth' => array( 'default' => $maxwidth, 'sanitize_callback' => 'absint', ), ), ), ) ); register_rest_route( 'oembed/1.0', '/proxy', array( array( 'methods' => WP_REST_Server::READABLE, 'callback' => array( $this, 'get_proxy_item' ), 'permission_callback' => array( $this, 'get_proxy_item_permissions_check' ), 'args' => array( 'url' => array( 'description' => __( 'The URL of the resource for which to fetch oEmbed data.' ), 'required' => true, 'type' => 'string', 'format' => 'uri', ), 'format' => array( 'description' => __( 'The oEmbed format to use.' ), 'type' => 'string', 'default' => 'json', 'enum' => array( 'json', 'xml', ), ), 'maxwidth' => array( 'description' => __( 'The maximum width of the embed frame in pixels.' ), 'type' => 'integer', 'default' => $maxwidth, 'sanitize_callback' => 'absint', ), 'maxheight' => array( 'description' => __( 'The maximum height of the embed frame in pixels.' ), 'type' => 'integer', 'sanitize_callback' => 'absint', ), 'discover' => array( 'description' => __( 'Whether to perform an oEmbed discovery request for unsanctioned providers.' ), 'type' => 'boolean', 'default' => true, ), ), ), ) ); } /** * Callback for the embed API endpoint. * * Returns the JSON object for the post. * * @since 4.4.0 * * @param WP_REST_Request $request Full data about the request. * @return array|WP_Error oEmbed response data or WP_Error on failure. */ public function get_item( $request ) { $post_id = url_to_postid( $request['url'] ); /** * Filters the determined post ID. * * @since 4.4.0 * * @param int $post_id The post ID. * @param string $url The requested URL. */ $post_id = apply_filters( 'oembed_request_post_id', $post_id, $request['url'] ); $data = get_oembed_response_data( $post_id, $request['maxwidth'] ); if ( ! $data ) { return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) ); } return $data; } /** * Checks if current user can make a proxy oEmbed request. * * @since 4.8.0 * * @return true|WP_Error True if the request has read access, WP_Error object otherwise. */ public function get_proxy_item_permissions_check() { if ( ! current_user_can( 'edit_posts' ) ) { return new WP_Error( 'rest_forbidden', __( 'Sorry, you are not allowed to make proxied oEmbed requests.' ), array( 'status' => rest_authorization_required_code() ) ); } return true; } /** * Callback for the proxy API endpoint. * * Returns the JSON object for the proxied item. * * @since 4.8.0 * * @see WP_oEmbed::get_html() * @global WP_Embed $wp_embed WordPress Embed object. * @global WP_Scripts $wp_scripts * * @param WP_REST_Request $request Full data about the request. * @return object|WP_Error oEmbed response data or WP_Error on failure. */ public function get_proxy_item( $request ) { global $wp_embed, $wp_scripts; $args = $request->get_params(); // Serve oEmbed data from cache if set. unset( $args['_wpnonce'] ); $cache_key = 'oembed_' . md5( serialize( $args ) ); $data = get_transient( $cache_key ); if ( ! empty( $data ) ) { return $data; } $url = $request['url']; unset( $args['url'] ); // Copy maxwidth/maxheight to width/height since WP_oEmbed::fetch() uses these arg names. if ( isset( $args['maxwidth'] ) ) { $args['width'] = $args['maxwidth']; } if ( isset( $args['maxheight'] ) ) { $args['height'] = $args['maxheight']; } // Short-circuit process for URLs belonging to the current site. $data = get_oembed_response_data_for_url( $url, $args ); if ( $data ) { return $data; } $data = _wp_oembed_get_object()->get_data( $url, $args ); if ( false === $data ) { // Try using a classic embed, instead. /* @var WP_Embed $wp_embed */ $html = $wp_embed->get_embed_handler_html( $args, $url ); if ( $html ) { // Check if any scripts were enqueued by the shortcode, and include them in the response. $enqueued_scripts = array(); foreach ( $wp_scripts->queue as $script ) { $enqueued_scripts[] = $wp_scripts->registered[ $script ]->src; } return (object) array( 'provider_name' => __( 'Embed Handler' ), 'html' => $html, 'scripts' => $enqueued_scripts, ); } return new WP_Error( 'oembed_invalid_url', get_status_header_desc( 404 ), array( 'status' => 404 ) ); } /** This filter is documented in wp-includes/class-wp-oembed.php */ $data->html = apply_filters( 'oembed_result', _wp_oembed_get_object()->data2html( (object) $data, $url ), $url, $args ); /** * Filters the oEmbed TTL value (time to live). * * Similar to the {@see 'oembed_ttl'} filter, but for the REST API * oEmbed proxy endpoint. * * @since 4.8.0 * * @param int $time Time to live (in seconds). * @param string $url The attempted embed URL. * @param array $args An array of embed request arguments. */ $ttl = apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args ); set_transient( $cache_key, $data, $ttl ); return $data; } } https://validator.w3.org/feed/docs/rss2.html Cleopatra: Lion Heart slot free spins King, Spouse, Legend 100 Boomanji slot free spins percent free Trial Harbors Enjoy 100 percent free Ports for fun Thunderstruck Position Opinion 2026: online casino Deal or No Deal Rtp RTP, Gameplay and you can The best places to Gamble Play 17,800+ Totally free the site Pokies and Position Video game NZ 2026 Better No Ok Online casino deposit and Free Indication-Up Local casino Incentives August 2026 Simple tips to Play Pokies and you source hyperlink may 6 Strategies for To try out Pokies 100 percent free Pokie Video game with Free Spins Play Online 50 free spins on Lakes Five Rtp #1 Totally free Pokies Best 5 Minimal Put Gambling enterprises in the 2026 Ranked and you top Grand Eagle 100 free spins no deposit may Analyzed Free online Pokies Play 7,400+ Free casino Lvbet $100 free spins Pokies Video game! Better Free limitless casino Casumo 30 free spins internet games Enjoy Now!!! Totally free Harbors 650+ Demonstration Video free Cyber Club 50 spins no deposit game, No Download otherwise Sign-Right up Survivor Megaways Slot Totally free Video free online slots with no download slot from the Big-time Gambling Better Online slots games in the 2026 Real cash Slot Unlimluck casino no deposit promo codes Video game Finest Real cash Online casinos inside casino Royal Swipe no deposit bonus 2026 100 percent free Ports No PrimeBetz casino bonuses Download Pharaoh’s Fortune 24 Casino betting Demonstration Gamble Slot Video game 100percent 100 percent free Dragon Hertzbetz slots Hook up Pokies On line Totally free and Wager A real income Free online Pokies: Enjoy casino Miami Vice login Pokies Zero Down load Play Cent Slot machines Greatest 5 Free Penny Ports casino Lucky Time login Inside the 2026 Shore trips: Just what the brand new cruisers would like to casino Cinema mobile know Stacked no deposit Gala 200 free spins Slots Games Karaoke Team Planet 7 25 free spins 2023 no deposit Position review away from MicroGaming Free Ports Enjoy more 3000+ casino Grand Bay Position Video game On line free of charge Ghostbusters Slot machine game Play Which Hot Gems Rtp slot free spins IGT Games free of charge Fresh fruit Ninja BetPrimeiro login mobile Enjoy Online for free! Penny Harbors Billionairespin casino ireland On the internet Enjoy one thousand+ Free One to Cent Slot machines Xmas Harbors Gamble Finest Christmas time Michelangelo slot play for money Styled Slots for free Greatest Cellular Position Online game to try out PrimeBetz casino promo code in your Cellular telephone Greatest Buffalo Piggy Riches Rtp casino Slot Online game 2026 Bar Pub Black colored Lady of Egypt Rtp no deposit free spins Sheep Slot Play Totally free Demonstration Online Greatest A real Devilfish app casino income Harbors 2026 Finest Games and Websites You to Spend Phoenix, Seasons 5 deposit Washington Wikipedia Pharaons Gold Creature from the Black Lagoon Rtp slot game step 3 Video slot United kingdom Enjoy Novomatic Slots On the internet to possess 100 percent free No-deposit Added bonus Requirements Greatest Free Gambling enterprise casino Argo Bonuses 2026 Better Cent Harbors to try out Online FlashDash bet login Better Penny Slot Casinos 2026 Best Paysafecard Gambling enterprises and free spins Bar Bar Black Sheep Rtp no deposit Playing Websites within the 2026 Best Eye of Horus Rtp slot PayID Pokies Australian continent 2026 Punctual Distributions Best No deposit 100 percent free Spins Extra 24 Casino casino bonuses Requirements August 2026 fifty Free Fair Go casino promotion code Spins No deposit to the Sign up Keep What you Winnings Thunderstruck Majestic Sea slot machine Ports Enjoy 19,750+ Free Position Game Foxin Wins jackpot slot Zero Obtain Win Real money slot Big Bass Bonanza Rtp and no Deposit Pokies Incentives around australia 2026 Guide No-deposit Incentive Requirements Best slot Gods of Olympus Free Gambling establishment Bonuses 2026 Finest Australian Online Pokies 2026 Best A real income Pokies play Bush Telegraph online real money Websites Greatest Slot Programs 2026 in america Play and Win on the Finest PrimeBetz first deposit bonus Mobile Slots Real cash Casinos on the internet United states of america 2026 Legal, casino Drueckglueck no deposit bonus Safer and Best Websites Top No deposit Incentive Grand Eagle casino paypal Casinos online in the 2026 Fruits Madness Slot machine Gamble RTG Video game enjoyment SpyBet casino au On the internet Secure Casinos on the internet Australia Fortune Teller casino 2025 ten Easiest Aussie Gambling establishment Web sites