add turbo

This commit is contained in:
2024-01-18 16:42:39 +03:00
parent 0acaed405a
commit 23ce0e4c37
8 changed files with 227 additions and 42 deletions

41
views/rss/dzen.php Normal file
View File

@@ -0,0 +1,41 @@
<?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>

View File

@@ -23,4 +23,4 @@
</item>
<?endforeach?>
</channel>
</rss>
</rss>

36
views/rss/yaturbo.php Normal file
View File

@@ -0,0 +1,36 @@
<?echo '<?xml version="1.0" encoding="UTF-8"?>';?>
<rss xmlns:yandex="http://news.yandex.ru"
xmlns:media="http://search.yahoo.com/mrss/"
xmlns:turbo="http://turbo.yandex.ru"
version="2.0">
<channel>
<title>Ветеринария и жизнь</title>
<link>https://vetandlife.ru</link>
<description>Краткое описание канала</description>
<yandex:analytics id="56480275" type="Yandex"></yandex:analytics>
<yandex:analytics id="G-VGN4NSFMW5" type="Google"></yandex:analytics>
<yandex:adNetwork type="Yandex" id="R-A-4145099"></yandex:adNetwork>
<language>ru</language>
<?foreach($posts as $post):?>
<item turbo="true">
<turbo:extendedHtml>true</turbo:extendedHtml>
<link><?=get_permalink($post->ID);?></link>
<?if (isset($author) and $author !== ''):?>
<author><?=$author?></author>
<?endif?>
<category>События</category>
<?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>
<turbo:content><![CDATA[<header><h1><?=htmlspecialchars($post->post_title)?></h1><?=$figure?></header><p><?=htmlspecialchars($post->post_excerpt)?></p><?=filtercontent($post->post_contentt);?><p>Добавляйте ВиЖ в свои источники в <a href="https://dzen.ru/vetandlife?favid=254162793">Дзен</a> и <a href="https://t.me/ViZHuvizh">Телеграм</a></p>]]></turbo:content>
</item>
<?endforeach?>
</channel>
</rss>