add widget pets

This commit is contained in:
2025-04-22 00:54:04 +03:00
parent 887258defa
commit 655a492022
5 changed files with 119 additions and 12 deletions

View File

@@ -75,14 +75,6 @@
</li> </li>
<li>
<a href="https://ok.ru/pitomcy.vetandlife" title="Одноклассники" target="_blank">
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="20" cy="20" r="19.5" stroke="#7A7A7A"/>
<path fill="#7A7A7A" d="M20.2,11c-2.6,0-4.7,2.1-4.7,4.7s2.1,4.7,4.7,4.7s4.7-2.1,4.7-4.7l0,0C24.8,13.1,22.8,11,20.2,11z M20.2,17.6 c-1.1,0-1.9-0.9-1.9-1.9c0-1.1,0.9-1.9,1.9-1.9s1.9,0.9,1.9,1.9l0,0C22.1,16.7,21.3,17.6,20.2,17.6L20.2,17.6z M21.8,24 c1.1-0.2,2.1-0.7,3-1.3c0.6-0.4,0.6-1.2,0.2-1.8s-1.2-0.6-1.8-0.2l0,0c-0.9,0.6-2,0.9-3.2,0.9c-1.1,0-2.2-0.3-3.2-0.9 c-0.6-0.4-1.4-0.3-1.8,0.2c-0.4,0.6-0.3,1.4,0.2,1.8l0,0c0.9,0.7,2,1.1,3.1,1.3l-2.7,2.8c-0.5,0.5-0.5,1.3,0,1.8 c0.5,0.5,1.3,0.5,1.8,0c0,0,0,0,0-0.1l2.7-2.5l2.7,2.7c0.5,0.5,1.3,0.4,1.8-0.1s0.5-1.2,0-1.7L21.8,24z"/>
</svg></a>
</li>
<li> <li>
<a href="https://dzen.ru/pitomcy_vetandlife?favid=254162793" title="Дзен" target="_blank"> <a href="https://dzen.ru/pitomcy_vetandlife?favid=254162793" title="Дзен" target="_blank">
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg"> <svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">

51
blocks/pets.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
// Задаем ID нужной категории (родительской)
$parent_cat_id = 14; // замените на нужный ID рубрики
// Получим ID подкатегорий
$subcats = get_categories( array(
'child_of' => $parent_cat_id,
'hide_empty' => false,
) );
// Собираем все ID: родительская + подкатегории
$category_ids = array( $parent_cat_id );
foreach ( $subcats as $cat ) {
$category_ids[] = $cat->term_id;
}
// Получаем 3 случайных поста из этих категорий
$args = array(
'category__in' => $category_ids,
'posts_per_page' => 3,
'post_status' => 'publish',
'orderby' => 'rand'
);
$random_posts = get_posts( $args );
// Если нашли посты
if ( $random_posts ) {
// Выбираем случайный один из трёх
$post = $random_posts[ array_rand( $random_posts ) ];
setup_postdata( $post );
?>
<div class="pets-widget">
<div class="pets-widget-maintitle"><a href="/pets">Питомцы</a></div>
<a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ) : ?>
<div>
<?php the_post_thumbnail('medium'); ?>
</div>
<?php endif; ?>
<h3 class="pets-widget-title"><?php the_title(); ?></h3>
</a>
</div>
<?php
wp_reset_postdata();
}
?>

View File

@@ -252,6 +252,20 @@ window.yaContextCb.push(()=>{
<a href="https://rutube.ru/u/Pets/" target="_blank"><span class="socs soc-rutube"></span></a> <a href="https://rutube.ru/u/Pets/" target="_blank"><span class="socs soc-rutube"></span></a>
<a href="https://vk.com/pitomcy_vetandlife" target="_blank"><span class="socs soc-vk"></span></a> <a href="https://vk.com/pitomcy_vetandlife" target="_blank"><span class="socs soc-vk"></span></a>
<a href="https://t.me/pitomcy_vetandlife" target="_blank"><span class="socs soc-tg"></span></a> <a href="https://t.me/pitomcy_vetandlife" target="_blank"><span class="socs soc-tg"></span></a>
<a href="https://dzen.ru/pitomcy_vetandlife?favid=254162793" target="_blank">
<svg width="40" height="40" viewBox="0 0 40 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="20" cy="20" r="19.5" stroke="#3B83B5"/>
<g id="_Слой_1-2">
<path fill="#3B83B5" d="M20.2,11.8c0,3.3,0.3,5.2,1.5,6.5s3.1,1.5,6.5,1.5C28.1,15.4,24.6,11.9,20.2,11.8z"/>
<path fill="#3B83B5" d="M18.2,18.2c1.2-1.3,1.5-3.1,1.5-6.5c-4.4,0.1-7.9,3.6-8,8C15.1,19.8,17,19.5,18.2,18.2z"/>
<path fill="#3B83B5" d="M11.8,20.2c0.1,4.4,3.6,7.9,8,8c0-3.3-0.3-5.2-1.5-6.5S15.1,20.3,11.8,20.2z"/>
<path fill="#3B83B5" d="M28.2,20.2c-3.3,0-5.2,0.3-6.5,1.5s-1.5,3.1-1.5,6.5C24.6,28.1,28.1,24.6,28.2,20.2L28.2,20.2z"/>
</g>
<path fill="#3B83B5" d="M20,1c10.5,0,19,8.5,19,19s-8.5,19-19,19S1,30.5,1,20S9.5,1,20,1 M20,0C9,0,0,9,0,20s9,20,20,20s20-9,20-20 S31,0,20,0z"/>
</svg>
</a>
</div> </div>
</div> </div>

View File

@@ -22,8 +22,8 @@
?> ?>
<?php // get_template_part( '/blocks/citats'); <?php // get_template_part( '/blocks/citats');
get_blocks_gen( 'citats' );?> get_template_part( '/blocks/pets');
//get_blocks_gen( 'citats' );?>
<?php //include VIJ_CACHE.'opinion.html';?> <?php //include VIJ_CACHE.'opinion.html';?>
<?php //get_template_part( '/blocks/citata', null, ['subclass' => '']);?> <?php //get_template_part( '/blocks/citata', null, ['subclass' => '']);?>
<?php //get_template_part( '/blocks/events');?> <?php //get_template_part( '/blocks/events');?>

View File

@@ -123,7 +123,7 @@ function vij_send_smtp_email( PHPMailer $phpmailer ) {
$phpmailer->SMTPSecure = 'ssl'; $phpmailer->SMTPSecure = 'ssl';
$phpmailer->From = 'info@vetandlife.ru'; $phpmailer->From = 'info@vetandlife.ru';
$phpmailer->FromName = 'Ветеринария и жизнь'; $phpmailer->FromName = 'Ветеринария и жизнь';
}*/ }
function vij_send_smtp_email( PHPMailer $phpmailer ) { function vij_send_smtp_email( PHPMailer $phpmailer ) {
$phpmailer->isSMTP(); $phpmailer->isSMTP();
@@ -138,7 +138,25 @@ function vij_send_smtp_email( PHPMailer $phpmailer ) {
} }
add_action( 'phpmailer_init', 'vij_send_smtp_email' ); //add_action( 'phpmailer_init', 'vij_send_smtp_email' );*/
function agroxpert_send_smtp_email( $phpmailer ) {
$phpmailer->isSMTP();
$phpmailer->Host = 'mail.vetandlife.ru';
$phpmailer->SMTPAuth = true;
$phpmailer->Port = 465;
$phpmailer->Username = 'ak@mail.agroexpert.press';
$phpmailer->Password = 'zhjk-ip-899-Jlie-Uisje3';
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->From = 'ak@mail.agroexpert.press';
$phpmailer->FromName = 'Андрей Кувшинов';
}
add_action( 'phpmailer_init', 'agroxpert_send_smtp_email' );
db_config(DB_NAME, 'mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD); db_config(DB_NAME, 'mysql:host='.DB_HOST.';dbname='.DB_NAME, DB_USER, DB_PASSWORD);
@@ -1119,4 +1137,36 @@ function restrict_author_publish_posts( $data ) {
} }
add_filter( 'wp_insert_post_data', 'restrict_author_publish_posts' ); add_filter( 'wp_insert_post_data', 'restrict_author_publish_posts' );
function replace_first_figure_in_content($content) {
global $post;
if (!isset($post->ID)) {
return $content;
}
// Ищем первое <figure>...</figure>
if (preg_match('/<figure.*?>.*?<\/figure>/is', $content, $match)) {
$original_figure = $match[0];
// Извлекаем <figcaption> (если есть)
$caption = '';
if (preg_match('/<figcaption.*?>(.*?)<\/figcaption>/is', $original_figure, $caption_match)) {
$caption = $caption_match[1]; // только содержимое
}
// Генерируем HTML изображения
$replacement = render_webp_picture_by_post($post->ID);
// Добавляем подпись, если есть
if (!empty($caption)) {
$replacement .= '<div class="image-caption">' . esc_html($caption) . '</div>';
}
// Заменяем первое вхождение <figure>...</figure> на $replacement
$content = preg_replace('/<figure.*?>.*?<\/figure>/is', $replacement, $content, 1);
}
return $content;
}