Edit File by line
/home/zeestwma/ajeebong.../wp-inclu.../SimplePi.../src
File: SimplePie.php
$this->max_checked_feeds,
[2000] Fix | Delete
$this->force_fsockopen,
[2001] Fix | Delete
$this->curl_options
[2002] Fix | Delete
]);
[2003] Fix | Delete
[2004] Fix | Delete
$http_client = $this->get_http_client();
[2005] Fix | Delete
[2006] Fix | Delete
if ($http_client instanceof Psr18Client) {
[2007] Fix | Delete
$locate->set_http_client(
[2008] Fix | Delete
$http_client->getHttpClient(),
[2009] Fix | Delete
$http_client->getRequestFactory(),
[2010] Fix | Delete
$http_client->getUriFactory()
[2011] Fix | Delete
);
[2012] Fix | Delete
}
[2013] Fix | Delete
[2014] Fix | Delete
if (!$locate->is_feed($file)) {
[2015] Fix | Delete
$copyStatusCode = $file->get_status_code();
[2016] Fix | Delete
$copyContentType = $file->get_header_line('content-type');
[2017] Fix | Delete
try {
[2018] Fix | Delete
$microformats = false;
[2019] Fix | Delete
if (class_exists('DOMXpath') && function_exists('Mf2\parse')) {
[2020] Fix | Delete
$doc = new \DOMDocument();
[2021] Fix | Delete
@$doc->loadHTML($file->get_body_content());
[2022] Fix | Delete
$xpath = new \DOMXpath($doc);
[2023] Fix | Delete
// Check for both h-feed and h-entry, as both a feed with no entries
[2024] Fix | Delete
// and a list of entries without an h-feed wrapper are both valid.
[2025] Fix | Delete
$query = '//*[contains(concat(" ", @class, " "), " h-feed ") or '.
[2026] Fix | Delete
'contains(concat(" ", @class, " "), " h-entry ")]';
[2027] Fix | Delete
[2028] Fix | Delete
/** @var \DOMNodeList<\DOMElement> $result */
[2029] Fix | Delete
$result = $xpath->query($query);
[2030] Fix | Delete
$microformats = $result->length !== 0;
[2031] Fix | Delete
}
[2032] Fix | Delete
// Now also do feed discovery, but if microformats were found don't
[2033] Fix | Delete
// overwrite the current value of file.
[2034] Fix | Delete
$discovered = $locate->find(
[2035] Fix | Delete
$this->autodiscovery,
[2036] Fix | Delete
$this->all_discovered_feeds
[2037] Fix | Delete
);
[2038] Fix | Delete
if ($microformats) {
[2039] Fix | Delete
$hub = $locate->get_rel_link('hub');
[2040] Fix | Delete
$self = $locate->get_rel_link('self');
[2041] Fix | Delete
if ($hub || $self) {
[2042] Fix | Delete
$file = $this->store_links($file, $hub, $self);
[2043] Fix | Delete
}
[2044] Fix | Delete
// Push the current file onto all_discovered feeds so the user can
[2045] Fix | Delete
// be shown this as one of the options.
[2046] Fix | Delete
if ($this->all_discovered_feeds !== null) {
[2047] Fix | Delete
$this->all_discovered_feeds[] = $file;
[2048] Fix | Delete
}
[2049] Fix | Delete
} else {
[2050] Fix | Delete
if ($discovered) {
[2051] Fix | Delete
$file = $discovered;
[2052] Fix | Delete
} else {
[2053] Fix | Delete
// We need to unset this so that if SimplePie::set_file() has
[2054] Fix | Delete
// been called that object is untouched
[2055] Fix | Delete
unset($file);
[2056] Fix | Delete
$this->error = "A feed could not be found at `$this->feed_url`; the status code is `$copyStatusCode` and content-type is `$copyContentType`";
[2057] Fix | Delete
$this->registry->call(Misc::class, 'error', [$this->error, E_USER_NOTICE, __FILE__, __LINE__]);
[2058] Fix | Delete
return false;
[2059] Fix | Delete
}
[2060] Fix | Delete
}
[2061] Fix | Delete
} catch (SimplePieException $e) {
[2062] Fix | Delete
// We need to unset this so that if SimplePie::set_file() has been called that object is untouched
[2063] Fix | Delete
unset($file);
[2064] Fix | Delete
// This is usually because DOMDocument doesn't exist
[2065] Fix | Delete
$this->error = $e->getMessage();
[2066] Fix | Delete
$this->registry->call(Misc::class, 'error', [$this->error, E_USER_NOTICE, $e->getFile(), $e->getLine()]);
[2067] Fix | Delete
return false;
[2068] Fix | Delete
}
[2069] Fix | Delete
[2070] Fix | Delete
if ($cache) {
[2071] Fix | Delete
$this->data = [
[2072] Fix | Delete
'url' => $this->feed_url,
[2073] Fix | Delete
'feed_url' => $file->get_final_requested_uri(),
[2074] Fix | Delete
'build' => Misc::get_build(),
[2075] Fix | Delete
'cache_expiration_time' => $this->cache_duration + time(),
[2076] Fix | Delete
];
[2077] Fix | Delete
[2078] Fix | Delete
if (!$cache->set_data($cacheKey, $this->data, $this->cache_duration)) {
[2079] Fix | Delete
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);
[2080] Fix | Delete
}
[2081] Fix | Delete
}
[2082] Fix | Delete
}
[2083] Fix | Delete
$this->feed_url = $file->get_final_requested_uri();
[2084] Fix | Delete
$locate = null;
[2085] Fix | Delete
}
[2086] Fix | Delete
[2087] Fix | Delete
$this->raw_data = $file->get_body_content();
[2088] Fix | Delete
$this->permanent_url = $file->get_permanent_uri();
[2089] Fix | Delete
[2090] Fix | Delete
$headers = [];
[2091] Fix | Delete
foreach ($file->get_headers() as $key => $values) {
[2092] Fix | Delete
$headers[$key] = implode(', ', $values);
[2093] Fix | Delete
}
[2094] Fix | Delete
[2095] Fix | Delete
$sniffer = $this->registry->create(Sniffer::class, [&$file]);
[2096] Fix | Delete
$sniffed = $sniffer->get_type();
[2097] Fix | Delete
[2098] Fix | Delete
return [$headers, $sniffed];
[2099] Fix | Delete
}
[2100] Fix | Delete
[2101] Fix | Delete
/**
[2102] Fix | Delete
* Get the error message for the occurred error
[2103] Fix | Delete
*
[2104] Fix | Delete
* @return string|string[]|null Error message, or array of messages for multifeeds
[2105] Fix | Delete
*/
[2106] Fix | Delete
public function error()
[2107] Fix | Delete
{
[2108] Fix | Delete
return $this->error;
[2109] Fix | Delete
}
[2110] Fix | Delete
[2111] Fix | Delete
/**
[2112] Fix | Delete
* Get the last HTTP status code
[2113] Fix | Delete
*
[2114] Fix | Delete
* @return int Status code
[2115] Fix | Delete
*/
[2116] Fix | Delete
public function status_code()
[2117] Fix | Delete
{
[2118] Fix | Delete
return $this->status_code;
[2119] Fix | Delete
}
[2120] Fix | Delete
[2121] Fix | Delete
/**
[2122] Fix | Delete
* Get the raw XML
[2123] Fix | Delete
*
[2124] Fix | Delete
* This is the same as the old `$feed->enable_xml_dump(true)`, but returns
[2125] Fix | Delete
* the data instead of printing it.
[2126] Fix | Delete
*
[2127] Fix | Delete
* @return string|false Raw XML data, false if the cache is used
[2128] Fix | Delete
*/
[2129] Fix | Delete
public function get_raw_data()
[2130] Fix | Delete
{
[2131] Fix | Delete
return $this->raw_data;
[2132] Fix | Delete
}
[2133] Fix | Delete
[2134] Fix | Delete
/**
[2135] Fix | Delete
* Get the character encoding used for output
[2136] Fix | Delete
*
[2137] Fix | Delete
* @since Preview Release
[2138] Fix | Delete
* @return string
[2139] Fix | Delete
*/
[2140] Fix | Delete
public function get_encoding()
[2141] Fix | Delete
{
[2142] Fix | Delete
return $this->sanitize->output_encoding;
[2143] Fix | Delete
}
[2144] Fix | Delete
[2145] Fix | Delete
/**
[2146] Fix | Delete
* Send the content-type header with correct encoding
[2147] Fix | Delete
*
[2148] Fix | Delete
* This method ensures that the SimplePie-enabled page is being served with
[2149] Fix | Delete
* the correct {@link http://www.iana.org/assignments/media-types/ mime-type}
[2150] Fix | Delete
* and character encoding HTTP headers (character encoding determined by the
[2151] Fix | Delete
* {@see set_output_encoding} config option).
[2152] Fix | Delete
*
[2153] Fix | Delete
* This won't work properly if any content or whitespace has already been
[2154] Fix | Delete
* sent to the browser, because it relies on PHP's
[2155] Fix | Delete
* {@link http://php.net/header header()} function, and these are the
[2156] Fix | Delete
* circumstances under which the function works.
[2157] Fix | Delete
*
[2158] Fix | Delete
* Because it's setting these settings for the entire page (as is the nature
[2159] Fix | Delete
* of HTTP headers), this should only be used once per page (again, at the
[2160] Fix | Delete
* top).
[2161] Fix | Delete
*
[2162] Fix | Delete
* @param string $mime MIME type to serve the page as
[2163] Fix | Delete
* @return void
[2164] Fix | Delete
*/
[2165] Fix | Delete
public function handle_content_type(string $mime = 'text/html')
[2166] Fix | Delete
{
[2167] Fix | Delete
if (!headers_sent()) {
[2168] Fix | Delete
$header = "Content-type: $mime;";
[2169] Fix | Delete
if ($this->get_encoding()) {
[2170] Fix | Delete
$header .= ' charset=' . $this->get_encoding();
[2171] Fix | Delete
} else {
[2172] Fix | Delete
$header .= ' charset=UTF-8';
[2173] Fix | Delete
}
[2174] Fix | Delete
header($header);
[2175] Fix | Delete
}
[2176] Fix | Delete
}
[2177] Fix | Delete
[2178] Fix | Delete
/**
[2179] Fix | Delete
* Get the type of the feed
[2180] Fix | Delete
*
[2181] Fix | Delete
* This returns a self::TYPE_* constant, which can be tested against
[2182] Fix | Delete
* using {@link http://php.net/language.operators.bitwise bitwise operators}
[2183] Fix | Delete
*
[2184] Fix | Delete
* @since 0.8 (usage changed to using constants in 1.0)
[2185] Fix | Delete
* @see self::TYPE_NONE Unknown.
[2186] Fix | Delete
* @see self::TYPE_RSS_090 RSS 0.90.
[2187] Fix | Delete
* @see self::TYPE_RSS_091_NETSCAPE RSS 0.91 (Netscape).
[2188] Fix | Delete
* @see self::TYPE_RSS_091_USERLAND RSS 0.91 (Userland).
[2189] Fix | Delete
* @see self::TYPE_RSS_091 RSS 0.91.
[2190] Fix | Delete
* @see self::TYPE_RSS_092 RSS 0.92.
[2191] Fix | Delete
* @see self::TYPE_RSS_093 RSS 0.93.
[2192] Fix | Delete
* @see self::TYPE_RSS_094 RSS 0.94.
[2193] Fix | Delete
* @see self::TYPE_RSS_10 RSS 1.0.
[2194] Fix | Delete
* @see self::TYPE_RSS_20 RSS 2.0.x.
[2195] Fix | Delete
* @see self::TYPE_RSS_RDF RDF-based RSS.
[2196] Fix | Delete
* @see self::TYPE_RSS_SYNDICATION Non-RDF-based RSS (truly intended as syndication format).
[2197] Fix | Delete
* @see self::TYPE_RSS_ALL Any version of RSS.
[2198] Fix | Delete
* @see self::TYPE_ATOM_03 Atom 0.3.
[2199] Fix | Delete
* @see self::TYPE_ATOM_10 Atom 1.0.
[2200] Fix | Delete
* @see self::TYPE_ATOM_ALL Any version of Atom.
[2201] Fix | Delete
* @see self::TYPE_ALL Any known/supported feed type.
[2202] Fix | Delete
* @return int-mask-of<self::TYPE_*> constant
[2203] Fix | Delete
*/
[2204] Fix | Delete
public function get_type()
[2205] Fix | Delete
{
[2206] Fix | Delete
if (!isset($this->data['type'])) {
[2207] Fix | Delete
$this->data['type'] = self::TYPE_ALL;
[2208] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_ATOM_10]['feed'])) {
[2209] Fix | Delete
$this->data['type'] &= self::TYPE_ATOM_10;
[2210] Fix | Delete
} elseif (isset($this->data['child'][self::NAMESPACE_ATOM_03]['feed'])) {
[2211] Fix | Delete
$this->data['type'] &= self::TYPE_ATOM_03;
[2212] Fix | Delete
} elseif (isset($this->data['child'][self::NAMESPACE_RDF]['RDF'])) {
[2213] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][self::NAMESPACE_RSS_10]['channel'])
[2214] Fix | Delete
|| isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][self::NAMESPACE_RSS_10]['image'])
[2215] Fix | Delete
|| isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][self::NAMESPACE_RSS_10]['item'])
[2216] Fix | Delete
|| isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][self::NAMESPACE_RSS_10]['textinput'])) {
[2217] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_10;
[2218] Fix | Delete
}
[2219] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][self::NAMESPACE_RSS_090]['channel'])
[2220] Fix | Delete
|| isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][self::NAMESPACE_RSS_090]['image'])
[2221] Fix | Delete
|| isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][self::NAMESPACE_RSS_090]['item'])
[2222] Fix | Delete
|| isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][self::NAMESPACE_RSS_090]['textinput'])) {
[2223] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_090;
[2224] Fix | Delete
}
[2225] Fix | Delete
} elseif (isset($this->data['child'][self::NAMESPACE_RSS_20]['rss'])) {
[2226] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_ALL;
[2227] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) {
[2228] Fix | Delete
switch (trim($this->data['child'][self::NAMESPACE_RSS_20]['rss'][0]['attribs']['']['version'])) {
[2229] Fix | Delete
case '0.91':
[2230] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_091;
[2231] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_RSS_20]['rss'][0]['child'][self::NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) {
[2232] Fix | Delete
switch (trim($this->data['child'][self::NAMESPACE_RSS_20]['rss'][0]['child'][self::NAMESPACE_RSS_20]['skiphours']['hour'][0]['data'])) {
[2233] Fix | Delete
case '0':
[2234] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_091_NETSCAPE;
[2235] Fix | Delete
break;
[2236] Fix | Delete
[2237] Fix | Delete
case '24':
[2238] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_091_USERLAND;
[2239] Fix | Delete
break;
[2240] Fix | Delete
}
[2241] Fix | Delete
}
[2242] Fix | Delete
break;
[2243] Fix | Delete
[2244] Fix | Delete
case '0.92':
[2245] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_092;
[2246] Fix | Delete
break;
[2247] Fix | Delete
[2248] Fix | Delete
case '0.93':
[2249] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_093;
[2250] Fix | Delete
break;
[2251] Fix | Delete
[2252] Fix | Delete
case '0.94':
[2253] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_094;
[2254] Fix | Delete
break;
[2255] Fix | Delete
[2256] Fix | Delete
case '2.0':
[2257] Fix | Delete
$this->data['type'] &= self::TYPE_RSS_20;
[2258] Fix | Delete
break;
[2259] Fix | Delete
}
[2260] Fix | Delete
}
[2261] Fix | Delete
} else {
[2262] Fix | Delete
$this->data['type'] = self::TYPE_NONE;
[2263] Fix | Delete
}
[2264] Fix | Delete
}
[2265] Fix | Delete
return $this->data['type'];
[2266] Fix | Delete
}
[2267] Fix | Delete
[2268] Fix | Delete
/**
[2269] Fix | Delete
* Get the URL for the feed
[2270] Fix | Delete
*
[2271] Fix | Delete
* When the 'permanent' mode is enabled, returns the original feed URL,
[2272] Fix | Delete
* except in the case of an `HTTP 301 Moved Permanently` status response,
[2273] Fix | Delete
* in which case the location of the first redirection is returned.
[2274] Fix | Delete
*
[2275] Fix | Delete
* When the 'permanent' mode is disabled (default),
[2276] Fix | Delete
* may or may not be different from the URL passed to {@see set_feed_url()},
[2277] Fix | Delete
* depending on whether auto-discovery was used, and whether there were
[2278] Fix | Delete
* any redirects along the way.
[2279] Fix | Delete
*
[2280] Fix | Delete
* @since Preview Release (previously called `get_feed_url()` since SimplePie 0.8.)
[2281] Fix | Delete
* @todo Support <itunes:new-feed-url>
[2282] Fix | Delete
* @todo Also, |atom:link|@rel=self
[2283] Fix | Delete
* @param bool $permanent Permanent mode to return only the original URL or the first redirection
[2284] Fix | Delete
* iff it is a 301 redirection
[2285] Fix | Delete
* @return string|null
[2286] Fix | Delete
*/
[2287] Fix | Delete
public function subscribe_url(bool $permanent = false)
[2288] Fix | Delete
{
[2289] Fix | Delete
if ($permanent) {
[2290] Fix | Delete
if ($this->permanent_url !== null) {
[2291] Fix | Delete
// sanitize encodes ampersands which are required when used in a url.
[2292] Fix | Delete
return str_replace(
[2293] Fix | Delete
'&amp;',
[2294] Fix | Delete
'&',
[2295] Fix | Delete
$this->sanitize(
[2296] Fix | Delete
$this->permanent_url,
[2297] Fix | Delete
self::CONSTRUCT_IRI
[2298] Fix | Delete
)
[2299] Fix | Delete
);
[2300] Fix | Delete
}
[2301] Fix | Delete
} else {
[2302] Fix | Delete
if ($this->feed_url !== null) {
[2303] Fix | Delete
return str_replace(
[2304] Fix | Delete
'&amp;',
[2305] Fix | Delete
'&',
[2306] Fix | Delete
$this->sanitize(
[2307] Fix | Delete
$this->feed_url,
[2308] Fix | Delete
self::CONSTRUCT_IRI
[2309] Fix | Delete
)
[2310] Fix | Delete
);
[2311] Fix | Delete
}
[2312] Fix | Delete
}
[2313] Fix | Delete
return null;
[2314] Fix | Delete
}
[2315] Fix | Delete
[2316] Fix | Delete
/**
[2317] Fix | Delete
* Get data for an feed-level element
[2318] Fix | Delete
*
[2319] Fix | Delete
* This method allows you to get access to ANY element/attribute that is a
[2320] Fix | Delete
* sub-element of the opening feed tag.
[2321] Fix | Delete
*
[2322] Fix | Delete
* The return value is an indexed array of elements matching the given
[2323] Fix | Delete
* namespace and tag name. Each element has `attribs`, `data` and `child`
[2324] Fix | Delete
* subkeys. For `attribs` and `child`, these contain namespace subkeys.
[2325] Fix | Delete
* `attribs` then has one level of associative name => value data (where
[2326] Fix | Delete
* `value` is a string) after the namespace. `child` has tag-indexed keys
[2327] Fix | Delete
* after the namespace, each member of which is an indexed array matching
[2328] Fix | Delete
* this same format.
[2329] Fix | Delete
*
[2330] Fix | Delete
* For example:
[2331] Fix | Delete
* <pre>
[2332] Fix | Delete
* // This is probably a bad example because we already support
[2333] Fix | Delete
* // <media:content> natively, but it shows you how to parse through
[2334] Fix | Delete
* // the nodes.
[2335] Fix | Delete
* $group = $item->get_item_tags(\SimplePie\SimplePie::NAMESPACE_MEDIARSS, 'group');
[2336] Fix | Delete
* $content = $group[0]['child'][\SimplePie\SimplePie::NAMESPACE_MEDIARSS]['content'];
[2337] Fix | Delete
* $file = $content[0]['attribs']['']['url'];
[2338] Fix | Delete
* echo $file;
[2339] Fix | Delete
* </pre>
[2340] Fix | Delete
*
[2341] Fix | Delete
* @since 1.0
[2342] Fix | Delete
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces
[2343] Fix | Delete
* @param string $namespace The URL of the XML namespace of the elements you're trying to access
[2344] Fix | Delete
* @param string $tag Tag name
[2345] Fix | Delete
* @return array<array<string, mixed>>|null
[2346] Fix | Delete
*/
[2347] Fix | Delete
public function get_feed_tags(string $namespace, string $tag)
[2348] Fix | Delete
{
[2349] Fix | Delete
$type = $this->get_type();
[2350] Fix | Delete
if ($type & self::TYPE_ATOM_10) {
[2351] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag])) {
[2352] Fix | Delete
return $this->data['child'][self::NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
[2353] Fix | Delete
}
[2354] Fix | Delete
}
[2355] Fix | Delete
if ($type & self::TYPE_ATOM_03) {
[2356] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag])) {
[2357] Fix | Delete
return $this->data['child'][self::NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
[2358] Fix | Delete
}
[2359] Fix | Delete
}
[2360] Fix | Delete
if ($type & self::TYPE_RSS_RDF) {
[2361] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag])) {
[2362] Fix | Delete
return $this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
[2363] Fix | Delete
}
[2364] Fix | Delete
}
[2365] Fix | Delete
if ($type & self::TYPE_RSS_SYNDICATION) {
[2366] Fix | Delete
if (isset($this->data['child'][self::NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag])) {
[2367] Fix | Delete
return $this->data['child'][self::NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
[2368] Fix | Delete
}
[2369] Fix | Delete
}
[2370] Fix | Delete
return null;
[2371] Fix | Delete
}
[2372] Fix | Delete
[2373] Fix | Delete
/**
[2374] Fix | Delete
* Get data for an channel-level element
[2375] Fix | Delete
*
[2376] Fix | Delete
* This method allows you to get access to ANY element/attribute in the
[2377] Fix | Delete
* channel/header section of the feed.
[2378] Fix | Delete
*
[2379] Fix | Delete
* See {@see SimplePie::get_feed_tags()} for a description of the return value
[2380] Fix | Delete
*
[2381] Fix | Delete
* @since 1.0
[2382] Fix | Delete
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces
[2383] Fix | Delete
* @param string $namespace The URL of the XML namespace of the elements you're trying to access
[2384] Fix | Delete
* @param string $tag Tag name
[2385] Fix | Delete
* @return array<array<string, mixed>>|null
[2386] Fix | Delete
*/
[2387] Fix | Delete
public function get_channel_tags(string $namespace, string $tag)
[2388] Fix | Delete
{
[2389] Fix | Delete
$type = $this->get_type();
[2390] Fix | Delete
if ($type & self::TYPE_ATOM_ALL) {
[2391] Fix | Delete
if ($return = $this->get_feed_tags($namespace, $tag)) {
[2392] Fix | Delete
return $return;
[2393] Fix | Delete
}
[2394] Fix | Delete
}
[2395] Fix | Delete
if ($type & self::TYPE_RSS_10) {
[2396] Fix | Delete
if ($channel = $this->get_feed_tags(self::NAMESPACE_RSS_10, 'channel')) {
[2397] Fix | Delete
if (isset($channel[0]['child'][$namespace][$tag])) {
[2398] Fix | Delete
return $channel[0]['child'][$namespace][$tag];
[2399] Fix | Delete
}
[2400] Fix | Delete
}
[2401] Fix | Delete
}
[2402] Fix | Delete
if ($type & self::TYPE_RSS_090) {
[2403] Fix | Delete
if ($channel = $this->get_feed_tags(self::NAMESPACE_RSS_090, 'channel')) {
[2404] Fix | Delete
if (isset($channel[0]['child'][$namespace][$tag])) {
[2405] Fix | Delete
return $channel[0]['child'][$namespace][$tag];
[2406] Fix | Delete
}
[2407] Fix | Delete
}
[2408] Fix | Delete
}
[2409] Fix | Delete
if ($type & self::TYPE_RSS_SYNDICATION) {
[2410] Fix | Delete
if ($channel = $this->get_feed_tags(self::NAMESPACE_RSS_20, 'channel')) {
[2411] Fix | Delete
if (isset($channel[0]['child'][$namespace][$tag])) {
[2412] Fix | Delete
return $channel[0]['child'][$namespace][$tag];
[2413] Fix | Delete
}
[2414] Fix | Delete
}
[2415] Fix | Delete
}
[2416] Fix | Delete
return null;
[2417] Fix | Delete
}
[2418] Fix | Delete
[2419] Fix | Delete
/**
[2420] Fix | Delete
* Get data for an channel-level element
[2421] Fix | Delete
*
[2422] Fix | Delete
* This method allows you to get access to ANY element/attribute in the
[2423] Fix | Delete
* image/logo section of the feed.
[2424] Fix | Delete
*
[2425] Fix | Delete
* See {@see SimplePie::get_feed_tags()} for a description of the return value
[2426] Fix | Delete
*
[2427] Fix | Delete
* @since 1.0
[2428] Fix | Delete
* @see http://simplepie.org/wiki/faq/supported_xml_namespaces
[2429] Fix | Delete
* @param string $namespace The URL of the XML namespace of the elements you're trying to access
[2430] Fix | Delete
* @param string $tag Tag name
[2431] Fix | Delete
* @return array<array<string, mixed>>|null
[2432] Fix | Delete
*/
[2433] Fix | Delete
public function get_image_tags(string $namespace, string $tag)
[2434] Fix | Delete
{
[2435] Fix | Delete
$type = $this->get_type();
[2436] Fix | Delete
if ($type & self::TYPE_RSS_10) {
[2437] Fix | Delete
if ($image = $this->get_feed_tags(self::NAMESPACE_RSS_10, 'image')) {
[2438] Fix | Delete
if (isset($image[0]['child'][$namespace][$tag])) {
[2439] Fix | Delete
return $image[0]['child'][$namespace][$tag];
[2440] Fix | Delete
}
[2441] Fix | Delete
}
[2442] Fix | Delete
}
[2443] Fix | Delete
if ($type & self::TYPE_RSS_090) {
[2444] Fix | Delete
if ($image = $this->get_feed_tags(self::NAMESPACE_RSS_090, 'image')) {
[2445] Fix | Delete
if (isset($image[0]['child'][$namespace][$tag])) {
[2446] Fix | Delete
return $image[0]['child'][$namespace][$tag];
[2447] Fix | Delete
}
[2448] Fix | Delete
}
[2449] Fix | Delete
}
[2450] Fix | Delete
if ($type & self::TYPE_RSS_SYNDICATION) {
[2451] Fix | Delete
if ($image = $this->get_channel_tags(self::NAMESPACE_RSS_20, 'image')) {
[2452] Fix | Delete
if (isset($image[0]['child'][$namespace][$tag])) {
[2453] Fix | Delete
return $image[0]['child'][$namespace][$tag];
[2454] Fix | Delete
}
[2455] Fix | Delete
}
[2456] Fix | Delete
}
[2457] Fix | Delete
return null;
[2458] Fix | Delete
}
[2459] Fix | Delete
[2460] Fix | Delete
/**
[2461] Fix | Delete
* Get the base URL value from the feed
[2462] Fix | Delete
*
[2463] Fix | Delete
* Uses `<xml:base>` if available,
[2464] Fix | Delete
* otherwise uses the first 'self' link or the first 'alternate' link of the feed,
[2465] Fix | Delete
* or failing that, the URL of the feed itself.
[2466] Fix | Delete
*
[2467] Fix | Delete
* @see get_link
[2468] Fix | Delete
* @see subscribe_url
[2469] Fix | Delete
*
[2470] Fix | Delete
* @param array<string, mixed> $element
[2471] Fix | Delete
* @return string
[2472] Fix | Delete
*/
[2473] Fix | Delete
public function get_base(array $element = [])
[2474] Fix | Delete
{
[2475] Fix | Delete
if (!empty($element['xml_base_explicit']) && isset($element['xml_base'])) {
[2476] Fix | Delete
return $element['xml_base'];
[2477] Fix | Delete
}
[2478] Fix | Delete
if (($link = $this->get_link(0, 'alternate')) !== null) {
[2479] Fix | Delete
return $link;
[2480] Fix | Delete
}
[2481] Fix | Delete
if (($link = $this->get_link(0, 'self')) !== null) {
[2482] Fix | Delete
return $link;
[2483] Fix | Delete
}
[2484] Fix | Delete
[2485] Fix | Delete
return $this->subscribe_url() ?? '';
[2486] Fix | Delete
}
[2487] Fix | Delete
[2488] Fix | Delete
/**
[2489] Fix | Delete
* Sanitize feed data
[2490] Fix | Delete
*
[2491] Fix | Delete
* @access private
[2492] Fix | Delete
* @see Sanitize::sanitize()
[2493] Fix | Delete
* @param string $data Data to sanitize
[2494] Fix | Delete
* @param int-mask-of<SimplePie::CONSTRUCT_*> $type
[2495] Fix | Delete
* @param string $base Base URL to resolve URLs against
[2496] Fix | Delete
* @return string Sanitized data
[2497] Fix | Delete
*/
[2498] Fix | Delete
public function sanitize(string $data, int $type, string $base = '')
[2499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function