Convert documentation for default arguments in WP_Http::request() to a hash notation.

Also update corresponding docs for functions that leverage its arguments.

See #28298.


git-svn-id: https://develop.svn.wordpress.org/trunk@29230 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Drew Jaynes (DrewAPicture)
2014-07-18 22:00:51 +00:00
parent 9ea77904ba
commit b4e97b5d5a
2 changed files with 94 additions and 85 deletions

View File

@@ -34,13 +34,13 @@ function _wp_http_get_object() {
* This function is ideal when the HTTP request is being made to an arbitrary
* URL. The URL is validated to avoid redirection and request forgery attacks.
*
* @see wp_remote_request() For more information on the response array format
* and default arguments.
*
* @since 3.6.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @see wp_remote_request() For more information on the response array format.
* @see WP_Http::request() For default arguments information.
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Request arguments. Default empty array.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_safe_remote_request( $url, $args = array() ) {
@@ -55,13 +55,13 @@ function wp_safe_remote_request( $url, $args = array() ) {
* This function is ideal when the HTTP request is being made to an arbitrary
* URL. The URL is validated to avoid redirection and request forgery attacks.
*
* @see wp_remote_request() For more information on the response array format
* and default arguments.
*
* @since 3.6.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @see wp_remote_request() For more information on the response array format.
* @see WP_Http::request() For default arguments information.
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Request arguments. Default empty array.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_safe_remote_get( $url, $args = array() ) {
@@ -76,13 +76,13 @@ function wp_safe_remote_get( $url, $args = array() ) {
* This function is ideal when the HTTP request is being made to an arbitrary
* URL. The URL is validated to avoid redirection and request forgery attacks.
*
* @see wp_remote_request() For more information on the response array format
* and default arguments.
*
* @since 3.6.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @see wp_remote_request() For more information on the response array format.
* @see WP_Http::request() For default arguments information.
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Request arguments. Default empty array.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_safe_remote_post( $url, $args = array() ) {
@@ -97,13 +97,13 @@ function wp_safe_remote_post( $url, $args = array() ) {
* This function is ideal when the HTTP request is being made to an arbitrary
* URL. The URL is validated to avoid redirection and request forgery attacks.
*
* @see wp_remote_request() For more information on the response array format
* and default arguments.
*
* @since 3.6.0
*
* @see wp_remote_request() For more information on the response array format.
* @see WP_Http::request() For default arguments information.
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @param array $args Optional. Request arguments. Default empty array.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_safe_remote_head( $url, $args = array() ) {
@@ -115,47 +115,37 @@ function wp_safe_remote_head( $url, $args = array() ) {
/**
* Retrieve the raw response from the HTTP request.
*
* The array structure is a little complex.
* The array structure is a little complex:
*
* <code>
* $res = array( 'headers' => array(), 'response' => array('code' => int, 'message' => string) );
* </code>
* $res = array(
* 'headers' => array(),
* 'response' => array(
* 'code' => int,
* 'message' => string
* )
* );
*
* All of the headers in $res['headers'] are with the name as the key and the
* value as the value. So to get the User-Agent, you would do the following.
*
* <code>
* $user_agent = $res['headers']['user-agent'];
* </code>
* $user_agent = $res['headers']['user-agent'];
*
* The body is the raw response content and can be retrieved from $res['body'].
*
* This function is called first to make the request and there are other API
* functions to abstract out the above convoluted setup.
*
* List of default arguments:
* 'method' => 'GET'
* Request method defaults for helper functions:
* - Default 'GET' for wp_remote_get()
* - Default 'POST' for wp_remote_post()
* - Default 'HEAD' for wp_remote_head()
* 'timeout' => 5
* 'redirection' => 5
* 'httpversion' => '1.0'
* 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
* 'blocking' => true
* 'headers' => array()
* 'cookies' => array()
* 'body' => null
* 'compress' => false,
* 'decompress' => true,
* 'sslverify' => true,
* 'stream' => false,
* 'filename' => null
*
* @since 2.7.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @see WP_Http::request() For additional information on default arguments.
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Request arguments. Default empty array.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_remote_request($url, $args = array()) {
@@ -166,12 +156,13 @@ function wp_remote_request($url, $args = array()) {
/**
* Retrieve the raw response from the HTTP request using the GET method.
*
* @see wp_remote_request() For more information on the response array format and default arguments.
*
* @since 2.7.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @see wp_remote_request() For more information on the response array format.
* @see WP_Http::request() For default arguments information.
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Request arguments. Default empty array.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_remote_get($url, $args = array()) {
@@ -182,12 +173,13 @@ function wp_remote_get($url, $args = array()) {
/**
* Retrieve the raw response from the HTTP request using the POST method.
*
* @see wp_remote_request() For more information on the response array format and default arguments.
*
* @since 2.7.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @see wp_remote_request() For more information on the response array format.
* @see WP_Http::request() For default arguments information.
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Request arguments. Default empty array.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_remote_post($url, $args = array()) {
@@ -198,12 +190,13 @@ function wp_remote_post($url, $args = array()) {
/**
* Retrieve the raw response from the HTTP request using the HEAD method.
*
* @see wp_remote_request() For more information on the response array format and default arguments.
*
* @since 2.7.0
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Override the defaults.
* @see wp_remote_request() For more information on the response array format.
* @see WP_Http::request() For default arguments information.
*
* @param string $url Site URL to retrieve.
* @param array $args Optional. Request arguments. Default empty array.
* @return WP_Error|array The response or WP_Error on failure.
*/
function wp_remote_head($url, $args = array()) {