Changeset 33969 for trunk/src/wp-includes/deprecated.php
- Timestamp:
- 09/09/2015 04:25:24 AM (11 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/deprecated.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/deprecated.php
r33673 r33969 3562 3562 } 3563 3563 3564 /** 3565 * Perform a HTTP HEAD or GET request. 3566 * 3567 * If $file_path is a writable filename, this will do a GET request and write 3568 * the file to that path. 3569 * 3570 * @since 2.5.0 3571 * @deprecated 4.4.0 Use WP_Http 3572 * @see WP_Http 3573 * 3574 * @param string $url URL to fetch. 3575 * @param string|bool $file_path Optional. File path to write request to. Default false. 3576 * @param int $red Optional. The number of Redirects followed, Upon 5 being hit, 3577 * returns false. Default 1. 3578 * @return bool|string False on failure and string of headers if HEAD request. 3579 */ 3580 function wp_get_http( $url, $file_path = false, $red = 1 ) { 3581 _deprecated_function( __FUNCTION__, '4.4', 'WP_Http' ); 3582 3583 @set_time_limit( 60 ); 3584 3585 if ( $red > 5 ) 3586 return false; 3587 3588 $options = array(); 3589 $options['redirection'] = 5; 3590 3591 if ( false == $file_path ) 3592 $options['method'] = 'HEAD'; 3593 else 3594 $options['method'] = 'GET'; 3595 3596 $response = wp_safe_remote_request( $url, $options ); 3597 3598 if ( is_wp_error( $response ) ) 3599 return false; 3600 3601 $headers = wp_remote_retrieve_headers( $response ); 3602 $headers['response'] = wp_remote_retrieve_response_code( $response ); 3603 3604 // WP_HTTP no longer follows redirects for HEAD requests. 3605 if ( 'HEAD' == $options['method'] && in_array($headers['response'], array(301, 302)) && isset( $headers['location'] ) ) { 3606 return wp_get_http( $headers['location'], $file_path, ++$red ); 3607 } 3608 3609 if ( false == $file_path ) 3610 return $headers; 3611 3612 // GET request - write it to the supplied filename 3613 $out_fp = fopen($file_path, 'w'); 3614 if ( !$out_fp ) 3615 return $headers; 3616 3617 fwrite( $out_fp, wp_remote_retrieve_body( $response ) ); 3618 fclose($out_fp); 3619 clearstatcache(); 3620 3621 return $headers; 3622 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)