Changeset 42343 for trunk/src/wp-includes/class-wp-simplepie-file.php
- Timestamp:
- 11/30/2017 11:09:33 PM (8 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/class-wp-simplepie-file.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-simplepie-file.php
r41162 r42343 33 33 * connection or not. Default false. 34 34 */ 35 public function __construct( $url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {36 $this->url = $url;37 $this->timeout = $timeout;35 public function __construct( $url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false ) { 36 $this->url = $url; 37 $this->timeout = $timeout; 38 38 $this->redirects = $redirects; 39 $this->headers = $headers;39 $this->headers = $headers; 40 40 $this->useragent = $useragent; 41 41 42 42 $this->method = SIMPLEPIE_FILE_SOURCE_REMOTE; 43 43 44 if ( preg_match( '/^http(s)?:\/\//i', $url) ) {44 if ( preg_match( '/^http(s)?:\/\//i', $url ) ) { 45 45 $args = array( 46 'timeout' => $this->timeout,46 'timeout' => $this->timeout, 47 47 'redirection' => $this->redirects, 48 48 ); 49 49 50 if ( ! empty($this->headers) )50 if ( ! empty( $this->headers ) ) { 51 51 $args['headers'] = $this->headers; 52 } 52 53 53 if ( SIMPLEPIE_USERAGENT != $this->useragent ) //Use default WP user agent unless custom has been specified54 if ( SIMPLEPIE_USERAGENT != $this->useragent ) { //Use default WP user agent unless custom has been specified 54 55 $args['user-agent'] = $this->useragent; 56 } 55 57 56 $res = wp_safe_remote_request( $url, $args);58 $res = wp_safe_remote_request( $url, $args ); 57 59 58 if ( is_wp_error( $res) ) {59 $this->error = 'WP HTTP Error: ' . $res->get_error_message();60 if ( is_wp_error( $res ) ) { 61 $this->error = 'WP HTTP Error: ' . $res->get_error_message(); 60 62 $this->success = false; 61 63 } else { 62 $this->headers = wp_remote_retrieve_headers( $res );63 $this->body = wp_remote_retrieve_body( $res );64 $this->headers = wp_remote_retrieve_headers( $res ); 65 $this->body = wp_remote_retrieve_body( $res ); 64 66 $this->status_code = wp_remote_retrieve_response_code( $res ); 65 67 } 66 68 } else { 67 $this->error = '';69 $this->error = ''; 68 70 $this->success = false; 69 71 }
Note: See TracChangeset
for help on using the changeset viewer.