| Server IP : 104.171.130.249 / Your IP : 216.73.216.146 Web Server : nginx/1.25.5 System : Linux 0dac65491b7e 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : root ( 0) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /var/www/html/wp-content/themes/matreshka/inc/ |
Upload File : |
<?php
/**
* Front-end asset registration and global page loader markup.
*/
/**
* Enqueue scripts and styles.
*/
function matreshka_scripts() {
// Google Fonts
wp_enqueue_style(
'matreshka-google-fonts',
'https://fonts.googleapis.com/css2?family=Montserrat+Alternates:wght@100;200;300;400;500;600;700;800;900&display=swap',
array(),
null
);
// Bootstrap CSS
wp_enqueue_style(
'matreshka-bootstrap',
get_template_directory_uri() . '/assets/css/bootstrap.min.css',
array(),
_S_VERSION
);
// Slick carousel CSS (если используется)
wp_enqueue_style(
'matreshka-slick',
get_template_directory_uri() . '/assets/css/slick.css',
array('matreshka-bootstrap'),
_S_VERSION
);
wp_enqueue_style(
'matreshka-slick-theme',
get_template_directory_uri() . '/assets/css/slick-theme.css',
array('matreshka-slick'),
"1.0.1"
);
// Кастомные шрифты
wp_enqueue_style(
'matreshka-fonts',
get_template_directory_uri() . '/assets/css/fonts.css',
array('matreshka-google-fonts'),
_S_VERSION
);
// Material Icons Outlined (self-hosted)
wp_enqueue_style(
'matreshka-material-icons',
get_template_directory_uri() . '/assets/css/material-icons.css',
array(),
_S_VERSION
);
// Основной стиль темы (последним)
wp_enqueue_style(
'matreshka-theme',
get_template_directory_uri() . '/assets/css/style.css',
array('matreshka-bootstrap', 'matreshka-slick', 'matreshka-fonts'),
"1.1.271"
);
// Стили акций (promotions) — homepage, archive, single
wp_enqueue_style(
'matreshka-promotions',
get_template_directory_uri() . '/assets/css/promotions.css',
array('matreshka-theme'),
'1.0.1'
);
// Mobile menu styles
wp_enqueue_style(
'matreshka-mobile-menu',
get_template_directory_uri() . '/assets/css/mobile-menu.css',
array('matreshka-theme'),
'1.0.0'
);
// Shared loader styles for the global page loader and checkout order loader.
wp_enqueue_style(
'matreshka-checkout-loader',
get_template_directory_uri() . '/assets/css/checkout-loader.css',
array('matreshka-theme', 'matreshka-material-icons'),
filemtime( get_template_directory() . '/assets/css/checkout-loader.css' )
);
// Стили страницы контактов
if ( is_page_template( 'page-contacts.php' ) ) {
wp_enqueue_style(
'matreshka-contacts',
get_template_directory_uri() . '/assets/css/contacts.css',
array('matreshka-theme'),
'1.0.0'
);
}
// Стили страницы "О сервисе" (використовує ті ж стилі, що й контакти)
if ( is_page_template( 'page-about-service.php' ) ) {
wp_enqueue_style(
'matreshka-about-service',
get_template_directory_uri() . '/assets/css/contacts.css',
array('matreshka-theme'),
'1.0.0'
);
}
// Стили страницы вакансий
if ( is_page_template( 'page-vacancies.php' ) ) {
wp_enqueue_style(
'matreshka-vacancies',
get_template_directory_uri() . '/assets/css/vacancies.css',
array('matreshka-theme'),
'1.0.0'
);
}
// Стили сповіщень у кошику
if ( is_cart() || is_checkout() ) {
wp_enqueue_style(
'matreshka-cart-notices',
get_template_directory_uri() . '/assets/css/cart-notices.css',
array('matreshka-theme'),
'1.0.5'
);
}
// Checkout loader overlay (красивый оверлей при оформлении заказа)
if ( function_exists('is_checkout') && is_checkout() ) {
wp_enqueue_script(
'matreshka-checkout-loader',
get_template_directory_uri() . '/assets/js/checkout-loader.js',
array('jquery'),
'1.0.0',
true
);
wp_enqueue_script(
'matreshka-checkout-phone',
get_template_directory_uri() . '/assets/js/checkout-phone.js',
array('jquery'),
filemtime( get_template_directory() . '/assets/js/checkout-phone.js' ),
true
);
}
// Базовый style.css темы для метаданных (опционально, если нужен)
wp_enqueue_style( 'matreshka-style', get_stylesheet_uri(), array(), "1.0.1" );
wp_style_add_data( 'matreshka-style', 'rtl', 'replace' );
// Скрипты
wp_enqueue_script( 'matreshka-navigation', get_template_directory_uri() . '/js/navigation.js', array(), _S_VERSION, true );
// jQuery (используем встроенную WordPress-бандл)
wp_enqueue_script( 'jquery' );
wp_enqueue_script(
'matreshka-page-loader',
get_template_directory_uri() . '/assets/js/page-loader.js',
array(),
filemtime( get_template_directory() . '/assets/js/page-loader.js' ),
true
);
wp_enqueue_script(
'matreshka-product-card-image',
get_template_directory_uri() . '/assets/js/product-card-image.js',
array(),
filemtime( get_template_directory() . '/assets/js/product-card-image.js' ),
true
);
// Slick slider
wp_enqueue_script(
'matreshka-slick',
get_template_directory_uri() . '/assets/js/slick.min.js',
array('jquery'),
_S_VERSION,
true
);
// Наши инициализации слайдеров
wp_enqueue_script(
'matreshka-sliders',
get_template_directory_uri() . '/assets/js/sliders.js',
array('jquery','matreshka-slick'),
'1.0.5',
true
);
// Управление количеством (кнопки +/- для товара)
if ( function_exists('is_product') && is_product() ) {
wp_enqueue_script(
'matreshka-quantity',
get_template_directory_uri() . '/assets/js/quantity.js',
array('jquery'),
filemtime( get_template_directory() . '/assets/js/quantity.js' ),
true
);
wp_enqueue_script(
'matreshka-quantity-validate',
get_template_directory_uri() . '/assets/js/quantity-validate.js',
array('jquery'),
'1.0.0',
true
);
wp_enqueue_script(
'matreshka-description-toggle',
get_template_directory_uri() . '/assets/js/description-toggle.js',
array('jquery'),
'1.0.0',
true
);
}
// Cart page scripts
if ( function_exists('is_cart') && is_cart() ) {
wp_enqueue_script(
'matreshka-cart',
get_template_directory_uri() . '/assets/js/cart.js',
array('jquery'),
filemtime( get_template_directory() . '/assets/js/cart.js' ),
true
);
wp_enqueue_script(
'matreshka-substitution-modal',
get_template_directory_uri() . '/assets/js/substitution-modal.js',
array('jquery'),
'1.0.0',
true
);
wp_enqueue_script(
'matreshka-payment-modal',
get_template_directory_uri() . '/assets/js/payment-modal.js',
array('jquery'),
'1.0.0',
true
);
}
if ( is_page_template( 'page-history.php' ) ) {
wp_enqueue_script(
'matreshka-history-order-modal',
get_template_directory_uri() . '/assets/js/history-order-modal.js',
array(),
filemtime( get_template_directory() . '/assets/js/history-order-modal.js' ),
true
);
}
// Add to cart script for product cards
wp_enqueue_script(
'matreshka-add-to-cart',
get_template_directory_uri() . '/assets/js/add-to-cart.js',
array('jquery'),
filemtime( get_template_directory() . '/assets/js/add-to-cart.js' ),
true
);
// Category filter script for product categories
wp_enqueue_script(
'matreshka-category-filter',
get_template_directory_uri() . '/assets/js/category-filter.js',
array('jquery'),
'1.0.6',
true
);
wp_enqueue_script(
'matreshka-product-scroll-hint',
get_template_directory_uri() . '/assets/js/product-scroll-hint.js',
array('jquery'),
filemtime( get_template_directory() . '/assets/js/product-scroll-hint.js' ),
true
);
wp_enqueue_script(
'matreshka-search',
get_template_directory_uri() . '/assets/js/search.js',
array('jquery'),
'1.0.3', // Final version - removed debug logs
true
);
wp_enqueue_script(
'matreshka-wishlist',
get_template_directory_uri() . '/assets/js/wishlist.js',
array('jquery'),
'1.0.0',
true
);
// Mobile menu script
wp_enqueue_script(
'matreshka-mobile-menu',
get_template_directory_uri() . '/assets/js/mobile-menu.js',
array('jquery'),
'1.0.0',
true
);
// Floating cart button (not on cart/checkout pages)
if ( ! ( function_exists('is_cart') && is_cart() ) && ! ( function_exists('is_checkout') && is_checkout() ) ) {
wp_enqueue_script(
'matreshka-floating-cart',
get_template_directory_uri() . '/assets/js/floating-cart.js',
array('jquery'),
'1.0.1',
true
);
}
// Пробрасываем в JS базовый URL темы
wp_localize_script( 'matreshka-sliders', 'matreshka', array(
'themeUrl' => get_template_directory_uri(),
) );
// Localize script for AJAX - shared between add-to-cart and search
$ajax_data = array(
'ajax_url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'matreshka_add_to_cart_nonce' ),
'shop_url' => function_exists( 'wc_get_page_id' ) ? get_permalink( wc_get_page_id( 'shop' ) ) : '',
);
wp_localize_script( 'matreshka-add-to-cart', 'matreshka_ajax', $ajax_data );
wp_localize_script( 'matreshka-search', 'matreshka_ajax', $ajax_data );
// Localize script for Wishlist
wp_localize_script( 'matreshka-wishlist', 'matreshka_wishlist', array(
'nonce' => wp_create_nonce( 'matreshka-wishlist-nonce' ),
'like_icon' => get_template_directory_uri() . '/assets/icons/like.svg',
'heart_icon' => get_template_directory_uri() . '/assets/icons/Heart.svg',
) );
wp_localize_script( 'matreshka-wishlist', 'matreshka_ajax', $ajax_data );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'matreshka_scripts' );
/**
* Render the global page loader as early as possible after the opening body tag.
*/
function matreshka_render_page_loader() {
if ( is_admin() ) {
return;
}
?>
<div id="matreshka-page-loader" class="matreshka-page-loader active" role="status" aria-live="polite" aria-label="<?php esc_attr_e( 'Загружаем страницу', 'matreshka' ); ?>">
<div class="mcl-spinner" aria-hidden="true">
<div class="mcl-spinner-ring"></div>
<svg class="mcl-spinner-icon" viewBox="0 -960 960 960" focusable="false" aria-hidden="true">
<path fill="currentColor" d="M240-80q-33 0-56.5-23.5T160-160v-480q0-33 23.5-56.5T240-720h80q0-66 47-113t113-47q66 0 113 47t47 113h80q33 0 56.5 23.5T800-640v480q0 33-23.5 56.5T720-80H240Zm0-80h480v-480h-80v80q0 17-11.5 28.5T600-520q-17 0-28.5-11.5T560-560v-80H400v80q0 17-11.5 28.5T360-520q-17 0-28.5-11.5T320-560v-80h-80v480Zm160-560h160q0-33-23.5-56.5T480-800q-33 0-56.5 23.5T400-720Z" />
</svg>
</div>
<div class="mcl-text">
<p class="mcl-title"><?php esc_html_e( 'Загружаем страницу', 'matreshka' ); ?></p>
<p class="mcl-subtitle"><?php esc_html_e( 'Пожалуйста, подождите…', 'matreshka' ); ?></p>
</div>
</div>
<noscript><style>#matreshka-page-loader{display:none!important}</style></noscript>
<?php
}
add_action( 'wp_body_open', 'matreshka_render_page_loader', 1 );