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

View File

@@ -37,7 +37,7 @@ else{
<div class="mob_menu_info">
<?php include get_template_directory().'/blocks/mobile-gazeta.php';?>
<?php include get_template_directory().'/blocks/mobile-subscript.php';?>
<?php include get_template_directory().'/blocks/social-buttons.php';?>
<?php include get_template_directory().'/blocks/social-buttons-pets.php';?>
</div>
<?php /**wp_nav_menu( array(

View File

@@ -0,0 +1,13 @@
<div id="socials">
<a href="https://vk.com/pitomcy_vetandlife" target="_blank"><i style="color: #3B83B5;" class="fab fa-vk btn_soc"></i></a>
<a href="https://t.me/pitomcy_vetandlife" target="_blank"><i style="color: #3B83B5;" class="fab fa-telegram-plane btn_soc"></i></a>
<a href="https://www.youtube.com/channel/UCGRWr7wG8zxFBMMKdPzYPUQ" target="_blank"><i style="color: red;" class="fab fa-youtube btn_soc"></i></a>
<!-- <div class="btn soc_vk"></div>
<div class="soc_btn soc_fb"></div>
<div class="soc_btn soc_telegram"></div>
<div class="soc_btn soc_youtube"></div>
<div class="soc_btn soc_instagram"></div> -->
</div>

View File

@@ -65,7 +65,7 @@ body {
max-width: 200px;
left: 0;
top: 0;
margin: 0 0 0 22px;
margin: 0 0 0 2%;
padding: 0;
}
@@ -218,9 +218,31 @@ ul.pets-menu-left{
}
@media (max-width: 375px) {
#petslogo{
width: 100%;
max-width: 100%;
margin: 0;
padding: 0 0 0 4px;
}
.pets-dog{
width: 133px;
}
}
@media (max-width: 767px) {
body{
width: 100%;
}
.toggle-nav-pets {
background: url(/wp-content/themes/vij/pub/icons/gumburger.svg) no-repeat;
width: 20px;

View File

@@ -1,20 +1,24 @@
<?php
include_once '/vhosts/vetandlife.ru/wp-load.php';
function filterHtml($html) {
$html = trim($html);
$html = preg_replace('/(\>)\s*(\<)/m', '$1$2', $html);
return preg_replace('/<!--(.*?)-->/', '', $html);
}
date_default_timezone_set('Europe/Moscow');
$posts = get_posts( array(
//Яндекс Новости
create_rss_yandex();
//Дзен
create_rss_dzen();
exit;
function create_rss_yandex(){
$posts = get_posts( array(
'numberposts' => 20,
'category' => 2,
'orderby' => 'date',
@@ -25,33 +29,54 @@ $posts = get_posts( array(
'meta_value' =>'',
'post_type' => 'post',
'suppress_filters' => true, // подавление работы фильтров изменения SQL запроса
));
// Яндекс Новости
create_rss_file($posts, 'views/rss/yanews.php', '/vhosts/vetandlife.ru/rss/yanews.xml');
// Общая лента
create_rss_file($posts, 'views/rss/rssnews.php', '/vhosts/vetandlife.ru/rss/news.xml');
));
exit;
// Яндекс Новости
create_rss_file($posts, 'views/rss/yanews.php', '/vhosts/vetandlife.ru/rss/yanews.xml');
if( $posts ){
// Общая лента
create_rss_file($posts, 'views/rss/rssnews.php', '/vhosts/vetandlife.ru/rss/news.xml');
//Турбо
create_rss_file($posts, 'views/rss/yaturbo.php', '/vhosts/vetandlife.ru/rss/turbo.xml');
return;
ob_start();
include('views/rss/yanews.php');
$result = ob_get_contents();
ob_end_clean();
}
$result = trim($result);
if ($result !== ''){
file_put_contents('/vhosts/beta/rss/yanews.xml', trim($result));
function create_rss_dzen(){
$subcategories = get_categories(array(
'child_of' => 14, // pets
));
$subcategories_ids = array($parent_category_id);
foreach ($subcategories as $subcategory) {
$subcategories_ids[] = $subcategory->term_id;
}
$args = array(
'category__in' => $subcategories_ids,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 30,
'orderby' => 'date',
'order' => 'DESC',
);
$posts = get_posts($args);
create_rss_file($posts, 'views/rss/dzen.php', '/vhosts/vetandlife.ru/rss/dzen.xml');
return;
}
@@ -60,7 +85,6 @@ function create_rss_file($posts, $temp, $file){
if( $posts ){
ob_start();
include($temp);
$result = ob_get_contents();
@@ -80,5 +104,50 @@ function create_rss_file($posts, $temp, $file){
}
function getMimeTypeFromExtension($imageUrl) {
$extension = pathinfo($imageUrl, PATHINFO_EXTENSION);
switch (strtolower($extension)) {
case 'jpg':
case 'jpeg':
return 'image/jpeg';
case 'png':
return 'image/png';
case 'gif':
return 'image/gif';
case 'webp':
return 'image/webp';
default:
return false; // Неизвестное расширение
}
}
function filterHtml($html) {
$html = trim($html);
$html = preg_replace('/(\>)\s*(\<)/m', '$1$2', $html);
return preg_replace('/<!--(.*?)-->/', '', $html);
}
function filtercontent($html){
$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>');
return $content;
}

View File

@@ -100,12 +100,16 @@ if ( $pets_cat ){
</div>
<div class="promo-agregators" style="text-align: center;">
<?if ( $pets_cat ):?>
<p>Читайте нас в <span class="promo-telega"><a href="https://t.me/pitomcy_vetandlife" target="_blank">Telegram</a></span></p>
<?else:?>
<p>Читайте нас в <span class="promo-telega"><a href="https://t.me/ViZHuvizh" target="_blank">Telegram</a></span></p>
<?endif?>
</div>
<div class="post_panel_info">
<div class="post_panel_info_sub">
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category['0']->name;?></a></span>, <nobr><?php the_time('j F Y, G:i');?></nobr>
<span class="post_link_category"><a href="<?=$category_link?>"><?=$category_name;?></a></span>, <nobr><?php the_time('j F Y, G:i');?></nobr>
</div>
<div class="post_panel_info_sub">
<!--Поделиться <i class="fas fa-share-square btn_soc_post"></i>--> <?php include get_template_directory().'/blocks/social-share.php';?>

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>

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>