* Set how much feed autodiscovery to do
* @see \SimplePie\SimplePie::LOCATOR_NONE
* @see \SimplePie\SimplePie::LOCATOR_AUTODISCOVERY
* @see \SimplePie\SimplePie::LOCATOR_LOCAL_EXTENSION
* @see \SimplePie\SimplePie::LOCATOR_LOCAL_BODY
* @see \SimplePie\SimplePie::LOCATOR_REMOTE_EXTENSION
* @see \SimplePie\SimplePie::LOCATOR_REMOTE_BODY
* @see \SimplePie\SimplePie::LOCATOR_ALL
* @param int $level Feed Autodiscovery Level (level can be a combination of the above constants, see bitwise OR operator)
public function set_autodiscovery_level($level = self::LOCATOR_ALL)
$this->autodiscovery = (int) $level;
* Use this to override SimplePie's default classes
* @see \SimplePie\Registry
public function &get_registry()
* Set which class SimplePie uses for caching
* @deprecated since SimplePie 1.3, use {@see set_cache()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_cache_class($class = Cache::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::set_cache()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Cache::class, $class, true);
* Set which class SimplePie uses for auto-discovery
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_locator_class($class = Locator::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Locator::class, $class, true);
* Set which class SimplePie uses for XML parsing
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_parser_class($class = Parser::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Parser::class, $class, true);
* Set which class SimplePie uses for remote file fetching
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_file_class($class = File::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(File::class, $class, true);
* Set which class SimplePie uses for data sanitization
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_sanitize_class($class = Sanitize::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Sanitize::class, $class, true);
* Set which class SimplePie uses for handling feed items
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_item_class($class = Item::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Item::class, $class, true);
* Set which class SimplePie uses for handling author data
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_author_class($class = Author::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Author::class, $class, true);
* Set which class SimplePie uses for handling category data
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_category_class($class = Category::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Category::class, $class, true);
* Set which class SimplePie uses for feed enclosures
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_enclosure_class($class = Enclosure::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Enclosure::class, $class, true);
* Set which class SimplePie uses for `<media:text>` captions
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_caption_class($class = Caption::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Caption::class, $class, true);
* Set which class SimplePie uses for `<media:copyright>`
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_copyright_class($class = Copyright::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Copyright::class, $class, true);
* Set which class SimplePie uses for `<media:credit>`
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_credit_class($class = Credit::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Credit::class, $class, true);
* Set which class SimplePie uses for `<media:rating>`
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_rating_class($class = Rating::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Rating::class, $class, true);
* Set which class SimplePie uses for `<media:restriction>`
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_restriction_class($class = Restriction::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Restriction::class, $class, true);
* Set which class SimplePie uses for content-type sniffing
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_content_type_sniffer_class($class = Sniffer::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Sniffer::class, $class, true);
* Set which class SimplePie uses item sources
* @deprecated since SimplePie 1.3, use {@see get_registry()} instead
* @param string $class Name of custom class
* @return boolean True on success, false otherwise
public function set_source_class($class = Source::class)
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.3, please use "SimplePie\SimplePie::get_registry()" instead.', __METHOD__), \E_USER_DEPRECATED);
return $this->registry->register(Source::class, $class, true);
* Set the user agent string
* @param string $ua New user agent string.
public function set_useragent($ua = null)
$ua = \SimplePie\Misc::get_default_useragent();
$this->useragent = (string) $ua;
* Set a namefilter to modify the cache filename with
* @param NameFilter $filter
public function set_cache_namefilter(NameFilter $filter): void
$this->cache_namefilter = $filter;
* Set callback function to create cache filename with
* @deprecated since SimplePie 1.8.0, use {@see set_cache_namefilter()} instead
* @param mixed $function Callback function
public function set_cache_name_function($function = 'md5')
// trigger_error(sprintf('"%s()" is deprecated since SimplePie 1.8.0, please use "SimplePie\SimplePie::set_cache_namefilter()" instead.', __METHOD__), \E_USER_DEPRECATED);
if (is_callable($function)) {
$this->cache_name_function = $function;
$this->set_cache_namefilter(new CallableNameFilter($this->cache_name_function));
* Set options to make SP as fast as possible
* Forgoes a substantial amount of data sanitization in favor of speed. This
* turns SimplePie into a dumb parser of feeds.
* @param bool $set Whether to set them or not
public function set_stupidly_fast($set = false)
$this->enable_order_by_date(false);
$this->remove_div(false);
$this->strip_comments(false);
$this->strip_htmltags(false);
$this->strip_attributes(false);
$this->add_attributes(false);
$this->set_image_handler(false);
$this->set_https_domains([]);
* Set maximum number of feeds to check with autodiscovery
* @param int $max Maximum number of feeds to check
public function set_max_checked_feeds($max = 10)
$this->max_checked_feeds = (int) $max;
public function remove_div($enable = true)
$this->sanitize->remove_div($enable);
public function strip_htmltags($tags = '', $encode = null)
$tags = $this->strip_htmltags;
$this->sanitize->strip_htmltags($tags);
$this->sanitize->encode_instead_of_strip($tags);
public function encode_instead_of_strip($enable = true)
$this->sanitize->encode_instead_of_strip($enable);
public function rename_attributes($attribs = '')
$attribs = $this->rename_attributes;
$this->sanitize->rename_attributes($attribs);
public function strip_attributes($attribs = '')
$attribs = $this->strip_attributes;
$this->sanitize->strip_attributes($attribs);
public function add_attributes($attribs = '')
$attribs = $this->add_attributes;
$this->sanitize->add_attributes($attribs);
* Set the output encoding
* Allows you to override SimplePie's output to match that of your webpage.
* This is useful for times when your webpages are not being served as
* UTF-8. This setting will be obeyed by {@see handle_content_type()}, and
* is similar to {@see set_input_encoding()}.
* It should be noted, however, that not all character encodings can support
* all characters. If your page is being served as ISO-8859-1 and you try
* to display a Japanese feed, you'll likely see garbled characters.
* Because of this, it is highly recommended to ensure that your webpages
* The number of supported character encodings depends on whether your web
* host supports {@link http://php.net/mbstring mbstring},
* {@link http://php.net/iconv iconv}, or both. See
* {@link http://simplepie.org/wiki/faq/Supported_Character_Encodings} for
* @param string $encoding
public function set_output_encoding($encoding = 'UTF-8')
$this->sanitize->set_output_encoding($encoding);
public function strip_comments($strip = false)
$this->sanitize->strip_comments($strip);
* Set element/attribute key/value pairs of HTML attributes
* containing URLs that need to be resolved relative to the feed
* Defaults to |a|@href, |area|@href, |blockquote|@cite, |del|@cite,
* |form|@action, |img|@longdesc, |img|@src, |input|@src, |ins|@cite,
* @param array|null $element_attribute Element/attribute key/value pairs, null for default
public function set_url_replacements($element_attribute = null)
$this->sanitize->set_url_replacements($element_attribute);
* Set the list of domains for which to force HTTPS.
* @see \SimplePie\Sanitize::set_https_domains()
* @param array List of HTTPS domains. Example array('biz', 'example.com', 'example.org', 'www.example.net').
public function set_https_domains($domains = [])
if (is_array($domains)) {
$this->sanitize->set_https_domains($domains);
* Set the handler to enable the display of cached images.
* @param string $page Web-accessible path to the handler_image.php file.
* @param string $qs The query string that the value should be passed to.
public function set_image_handler($page = false, $qs = 'i')
$this->sanitize->set_image_handler($page . '?' . $qs . '=');
$this->image_handler = '';
* Set the limit for items returned per-feed with multifeeds
* @param integer $limit The maximum number of items to return.
public function set_item_limit($limit = 0)
$this->item_limit = (int) $limit;
* Enable throwing exceptions
* @param boolean $enable Should we throw exceptions, or use the old-style error property?
public function enable_exceptions($enable = true)