Skip to content

REST API: Build oEmbed proxy URL with wp.apiRequest (#41554)#11479

Open
pranav-inamdar wants to merge 1 commit intoWordPress:trunkfrom
pranav-inamdar:fix/41554-oembed-api-request
Open

REST API: Build oEmbed proxy URL with wp.apiRequest (#41554)#11479
pranav-inamdar wants to merge 1 commit intoWordPress:trunkfrom
pranav-inamdar:fix/41554-oembed-api-request

Conversation

@pranav-inamdar
Copy link
Copy Markdown

Summary

Replaces localized oEmbedProxyUrl (full REST URL from PHP) with wp.apiRequest() using namespace: 'oembed/1.0' and endpoint: 'proxy', so admin embed code builds the oEmbed proxy URL consistently with other REST clients and avoids passing rest_url() output through script localization.

Follow-up to #40919; implements #41554.

Changes

  • Update media embed JS to call wp.apiRequest() for oEmbed proxy previews.
  • Remove the corresponding wp_localize_script / settings property from PHP (where previously passed into wp.media / related scripts).

Testing

Manual:

  1. Open the media modal and use Insert from URL (not only the block editor Embed block).
  2. Paste a supported URL (e.g. a YouTube watch URL) and confirm the embed preview loads.
  3. In the browser Network tab, confirm the request targets the /oembed/1.0/proxy REST route (or equivalent with plain permalinks / rest_route).

Automated:

  • Run relevant PHPUnit tests for the oEmbed REST proxy (e.g. tests/phpunit/tests/oembed/controller.php) in your environment.

Trac ticket: https://core.trac.wordpress.org/ticket/41554

Use of AI Tools

AI assistance: Yes
Tool(s): Cursor
Used for: Exploring the codebase, drafting and iterating on the patch, and PR description text; implementation was reviewed and adjusted manually before submission.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @pi-20.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 9, 2026

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants