wp_remote_get( string $url, array $args = array() ): array|WP_Error
- Since
- 2.7.0
- Source
wp-includes/http.php:187
Description
Important: If the URL is user-controlled, use wp_safe_remote_get() instead.
Parameters
$urlstring- URL to retrieve.
$argsarrayoptional- Request arguments. Default empty array.
See WP_Http::request() for information on accepted arguments.Default:array()
Return
array|WP_Error- The response or WP_Error on failure.
See WP_Http::request() for information on return value.
Cost profile
Measured from the compiled opcodes, not from a stopwatch. Every number here is identical on any machine that runs the same PHP version, and every function in core is ranked by these figures.
- Cost class
- Expensive
- Scaling
- Constant
- Instructions
- 10
- Plugin surface
- None
- Called by
- 20
Makes an outbound HTTP request.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.4. The body compiles to 10.
Nothing here hands control to plugin code.
20 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- httpoutbound HTTP request
wp_remote_get()this function does it
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_remote_get() can have, taken from its control-flow graph on PHP 8.4.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 10 | _wp_http_get_object()->get() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
7.4 | 10 | 10 | 0 | Compiles to the same instructions |
8.1 | 10 | 10 | 0 | Compiles to the same instructions |
8.2 | 10 | 10 | 0 | Compiles to the same instructions |
8.3 | 10 | 10 | 0 | Compiles to the same instructions |
8.4 | 10 | 10 | 0 | Compiles to the same instructions |
Oldest PHP that compiles this body: 7.4. An instruction is not a fixed amount of time, so a version with the same count is not necessarily the same speed; what the count rules out is a difference in the work itself.
Uses · 1
- _wp_http_get_object()Returns the initialized WP_Http Object
Used by · 20
- WP_Automatic_Updater::has_fatal_error()Performs a loopback request to check for potential fatal errors.
- WP_Community_Events::get_events()Gets data about events near a particular location.
- WP_Debug_Data::get_wp_core()Gets the WordPress core section of the debug data.
- WP_REST_Pattern_Directory_Controller::get_items()Search and retrieve block patterns metadata
- WP_Site_Health::check_for_page_caching()Checks if site has page cache enabled or not.
- WP_Site_Health::get_test_dotorg_communication()Tests if the site can communicate with WordPress.org.
- WP_Site_Health::get_test_rest_availability()Tests if the REST API is accessible.
- WP_Site_Health::wp_cron_scheduled_check()Runs the scheduled event to check and update the latest site health status for the website.
- get_block_editor_theme_styles()Creates an array of theme styles to load into the block editor.
- get_core_checksums()Gets and caches the checksums for the given version of WordPress.
- network_step2()Prints step 2 for Network installation process.
- plugins_api()Retrieves plugin installer pages from the WordPress.org Plugins API.
Show all 20
- populate_network()Populate network settings.
- themes_api()Retrieves theme installer pages from the WordPress.org Themes API.
- url_is_accessable_via_ssl()Determines if the URL can be accessed over SSL.
- wp_check_php_version()Checks if the user needs to update PHP.
- wp_credits()Retrieves the contributor credits.
- wp_edit_theme_plugin_file()Attempts to edit a file for a theme or plugin.
- wp_get_popular_importers()Returns a list from WordPress.org of popular importer plugins.
- wp_install_maybe_enable_pretty_permalinks()Maybe enable pretty permalinks on installation.
Source
function wp_remote_get( $url, $args = array() ) { $http = _wp_http_get_object(); return $http->get( $url, $args );}History
Introduced in 2.7.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/http.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.