WordPress.org

Make WordPress Core

Opened 10 months ago

Last modified 6 weeks ago

#41554 new enhancement

REST API: Use `wp.apiRequest` helper to build URLs for media embed requests

Reported by: jnylen0 Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version:
Component: REST API Keywords: good-first-bug has-patch
Focuses: javascript, administration, rest-api Cc:

Description

Follow-up to #40919.

Let's explore getting rid of the oEmbedProxyUrl property used to pass a REST API URL down to wp-admin code that calls out to this endpoint (example). We can use the helper library introduced in #40919 instead:

wp.apiRequest( {
    namespace: 'oembed/1.0',
    path: '/proxy',
    // ...
} );

This helper will allow us to eliminate all rest_url calls passed to client code through script localization. This will eventually lead to a lot of duplication, but it seems like it should be very clear from the requesting code which API endpoint is being called.

Attachments (2)

41554.diff (3.3 KB) - added by nezhar 6 weeks ago.
41554.2.diff (3.3 KB) - added by nezhar 6 weeks ago.

Download all attachments as: .zip

Change History (3)

@nezhar
6 weeks ago

@nezhar
6 weeks ago

#1 @nezhar
6 weeks ago

  • Keywords has-patch added; needs-patch removed

I have done the path a described above. How can I test this actually? I tried by embedding a Youtube video, but I don't think it uses the action that got modified.

Note: See TracTickets for help on using tickets.