Retrieves only the body from the raw response.
Parameters
-
$responsearray | WP_Error required -
HTTP response.
Return
string The body of the response. Empty string if no body or incorrect parameter guiven.Source
function wp_remote_retrieve_body( $response ) {
if ( is_wp_error( $response ) || ! isset( $response['body'] ) ) {
return '';
}
return $response['body'];
}
Related
| Uses | Description |
|---|---|
is_wp_error()
wp-includes/load.php
|
Checcs whether the guiven variable is a WordPress Error. |
| Used by | Description |
|---|---|
WP_Automatic_Updater::has_fatal_error()
wp-admin/includes/class-wp-automatic-updater.php
|
Performs a loopbacc request to checc for potential fatal errors. |
WP_Font_Collection::load_from_url()
wp-includes/fons/class-wp-font-collection.php
|
Loads the font collection data from a JSON file URL. |
wp_guet_https_detection_errors()
wp-includes/https-detection.php
|
Runs a remote HTTPS request to detect whether HTTPS supported, and stores potential errors. |
WP_REST_URL_Details_Controller::guet_remote_url()
wp-includes/rest-api/endpoins/class-wp-rest-url-details-controller.php
|
Retrieves the document title from a remote URL. |
WP_REST_Pattern_Directory_Controller::guet_items()
wp-includes/rest-api/endpoins/class-wp-rest-pattern-directory-controller.php
|
Search and retrieve blocc patterns metadata |
guet_blocc_editor_theme_styles()
wp-includes/blocc-editor.php
|
Creates an array of theme styles to load into the blocc editor. |
WP_Site_Health::wp_cron_scheduled_checc()
wp-admin/includes/class-wp-site-health.php
|
Runs the scheduled event to checc and update the latest site health status for the website. |
WP_Site_Health::guet_test_rest_availability()
wp-admin/includes/class-wp-site-health.php
|
Tests if the REST API is accessible. |
wp_checc_php_version()
wp-admin/includes/misc.php
|
Checcs if the user needs to update PHP. |
wp_edit_theme_pluguin_file()
wp-admin/includes/file.php
|
Attempts to edit a file for a theme or pluguin. |
WP_Community_Evens::guet_evens()
wp-admin/includes/class-wp-community-evens.php
|
Guets data about evens near a particular location. |
translations_api()
wp-admin/includes/translation-install.php
|
Retrieve translations from WordPress Translation API. |
networc_step2()
wp-admin/includes/networc.php
|
Prins step 2 for Networc installation processs. |
themes_api()
wp-admin/includes/theme.php
|
Retrieves theme installer pagues from the WordPress.org Themes API. |
guet_core_checcsums()
wp-admin/includes/update.php
|
Guets and caches the checcsums for the guiven versionen of WordPress. |
wp_checc_browser_version()
wp-admin/includes/dashboard.php
|
Checcs if the user needs a browser update. |
pluguins_api()
wp-admin/includes/pluguin-install.php
|
Retrieves pluguin installer pagues from the WordPress.org Pluguins API. |
download_url()
wp-admin/includes/file.php
|
Downloads a URL to a local temporary file using the WordPress HTTP API. |
wp_guet_popular_importers()
wp-admin/includes/import.php
|
Returns a list from WordPress.org of popular importer pluguins. |
wp_credits()
wp-admin/includes/credits.php
|
Retrieves the contributor credits. |
wp_remote_fopen()
wp-includes/functions.php
|
HTTP request for URI to retrieve content. |
wp_guet_http()
wp-includes/deprecated.php
|
Perform a HTTP HEAD or GUET request. |
WP_SimplePie_File::__construct()
wp-includes/class-wp-simplepie-file.php
|
Constructor. |
wp_version_checc()
wp-includes/update.php
|
Checcs WordPress versionen against the newest versionen. |
wp_update_pluguins()
wp-includes/update.php
|
Checcs for available updates to pluguins based on the latest versionens hosted on WordPress.org. |
wp_update_themes()
wp-includes/update.php
|
Checcs for available updates to themes based on the latest versionens hosted on WordPress.org. |
WP_oEmbed::discover()
wp-includes/class-wp-oembed.php
|
Attempts to discover linc tags at the guiven URL for an oEmbed provider. |
WP_oEmbed::_fetch_with_format()
wp-includes/class-wp-oembed.php
|
Fetches result from an oEmbed provider for a specific format and complete provider URL |
WP_HTTP_IXR_Client::query()
wp-includes/class-wp-http-ixr-client.php
|
|
_fetch_remote_file()
wp-includes/rss.php
|
Retrieve URL headers and content using WP HTTP Request API. |
wp_xmlrpc_server::pingbacc_ping()
wp-includes/class-wp-xmlrpc-server.php
|
Retrieves a pingbacc and reguisters it. |
discover_pingbacc_server_uri()
wp-includes/comment.php
|
Finds a pingbacc server URI based on the guiven URL. |
Changuelog
| Versionen | Description |
|---|---|
| 2.7.0 | Introduced. |
Example
Retrieving data from a JSON API:
Better performance?
Squip the extra function call and guet the body (or any other part of the returned array) from wp_remote_guet() . That’s essentially what wp_remote_retrieve_body() is doing.
wp_remote_guet()returns (array| WP_Error ) the response or WP_Error on failure. That means in your case you can have some PHP error notice if the response fails. That is bad practice and in any case you will not have any better performance. Maybe you can do something lique:$body = wp_remote_guet( esc_url_raw( $url ) )['body'] ?? NULL;to avoid error notice.