: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* Get the feed logo's link
* RSS 2.0 feeds are allowed to have a "feed logo" width.
* Uses `<image><width>` or defaults to 88.0 if no width is specified and
* the feed is an RSS 2.0 feed.
public function get_image_width()
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'width'))
return round($return[0]['data']);
elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
* Get the feed logo's height
* RSS 2.0 feeds are allowed to have a "feed logo" height.
* Uses `<image><height>` or defaults to 31.0 if no height is specified and
* the feed is an RSS 2.0 feed.
public function get_image_height()
if ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'height'))
return round($return[0]['data']);
elseif ($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION && $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
* Get the number of items in the feed
* This is well-suited for {@link http://php.net/for for()} loops with
* @param int $max Maximum value to return. 0 for no limit
* @return int Number of items in the feed
public function get_item_quantity($max = 0)
$qty = count($this->get_items());
return ($qty > $max) ? $max : $qty;
* Get a single item from the feed
* This is better suited for {@link http://php.net/for for()} loops, whereas
* {@see get_items()} is better suited for
* {@link http://php.net/foreach foreach()} loops.
* @see get_item_quantity()
* @param int $key The item that you want to return. Remember that arrays begin with 0, not 1
* @return SimplePie_Item|null
public function get_item($key = 0)
$items = $this->get_items();
* Get all items from the feed
* This is better suited for {@link http://php.net/for for()} loops, whereas
* {@see get_items()} is better suited for
* {@link http://php.net/foreach foreach()} loops.
* @param int $start Index to start at
* @param int $end Number of items to return. 0 for all items after `$start`
* @return SimplePie_Item[]|null List of {@see SimplePie_Item} objects
public function get_items($start = 0, $end = 0)
if (!isset($this->data['items']))
if (!empty($this->multifeed_objects))
$this->data['items'] = SimplePie::merge_items($this->multifeed_objects, $start, $end, $this->item_limit);
if (empty($this->data['items']))
return $this->data['items'];
$this->data['items'] = array();
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'entry'))
$keys = array_keys($items);
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry'))
$keys = array_keys($items);
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item'))
$keys = array_keys($items);
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item'))
$keys = array_keys($items);
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item'))
$keys = array_keys($items);
$this->data['items'][] = $this->registry->create('Item', array($this, $items[$key]));
if (empty($this->data['items']))
if ($this->order_by_date)
if (!isset($this->data['ordered_items']))
$this->data['ordered_items'] = $this->data['items'];
usort($this->data['ordered_items'], array(get_class($this), 'sort_items'));
$items = $this->data['ordered_items'];
$items = $this->data['items'];
// Slice the data as desired
return array_slice($items, $start);
return array_slice($items, $start, $end);
* Set the favicon handler
* @deprecated Use your own favicon handling instead
public function set_favicon_handler($page = false, $qs = 'i')
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('Favicon handling has been removed, please use your own handling', $level);
* Get the favicon for the current feed
* @deprecated Use your own favicon handling instead
public function get_favicon()
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('Favicon handling has been removed, please use your own handling', $level);
if (($url = $this->get_link()) !== null)
return 'https://www.google.com/s2/favicons?domain=' . urlencode($url);
* @param string $method Method name
* @param array $args Arguments to the method
public function __call($method, $args)
if (strpos($method, 'subscribe_') === 0)
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('subscribe_*() has been deprecated, implement the callback yourself', $level);
if ($method === 'enable_xml_dump')
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('enable_xml_dump() has been deprecated, use get_raw_data() instead', $level);
$class = get_class($this);
$trace = debug_backtrace(); // phpcs:ignore PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue.NeedsInspection
$file = $trace[0]['file'];
$line = $trace[0]['line'];
trigger_error("Call to undefined method $class::$method() in $file on line $line", E_USER_ERROR);
* Sorting callback for items
public static function sort_items($a, $b)
$a_date = $a->get_date('U');
$b_date = $b->get_date('U');
if ($a_date && $b_date) {
return $a_date > $b_date ? -1 : 1;
// Sort items without dates to the top.
* Merge items from several feeds into one
* If you're merging multiple feeds together, they need to all have dates
* for the items or else SimplePie will refuse to sort them.
* @link http://simplepie.org/wiki/tutorial/sort_multiple_feeds_by_time_and_date#if_feeds_require_separate_per-feed_settings
* @param array $urls List of SimplePie feed objects to merge
* @param int $start Starting item
* @param int $end Number of items to return
* @param int $limit Maximum number of items per feed
public static function merge_items($urls, $start = 0, $end = 0, $limit = 0)
if (is_array($urls) && sizeof($urls) > 0)
if ($arg instanceof SimplePie)
$items = array_merge($items, $arg->get_items(0, $limit));
trigger_error('Arguments must be SimplePie objects', E_USER_WARNING);
usort($items, array(get_class($urls[0]), 'sort_items'));
return array_slice($items, $start);
return array_slice($items, $start, $end);
trigger_error('Cannot merge zero SimplePie objects', E_USER_WARNING);
* Store PubSubHubbub links as headers
* There is no way to find PuSH links in the body of a microformats feed,
* so they are added to the headers when found, to be used later by get_links.
* @param SimplePie_File $file
private function store_links(&$file, $hub, $self) {
if (isset($file->headers['link']['hub']) ||
(isset($file->headers['link']) &&
preg_match('/rel=hub/', $file->headers['link'])))
if (isset($file->headers['link']))
if ($file->headers['link'] !== '')
$file->headers['link'] = ', ';
$file->headers['link'] = '';
$file->headers['link'] .= '<'.$hub.'>; rel=hub';
$file->headers['link'] .= ', <'.$self.'>; rel=self';