SimplePie_Content_Type_Sniffer::get_type

Advertisement

Summery Summery

Get the Content-Type of the specified file

Syntax Syntax

SimplePie_Content_Type_Sniffer::get_type()

Return Return

(string) Actual Content-Type

Source Source

File: wp-includes/SimplePie/Content/Type/Sniffer.php

	{
		if (isset($this->file->headers['content-type']))
		{
			if (!isset($this->file->headers['content-encoding'])
				&& ($this->file->headers['content-type'] === 'text/plain'
					|| $this->file->headers['content-type'] === 'text/plain; charset=ISO-8859-1'
					|| $this->file->headers['content-type'] === 'text/plain; charset=iso-8859-1'
					|| $this->file->headers['content-type'] === 'text/plain; charset=UTF-8'))
			{
				return $this->text_or_binary();
			}

			if (($pos = strpos($this->file->headers['content-type'], ';')) !== false)
			{
				$official = substr($this->file->headers['content-type'], 0, $pos);
			}
			else
			{
				$official = $this->file->headers['content-type'];
			}
			$official = trim(strtolower($official));

			if ($official === 'unknown/unknown'
				|| $official === 'application/unknown')
			{
				return $this->unknown();
			}
			elseif (substr($official, -4) === '+xml'
				|| $official === 'text/xml'
				|| $official === 'application/xml')
			{
				return $official;
			}
			elseif (substr($official, 0, 6) === 'image/')
			{
				if ($return = $this->image())
				{
					return $return;
				}

				return $official;
			}
			elseif ($official === 'text/html')
			{
				return $this->feed_or_html();
			}

			return $official;
		}

		return $this->unknown();
	}

	/**
	 * Sniff text or binary
	 *
	 * @return string Actual Content-Type
	 */
	public function text_or_binary()

Advertisement

Advertisement

Leave a Reply