Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#35803 closed enhancement (fixed)

Introduce rest_get_request_from_url() for getting a WP_REST_Request object from a provided URL

Reported by: danielbachhuber's profile danielbachhuber Owned by: rmccue's profile rmccue
Milestone: 4.5 Priority: normal
Severity: normal Version:
Component: REST API Keywords: has-patch has-unit-tests dev-feedback
Focuses: Cc:

Description

rest_get_request_from_url() makes it easier to get a WP_REST_Request object from a provided URL. Because _links are the full URL, and not just the route, we should have a mechanism for resolving these URLs to WP_REST_Request objects.

As a matter of fact, I'm pretty sure WP_REST_Server::embed_links() doesn't work right now when pretty permalinks are disabled.

Originally https://github.com/WP-API/WP-API/issues/2109

Attachments (4)

35803.1.diff (2.9 KB) - added by danielbachhuber 9 years ago.
35803.2.diff (3.5 KB) - added by rmccue 9 years ago.
Move to WP_REST_Request::from_url and rework internals
35803.3.diff (3.0 KB) - added by rmccue 9 years ago.
Combine filters
35803.4.diff (3.0 KB) - added by rmccue 9 years ago.
Simplify parse_url call

Download all attachments as: .zip

Change History (20)

#1 @danielbachhuber
9 years ago

@joehoyle @rmccue @rachelbaker Feedback on this when you have a moment. Couple of pieces I didn't get to in this first patch:

  1. When the $url is to a different domain, we should return false instead of creating a WP_REST_Request object.
  2. Needs to be hooked into WP_REST_Server::embed_links() and make sure we have sufficient test coverage.

#2 @danielbachhuber
9 years ago

Oops, I already found the non-pretty permalinks bug :) #35629

This ticket was mentioned in Slack in #core-restapi by danielbachhuber. View the logs.


9 years ago

This ticket was mentioned in Slack in #core-restapi by danielbachhuber. View the logs.


9 years ago

This ticket was mentioned in Slack in #core-restapi by danielbachhuber. View the logs.


9 years ago

This ticket was mentioned in Slack in #core by chriscct7. View the logs.


9 years ago

#7 @chriscct7
9 years ago

Crossposting from slack:

@danielbachhuber: @joehoyle @rachelbaker @rmccue could I get feedback on https://core.trac.wordpress.org/ticket/35803 pretty please?

This ticket was mentioned in Slack in #core-restapi by danielbachhuber. View the logs.


9 years ago

#9 @rmccue
9 years ago

Sorry for the delayed response! LGTM; not the nicest code, but not much you can do about that. I'm not sure on the naming though; what about WP_REST_Request::from_url() ?

#10 @rmccue
9 years ago

  • Owner set to rmccue
  • Status changed from new to assigned

This ticket was mentioned in Slack in #core by jorbin. View the logs.


9 years ago

@rmccue
9 years ago

Move to WP_REST_Request::from_url and rework internals

@rmccue
9 years ago

Combine filters

@rmccue
9 years ago

Simplify parse_url call

#12 @rmccue
9 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 36673:

REST API: Add WP_REST_Request::from_url()

Allows converting a REST URL into a Request object.

Props danielbachhuber.
Fixes #35803.

#13 @rmccue
9 years ago

In 36674:

REST API: Use WP_REST_Request::from_url() when embedding.

See #35803.

#14 @DrewAPicture
9 years ago

In 37013:

Docs: Improve the DocBlock for WP_REST_Request::from_url(), introduced in [36673].

See #35803. See #35986.

#15 @DrewAPicture
9 years ago

In 37014:

Docs: Improve parameter description syntax in the hook doc for the rest_request_from_url filter, introduced in [36673].

See #35803. See #35986,

#16 @rachelbaker
9 years ago

In 37021:

REST API: Remove unused variable $api_root from WP_Rest_Server->embed_links() method.

After [r36674] the variable $api_root is no longer used in this method and should be removed.

See #35803.

Note: See TracTickets for help on using tickets.