parent
982f833545
commit
ffca487440
@ -0,0 +1,129 @@ |
|||||||
|
<?php |
||||||
|
/** |
||||||
|
* Template Name: New Main Page |
||||||
|
* Description: Front page template |
||||||
|
*/ |
||||||
|
|
||||||
|
if (!class_exists('Timber')) { |
||||||
|
echo 'Timber не установлен. Пожалуйста, активируйте плагин Timber.'; |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
function enqueue_custom_gallery_assets() { |
||||||
|
// Fancybox 5 |
||||||
|
wp_enqueue_style( |
||||||
|
'fancybox-css', |
||||||
|
'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.css', |
||||||
|
[], |
||||||
|
null |
||||||
|
); |
||||||
|
|
||||||
|
wp_enqueue_script( |
||||||
|
'fancybox-js', |
||||||
|
'https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox/fancybox.umd.js', |
||||||
|
[], |
||||||
|
null, |
||||||
|
true |
||||||
|
); |
||||||
|
|
||||||
|
// Инициализация Fancybox |
||||||
|
wp_add_inline_script('fancybox-js', " |
||||||
|
document.addEventListener('DOMContentLoaded', function () { |
||||||
|
Fancybox.bind('[data-fancybox=\"gallery\"]', {}); |
||||||
|
}); |
||||||
|
"); |
||||||
|
} |
||||||
|
add_action('wp_enqueue_scripts', 'enqueue_custom_gallery_assets'); |
||||||
|
|
||||||
|
|
||||||
|
function theme_enqueue_scripts() { |
||||||
|
wp_enqueue_style('gp-front-page-materialize-css', get_template_directory_uri() . '/static/css/libs/materialize.min.css'); |
||||||
|
wp_enqueue_style( |
||||||
|
'gp-front-page-style-2', |
||||||
|
get_template_directory_uri() . '/static/css/front-page-style.css', |
||||||
|
array(), |
||||||
|
filemtime(get_template_directory() . '/static/css/front-page-style.css') |
||||||
|
); |
||||||
|
|
||||||
|
wp_enqueue_style( |
||||||
|
'gp-front-page-style', |
||||||
|
get_template_directory_uri() . '/static/css/new-front-page-style.css', |
||||||
|
array(), |
||||||
|
filemtime(get_template_directory() . '/static/css/new-front-page-style.css') |
||||||
|
); |
||||||
|
wp_enqueue_script('gp-front-page-materialize', get_template_directory_uri() . '/static/js/libs/materialize.min.js', array(), null, true); |
||||||
|
wp_enqueue_script('gp-front-page-main', get_template_directory_uri() . '/static/js/new-front-page.js', array(), null, true); |
||||||
|
} |
||||||
|
add_action('wp_enqueue_scripts', 'theme_enqueue_scripts'); |
||||||
|
|
||||||
|
|
||||||
|
include_component('blog', 'main-page-block'); |
||||||
|
include_component('shop', 'product-card'); |
||||||
|
|
||||||
|
|
||||||
|
$reviews_food_query = get_posts(array( |
||||||
|
'post_type' => 'p_reviews', |
||||||
|
'numberposts' => -1, |
||||||
|
'meta_key' => 'food_enable', |
||||||
|
'meta_value' => true, |
||||||
|
'meta_compare' => '=' |
||||||
|
)); |
||||||
|
|
||||||
|
$reviews_treats_query = get_posts(array( |
||||||
|
'post_type' => 'p_reviews', |
||||||
|
'numberposts' => -1, |
||||||
|
'meta_key' => 'treats_enable', |
||||||
|
'meta_value' => true, |
||||||
|
'meta_compare' => '=' |
||||||
|
)); |
||||||
|
|
||||||
|
$context = Timber::context(); |
||||||
|
|
||||||
|
if (function_exists('get_field')) { |
||||||
|
//products |
||||||
|
$context['reviews_treats_query'] = $reviews_treats_query; |
||||||
|
$context['reviews_food_query'] = $reviews_food_query; |
||||||
|
// main |
||||||
|
$context['main_slider'] = get_field('main_slider'); |
||||||
|
// about |
||||||
|
$context['main_about_title'] = get_field('main_about-title'); |
||||||
|
$context['main_about_image'] = get_field('main_about-image'); |
||||||
|
$context['main_about_text'] = get_field('main_about-text'); |
||||||
|
$context['main_about_banner_bg'] = get_field('main_about-banner-bg'); |
||||||
|
$context['main_about_banner_title'] = get_field('main_about-banner-title'); |
||||||
|
$context['main_about_banner_descr'] = get_field('main_about-banner-descr'); |
||||||
|
// why |
||||||
|
$context['main_why_title'] = get_field('main_why-title'); |
||||||
|
$context['main_why_items'] = get_field('main_why-items'); |
||||||
|
$context['main_why_text'] = get_field('main_why-text'); |
||||||
|
$context['main_why_logos'] = get_field('main_why-logos'); |
||||||
|
// ingredients |
||||||
|
$context['main_ingredients_title'] = get_field('main_ingredients-title'); |
||||||
|
$context['main_ingredients_slider'] = get_field('main_ingredients-slider'); |
||||||
|
// specialists |
||||||
|
$context['main_specialists_title'] = get_field('main_specialists-title'); |
||||||
|
$context['main_specialists_items'] = get_field('main_specialists-items'); |
||||||
|
// cosmopetx |
||||||
|
$context['other_post'] = Timber::get_post(383); // Загружаем пост с ID 383 |
||||||
|
//quiz |
||||||
|
$context['q_title'] = get_field('q_title'); |
||||||
|
$context['reviews_title'] = get_field('reviews_title'); |
||||||
|
$context['q_1'] = get_field('q_1', 383); |
||||||
|
$context['q_2'] = get_field('q_2', 383); |
||||||
|
$context['q_3'] = get_field('q_3', 383); |
||||||
|
$context['q_4'] = get_field('q_4', 383); |
||||||
|
$context['q_5'] = get_field('q_5', 383); |
||||||
|
|
||||||
|
// |
||||||
|
|
||||||
|
$context['food_list'] = get_field('featured_food'); |
||||||
|
$context['treats_list'] = get_field('featured_treats'); |
||||||
|
} |
||||||
|
|
||||||
|
try { |
||||||
|
Timber::render('_pages/new-front-page.twig', $context); // Рендерим отдельный Twig-шаблон |
||||||
|
} catch (Exception $e) { |
||||||
|
error_log('Ошибка рендеринга: ' . $e->getMessage()); |
||||||
|
echo 'Произошла ошибка при рендеринге шаблона. Проверь логи: ' . $e->getMessage(); |
||||||
|
} |
||||||
|
?> |
Loading…
Reference in new issue