wp/wp-includes/class-wp-simplepie-file.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    14  * to hook into the process.
    14  * to hook into the process.
    15  *
    15  *
    16  * @since 2.8.0
    16  * @since 2.8.0
    17  */
    17  */
    18 #[AllowDynamicProperties]
    18 #[AllowDynamicProperties]
    19 class WP_SimplePie_File extends SimplePie_File {
    19 class WP_SimplePie_File extends SimplePie\File {
    20 
    20 
    21 	/**
    21 	/**
    22 	 * Timeout.
    22 	 * Timeout.
    23 	 *
    23 	 *
    24 	 * @var int How long the connection should stay open in seconds.
    24 	 * @var int How long the connection should stay open in seconds.
    48 		$this->timeout   = $timeout;
    48 		$this->timeout   = $timeout;
    49 		$this->redirects = $redirects;
    49 		$this->redirects = $redirects;
    50 		$this->headers   = $headers;
    50 		$this->headers   = $headers;
    51 		$this->useragent = $useragent;
    51 		$this->useragent = $useragent;
    52 
    52 
    53 		$this->method = SIMPLEPIE_FILE_SOURCE_REMOTE;
    53 		$this->method = SimplePie\SimplePie::FILE_SOURCE_REMOTE;
    54 
    54 
    55 		if ( preg_match( '/^http(s)?:\/\//i', $url ) ) {
    55 		if ( preg_match( '/^http(s)?:\/\//i', $url ) ) {
    56 			$args = array(
    56 			$args = array(
    57 				'timeout'     => $this->timeout,
    57 				'timeout'     => $this->timeout,
    58 				'redirection' => $this->redirects,
    58 				'redirection' => $this->redirects,
    60 
    60 
    61 			if ( ! empty( $this->headers ) ) {
    61 			if ( ! empty( $this->headers ) ) {
    62 				$args['headers'] = $this->headers;
    62 				$args['headers'] = $this->headers;
    63 			}
    63 			}
    64 
    64 
    65 			if ( SIMPLEPIE_USERAGENT !== $this->useragent ) { // Use default WP user agent unless custom has been specified.
    65 			if ( SimplePie\Misc::get_default_useragent() !== $this->useragent ) { // Use default WP user agent unless custom has been specified.
    66 				$args['user-agent'] = $this->useragent;
    66 				$args['user-agent'] = $this->useragent;
    67 			}
    67 			}
    68 
    68 
    69 			$res = wp_safe_remote_request( $url, $args );
    69 			$res = wp_safe_remote_request( $url, $args );
    70 
    70 
    81 				 * to be converted.
    81 				 * to be converted.
    82 				 *
    82 				 *
    83 				 * The only exception to that is the `content-type` header, which should ignore
    83 				 * The only exception to that is the `content-type` header, which should ignore
    84 				 * any previous values and only use the last one.
    84 				 * any previous values and only use the last one.
    85 				 *
    85 				 *
    86 				 * @see SimplePie_HTTP_Parser::new_line().
    86 				 * @see SimplePie\HTTP\Parser::new_line().
    87 				 */
    87 				 */
    88 				foreach ( $this->headers as $name => $value ) {
    88 				foreach ( $this->headers as $name => $value ) {
    89 					if ( ! is_array( $value ) ) {
    89 					if ( ! is_array( $value ) ) {
    90 						continue;
    90 						continue;
    91 					}
    91 					}