Edit File by line
/home/zeestwma/richards.../wp-inclu.../SimplePi.../src
File: SimplePie.php
{
[2500] Fix | Delete
try {
[2501] Fix | Delete
// This really returns string|false but changing encoding is uncommon and we are going to deprecate it, so let’s just lie to PHPStan in the interest of cleaner annotations.
[2502] Fix | Delete
return $this->sanitize->sanitize($data, $type, $base);
[2503] Fix | Delete
} catch (SimplePieException $e) {
[2504] Fix | Delete
if (!$this->enable_exceptions) {
[2505] Fix | Delete
$this->error = $e->getMessage();
[2506] Fix | Delete
$this->registry->call(Misc::class, 'error', [$this->error, E_USER_WARNING, $e->getFile(), $e->getLine()]);
[2507] Fix | Delete
return '';
[2508] Fix | Delete
}
[2509] Fix | Delete
[2510] Fix | Delete
throw $e;
[2511] Fix | Delete
}
[2512] Fix | Delete
}
[2513] Fix | Delete
[2514] Fix | Delete
/**
[2515] Fix | Delete
* Get the title of the feed
[2516] Fix | Delete
*
[2517] Fix | Delete
* Uses `<atom:title>`, `<title>` or `<dc:title>`
[2518] Fix | Delete
*
[2519] Fix | Delete
* @since 1.0 (previously called `get_feed_title` since 0.8)
[2520] Fix | Delete
* @return string|null
[2521] Fix | Delete
*/
[2522] Fix | Delete
public function get_title()
[2523] Fix | Delete
{
[2524] Fix | Delete
if ($return = $this->get_channel_tags(self::NAMESPACE_ATOM_10, 'title')) {
[2525] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[2526] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_ATOM_03, 'title')) {
[2527] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[2528] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_RSS_10, 'title')) {
[2529] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[2530] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_RSS_090, 'title')) {
[2531] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[2532] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_RSS_20, 'title')) {
[2533] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[2534] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_DC_11, 'title')) {
[2535] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2536] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_DC_10, 'title')) {
[2537] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2538] Fix | Delete
}
[2539] Fix | Delete
[2540] Fix | Delete
return null;
[2541] Fix | Delete
}
[2542] Fix | Delete
[2543] Fix | Delete
/**
[2544] Fix | Delete
* Get a category for the feed
[2545] Fix | Delete
*
[2546] Fix | Delete
* @since Unknown
[2547] Fix | Delete
* @param int $key The category that you want to return. Remember that arrays begin with 0, not 1
[2548] Fix | Delete
* @return Category|null
[2549] Fix | Delete
*/
[2550] Fix | Delete
public function get_category(int $key = 0)
[2551] Fix | Delete
{
[2552] Fix | Delete
$categories = $this->get_categories();
[2553] Fix | Delete
if (isset($categories[$key])) {
[2554] Fix | Delete
return $categories[$key];
[2555] Fix | Delete
}
[2556] Fix | Delete
[2557] Fix | Delete
return null;
[2558] Fix | Delete
}
[2559] Fix | Delete
[2560] Fix | Delete
/**
[2561] Fix | Delete
* Get all categories for the feed
[2562] Fix | Delete
*
[2563] Fix | Delete
* Uses `<atom:category>`, `<category>` or `<dc:subject>`
[2564] Fix | Delete
*
[2565] Fix | Delete
* @since Unknown
[2566] Fix | Delete
* @return array<Category>|null List of {@see Category} objects
[2567] Fix | Delete
*/
[2568] Fix | Delete
public function get_categories()
[2569] Fix | Delete
{
[2570] Fix | Delete
$categories = [];
[2571] Fix | Delete
[2572] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_ATOM_10, 'category') as $category) {
[2573] Fix | Delete
$term = null;
[2574] Fix | Delete
$scheme = null;
[2575] Fix | Delete
$label = null;
[2576] Fix | Delete
if (isset($category['attribs']['']['term'])) {
[2577] Fix | Delete
$term = $this->sanitize($category['attribs']['']['term'], self::CONSTRUCT_TEXT);
[2578] Fix | Delete
}
[2579] Fix | Delete
if (isset($category['attribs']['']['scheme'])) {
[2580] Fix | Delete
$scheme = $this->sanitize($category['attribs']['']['scheme'], self::CONSTRUCT_TEXT);
[2581] Fix | Delete
}
[2582] Fix | Delete
if (isset($category['attribs']['']['label'])) {
[2583] Fix | Delete
$label = $this->sanitize($category['attribs']['']['label'], self::CONSTRUCT_TEXT);
[2584] Fix | Delete
}
[2585] Fix | Delete
$categories[] = $this->registry->create(Category::class, [$term, $scheme, $label]);
[2586] Fix | Delete
}
[2587] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_RSS_20, 'category') as $category) {
[2588] Fix | Delete
// This is really the label, but keep this as the term also for BC.
[2589] Fix | Delete
// Label will also work on retrieving because that falls back to term.
[2590] Fix | Delete
$term = $this->sanitize($category['data'], self::CONSTRUCT_TEXT);
[2591] Fix | Delete
if (isset($category['attribs']['']['domain'])) {
[2592] Fix | Delete
$scheme = $this->sanitize($category['attribs']['']['domain'], self::CONSTRUCT_TEXT);
[2593] Fix | Delete
} else {
[2594] Fix | Delete
$scheme = null;
[2595] Fix | Delete
}
[2596] Fix | Delete
$categories[] = $this->registry->create(Category::class, [$term, $scheme, null]);
[2597] Fix | Delete
}
[2598] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_DC_11, 'subject') as $category) {
[2599] Fix | Delete
$categories[] = $this->registry->create(Category::class, [$this->sanitize($category['data'], self::CONSTRUCT_TEXT), null, null]);
[2600] Fix | Delete
}
[2601] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_DC_10, 'subject') as $category) {
[2602] Fix | Delete
$categories[] = $this->registry->create(Category::class, [$this->sanitize($category['data'], self::CONSTRUCT_TEXT), null, null]);
[2603] Fix | Delete
}
[2604] Fix | Delete
[2605] Fix | Delete
if (!empty($categories)) {
[2606] Fix | Delete
return array_unique($categories);
[2607] Fix | Delete
}
[2608] Fix | Delete
[2609] Fix | Delete
return null;
[2610] Fix | Delete
}
[2611] Fix | Delete
[2612] Fix | Delete
/**
[2613] Fix | Delete
* Get an author for the feed
[2614] Fix | Delete
*
[2615] Fix | Delete
* @since 1.1
[2616] Fix | Delete
* @param int $key The author that you want to return. Remember that arrays begin with 0, not 1
[2617] Fix | Delete
* @return Author|null
[2618] Fix | Delete
*/
[2619] Fix | Delete
public function get_author(int $key = 0)
[2620] Fix | Delete
{
[2621] Fix | Delete
$authors = $this->get_authors();
[2622] Fix | Delete
if (isset($authors[$key])) {
[2623] Fix | Delete
return $authors[$key];
[2624] Fix | Delete
}
[2625] Fix | Delete
[2626] Fix | Delete
return null;
[2627] Fix | Delete
}
[2628] Fix | Delete
[2629] Fix | Delete
/**
[2630] Fix | Delete
* Get all authors for the feed
[2631] Fix | Delete
*
[2632] Fix | Delete
* Uses `<atom:author>`, `<author>`, `<dc:creator>` or `<itunes:author>`
[2633] Fix | Delete
*
[2634] Fix | Delete
* @since 1.1
[2635] Fix | Delete
* @return array<Author>|null List of {@see Author} objects
[2636] Fix | Delete
*/
[2637] Fix | Delete
public function get_authors()
[2638] Fix | Delete
{
[2639] Fix | Delete
$authors = [];
[2640] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_ATOM_10, 'author') as $author) {
[2641] Fix | Delete
$name = null;
[2642] Fix | Delete
$uri = null;
[2643] Fix | Delete
$email = null;
[2644] Fix | Delete
if (isset($author['child'][self::NAMESPACE_ATOM_10]['name'][0]['data'])) {
[2645] Fix | Delete
$name = $this->sanitize($author['child'][self::NAMESPACE_ATOM_10]['name'][0]['data'], self::CONSTRUCT_TEXT);
[2646] Fix | Delete
}
[2647] Fix | Delete
if (isset($author['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
[2648] Fix | Delete
$uri = $author['child'][self::NAMESPACE_ATOM_10]['uri'][0];
[2649] Fix | Delete
$uri = $this->sanitize($uri['data'], self::CONSTRUCT_IRI, $this->get_base($uri));
[2650] Fix | Delete
}
[2651] Fix | Delete
if (isset($author['child'][self::NAMESPACE_ATOM_10]['email'][0]['data'])) {
[2652] Fix | Delete
$email = $this->sanitize($author['child'][self::NAMESPACE_ATOM_10]['email'][0]['data'], self::CONSTRUCT_TEXT);
[2653] Fix | Delete
}
[2654] Fix | Delete
if ($name !== null || $email !== null || $uri !== null) {
[2655] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$name, $uri, $email]);
[2656] Fix | Delete
}
[2657] Fix | Delete
}
[2658] Fix | Delete
if ($author = $this->get_channel_tags(self::NAMESPACE_ATOM_03, 'author')) {
[2659] Fix | Delete
$name = null;
[2660] Fix | Delete
$url = null;
[2661] Fix | Delete
$email = null;
[2662] Fix | Delete
if (isset($author[0]['child'][self::NAMESPACE_ATOM_03]['name'][0]['data'])) {
[2663] Fix | Delete
$name = $this->sanitize($author[0]['child'][self::NAMESPACE_ATOM_03]['name'][0]['data'], self::CONSTRUCT_TEXT);
[2664] Fix | Delete
}
[2665] Fix | Delete
if (isset($author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'])) {
[2666] Fix | Delete
$url = $author[0]['child'][self::NAMESPACE_ATOM_03]['url'][0];
[2667] Fix | Delete
$url = $this->sanitize($url['data'], self::CONSTRUCT_IRI, $this->get_base($url));
[2668] Fix | Delete
}
[2669] Fix | Delete
if (isset($author[0]['child'][self::NAMESPACE_ATOM_03]['email'][0]['data'])) {
[2670] Fix | Delete
$email = $this->sanitize($author[0]['child'][self::NAMESPACE_ATOM_03]['email'][0]['data'], self::CONSTRUCT_TEXT);
[2671] Fix | Delete
}
[2672] Fix | Delete
if ($name !== null || $email !== null || $url !== null) {
[2673] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$name, $url, $email]);
[2674] Fix | Delete
}
[2675] Fix | Delete
}
[2676] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_DC_11, 'creator') as $author) {
[2677] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], self::CONSTRUCT_TEXT), null, null]);
[2678] Fix | Delete
}
[2679] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_DC_10, 'creator') as $author) {
[2680] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], self::CONSTRUCT_TEXT), null, null]);
[2681] Fix | Delete
}
[2682] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_ITUNES, 'author') as $author) {
[2683] Fix | Delete
$authors[] = $this->registry->create(Author::class, [$this->sanitize($author['data'], self::CONSTRUCT_TEXT), null, null]);
[2684] Fix | Delete
}
[2685] Fix | Delete
[2686] Fix | Delete
if (!empty($authors)) {
[2687] Fix | Delete
return array_unique($authors);
[2688] Fix | Delete
}
[2689] Fix | Delete
[2690] Fix | Delete
return null;
[2691] Fix | Delete
}
[2692] Fix | Delete
[2693] Fix | Delete
/**
[2694] Fix | Delete
* Get a contributor for the feed
[2695] Fix | Delete
*
[2696] Fix | Delete
* @since 1.1
[2697] Fix | Delete
* @param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1
[2698] Fix | Delete
* @return Author|null
[2699] Fix | Delete
*/
[2700] Fix | Delete
public function get_contributor(int $key = 0)
[2701] Fix | Delete
{
[2702] Fix | Delete
$contributors = $this->get_contributors();
[2703] Fix | Delete
if (isset($contributors[$key])) {
[2704] Fix | Delete
return $contributors[$key];
[2705] Fix | Delete
}
[2706] Fix | Delete
[2707] Fix | Delete
return null;
[2708] Fix | Delete
}
[2709] Fix | Delete
[2710] Fix | Delete
/**
[2711] Fix | Delete
* Get all contributors for the feed
[2712] Fix | Delete
*
[2713] Fix | Delete
* Uses `<atom:contributor>`
[2714] Fix | Delete
*
[2715] Fix | Delete
* @since 1.1
[2716] Fix | Delete
* @return array<Author>|null List of {@see Author} objects
[2717] Fix | Delete
*/
[2718] Fix | Delete
public function get_contributors()
[2719] Fix | Delete
{
[2720] Fix | Delete
$contributors = [];
[2721] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_ATOM_10, 'contributor') as $contributor) {
[2722] Fix | Delete
$name = null;
[2723] Fix | Delete
$uri = null;
[2724] Fix | Delete
$email = null;
[2725] Fix | Delete
if (isset($contributor['child'][self::NAMESPACE_ATOM_10]['name'][0]['data'])) {
[2726] Fix | Delete
$name = $this->sanitize($contributor['child'][self::NAMESPACE_ATOM_10]['name'][0]['data'], self::CONSTRUCT_TEXT);
[2727] Fix | Delete
}
[2728] Fix | Delete
if (isset($contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0]['data'])) {
[2729] Fix | Delete
$uri = $contributor['child'][self::NAMESPACE_ATOM_10]['uri'][0];
[2730] Fix | Delete
$uri = $this->sanitize($uri['data'], self::CONSTRUCT_IRI, $this->get_base($uri));
[2731] Fix | Delete
}
[2732] Fix | Delete
if (isset($contributor['child'][self::NAMESPACE_ATOM_10]['email'][0]['data'])) {
[2733] Fix | Delete
$email = $this->sanitize($contributor['child'][self::NAMESPACE_ATOM_10]['email'][0]['data'], self::CONSTRUCT_TEXT);
[2734] Fix | Delete
}
[2735] Fix | Delete
if ($name !== null || $email !== null || $uri !== null) {
[2736] Fix | Delete
$contributors[] = $this->registry->create(Author::class, [$name, $uri, $email]);
[2737] Fix | Delete
}
[2738] Fix | Delete
}
[2739] Fix | Delete
foreach ((array) $this->get_channel_tags(self::NAMESPACE_ATOM_03, 'contributor') as $contributor) {
[2740] Fix | Delete
$name = null;
[2741] Fix | Delete
$url = null;
[2742] Fix | Delete
$email = null;
[2743] Fix | Delete
if (isset($contributor['child'][self::NAMESPACE_ATOM_03]['name'][0]['data'])) {
[2744] Fix | Delete
$name = $this->sanitize($contributor['child'][self::NAMESPACE_ATOM_03]['name'][0]['data'], self::CONSTRUCT_TEXT);
[2745] Fix | Delete
}
[2746] Fix | Delete
if (isset($contributor['child'][self::NAMESPACE_ATOM_03]['url'][0]['data'])) {
[2747] Fix | Delete
$url = $contributor['child'][self::NAMESPACE_ATOM_03]['url'][0];
[2748] Fix | Delete
$url = $this->sanitize($url['data'], self::CONSTRUCT_IRI, $this->get_base($url));
[2749] Fix | Delete
}
[2750] Fix | Delete
if (isset($contributor['child'][self::NAMESPACE_ATOM_03]['email'][0]['data'])) {
[2751] Fix | Delete
$email = $this->sanitize($contributor['child'][self::NAMESPACE_ATOM_03]['email'][0]['data'], self::CONSTRUCT_TEXT);
[2752] Fix | Delete
}
[2753] Fix | Delete
if ($name !== null || $email !== null || $url !== null) {
[2754] Fix | Delete
$contributors[] = $this->registry->create(Author::class, [$name, $url, $email]);
[2755] Fix | Delete
}
[2756] Fix | Delete
}
[2757] Fix | Delete
[2758] Fix | Delete
if (!empty($contributors)) {
[2759] Fix | Delete
return array_unique($contributors);
[2760] Fix | Delete
}
[2761] Fix | Delete
[2762] Fix | Delete
return null;
[2763] Fix | Delete
}
[2764] Fix | Delete
[2765] Fix | Delete
/**
[2766] Fix | Delete
* Get a single link for the feed
[2767] Fix | Delete
*
[2768] Fix | Delete
* @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8)
[2769] Fix | Delete
* @param int $key The link that you want to return. Remember that arrays begin with 0, not 1
[2770] Fix | Delete
* @param string $rel The relationship of the link to return
[2771] Fix | Delete
* @return string|null Link URL
[2772] Fix | Delete
*/
[2773] Fix | Delete
public function get_link(int $key = 0, string $rel = 'alternate')
[2774] Fix | Delete
{
[2775] Fix | Delete
$links = $this->get_links($rel);
[2776] Fix | Delete
if (isset($links[$key])) {
[2777] Fix | Delete
return $links[$key];
[2778] Fix | Delete
}
[2779] Fix | Delete
[2780] Fix | Delete
return null;
[2781] Fix | Delete
}
[2782] Fix | Delete
[2783] Fix | Delete
/**
[2784] Fix | Delete
* Get the permalink for the item
[2785] Fix | Delete
*
[2786] Fix | Delete
* Returns the first link available with a relationship of "alternate".
[2787] Fix | Delete
* Identical to {@see get_link()} with key 0
[2788] Fix | Delete
*
[2789] Fix | Delete
* @see get_link
[2790] Fix | Delete
* @since 1.0 (previously called `get_feed_link` since Preview Release, `get_feed_permalink()` since 0.8)
[2791] Fix | Delete
* @internal Added for parity between the parent-level and the item/entry-level.
[2792] Fix | Delete
* @return string|null Link URL
[2793] Fix | Delete
*/
[2794] Fix | Delete
public function get_permalink()
[2795] Fix | Delete
{
[2796] Fix | Delete
return $this->get_link(0);
[2797] Fix | Delete
}
[2798] Fix | Delete
[2799] Fix | Delete
/**
[2800] Fix | Delete
* Get all links for the feed
[2801] Fix | Delete
*
[2802] Fix | Delete
* Uses `<atom:link>` or `<link>`
[2803] Fix | Delete
*
[2804] Fix | Delete
* @since Beta 2
[2805] Fix | Delete
* @param string $rel The relationship of links to return
[2806] Fix | Delete
* @return array<string>|null Links found for the feed (strings)
[2807] Fix | Delete
*/
[2808] Fix | Delete
public function get_links(string $rel = 'alternate')
[2809] Fix | Delete
{
[2810] Fix | Delete
if (!isset($this->data['links'])) {
[2811] Fix | Delete
$this->data['links'] = [];
[2812] Fix | Delete
if ($links = $this->get_channel_tags(self::NAMESPACE_ATOM_10, 'link')) {
[2813] Fix | Delete
foreach ($links as $link) {
[2814] Fix | Delete
if (isset($link['attribs']['']['href'])) {
[2815] Fix | Delete
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
[2816] Fix | Delete
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], self::CONSTRUCT_IRI, $this->get_base($link));
[2817] Fix | Delete
}
[2818] Fix | Delete
}
[2819] Fix | Delete
}
[2820] Fix | Delete
if ($links = $this->get_channel_tags(self::NAMESPACE_ATOM_03, 'link')) {
[2821] Fix | Delete
foreach ($links as $link) {
[2822] Fix | Delete
if (isset($link['attribs']['']['href'])) {
[2823] Fix | Delete
$link_rel = (isset($link['attribs']['']['rel'])) ? $link['attribs']['']['rel'] : 'alternate';
[2824] Fix | Delete
$this->data['links'][$link_rel][] = $this->sanitize($link['attribs']['']['href'], self::CONSTRUCT_IRI, $this->get_base($link));
[2825] Fix | Delete
}
[2826] Fix | Delete
}
[2827] Fix | Delete
}
[2828] Fix | Delete
if ($links = $this->get_channel_tags(self::NAMESPACE_RSS_10, 'link')) {
[2829] Fix | Delete
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], self::CONSTRUCT_IRI, $this->get_base($links[0]));
[2830] Fix | Delete
}
[2831] Fix | Delete
if ($links = $this->get_channel_tags(self::NAMESPACE_RSS_090, 'link')) {
[2832] Fix | Delete
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], self::CONSTRUCT_IRI, $this->get_base($links[0]));
[2833] Fix | Delete
}
[2834] Fix | Delete
if ($links = $this->get_channel_tags(self::NAMESPACE_RSS_20, 'link')) {
[2835] Fix | Delete
$this->data['links']['alternate'][] = $this->sanitize($links[0]['data'], self::CONSTRUCT_IRI, $this->get_base($links[0]));
[2836] Fix | Delete
}
[2837] Fix | Delete
[2838] Fix | Delete
$keys = array_keys($this->data['links']);
[2839] Fix | Delete
foreach ($keys as $key) {
[2840] Fix | Delete
if ($this->registry->call(Misc::class, 'is_isegment_nz_nc', [$key])) {
[2841] Fix | Delete
if (isset($this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key])) {
[2842] Fix | Delete
$this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = array_merge($this->data['links'][$key], $this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key]);
[2843] Fix | Delete
$this->data['links'][$key] = &$this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key];
[2844] Fix | Delete
} else {
[2845] Fix | Delete
$this->data['links'][self::IANA_LINK_RELATIONS_REGISTRY . $key] = &$this->data['links'][$key];
[2846] Fix | Delete
}
[2847] Fix | Delete
} elseif (substr($key, 0, 41) === self::IANA_LINK_RELATIONS_REGISTRY) {
[2848] Fix | Delete
$this->data['links'][substr($key, 41)] = &$this->data['links'][$key];
[2849] Fix | Delete
}
[2850] Fix | Delete
$this->data['links'][$key] = array_unique($this->data['links'][$key]);
[2851] Fix | Delete
}
[2852] Fix | Delete
}
[2853] Fix | Delete
[2854] Fix | Delete
if (isset($this->data['headers']['link'])) {
[2855] Fix | Delete
$link_headers = $this->data['headers']['link'];
[2856] Fix | Delete
if (is_array($link_headers)) {
[2857] Fix | Delete
$link_headers = implode(',', $link_headers);
[2858] Fix | Delete
}
[2859] Fix | Delete
// https://datatracker.ietf.org/doc/html/rfc8288
[2860] Fix | Delete
if (is_string($link_headers) &&
[2861] Fix | Delete
preg_match_all('/<(?P<uri>[^>]+)>\s*;\s*rel\s*=\s*(?P<quote>"?)' . preg_quote($rel) . '(?P=quote)\s*(?=,|$)/i', $link_headers, $matches)) {
[2862] Fix | Delete
return $matches['uri'];
[2863] Fix | Delete
}
[2864] Fix | Delete
}
[2865] Fix | Delete
[2866] Fix | Delete
if (isset($this->data['links'][$rel])) {
[2867] Fix | Delete
return $this->data['links'][$rel];
[2868] Fix | Delete
}
[2869] Fix | Delete
[2870] Fix | Delete
return null;
[2871] Fix | Delete
}
[2872] Fix | Delete
[2873] Fix | Delete
/**
[2874] Fix | Delete
* @return ?array<Response>
[2875] Fix | Delete
*/
[2876] Fix | Delete
public function get_all_discovered_feeds()
[2877] Fix | Delete
{
[2878] Fix | Delete
return $this->all_discovered_feeds;
[2879] Fix | Delete
}
[2880] Fix | Delete
[2881] Fix | Delete
/**
[2882] Fix | Delete
* Get the content for the item
[2883] Fix | Delete
*
[2884] Fix | Delete
* Uses `<atom:subtitle>`, `<atom:tagline>`, `<description>`,
[2885] Fix | Delete
* `<dc:description>`, `<itunes:summary>` or `<itunes:subtitle>`
[2886] Fix | Delete
*
[2887] Fix | Delete
* @since 1.0 (previously called `get_feed_description()` since 0.8)
[2888] Fix | Delete
* @return string|null
[2889] Fix | Delete
*/
[2890] Fix | Delete
public function get_description()
[2891] Fix | Delete
{
[2892] Fix | Delete
if ($return = $this->get_channel_tags(self::NAMESPACE_ATOM_10, 'subtitle')) {
[2893] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[2894] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_ATOM_03, 'tagline')) {
[2895] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[2896] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_RSS_10, 'description')) {
[2897] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[2898] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_RSS_090, 'description')) {
[2899] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_MAYBE_HTML, $this->get_base($return[0]));
[2900] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_RSS_20, 'description')) {
[2901] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_HTML, $this->get_base($return[0]));
[2902] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_DC_11, 'description')) {
[2903] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2904] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_DC_10, 'description')) {
[2905] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2906] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_ITUNES, 'summary')) {
[2907] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_HTML, $this->get_base($return[0]));
[2908] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_ITUNES, 'subtitle')) {
[2909] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_HTML, $this->get_base($return[0]));
[2910] Fix | Delete
}
[2911] Fix | Delete
[2912] Fix | Delete
return null;
[2913] Fix | Delete
}
[2914] Fix | Delete
[2915] Fix | Delete
/**
[2916] Fix | Delete
* Get the copyright info for the feed
[2917] Fix | Delete
*
[2918] Fix | Delete
* Uses `<atom:rights>`, `<atom:copyright>` or `<dc:rights>`
[2919] Fix | Delete
*
[2920] Fix | Delete
* @since 1.0 (previously called `get_feed_copyright()` since 0.8)
[2921] Fix | Delete
* @return string|null
[2922] Fix | Delete
*/
[2923] Fix | Delete
public function get_copyright()
[2924] Fix | Delete
{
[2925] Fix | Delete
if ($return = $this->get_channel_tags(self::NAMESPACE_ATOM_10, 'rights')) {
[2926] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_10_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[2927] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_ATOM_03, 'copyright')) {
[2928] Fix | Delete
return $this->sanitize($return[0]['data'], $this->registry->call(Misc::class, 'atom_03_construct_type', [$return[0]['attribs']]), $this->get_base($return[0]));
[2929] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_RSS_20, 'copyright')) {
[2930] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2931] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_DC_11, 'rights')) {
[2932] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2933] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_DC_10, 'rights')) {
[2934] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2935] Fix | Delete
}
[2936] Fix | Delete
[2937] Fix | Delete
return null;
[2938] Fix | Delete
}
[2939] Fix | Delete
[2940] Fix | Delete
/**
[2941] Fix | Delete
* Get the language for the feed
[2942] Fix | Delete
*
[2943] Fix | Delete
* Uses `<language>`, `<dc:language>`, or @xml_lang
[2944] Fix | Delete
*
[2945] Fix | Delete
* @since 1.0 (previously called `get_feed_language()` since 0.8)
[2946] Fix | Delete
* @return string|null
[2947] Fix | Delete
*/
[2948] Fix | Delete
public function get_language()
[2949] Fix | Delete
{
[2950] Fix | Delete
if ($return = $this->get_channel_tags(self::NAMESPACE_RSS_20, 'language')) {
[2951] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2952] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_DC_11, 'language')) {
[2953] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2954] Fix | Delete
} elseif ($return = $this->get_channel_tags(self::NAMESPACE_DC_10, 'language')) {
[2955] Fix | Delete
return $this->sanitize($return[0]['data'], self::CONSTRUCT_TEXT);
[2956] Fix | Delete
} elseif (isset($this->data['child'][self::NAMESPACE_ATOM_10]['feed'][0]['xml_lang'])) {
[2957] Fix | Delete
return $this->sanitize($this->data['child'][self::NAMESPACE_ATOM_10]['feed'][0]['xml_lang'], self::CONSTRUCT_TEXT);
[2958] Fix | Delete
} elseif (isset($this->data['child'][self::NAMESPACE_ATOM_03]['feed'][0]['xml_lang'])) {
[2959] Fix | Delete
return $this->sanitize($this->data['child'][self::NAMESPACE_ATOM_03]['feed'][0]['xml_lang'], self::CONSTRUCT_TEXT);
[2960] Fix | Delete
} elseif (isset($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['xml_lang'])) {
[2961] Fix | Delete
return $this->sanitize($this->data['child'][self::NAMESPACE_RDF]['RDF'][0]['xml_lang'], self::CONSTRUCT_TEXT);
[2962] Fix | Delete
} elseif (isset($this->data['headers']['content-language'])) {
[2963] Fix | Delete
return $this->sanitize($this->data['headers']['content-language'], self::CONSTRUCT_TEXT);
[2964] Fix | Delete
}
[2965] Fix | Delete
[2966] Fix | Delete
return null;
[2967] Fix | Delete
}
[2968] Fix | Delete
[2969] Fix | Delete
/**
[2970] Fix | Delete
* Get the latitude coordinates for the item
[2971] Fix | Delete
*
[2972] Fix | Delete
* Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
[2973] Fix | Delete
*
[2974] Fix | Delete
* Uses `<geo:lat>` or `<georss:point>`
[2975] Fix | Delete
*
[2976] Fix | Delete
* @since 1.0
[2977] Fix | Delete
* @link http://www.w3.org/2003/01/geo/ W3C WGS84 Basic Geo
[2978] Fix | Delete
* @link http://www.georss.org/ GeoRSS
[2979] Fix | Delete
* @return float|null
[2980] Fix | Delete
*/
[2981] Fix | Delete
public function get_latitude()
[2982] Fix | Delete
{
[2983] Fix | Delete
if ($return = $this->get_channel_tags(self::NAMESPACE_W3C_BASIC_GEO, 'lat')) {
[2984] Fix | Delete
return (float) $return[0]['data'];
[2985] Fix | Delete
} elseif (($return = $this->get_channel_tags(self::NAMESPACE_GEORSS, 'point')) && preg_match('/^((?:-)?[0-9]+(?:\.[0-9]+)) ((?:-)?[0-9]+(?:\.[0-9]+))$/', trim($return[0]['data']), $match)) {
[2986] Fix | Delete
return (float) $match[1];
[2987] Fix | Delete
}
[2988] Fix | Delete
[2989] Fix | Delete
return null;
[2990] Fix | Delete
}
[2991] Fix | Delete
[2992] Fix | Delete
/**
[2993] Fix | Delete
* Get the longitude coordinates for the feed
[2994] Fix | Delete
*
[2995] Fix | Delete
* Compatible with the W3C WGS84 Basic Geo and GeoRSS specifications
[2996] Fix | Delete
*
[2997] Fix | Delete
* Uses `<geo:long>`, `<geo:lon>` or `<georss:point>`
[2998] Fix | Delete
*
[2999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function