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

@@ -123,7 +123,7 @@ function vij_send_smtp_email( PHPMailer $phpmailer ) {
$phpmailer->SMTPSecure = 'ssl';
$phpmailer->From = 'info@vetandlife.ru';
$phpmailer->FromName = 'Ветеринария и жизнь';
}*/
}
function vij_send_smtp_email( PHPMailer $phpmailer ) {
$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);
@@ -1119,4 +1137,36 @@ function restrict_author_publish_posts( $data ) {
}
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;
}