520 lines
25 KiB
PHP
520 lines
25 KiB
PHP
<?php
|
||
add_action( 'wp_enqueue_scripts', 'armanty_get_styles');
|
||
add_action( 'wp_enqueue_scripts', 'armanty_get_scripts');
|
||
add_action( 'after_setup_theme', 'armanty_register_menus');
|
||
add_filter( 'nav_menu_submenu_css_class', 'change_wp_nav_menu', 10, 3 );
|
||
add_action( 'init', 'register_armanty_types' );
|
||
add_theme_support( 'post-thumbnails' );
|
||
|
||
add_action( 'wp_ajax_send_mail', 'send_mail');
|
||
add_action( 'wp_ajax_nopriv_send_mail', 'send_mail');
|
||
|
||
add_action( 'wp_ajax_send_main_form', 'send_main_form');
|
||
add_action( 'wp_ajax_nopriv_send_main_form', 'send_main_form');
|
||
|
||
add_action( 'wp_ajax_send_callback', 'send_callback');
|
||
add_action( 'wp_ajax_nopriv_send_callback', 'send_callback');
|
||
|
||
add_action( 'wp_ajax_graduation_callback', 'graduation_callback');
|
||
add_action( 'wp_ajax_nopriv_graduation_callback', 'graduation_callback');
|
||
|
||
add_action( 'admin_menu', 'remove_menus' );
|
||
|
||
// Удаляем ненужные пункты в консоли WordPress
|
||
function remove_menus(){
|
||
remove_menu_page( 'index.php' ); //Консоль
|
||
remove_menu_page( 'edit.php' ); //Записи
|
||
// remove_menu_page( 'upload.php' ); //Медиафайлы
|
||
// remove_menu_page( 'edit.php?post_type=page' ); //Страницы
|
||
remove_menu_page( 'edit-comments.php' ); //Комментарии
|
||
// remove_menu_page( 'themes.php' ); //Внешний вид
|
||
// remove_menu_page( 'plugins.php' ); //Плагины
|
||
remove_menu_page( 'users.php' ); //Пользователи
|
||
// remove_menu_page( 'tools.php' ); //Инструменты
|
||
// remove_menu_page( 'options-general.php' ); //Настройки
|
||
}
|
||
|
||
function armanty_get_styles(){
|
||
wp_enqueue_style( 'styles', get_stylesheet_uri());
|
||
|
||
wp_enqueue_style('fonts', "https://fonts.googleapis.com/css?family=PT+Sans:400,700&display=swap&subset=cyrillic");
|
||
wp_enqueue_style('fontawesome', get_template_directory_uri() . '/assets/libs/font-awesome-4.7.0/css/font-awesome.min.css');
|
||
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/assets/libs/bootstrap-4.4.1-dist/css/bootstrap.min.css');
|
||
wp_enqueue_style('owlcarousel', get_template_directory_uri() . '/assets/libs/OwlCarousel2-2.3.4/dist/assets/owl.carousel.min.css');
|
||
if(is_page ('59')){
|
||
wp_enqueue_style('btdtpicker', get_template_directory_uri() . '/assets/libs/bootstrap_datetimepicker/css/bootstrap.min.css');
|
||
}
|
||
wp_enqueue_style('dtpicker', get_template_directory_uri() . '/assets/libs/bootstrap_datetimepicker/css/bootstrap-datetimepicker.min.css');
|
||
wp_enqueue_style('bootstrapselect', get_template_directory_uri() . '/assets/libs/bootstrap-select/bootstrap-select.min.css');
|
||
wp_enqueue_style('slick', 'http://cdn.jsdelivr.net/npm/slick-carousel@1.8.1/slick/slick.css');
|
||
|
||
wp_enqueue_style('armanty_style', get_template_directory_uri() . '/assets/css/style.css');
|
||
wp_enqueue_style('armanty_other', get_template_directory_uri() . '/assets/css/other.css');
|
||
|
||
|
||
if (is_page_template('templates/about.php')) wp_enqueue_style('armanty_about', get_template_directory_uri() . '/assets/css/pages/about.css');
|
||
if (is_page_template('templates/certificates.php')) wp_enqueue_style('armanty_certificates', get_template_directory_uri() . '/assets/css/pages/certificates.css');
|
||
if (is_page_template('templates/contacts.php')) wp_enqueue_style('armanty_contacts', get_template_directory_uri() . '/assets/css/pages/contacts.css');
|
||
if (is_page_template('templates/form.php')) wp_enqueue_style('armanty_form', get_template_directory_uri() . '/assets/css/pages/form.css');
|
||
if (is_page_template('templates/gallery.php')) wp_enqueue_style('armanty_gallery', get_template_directory_uri() . '/assets/css/pages/gallery.css');
|
||
// if (is_page_template('templates/holiday.php')) wp_enqueue_style('armanty_holiday', get_template_directory_uri() . '/assets/css/pages/holiday.css');
|
||
if (is_page_template('templates/home.php')) wp_enqueue_style('armanty_home', get_template_directory_uri() . '/assets/css/pages/home.css');
|
||
if (is_page_template('templates/price.php')) wp_enqueue_style('armanty_price', get_template_directory_uri() . '/assets/css/pages/price.css');
|
||
if (is_page_template('templates/quests.php')) wp_enqueue_style('armanty_quests', get_template_directory_uri() . '/assets/css/pages/quests.css');
|
||
if (is_page_template('templates/sales.php')) wp_enqueue_style('armanty_sales', get_template_directory_uri() . '/assets/css/pages/sales.css');
|
||
if (is_page_template('templates/single-quest.php')) wp_enqueue_style('armanty_single-quest', get_template_directory_uri() . '/assets/css/pages/single-quest.css');
|
||
if (is_page_template('templates/graduation.php')) wp_enqueue_style('armanty_graduation', get_template_directory_uri() . '/assets/css/pages/graduation.css');
|
||
|
||
wp_enqueue_style('armanty_holiday', get_template_directory_uri() . '/assets/css/pages/holiday.css');
|
||
wp_enqueue_style('armanty_quests', get_template_directory_uri() . '/assets/css/pages/quests.css');
|
||
|
||
}
|
||
|
||
function armanty_get_scripts(){
|
||
|
||
wp_deregister_script( 'jquery' );
|
||
wp_register_script( 'jquery', get_template_directory_uri() . '/assets/libs/jquery-3.4.1/jquery-3.4.1.min.js');
|
||
wp_enqueue_script('jquery');
|
||
|
||
wp_enqueue_script( 'jqmask', get_template_directory_uri( ) . '/assets/libs/jQuery-Mask-Plugin-master/dist/jquery.mask.min.js', ['jquery'], null, true);
|
||
|
||
if (!is_page_template('templates/graduation.php')) {
|
||
wp_enqueue_script( 'poper', get_template_directory_uri( ) . '/assets/libs/bootstrap-4.4.1-dist/js/popper.min.js', ['jquery'], null, true);
|
||
wp_enqueue_script( 'bootstrap', get_template_directory_uri( ) . '/assets/libs/bootstrap-4.4.1-dist/js/bootstrap.bundle.min.js', ['jquery'], null, true);
|
||
wp_enqueue_script( 'owlcarousel', get_template_directory_uri( ) . '/assets/libs/OwlCarousel2-2.3.4/dist/owl.carousel.js', ['jquery'], null, true);
|
||
wp_enqueue_script( 'moment', get_template_directory_uri( ) . '/assets/libs/bootstrap_datetimepicker/js/moment-with-locales.min.js', ['jquery'], null, true);
|
||
wp_enqueue_script( 'bootstrap', get_template_directory_uri( ) . '/assets/libs/bootstrap_datetimepicker/js/bootstrap.min.js', ['jquery', 'moment'], null, true);
|
||
wp_enqueue_script( 'dtpicker', get_template_directory_uri( ) . '/assets/libs/bootstrap_datetimepicker/js/bootstrap-datetimepicker.min.js', ['jquery', 'moment'], null, true);
|
||
wp_enqueue_script( 'select', get_template_directory_uri() . '/assets/libs/bootstrap-select/bootstrap-select.min.js');
|
||
wp_enqueue_script( 'ksv741script', get_template_directory_uri( ) . '/assets/js/script.js', ['jquery'], null, true);
|
||
wp_enqueue_script( 'slider', get_template_directory_uri( ) . '/assets/libs/jQuery-Waterwheel-Carousel/js/jquery.waterwheelCarousel.min.js', ['jquery'], null, true);
|
||
wp_enqueue_script( 'swiper', get_template_directory_uri( ) . '/assets/libs/jQueryTouchSwipe/jquery.touchSwipe.min.js', ['jquery'], null, true);
|
||
wp_enqueue_script( 'slick', 'https://cdnjs.cloudflare.com/ajax/libs/slick-carousel/1.9.0/slick.min.js', ['jquery'], null, true);
|
||
|
||
|
||
if(is_front_page() || is_page ('24') || is_page('35') || is_page('56')){
|
||
wp_enqueue_script( 'main', get_template_directory_uri( ) . '/assets/js/components/main.js', ['jquery'], null, true);
|
||
}
|
||
if(is_page ('8')){
|
||
wp_enqueue_script( 'quests', get_template_directory_uri( ) . '/assets/js/components/quests.js', ['jquery'], null, true);
|
||
}
|
||
if(is_page ('24')){
|
||
wp_enqueue_script( 'quests', get_template_directory_uri( ) . '/assets/js/components/holiday.js', ['jquery'], null, true);
|
||
}
|
||
if(is_page ('35')){
|
||
wp_enqueue_script( 'certificates', get_template_directory_uri( ) . '/assets/js/components/certificates.js', ['jquery'], null, true);
|
||
}
|
||
if(is_page ('56')){
|
||
wp_enqueue_script( 'sales', get_template_directory_uri( ) . '/assets/js/components/sales.js', ['jquery'], null, true);
|
||
}
|
||
if(is_page ('59')){
|
||
wp_enqueue_script( 'form', get_template_directory_uri( ) . '/assets/js/components/form.js', ['jquery'], null, true);
|
||
}
|
||
}
|
||
if (is_page_template('templates/graduation.php')) {
|
||
wp_enqueue_script( 'graduation', get_template_directory_uri( ) . '/assets/js/components/graduation.js');
|
||
}
|
||
}
|
||
|
||
function armanty_register_menus(){
|
||
register_nav_menus( [
|
||
'header_menu' => 'Меню в шапке',
|
||
'footer_menu' => 'Меню в подвале'
|
||
] );
|
||
}
|
||
|
||
function change_wp_nav_menu( $classes, $args, $depth ) {
|
||
if ( $args->theme_location == 'header_menu' ) {
|
||
$classes[] = 'header-submenu';
|
||
}
|
||
if ( $args->theme_location == 'footer_menu' ) {
|
||
$classes[] = 'footer__submenu';
|
||
}
|
||
|
||
return $classes;
|
||
}
|
||
|
||
function register_armanty_types(){
|
||
register_post_type('armanty_quests', array(
|
||
'labels' => array(
|
||
'name' => 'Квесты', // Основное название типа записи
|
||
'singular_name' => 'Квест', // отдельное название записи типа Book
|
||
'add_new' => 'Добавить новый',
|
||
'add_new_item' => 'Добавить новый квест',
|
||
'edit_item' => 'Редактировать квест',
|
||
'new_item' => 'Новый квест',
|
||
'view_item' => 'Посмотреть квест',
|
||
'search_items' => 'Найти квест',
|
||
'not_found' => 'Квестов не найдено',
|
||
'not_found_in_trash' => 'В корзине квестов не найдено',
|
||
'parent_item_colon' => '',
|
||
'menu_name' => 'Квесты'
|
||
|
||
),
|
||
'public' => true,
|
||
'publicly_queryable' => true,
|
||
'show_ui' => true,
|
||
'show_in_menu' => true,
|
||
'query_var' => true,
|
||
'has_archive' => 'true', // если нужна страница архива тут указываем её ярлык а не true
|
||
'capability_type' => 'post',
|
||
'hierarchical' => false,
|
||
'menu_position' => 2,
|
||
'menu_icon' => 'dashicons-universal-access',
|
||
'supports' => array('title','editor','thumbnail','excerpt')
|
||
) );
|
||
|
||
register_post_type('armanty_rooms', array(
|
||
'labels' => array(
|
||
'name' => 'Комнаты', // Основное название типа записи
|
||
'singular_name' => 'Комната', // отдельное название записи типа Book
|
||
'add_new' => 'Добавить новую',
|
||
'add_new_item' => 'Добавить новую комнату',
|
||
'edit_item' => 'Редактировать комнату',
|
||
'new_item' => 'Новая комната',
|
||
'view_item' => 'Посмотреть комнату',
|
||
'search_items' => 'Найти комнату',
|
||
'not_found' => 'Комнат не найдено',
|
||
'not_found_in_trash' => 'В корзине комнаты не найдено',
|
||
'parent_item_colon' => '',
|
||
'menu_name' => 'Комнаты'
|
||
|
||
),
|
||
'public' => true,
|
||
'publicly_queryable' => true,
|
||
'show_ui' => true,
|
||
'show_in_menu' => true,
|
||
'query_var' => true,
|
||
'has_archive' => 'true', // если нужна страница архива тут указываем её ярлык а не true
|
||
'capability_type' => 'post',
|
||
'hierarchical' => false,
|
||
'menu_position' => 2,
|
||
'menu_icon' => 'dashicons-admin-home',
|
||
'supports' => array('title','editor','thumbnail','excerpt')
|
||
) );
|
||
|
||
register_post_type('armanty_discounts', array(
|
||
'labels' => array(
|
||
'name' => 'Скидки', // Основное название типа записи
|
||
'singular_name' => 'Скидка', // отдельное название записи типа Book
|
||
'add_new' => 'Добавить новую',
|
||
'add_new_item' => 'Добавить новую скидку',
|
||
'edit_item' => 'Редактировать скидку',
|
||
'new_item' => 'Новая скидка',
|
||
'view_item' => 'Посмотреть скидку',
|
||
'search_items' => 'Найти скидку',
|
||
'not_found' => 'Скидки не найдено',
|
||
'not_found_in_trash' => 'В корзине скидок не найдено',
|
||
'parent_item_colon' => '',
|
||
'menu_name' => 'Скидки'
|
||
|
||
),
|
||
'public' => true,
|
||
'publicly_queryable' => true,
|
||
'show_ui' => true,
|
||
'show_in_menu' => true,
|
||
'query_var' => true,
|
||
'has_archive' => 'true', // если нужна страница архива тут указываем её ярлык а не true
|
||
'capability_type' => 'post',
|
||
'hierarchical' => false,
|
||
'menu_position' => 2,
|
||
'menu_icon' => 'dashicons-tag',
|
||
'supports' => array('title','editor','thumbnail','excerpt')
|
||
) );
|
||
|
||
register_post_type('armanty_certificate', array(
|
||
'labels' => array(
|
||
'name' => 'Сертификаты', // Основное название типа записи
|
||
'singular_name' => 'Сертификат', // отдельное название записи типа Book
|
||
'add_new' => 'Добавить новый',
|
||
'add_new_item' => 'Добавить новый сертификат',
|
||
'edit_item' => 'Редактировать сертификат',
|
||
'new_item' => 'Новый скидка',
|
||
'view_item' => 'Посмотреть сертификат',
|
||
'search_items' => 'Найти сертификат',
|
||
'not_found' => 'Сертификатов не найдено',
|
||
'not_found_in_trash' => 'В корзине сертификатов не найдено',
|
||
'parent_item_colon' => '',
|
||
'menu_name' => 'Сертификаты'
|
||
|
||
),
|
||
'public' => true,
|
||
'publicly_queryable' => true,
|
||
'show_ui' => true,
|
||
'show_in_menu' => true,
|
||
'query_var' => true,
|
||
'has_archive' => 'true', // если нужна страница архива тут указываем её ярлык а не true
|
||
'capability_type' => 'post',
|
||
'hierarchical' => false,
|
||
'menu_position' => 2,
|
||
'menu_icon' => 'dashicons-media-document',
|
||
'supports' => array('title','editor','thumbnail','excerpt')
|
||
) );
|
||
|
||
register_post_type('armanty_offer', array(
|
||
'labels' => array(
|
||
'name' => 'Пакетные предложения', // Основное название типа записи
|
||
'singular_name' => 'Пакет', // отдельное название записи типа Book
|
||
'add_new' => 'Добавить новый',
|
||
'add_new_item' => 'Добавить новый пакет',
|
||
'edit_item' => 'Редактировать пакет',
|
||
'new_item' => 'Новый пакет',
|
||
'view_item' => 'Посмотреть пакет',
|
||
'search_items' => 'Найти пакет',
|
||
'not_found' => 'Пакетов не найдено',
|
||
'not_found_in_trash' => 'В корзине пакетных предложений не найдено',
|
||
'parent_item_colon' => '',
|
||
'menu_name' => 'Пакетные предложения'
|
||
|
||
),
|
||
'public' => true,
|
||
'publicly_queryable' => true,
|
||
'show_ui' => true,
|
||
'show_in_menu' => true,
|
||
'query_var' => true,
|
||
'has_archive' => 'true', // если нужна страница архива тут указываем её ярлык а не true
|
||
'capability_type' => 'post',
|
||
'hierarchical' => false,
|
||
'menu_position' => 2,
|
||
'menu_icon' => 'dashicons-tickets-alt',
|
||
'supports' => array('thumbnail')
|
||
) );
|
||
|
||
register_post_type('armanty_feedback', array(
|
||
'labels' => array(
|
||
'name' => 'Отзывы', // Основное название типа записи
|
||
'singular_name' => 'Отзыв', // отдельное название записи типа Book
|
||
'add_new' => 'Добавить новый',
|
||
'add_new_item' => 'Добавить новый отзыв',
|
||
'edit_item' => 'Редактировать отзыв',
|
||
'new_item' => 'Новый отзыв',
|
||
'view_item' => 'Посмотреть отзыв',
|
||
'search_items' => 'Найти отзыв',
|
||
'not_found' => 'Отзывов не найдено',
|
||
'not_found_in_trash' => 'В корзине отзывов не найдено',
|
||
'parent_item_colon' => '',
|
||
'menu_name' => 'Отзывы'
|
||
|
||
),
|
||
'public' => true,
|
||
'publicly_queryable' => true,
|
||
'show_ui' => true,
|
||
'show_in_menu' => true,
|
||
'query_var' => true,
|
||
'has_archive' => 'true', // если нужна страница архива тут указываем её ярлык а не true
|
||
'capability_type' => 'post',
|
||
'hierarchical' => false,
|
||
'menu_position' => 2,
|
||
'menu_icon' => 'dashicons-share-alt2',
|
||
'supports' => array('title', 'thumbnail')
|
||
) );
|
||
|
||
register_post_type('armanty_partners', array(
|
||
'labels' => array(
|
||
'name' => 'Партнеры', // Основное название типа записи
|
||
'singular_name' => 'Партнего', // отдельное название записи типа Book
|
||
'add_new' => 'Добавить нового',
|
||
'add_new_item' => 'Добавить нового партнера',
|
||
'edit_item' => 'Редактировать партнера',
|
||
'new_item' => 'Новый партнер',
|
||
'view_item' => 'Посмотреть партнера',
|
||
'search_items' => 'Найти партнера',
|
||
'not_found' => 'Партнеров не найдено',
|
||
'not_found_in_trash' => 'В корзине партнеров не найдено',
|
||
'parent_item_colon' => '',
|
||
'menu_name' => 'Партнеры'
|
||
|
||
),
|
||
'public' => true,
|
||
'publicly_queryable' => true,
|
||
'show_ui' => true,
|
||
'show_in_menu' => true,
|
||
'query_var' => true,
|
||
'has_archive' => 'true', // если нужна страница архива тут указываем её ярлык а не true
|
||
'capability_type' => 'post',
|
||
'hierarchical' => false,
|
||
'menu_position' => 2,
|
||
'menu_icon' => 'dashicons-businesswoman',
|
||
'supports' => array('title', 'thumbnail')
|
||
) );
|
||
|
||
}
|
||
|
||
function send_mail(){
|
||
$orderName = $_POST['orderName'];
|
||
$orderTel = $_POST['orderTel'];
|
||
$orderEmail = $_POST['orderEmail'];
|
||
$orderOthers = $_POST['orderOthers'];
|
||
// подразумевается что $to, $subject, $message уже определены...
|
||
$to = get_option('admin_email');
|
||
$subject = 'Перезвонить';
|
||
$message = '<b>Имя:</b> ' . $orderName . '<br/>' .
|
||
'<b>Телефон:</b> ' . $orderTel . '<br/>' .
|
||
'<b>Почта:</b> ' . $orderEmail . '<br/>' .
|
||
'<b>Пожелание:</b> ' . $orderOthers . '<br/>';
|
||
// удалим фильтры, которые могут изменять заголовок $headers
|
||
remove_all_filters( 'wp_mail_from' );
|
||
remove_all_filters( 'wp_mail_from_name' );
|
||
|
||
$headers = array(
|
||
'From: Armanty Quest <me@example.net>',
|
||
'content-type: text/html',
|
||
);
|
||
|
||
wp_mail( $to, $subject, $message, $headers );
|
||
wp_die();
|
||
}
|
||
|
||
function send_main_form(){
|
||
$name = $_POST['name'];
|
||
$phone = $_POST['phone'];
|
||
$holidayType = $_POST['holidayType'];
|
||
$birthdayName = $_POST['birthdayName'];
|
||
$birthdayDate = $_POST['birthdayDate'];
|
||
$questName = $_POST['questName'];
|
||
$questRoom = $_POST['questRoom'];
|
||
$guestCount = $_POST['guestCount'];
|
||
$date = $_POST['date'];
|
||
$startSum = $_POST['startSum'];
|
||
$addingSum = $_POST['addingSum'];
|
||
$sum = $_POST['sum'];
|
||
$addingItems = $_POST['addingItems'];
|
||
|
||
// подразумевается что $to, $subject, $message уже определены...
|
||
if($holidayType == 'Birthday'){
|
||
$holiday = '<b>Тип праздника:</b> ' . 'День Рождения' . '<br/>' .
|
||
'<b>Имя именинника:</b> ' . $birthdayName . '<br/>'.
|
||
'<b>День Рождения:</b> ' . $birthdayDate . '<br/>';
|
||
}else{
|
||
$holiday = '<b>Тип праздника:</b> ' . 'Выпускной' . '<br/>';
|
||
}
|
||
$add = '<b>Доп.услуги:</b><br/>';
|
||
foreach ($addingItems as $addItem){
|
||
$add = $add . ' ' . $addItem[name] . ' - '. $addItem[price] . ' рублей<br/>';
|
||
}
|
||
if($addingSum !== ''){
|
||
$addSum = 'Доплата за количество детей ' . $addingSum . '<br/>';
|
||
}
|
||
|
||
|
||
$to = get_option('admin_email');
|
||
$subject = 'Заяка на проведение праздника';
|
||
$message = '<b>Имя:</b> ' . $name . '<br/>' .
|
||
'<b>Телефон:</b> ' . $phone . '<br/>' .
|
||
$holiday .
|
||
'<b>Квест:</b> ' . $questName . '<br/>' .
|
||
'<b>Комната:</b> ' . $questRoom . '<br/>' .
|
||
'<b>Количество гостей:</b> ' . $guestCount . '<br/>' .
|
||
'<b>Дата бронирования:</b> ' . $date . '<br/>' .
|
||
'<b>Цена в этот день:</b> ' . $startSum . '<br/>' .
|
||
$add .
|
||
$addSum .
|
||
'<b>Cумма:</b> ' . $sum . '<br/>';
|
||
// удалим фильтры, которые могут изменять заголовок $headers
|
||
remove_all_filters( 'wp_mail_from' );
|
||
remove_all_filters( 'wp_mail_from_name' );
|
||
|
||
$headers = array(
|
||
'From: Armanty Quest <me@example.net>',
|
||
'content-type: text/html',
|
||
);
|
||
|
||
wp_mail( $to, $subject, $message, $headers );
|
||
wp_die();
|
||
}
|
||
|
||
function send_callback(){
|
||
$name = $_POST['name'];
|
||
$phone = $_POST['phone'];
|
||
|
||
$to = get_option('admin_email');
|
||
$subject = 'Требуется перезвонить';
|
||
$message = '<b>Имя:</b> ' . $name . '<br/>' .
|
||
'<b>Телефон:</b> ' . $phone . '<br/>';
|
||
// удалим фильтры, которые могут изменять заголовок $headers
|
||
remove_all_filters( 'wp_mail_from' );
|
||
remove_all_filters( 'wp_mail_from_name' );
|
||
|
||
$headers = array(
|
||
'From: Armanty Quest <admin@armanty-quests.ru>',
|
||
'content-type: text/html',
|
||
);
|
||
|
||
wp_mail( $to, $subject, $message, $headers );
|
||
wp_die();
|
||
|
||
}
|
||
|
||
function graduation_callback(){
|
||
date_default_timezone_set('Europe/Moscow');
|
||
|
||
$name = $_POST['name'];
|
||
$phone = $_POST['phone'];
|
||
$packetName = $_POST['packetName'];
|
||
$date = date('m/d/Y h:i:s a', time());
|
||
|
||
$to = get_option('admin_email');
|
||
$subject = 'Требуется перезвонить (Выпускной)';
|
||
$message = '<b>Имя:</b> ' . $name . '<br/>' .
|
||
'<b>Телефон:</b> ' . $phone . '<br/>';
|
||
if ($packetName) $message = $message . '<b>Пакет:</b> ' . $packetName . '<br/>';
|
||
$message = $message . '<b>Время отправки:</b> ' . $date . '<br/>';
|
||
|
||
|
||
// удалим фильтры, которые могут изменять заголовок $headers
|
||
remove_all_filters( 'wp_mail_from' );
|
||
remove_all_filters( 'wp_mail_from_name' );
|
||
|
||
$headers = array(
|
||
'From: Armanty Quest <admin@armanty-quests.ru>',
|
||
'content-type: text/html',
|
||
);
|
||
|
||
wp_mail( $to, $subject, $message, $headers );
|
||
wp_die();
|
||
}
|
||
|
||
/**
|
||
* Like get_template_part() put lets you pass args to the template file
|
||
* Args are available in the tempalte as $template_args array
|
||
* @param string filepart
|
||
* @param mixed wp_args style argument list
|
||
*/
|
||
function hm_get_template_part( $file, $template_args = array(), $cache_args = array() ) {
|
||
$template_args = wp_parse_args( $template_args );
|
||
$cache_args = wp_parse_args( $cache_args );
|
||
if ( $cache_args ) {
|
||
foreach ( $template_args as $key => $value ) {
|
||
if ( is_scalar( $value ) || is_array( $value ) ) {
|
||
$cache_args[$key] = $value;
|
||
} else if ( is_object( $value ) && method_exists( $value, 'get_id' ) ) {
|
||
$cache_args[$key] = call_user_method( 'get_id', $value );
|
||
}
|
||
}
|
||
if ( ( $cache = wp_cache_get( $file, serialize( $cache_args ) ) ) !== false ) {
|
||
if ( ! empty( $template_args['return'] ) )
|
||
return $cache;
|
||
echo $cache;
|
||
return;
|
||
}
|
||
}
|
||
$file_handle = $file;
|
||
do_action( 'start_operation', 'hm_template_part::' . $file_handle );
|
||
if ( file_exists( get_stylesheet_directory() . '/' . $file . '.php' ) )
|
||
$file = get_stylesheet_directory() . '/' . $file . '.php';
|
||
elseif ( file_exists( get_template_directory() . '/' . $file . '.php' ) )
|
||
$file = get_template_directory() . '/' . $file . '.php';
|
||
ob_start();
|
||
$return = require( $file );
|
||
$data = ob_get_clean();
|
||
do_action( 'end_operation', 'hm_template_part::' . $file_handle );
|
||
if ( $cache_args ) {
|
||
wp_cache_set( $file, $data, serialize( $cache_args ), 3600 );
|
||
}
|
||
if ( ! empty( $template_args['return'] ) )
|
||
if ( $return === false )
|
||
return false;
|
||
else
|
||
return $data;
|
||
echo $data;
|
||
} |