SimplePie::get_type

Advertisement

Summery Summery

Get the type of the feed

Syntax Syntax

SimplePie::get_type()

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

Changelog
Version Description
0.8 Introduced.

See also See also

Advertisement

Leave a Reply