File: /home/k/kulikosl/kulikosl.beget.tech/public_html/back/zootheme 2612/functions.php
<?php
add_action('wp_enqueue_scripts', 'theme_name_scripts');
function theme_name_scripts()
{
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://code.jquery.com/jquery-3.6.0.min.js');
wp_enqueue_script('jquery');
wp_enqueue_style('slickStyle', 'https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css');
wp_enqueue_script('slickScript', 'https://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.min.js', array('jquery'), 'null', true);
}
//delete_option('api_key');
//delete_option('zoo_port_price_options');
$a['api_key'] = '0db6910222b3ee6276b91fa5871c6c2d';
update_option('zoo_port_price_options', $a);
add_theme_support('post-thumbnails');
register_nav_menus(array(
'top' => 'Верхнее меню',
'bottom' => 'Нижнее меню'
));
//стили и срипты в админке
add_action('admin_head', 'my_custom_fonts');
function my_custom_fonts()
{
echo '<link rel="stylesheet" href="' . get_bloginfo('template_url') . '/functions/css/my_admin_style.css?v=' . time() . '" type="text/css" media="all" />';
}
add_action('admin_enqueue_scripts', 'my_enqueue');
function my_enqueue()
{
wp_enqueue_script('my-upload', get_bloginfo('stylesheet_directory') . '/functions/js/upload.js?v=' . time(), array('jquery'));
wp_enqueue_script('my-tabs', get_bloginfo('stylesheet_directory') . '/functions/js/tabs.js?v=' . time(), array('jquery'));
wp_enqueue_script('my-admin', get_bloginfo('stylesheet_directory') . '/functions/js/admin.js?v=' . time(), array('jquery'));
wp_enqueue_script('basic', get_bloginfo('stylesheet_directory') . '/functions/js/basic.js?v=' . time(), array('jquery'));
wp_enqueue_script('jquery-ui-draggable');
wp_enqueue_script('jquery-ui-droppable');
wp_enqueue_script('jquery-ui-sortable');
}
//стили и скрипты фронтэнда
add_action('wp_enqueue_scripts', 'my_front_js');
function my_front_js()
{
wp_enqueue_script('basic', get_bloginfo('stylesheet_directory') . '/functions/js/basic.js?v=' . time(), array('jquery'));
wp_enqueue_script('yandex', 'https://api-maps.yandex.ru/2.1/?lang=ru-RU&apikey=' . get_option('yandex_key'), array('jquery'), time(), true);
wp_enqueue_style('fancybox', 'https://cdn.jsdelivr.net/npm/@fancyapps/ui@4.0/dist/fancybox.css', '', false, 'all');
wp_enqueue_style('style', get_bloginfo('stylesheet_directory') . '/css/style.css', '', false, 'all');
wp_enqueue_style('core', get_bloginfo('stylesheet_directory') . '/css/wp_core.css', '', false, 'all');
wp_enqueue_style('main-css', get_stylesheet_uri(), '', time(), 'all');
//wp_enqueue_script( 'jQuery' );
//wp_enqueue_style( 'jquery-ui' );
wp_enqueue_script('mask', get_bloginfo('stylesheet_directory') . '/js/jquery.maskedinput.min.js', array('jquery'), time(), true);
wp_enqueue_script('custom', get_bloginfo('stylesheet_directory') . '/js/custom.js', array('jquery'), time(), true);
}
//include (TEMPLATEPATH . '/functions/auth.php');
include(TEMPLATEPATH . '/functions/fields.php');
include(TEMPLATEPATH . '/functions/yandex.php');
include(TEMPLATEPATH . '/functions/options.php');
function pre($i)
{
echo '<pre>';
print_r($i);
echo '</pre>';
}
add_action('init', 'cpt_register');
function cpt_register()
{
register_post_type('clinics', array(
'label' => 'Клиники',
'singular_label' => 'Клиника',
'public' => true,
'menu_position' => 20,
'show_in_menu' => TRUE,
'show_in_nav_menus' => TRUE,
'rewrite' => array('slug' => 'vetkliniki'),
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail')
));
register_post_type('pharmacy', array(
'label' => 'Аптеки',
'singular_label' => 'Аптека',
'public' => true,
'menu_position' => 20,
'show_in_menu' => TRUE,
'show_in_nav_menus' => TRUE,
// 'rewrite' => true,
'rewrite' => array('slug' => 'vetapteki'),
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail')
));
register_post_type('shops', array(
'label' => 'Магазины',
'singular_label' => 'Магазин',
'public' => true,
'menu_position' => 20,
'show_in_menu' => TRUE,
'show_in_nav_menus' => TRUE,
// 'rewrite' => true,
'rewrite' => array('slug' => 'zoomagaziny'),
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail')
));
register_post_type('grooming', array(
'label' => 'Груминг',
'singular_label' => 'Груминг',
'public' => true,
'menu_position' => 20,
'show_in_menu' => TRUE,
'show_in_nav_menus' => TRUE,
// 'rewrite' => true,
'rewrite' => array('slug' => 'gruming-salony'),
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail')
));
register_post_type('doctors', array(
'label' => 'Врачи',
'singular_label' => 'Врач',
'public' => true,
'menu_position' => 20,
'show_in_menu' => TRUE,
'show_in_nav_menus' => TRUE,
// 'rewrite' => true,
'rewrite' => array('slug' => 'veterinary'),
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail')
));
register_post_type('actions', array(
'label' => 'Акции',
'singular_label' => 'Акция',
'public' => true,
'menu_position' => 20,
'show_in_menu' => TRUE,
'show_in_nav_menus' => TRUE,
'rewrite' => true,
'has_archive' => true,
'supports' => array('title', 'editor', 'thumbnail')
));
register_post_type('services', array(
'label' => 'Услуги',
'singular_label' => 'Услуга',
'public' => true,
'menu_position' => 20,
'show_in_menu' => TRUE,
'show_in_nav_menus' => TRUE,
// 'rewrite' => true,
// 'rewrite' => array('slug' => '%category%/uslugi', 'with_front' => false, 'pages' => false),
'rewrite' => array('slug' => 'uslugi'),
'has_archive' => true,
'hierarchical' => true,
'supports' => array('title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes')
));
flush_rewrite_rules(false);
}
add_action('init', 'create_my_taxonomies', 0);
function create_my_taxonomies()
{
register_taxonomy(
'specialization',
'doctors',
array(
'labels' => array(
'name' => 'Специализация',
'add_new_item' => 'Специализация',
'new_item_name' => "Специализация"
),
'show_ui' => true,
'show_tagcloud' => false
// 'hierarchical' => true,
// 'rewrite' => array('slug' => 'veterinary')
)
);
}
function get_phone($i)
{
$i = str_replace(' ', '', $i);
$i = str_replace('-', '', $i);
$i = str_replace('(', '', $i);
$i = str_replace(')', '', $i);
return $i;
}
function get_my_avatar($id)
{
$file = '/wp-content/themes/zootheme/img/avatar.svg';
if (get_post_meta($id, 'img1', true)) {
$thumb_url = wp_get_attachment_image_src(get_post_meta($id, 'img1', 1), 'thumbnail', true);
$file = $thumb_url[0];
}
return $file;
}
function send_my_mail($to, $name, $title, $message)
{
$dom = get_site_url();
$dom = str_replace('http://', '', $dom);
$dom = str_replace('https://', '', $dom);
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: ' . $name . ' <noreply@' . $dom . '>' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
//echo $headers;
$mes = '';
$mes .= '<table style="background:#F7F6FF ;max-width:800px; margin:50px auto; width: 100%; border-collapse:collapse; font-family: Tahoma; color: #2A2A2A; font-size: 14px; line-height: 20px;">';
$mes .= '<tr><th style=" padding:40px 50px; text-align: left; background-color:#fff"><img src="" style="width:120px; height: auto;"></th></tr>';
$mes .= '<tr><td style="padding:25px 80px 65px 80px; border-top:2px solid #fff;font-size: 15px; line-height: 18px; "><h1 style="display:block; font-weight:200; font-size: 24px; line-height: 28px; font-weight: 400; margin-bottom: 28px; padding:0px;">Здравствуйте</h1>';
$mes .= $message;
$mes .= '<br>
<a style="display:inline-block; border:transparent; background:#2C7BE5; color:#fff; padding:10px 20px; margin:20px 0px; text-decoration:none" href="' . get_bloginfo('url') . '">Перейти на сайт</a><br>
<div style="">С уважением, администрация портала <br>«Название»</div>
<div style="margin-top:90px; color:#6E84A3; font-size:14px;">
Если вы не регистрировались на нашем портале,<br> просто проигнорируйте это письмо.
</div>
<br><br>
</td>
</tr>
</table>';
mail($to, $title, $mes, $headers);
//wp_mail($to, $title, $mes, $headers);
//wp_mail($to, $title, $mes);
}
function mycallback()
{
if (wp_verify_nonce($_POST['form'], 'form')) {
$message = 'Страница: ' . sanitize_text_field($_POST['title']) . PHP_EOL . sanitize_text_field($_POST['link']) . PHP_EOL;
$message .= 'ФИО: ' . sanitize_text_field($_POST['name']) . PHP_EOL;
$message .= 'Телефон: ' . sanitize_text_field($_POST['phone']);
$subject = 'Заявка на консультацию';
$to = ['razuvaeva_ai@zoo-port.ru ', 'Nesterova_IY@zoo-port.ru', 'titov_ad@zoo-port.ru'];
wp_mail($to, $subject, $message);
//send_my_mail(get_option('mail_adres'),get_option('mail_from'),get_option('mail_title'),$message);
}
wp_die();
}
add_action('wp_ajax_callback', 'mycallback');
add_action('wp_ajax_nopriv_callback', 'mycallback');
function do_excerpt($string, $word_limit)
{
$words = explode(' ', $string, ($word_limit + 1));
if (count($words) > $word_limit)
array_pop($words);
echo '<p>' . implode(' ', $words) . ' ...</p>';
}
function rep($string, $option)
{
return str_replace($option, '', $string);
function wp_corenavi()
{
global $wp_query;
$total = isset($wp_query->max_num_pages) ? $wp_query->max_num_pages : 1;
$a['total'] = $total;
$a['mid_size'] = 3; // сколько ссылок показывать слева и справа от текущей
$a['end_size'] = 1; // сколько ссылок показывать в начале и в конце
$a['prev_text'] = '«'; // текст ссылки "Предыдущая страница"
$a['next_text'] = '»'; // текст ссылки "Следующая страница"
if ($total > 1) echo '<nav class="pagination">';
echo paginate_links($a);
if ($total > 1) echo '</nav>';
}
}
/**/
// function change_url_placeholder( $permalink, $post ){
// if ( strpos( $permalink, '/category/' ) === false ) {
// return $permalink;
// }
// if( is_single( $post ) ){
// if ( strpos( $permalink, '/category/' ) != false ) {
// $terms = get_the_terms( $post, 'services' );
// if ( ! is_wp_error( $terms ) && !empty( $terms ) && is_object( $terms[0] ) ) {
// $term_slug = array_pop( $terms )->slug;
// } else {
// $term_slug = 'no-brand';
// }
// $permalink = str_replace( '/category/', $term_slug, $permalink );
// return $permalink;
// }
// }
// }
// add_filter( 'post_type_link', 'change_url_placeholder', 1, 2 );
//Contact Form
add_action('wp_ajax_custom_contact_form', 'custom_contact_form');
add_action('wp_ajax_nopriv_custom_contact_form', 'custom_contact_form');
function custom_contact_form()
{
if (!wp_verify_nonce($_POST['nonce'], 'ccf_front_nonce')) {
echo json_encode(['error' => true]);
wp_die();
}
parse_str($_POST['form_data'], $form_data);
$to = ['razuvaeva_ai@zoo-port.ru ', 'Nesterova_IY@zoo-port.ru', 'titov_ad@zoo-port.ru', 'devpm85@gmail.com'];
$subject = 'Запись на прием';
$message = '
Имя: ' . sanitize_text_field($form_data['ccf_name']) . PHP_EOL . '
Телефон: ' . sanitize_text_field($form_data['ccf_tel']) . PHP_EOL . '
Email: ' . sanitize_text_field($form_data['ccf_mail']) . PHP_EOL . '
Дата приема: ' . sanitize_text_field($form_data['ccf_date']) . PHP_EOL . '
Время приема: ' . sanitize_text_field($form_data['ccf_time']) . PHP_EOL . '
Филиал: ' . sanitize_text_field($form_data['ccf_filial']) . PHP_EOL . '
Комментарий: ' . sanitize_text_field($form_data['ccf_comment']);
wp_mail($to, $subject, $message);
echo json_encode(['error' => false, 'msg' => 'Ваше сообщение отправлено! <br/>Мы свяжемся с Вами в ближайшее время']);
wp_die();
}
/** * Шорткод формы "Запись на прием" */
add_shortcode('custom_contact_form', 'custom_contact_form_shortcode');
function custom_contact_form_shortcode()
{
$html = '
<div class="form-shedule">
<div class="form-container">
<div class="text">Оставьте заявку и мы свяжемся с Вами для подтверждения записи</div>
<form action="/" method="POST" class="js_ccf">
<div class="form-row">
<div class="input-data">
<input type="text" name="ccf_name" />
<div class="underline"></div>
<label for="">Ваше имя</label>
</div>
<div class="input-data">
<input type="date" name="ccf_date" />
<div class="underline"></div>
<label for="">Предпочтительная дата приема</label>
</div>
</div>
<div class="form-row">
<div class="input-data">
<input type="tel" class="js_ccf_tel" name="ccf_tel" placeholder="_ (___) ___ __ __" required />
<div class="underline"></div>
<label for="">Ваш телефон <span>*</span></label>
</div>
<div class="input-data">
<input type="text" class="js_ccf_time" name="ccf_time" placeholder="__:__" />
<div class="underline"></div>
<label for="">Предпочтительное время приема</label>
</div>
</div>
<div class="form-row">
<div class="input-data">
<input type="email" name="ccf_mail">
<div class="underline"></div>
<label for="">Email</label>
</div>
<div class="input-data select">
<select name="ccf_filial" >
<option value="Не выбран">Удобный филиал ЗооПорт</option>
<option value="ЗооПорт на Сухаревской">ЗооПорт на Сухаревской</option>
<option value="ЗооПорт на Автозаводской">ЗооПорт на Автозаводской</option>
<option value="ЗооПорт на Тимирязевской">ЗооПорт на Тимирязевской</option>
<option value="ЗооПорт у метро 1905 года">ЗооПорт у метро 1905 года</option>
<option value="ЗооПорт у метро Аэропорт">ЗооПорт у метро Аэропорт</option>
<option value="ЗооПорт у метро Ясенево">ЗооПорт у метро Ясенево</option>
<option value="ЗооПорт у метро Верхние Лихоборы">ЗооПорт у метро Верхние Лихоборы</option>
</select>
<div class="underline"></div>
<!--<label for="">Удобный филиал</label>-->
</div>
</div>
<div class="form-row">
<div class="input-data textarea">
<textarea name="ccf_comment"></textarea>
<div class="underline"></div>
<label for="">Комментарий для врача: вид питомца, причина обращения</label>
</div>
</div>
<div class="agree">
<div>Отправляя данные, вы соглашаетесь на обработку персональных данных</div>
</div>
<div class="form-row">
<button class="submit-btn" type="submit">Отправить</button>
</div>
<div class="form-row">
<div class="js_ccf_msg ccf_msg"></div>
</div>
</form>
</div>
</div>';
$html .= wp_nonce_field('ccf_front_nonce', 'ccf_front_nonce_value', false, false);
$html .= '<script src="' . get_stylesheet_directory_uri() . '/js/custom_contact_form.js"></script>';
return $html;
}
/** * Шорткод формы "Запись на прием маленькая" */
add_shortcode('custom_contact_form_small', 'custom_contact_form_small_shortcode');
function custom_contact_form_small_shortcode()
{
$html = '
<div class="form-shedule">
<div class="form-container">
<div class="text">Оставьте заявку и мы свяжемся с Вами для подтверждения записи</div>
<form action="/" method="POST" class="js_ccf">
<div class="form-row">
<div class="input-data">
<input type="text" name="ccf_name" />
<div class="underline"></div>
<label for="">Ваше имя</label>
</div>
</div>
<div class="form-row">
<div class="input-data">
<input type="tel" class="js_ccf_tel" name="ccf_tel" placeholder="_ (___) ___ __ __" required />
<div class="underline"></div>
<label for="">Ваш телефон <span>*</span></label>
</div>
</div>
<div class="form-row">
</div>
<div class="form-row">
</div>
<div class="agree">
<div>Отправляя данные, вы соглашаетесь на обработку персональных данных</div>
</div>
<div class="form-row">
<button class="submit-btn" type="submit">Отправить</button>
</div>
<div class="form-row">
<div class="js_ccf_msg ccf_msg"></div>
</div>
</form>
</div>
</div>';
$html .= wp_nonce_field('ccf_front_nonce', 'ccf_front_nonce_value', false, false);
$html .= '<script src="' . get_stylesheet_directory_uri() . '/js/custom_contact_form.js"></script>';
return $html;
}
add_shortcode('newclinic', 'newclinic');
function newclinic()
{
ob_start(); ?>
<div class="singl_doc_24c">
<div class="section__item section__item-adv1 text-color-inverse">
<h3 class="section__item-title">Стационар 24ч</h3>
<div class="section__item-textsingl_doc_24">
<b> Ветклиника ЗООПОРТ </b>на 1905 года, работает в круглосуточном режиме!
</div>
<div class="section__item-textsingl_doc_24_adress">
Шмитовский проезд, 13.
</div>
<div class="section__item-textsingl_doc_24">
<a href="tel:+74950856363">
+7 (495) 085-63-63</a>
</div>
<button class="section__button" onclick="location.href='/zapis-vetklinica/'">Записаться на прием</button>
</div>
</div>
<?php
$myvariable = ob_get_clean();
return $myvariable;
}
add_shortcode('newclinic', 'newclinic');
// Скрываем уведомления о новой версии WordPress
if (1) {
// Общий счётчик обновлений в админ-баре
add_action('admin_bar_menu', function ($wp_adminbar) {
$wp_adminbar->remove_node('updates');
}, 999);
add_action('admin_menu', function () {
// "Доступен WordPress X.X" в Консоле - Для Single установки
remove_action('admin_notices', 'update_nag', 3);
// "Доступен WordPress X.X" в Консоле - Для Multisite установки
remove_action('network_admin_notices', 'update_nag', 3);
// "Скачать версию X.X" в футере
remove_action('update_footer', 'core_update_footer');
// Общий счётчик обновлений в админ-меню
remove_submenu_page('index.php', 'update-core.php');
// Счётчик плагинов для обновления в админ-меню
$GLOBALS['menu'][65][0] = __('Plugins');
}, 999);
// "Обновление до X.X" в виджете "На виду" в Консоле
add_action('admin_head-index.php', function () {
?>
<style>
#wp-version-message .button {
display: none;
}
</style>
<?php
});
}