Summery Summery
Get the type of the feed
Syntax Syntax
Description Description
This returns a SIMPLEPIE_TYPE_* constant, which can be tested against using bitwise operators
Return Return
(int) SIMPLEPIE*TYPE** constant
Source Source
File: wp-includes/class-simplepie.php
try
{
$microformats = false;
if (class_exists('DOMXpath') && function_exists('Mf2\parse')) {
$doc = new DOMDocument();
@$doc->loadHTML($file->body);
$xpath = new DOMXpath($doc);
// Check for both h-feed and h-entry, as both a feed with no entries
// and a list of entries without an h-feed wrapper are both valid.
$query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '.
'contains(concat(" ", @class, " "), " h-entry ")]';
$result = $xpath->query($query);
$microformats = $result->length !== 0;
}
// Now also do feed discovery, but if microformats were found don't
// overwrite the current value of file.
$discovered = $locate->find($this->autodiscovery,
$this->all_discovered_feeds);
if ($microformats)
{
if ($hub = $locate->get_rel_link('hub'))
{
$self = $locate->get_rel_link('self');
$this->store_links($file, $hub, $self);
}
// Push the current file onto all_discovered feeds so the user can
// be shown this as one of the options.
if (isset($this->all_discovered_feeds)) {
$this->all_discovered_feeds[] = $file;
}
}
else
{
if ($discovered)
{
$file = $discovered;
}
else
{
// We need to unset this so that if SimplePie::set_file() has
// been called that object is untouched
unset($file);
$this->error = "A feed could not be found at `$this->feed_url`; the status code is `$copyStatusCode` and content-type is `$copyContentType`";
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, __FILE__, __LINE__));
return false;
}
}
}
catch (SimplePie_Exception $e)
{
// We need to unset this so that if SimplePie::set_file() has been called that object is untouched
unset($file);
// This is usually because DOMDocument doesn't exist
$this->error = $e->getMessage();
$this->registry->call('Misc', 'error', array($this->error, E_USER_NOTICE, $e->getFile(), $e->getLine()));
return false;
}
if ($cache)
{
$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
if (!$cache->save($this))
{
trigger_error("$this->cache_location is not writable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
}
$cache = $this->registry->call('Cache', 'get_handler', array($this->cache_location, call_user_func($this->cache_name_function, $file->url), 'spc'));
}
}
$this->feed_url = $file->url;
$locate = null;
}
$this->raw_data = $file->body;
$this->permanent_url = $file->permanent_url;
$headers = $file->headers;
$sniffer = $this->registry->create('Content_Type_Sniffer', array(&$file));
$sniffed = $sniffer->get_type();
return array($headers, $sniffed);
}
Advertisement
Changelog Changelog
| Version | Description |
|---|---|
| 0.8 | Introduced. |
See also See also
- SIMPLEPIE_TYPE_NONE: Unknown.
- SIMPLEPIE_TYPE_RSS_090: RSS 0.90.
- SIMPLEPIE_TYPE_RSS_091_NETSCAPE: RSS 0.91 (Netscape).
- SIMPLEPIE_TYPE_RSS_091_USERLAND: RSS 0.91 (Userland).
- SIMPLEPIE_TYPE_RSS_091: RSS 0.91.
- SIMPLEPIE_TYPE_RSS_092: RSS 0.92.
- SIMPLEPIE_TYPE_RSS_093: RSS 0.93.
- SIMPLEPIE_TYPE_RSS_094: RSS 0.94.
- SIMPLEPIE_TYPE_RSS_10: RSS 1.0.
- SIMPLEPIE_TYPE_RSS_20: RSS 2.0.x.
- SIMPLEPIE_TYPE_RSS_RDF: RDF-based RSS.
- SIMPLEPIE_TYPE_RSS_SYNDICATION: Non-RDF-based RSS (truly intended as syndication format).
- SIMPLEPIE_TYPE_RSS_ALL: Any version of RSS.
- SIMPLEPIE_TYPE_ATOM_03: Atom 0.3.
- SIMPLEPIE_TYPE_ATOM_10: Atom 1.0.
- SIMPLEPIE_TYPE_ATOM_ALL: Any version of Atom.
- SIMPLEPIE_TYPE_ALL: Any known/supported feed type.