web/wp-includes/class-feed.php
changeset 194 32102edaa81b
parent 136 bde1974c263b
child 204 09a1c134465b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
     2 
     2 
     3 if ( !class_exists('SimplePie') )
     3 if ( !class_exists('SimplePie') )
     4 	require_once (ABSPATH . WPINC . '/class-simplepie.php');
     4 	require_once (ABSPATH . WPINC . '/class-simplepie.php');
     5 
     5 
     6 class WP_Feed_Cache extends SimplePie_Cache {
     6 class WP_Feed_Cache extends SimplePie_Cache {
     7 	/**
       
     8 	 * Don't call the constructor. Please.
       
     9 	 *
       
    10 	 * @access private
       
    11 	 */
       
    12 	function WP_Feed_Cache() {
       
    13 		trigger_error('Please call SimplePie_Cache::create() instead of the constructor', E_USER_ERROR);
       
    14 	}
       
    15 
       
    16 	/**
     7 	/**
    17 	 * Create a new SimplePie_Cache object
     8 	 * Create a new SimplePie_Cache object
    18 	 *
     9 	 *
    19 	 * @static
    10 	 * @static
    20 	 * @access public
    11 	 * @access public
    27 class WP_Feed_Cache_Transient {
    18 class WP_Feed_Cache_Transient {
    28 	var $name;
    19 	var $name;
    29 	var $mod_name;
    20 	var $mod_name;
    30 	var $lifetime = 43200; //Default lifetime in cache of 12 hours
    21 	var $lifetime = 43200; //Default lifetime in cache of 12 hours
    31 
    22 
    32 	function WP_Feed_Cache_Transient($location, $filename, $extension) {
    23 	function __construct($location, $filename, $extension) {
    33 		$this->name = 'feed_' . $filename;
    24 		$this->name = 'feed_' . $filename;
    34 		$this->mod_name = 'feed_mod_' . $filename;
    25 		$this->mod_name = 'feed_mod_' . $filename;
    35 		$this->lifetime = apply_filters('wp_feed_cache_transient_lifetime', $this->lifetime, $filename);
    26 		$this->lifetime = apply_filters('wp_feed_cache_transient_lifetime', $this->lifetime, $filename);
    36 	}
    27 	}
    37 
    28 
    63 	}
    54 	}
    64 }
    55 }
    65 
    56 
    66 class WP_SimplePie_File extends SimplePie_File {
    57 class WP_SimplePie_File extends SimplePie_File {
    67 
    58 
    68 	function WP_SimplePie_File($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
    59 	function __construct($url, $timeout = 10, $redirects = 5, $headers = null, $useragent = null, $force_fsockopen = false) {
    69 		$this->url = $url;
    60 		$this->url = $url;
    70 		$this->timeout = $timeout;
    61 		$this->timeout = $timeout;
    71 		$this->redirects = $redirects;
    62 		$this->redirects = $redirects;
    72 		$this->headers = $headers;
    63 		$this->headers = $headers;
    73 		$this->useragent = $useragent;
    64 		$this->useragent = $useragent;
    87 
    78 
    88 			if ( is_wp_error($res) ) {
    79 			if ( is_wp_error($res) ) {
    89 				$this->error = 'WP HTTP Error: ' . $res->get_error_message();
    80 				$this->error = 'WP HTTP Error: ' . $res->get_error_message();
    90 				$this->success = false;
    81 				$this->success = false;
    91 			} else {
    82 			} else {
    92 				$this->headers = $res['headers'];
    83 				$this->headers = wp_remote_retrieve_headers( $res );
    93 				$this->body = $res['body'];
    84 				$this->body = wp_remote_retrieve_body( $res );
    94 				$this->status_code = $res['response']['code'];
    85 				$this->status_code = wp_remote_retrieve_response_code( $res );
    95 			}
    86 			}
    96 		} else {
    87 		} else {
    97 			if ( ! $this->body = file_get_contents($url) ) {
    88 			if ( ! $this->body = file_get_contents($url) ) {
    98 				$this->error = 'file_get_contents could not read the file';
    89 				$this->error = 'file_get_contents could not read the file';
    99 				$this->success = false;
    90 				$this->success = false;