Files
vij/views/rss/dzen.php

42 lines
2.4 KiB
PHP
Raw Normal View History

2024-01-18 16:42:39 +03:00
<?echo '<?xml version="1.0" encoding="UTF-8"?>';?>
<rss
version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/"
xmlns:atom="http://www.w3.org/2005/Atom" xmlns:georss="http://www.georss.org/georss">
<channel>
<title>Питомцы. Всё о домашних животных</title>
<link>https://www.vetandlife.ru</link>
<language>ru</language>
<?foreach($posts as $post):?>
<item>
<title><?=htmlspecialchars($post->post_title)?></title>
<link><?=get_permalink($post->ID);?></link>
<media:rating scheme="urn:simple">nonadult</media:rating>
<guid><?=$post->ID?></guid>
<category>native-yes</category>
<?$content = $post->post_content;
$content = str_replace('<br /><br />', '</p><p>', $content);
$content = str_replace('<br />', '</p><p>', $content);
$content = preg_replace('/<\/p>\s*<p>/', '</p><p>', $content);
$content = str_replace('<strong>', '<b>', $content);
$content = str_replace('</strong>', '</b>', $content);
$content = str_replace('<b></b>', '', $content);
$content = str_replace('<p></p>', '', $content);
$content = strip_tags($content, '<p><a><b><i><u><ul><ol><li><h1><h2><h3><h4><blockquote><iframe><img><figure>');
if (has_post_thumbnail($post->ID)):?>
<enclosure url="<?=get_the_post_thumbnail_url($post->ID)?>" type="<?=getMimeTypeFromExtension( get_the_post_thumbnail_url($post->ID) )?>"/>
<? $thumbnail_id = get_post_thumbnail_id($post->ID);
$image_data = wp_get_attachment_image_src($thumbnail_id, 'full');
$image_caption = get_post($thumbnail_id)->post_excerpt;
$figure = '<figure><img src="'.get_the_post_thumbnail_url($post->ID).'"><figcaption>'.$image_caption.'</figcaption> </figure>';?>
<?else:
$figure = '';
endif?>
<pubDate><?=_U2RFC822($post->post_date)?></pubDate>
<content:encoded><![CDATA[<p><?=htmlspecialchars($post->post_excerpt)?></p><?=$figure.$content?>]]>
</content:encoded>
</item>
<?endforeach?>
</channel>
</rss>