wp_get_http [ WordPress Function ]
wp_get_http ( $url, $file_path = false, $red = 1 )
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Soorgelijke functies: wp_get_http_headers, wp_get_theme, wp_get_shortlink, wp_get_themes, wp_ext2type
Perform a HTTP HEAD or GET request.
If $file_path is a writable filename, this will do a GET request and write the file to that path.
Source
<?php
function wp_get_http( $url, $file_path = false, $red = 1 ) {
@set_time_limit( 60 );
if ( $red > 5 )
return false;
$options = array();
$options['redirection'] = 5;
if ( false == $file_path )
$options['method'] = 'HEAD';
else
$options['method'] = 'GET';
$response = wp_remote_request($url, $options);
if ( is_wp_error( $response ) )
return false;
$headers = wp_remote_retrieve_headers( $response );
$headers['response'] = wp_remote_retrieve_response_code( $response );
// WP_HTTP no longer follows redirects for HEAD requests.
if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) {
return wp_get_http( $headers['location'], $file_path, ++$red );
}
if ( false == $file_path )
return $headers;
// GET request - write it to the supplied filename
$out_fp = fopen($file_path, 'w');
if ( !$out_fp )
return $headers;
fwrite( $out_fp, wp_remote_retrieve_body( $response ) );
fclose($out_fp);
clearstatcache();
return $headers;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- PHPXRef 0.7 : WordPress : Function Reference: wp_get_http()
Function and Method Cross Reference. wp_get_http(). Defined at: /wp-includes/ functions.php -> line 478. Referenced 1 times: /wp-includes/functions.php -> line ...
phpxref.ftwr.co.uk - wp_get_http (WordPress Function) - WPSeek.com
WordPress lookup for wp_get_http, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com - WordPress › Support » wp_get_http hanging on HEAD request
I'm using wp_get_http in a plugin to validate the existence of a submitted URL and I've noticed that the function hangs on certain URLs. Hangs as in no response ...
wordpress.org - WordPress › Support » Tags — wp_get_http
WordPress › Support » wp_get_http. Tag: wp_get_http Add New » · Developer Information ... wp_get_http hanging on HEAD request, 1, max_Q, 6 months ...
wordpress.org