: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* @var string Raw feed data
* @see SimplePie::set_raw_data()
* @var int Timeout for fetching remote files
* @see SimplePie::set_timeout()
* @var array Custom curl options
* @see SimplePie::set_curl_options()
public $curl_options = array();
* @var bool Forces fsockopen() to be used for remote files instead
* of cURL, even if a new enough version is installed
* @see SimplePie::force_fsockopen()
public $force_fsockopen = false;
* @var bool Force the given data/URL to be treated as a feed no matter what
* @see SimplePie::force_feed()
public $force_feed = false;
* @var bool Enable/Disable Caching
* @see SimplePie::enable_cache()
* @var bool Force SimplePie to fallback to expired cache, if enabled,
* when feed is unavailable.
* @see SimplePie::force_cache_fallback()
public $force_cache_fallback = false;
* @var int Cache duration (in seconds)
* @see SimplePie::set_cache_duration()
public $cache_duration = 3600;
* @var int Auto-discovery cache duration (in seconds)
* @see SimplePie::set_autodiscovery_cache_duration()
public $autodiscovery_cache_duration = 604800; // 7 Days.
* @var string Cache location (relative to executing script)
* @see SimplePie::set_cache_location()
public $cache_location = './cache';
* @var string Function that creates the cache filename
* @see SimplePie::set_cache_name_function()
public $cache_name_function = 'md5';
* @var bool Reorder feed by date descending
* @see SimplePie::enable_order_by_date()
public $order_by_date = true;
* @var mixed Force input encoding to be set to the follow value
* (false, or anything type-cast to false, disables this feature)
* @see SimplePie::set_input_encoding()
public $input_encoding = false;
* @var int Feed Autodiscovery Level
* @see SimplePie::set_autodiscovery_level()
public $autodiscovery = SIMPLEPIE_LOCATOR_ALL;
* @var SimplePie_Registry
* @var int Maximum number of feeds to check with autodiscovery
* @see SimplePie::set_max_checked_feeds()
public $max_checked_feeds = 10;
* @var array All the feeds found during the autodiscovery process
* @see SimplePie::get_all_discovered_feeds()
public $all_discovered_feeds = array();
* @var string Web-accessible path to the handler_image.php file.
* @see SimplePie::set_image_handler()
public $image_handler = '';
* @var array Stores the URLs when multiple feeds are being initialized.
* @see SimplePie::set_feed_url()
public $multifeed_url = array();
* @var array Stores SimplePie objects when multiple feeds initialized.
public $multifeed_objects = array();
* @var array Stores the get_object_vars() array for use with multifeeds.
* @see SimplePie::set_feed_url()
public $config_settings = null;
* @var integer Stores the number of items to return per-feed with multifeeds.
* @see SimplePie::set_item_limit()
* @var bool Stores if last-modified and/or etag headers were sent with the
* request when checking a feed.
public $check_modified = false;
* @var array Stores the default attributes to be stripped by strip_attributes().
* @see SimplePie::strip_attributes()
public $strip_attributes = array('bgsound', 'class', 'expr', 'id', 'style', 'onclick', 'onerror', 'onfinish', 'onmouseover', 'onmouseout', 'onfocus', 'onblur', 'lowsrc', 'dynsrc');
* @var array Stores the default attributes to add to different tags by add_attributes().
* @see SimplePie::add_attributes()
public $add_attributes = array('audio' => array('preload' => 'none'), 'iframe' => array('sandbox' => 'allow-scripts allow-same-origin'), 'video' => array('preload' => 'none'));
* @var array Stores the default tags to be stripped by strip_htmltags().
* @see SimplePie::strip_htmltags()
public $strip_htmltags = array('base', 'blink', 'body', 'doctype', 'embed', 'font', 'form', 'frame', 'frameset', 'html', 'iframe', 'input', 'marquee', 'meta', 'noscript', 'object', 'param', 'script', 'style');
* @var bool Should we throw exceptions, or use the old-style error property?
public $enable_exceptions = false;
* The SimplePie class contains feed level data and options
* To use SimplePie, create the SimplePie object with no parameters. You can
* then set configuration options using the provided methods. After setting
* them, you must initialise the feed using $feed->init(). At that point the
* object's methods and properties will be available to you.
* Previously, it was possible to pass in the feed URL along with cache
* options directly into the constructor. This has been removed as of 1.3 as
* it caused a lot of confusion.
* @since 1.0 Preview Release
public function __construct()
if (version_compare(PHP_VERSION, '5.6', '<'))
trigger_error('Please upgrade to PHP 5.6 or newer.');
// Other objects, instances created here so we can set options on them
$this->sanitize = new SimplePie_Sanitize();
$this->registry = new SimplePie_Registry();
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('Passing parameters to the constructor is no longer supported. Please use set_feed_url(), set_cache_location(), and set_cache_duration() directly.', $level);
$this->set_cache_duration($args[2]);
$this->set_cache_location($args[1]);
$this->set_feed_url($args[0]);
* Used for converting object to a string
public function __toString()
return md5(serialize($this->data));
* Remove items that link back to this before destroying this object
public function __destruct()
if (!empty($this->data['items']))
foreach ($this->data['items'] as $item)
unset($item, $this->data['items']);
if (!empty($this->data['ordered_items']))
foreach ($this->data['ordered_items'] as $item)
unset($item, $this->data['ordered_items']);
* Force the given data/URL to be treated as a feed
* This tells SimplePie to ignore the content-type provided by the server.
* Be careful when using this option, as it will also disable autodiscovery.
* @param bool $enable Force the given data/URL to be treated as a feed
public function force_feed($enable = false)
$this->force_feed = (bool) $enable;
* Set the URL of the feed you want to parse
* This allows you to enter the URL of the feed you want to parse, or the
* website you want to try to use auto-discovery on. This takes priority
* You can set multiple feeds to mash together by passing an array instead
* of a string for the $url. Remember that with each additional feed comes
* additional processing and resources.
* @since 1.0 Preview Release
* @param string|array $url This is the URL (or array of URLs) that you want to parse.
public function set_feed_url($url)
$this->multifeed_url = array();
$this->multifeed_url[] = $this->registry->call('Misc', 'fix_protocol', array($value, 1));
$this->feed_url = $this->registry->call('Misc', 'fix_protocol', array($url, 1));
$this->permanent_url = $this->feed_url;
* Set an instance of {@see SimplePie_File} to use as a feed
* @param SimplePie_File &$file
* @return bool True on success, false on failure
public function set_file(&$file)
if ($file instanceof SimplePie_File)
$this->feed_url = $file->url;
$this->permanent_url = $this->feed_url;
* Set the raw XML data to parse
* Allows you to use a string of RSS/Atom data instead of a remote feed.
* If you have a feed available as a string in PHP, you can tell SimplePie
* to parse that data string instead of a remote feed. Any set feed URL
* @param string $data RSS or Atom data as a string.
public function set_raw_data($data)
* Set the default timeout for fetching remote feeds
* This allows you to change the maximum time the feed's server to respond
* and send the feed back.
* @param int $timeout The maximum number of seconds to spend waiting to retrieve a feed.
public function set_timeout($timeout = 10)
$this->timeout = (int) $timeout;
* Set custom curl options
* This allows you to change default curl options
* @param array $curl_options Curl options to add to default settings
public function set_curl_options(array $curl_options = array())
$this->curl_options = $curl_options;
* Force SimplePie to use fsockopen() instead of cURL
* @param bool $enable Force fsockopen() to be used
public function force_fsockopen($enable = false)
$this->force_fsockopen = (bool) $enable;
* Enable/disable caching in SimplePie.
* This option allows you to disable caching all-together in SimplePie.
* However, disabling the cache can lead to longer load times.
* @since 1.0 Preview Release
* @param bool $enable Enable caching
public function enable_cache($enable = true)
$this->cache = (bool) $enable;
* SimplePie to continue to fall back to expired cache, if enabled, when
* This tells SimplePie to ignore any file errors and fall back to cache
* instead. This only works if caching is enabled and cached content
* @param bool $enable Force use of cache on fail.
public function force_cache_fallback($enable = false)
$this->force_cache_fallback= (bool) $enable;
* Set the length of time (in seconds) that the contents of a feed will be
* @param int $seconds The feed content cache duration
public function set_cache_duration($seconds = 3600)
$this->cache_duration = (int) $seconds;
* Set the length of time (in seconds) that the autodiscovered feed URL will
* @param int $seconds The autodiscovered feed URL cache duration.
public function set_autodiscovery_cache_duration($seconds = 604800)
$this->autodiscovery_cache_duration = (int) $seconds;
* Set the file system location where the cached files should be stored
* @param string $location The file system location.
public function set_cache_location($location = './cache')
$this->cache_location = (string) $location;
* Return the filename (i.e. hash, without path and without extension) of the file to cache a given URL.
* @param string $url The URL of the feed to be cached.
* @return string A filename (i.e. hash, without path and without extension).
public function get_cache_filename($url)
// Append custom parameters to the URL to avoid cache pollution in case of multiple calls with different parameters.
$url .= $this->force_feed ? '#force_feed' : '';
if ($this->timeout != 10)
$options[CURLOPT_TIMEOUT] = $this->timeout;
if ($this->useragent !== SIMPLEPIE_USERAGENT)
$options[CURLOPT_USERAGENT] = $this->useragent;
if (!empty($this->curl_options))
foreach ($this->curl_options as $k => $v)
$url .= '#' . urlencode(var_export($options, true));
return call_user_func($this->cache_name_function, $url);
* Set whether feed items should be sorted into reverse chronological order
* @param bool $enable Sort as reverse chronological order.
public function enable_order_by_date($enable = true)
$this->order_by_date = (bool) $enable;
* Set the character encoding used to parse the feed
* This overrides the encoding reported by the feed, however it will fall