WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

#10413 closed enhancement (fixed)

Allow plugins to short -circuit WP_Http::request()

Reported by: johnbillion Owned by: dd32
Milestone: 2.9 Priority: normal
Severity: normal Version: 2.8.1
Component: HTTP API Keywords: has-patch tested
Focuses: Cc:

Description

There is no way for plugins to add caching functionality to any of the HTTP functions (such as wp_remote_get()) in WordPress.

An easy way to add this is to provide a short-circuit option just like that found in get_option() where a plugin can hook into pre_option_{$option_name} and return a value for that option.

A simple filter which passes the arguments array and the URL will do nicely.

Attachments (1)

10413.patch (792 bytes) - added by johnbillion 5 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 johnbillion5 years ago

  • Keywords has-patch added

Patch.

Adds a new filter called pre_http_request which passes the arguments array and the URL of the request.

comment:2 johnbillion5 years ago

Patch updated.

Of course, we also need a way for plugins to access the result of the HTTP request (and potentially cache it), so let's add a http_response filter to the response.

johnbillion5 years ago

comment:3 Denis-de-Bernardy5 years ago

  • Milestone changed from Unassigned to 2.9

*grin*

Closing #10231 as dup, since this patch is better.

comment:4 Denis-de-Bernardy5 years ago

  • Keywords tested added

I'm all +1 for this patch. It fixes my own problem too.

comment:5 markjaquith5 years ago

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

(In [11758]) add some filters so that HTTP requests can be filtered. props johnbillion. fixes #10413

Note: See TracTickets for help on using tickets.