288 lines
13 KiB
PHP
288 lines
13 KiB
PHP
<?php
|
||
/**
|
||
* БИТ.WMS Child Theme — functions.php
|
||
*
|
||
* Bootstraps the child theme: enqueues parent GeneratePress styles,
|
||
* enqueues the child theme stylesheet, and loads include files.
|
||
*
|
||
* @package bitwms-child
|
||
* @version 1.0.0
|
||
*/
|
||
|
||
if ( ! defined( 'ABSPATH' ) ) {
|
||
exit; // Prevent direct access.
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 1. Enqueue parent + child styles
|
||
// ---------------------------------------------------------------------------
|
||
|
||
add_action( 'wp_enqueue_scripts', 'bitwms_child_enqueue_styles' );
|
||
|
||
function bitwms_child_enqueue_styles() {
|
||
// Parent GeneratePress stylesheet.
|
||
wp_enqueue_style(
|
||
'generatepress-style',
|
||
get_template_directory_uri() . '/style.css',
|
||
array(),
|
||
wp_get_theme( 'generatepress' )->get( 'Version' )
|
||
);
|
||
|
||
// Child theme stylesheet — depends on parent.
|
||
wp_enqueue_style(
|
||
'bitwms-child-style',
|
||
get_stylesheet_uri(),
|
||
array( 'generatepress-style' ),
|
||
wp_get_theme()->get( 'Version' )
|
||
);
|
||
}
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 2. Load include files
|
||
// ---------------------------------------------------------------------------
|
||
|
||
$bitwms_includes = array(
|
||
'inc/enqueue.php',
|
||
'inc/cpt.php',
|
||
'inc/acf-fields.php',
|
||
'inc/ajax-filter.php',
|
||
);
|
||
|
||
foreach ( $bitwms_includes as $bitwms_file ) {
|
||
$bitwms_path = get_stylesheet_directory() . '/' . $bitwms_file;
|
||
if ( file_exists( $bitwms_path ) ) {
|
||
require_once $bitwms_path;
|
||
}
|
||
}
|
||
unset( $bitwms_file, $bitwms_path );
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 3. Inject sidebar navigation before the GeneratePress header
|
||
// ---------------------------------------------------------------------------
|
||
|
||
add_action( 'generate_before_header', function () {
|
||
get_template_part( 'templates/sidebar-nav' );
|
||
} );
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 4. Inject top header bar (priority 20 — after sidebar at default/10)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
add_action( 'generate_before_header', function () {
|
||
get_template_part( 'templates/top-header' );
|
||
}, 20 );
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 5. Custom footer (before GeneratePress footer, priority 5)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
add_action( 'generate_before_footer_content', function () {
|
||
$theme_uri = get_stylesheet_directory_uri();
|
||
$current_year = gmdate( 'Y' );
|
||
?>
|
||
<div class="custom-footer">
|
||
<div class="container">
|
||
<div class="custom-footer__grid">
|
||
|
||
<!-- Col 1: Logo + contacts -->
|
||
<div class="custom-footer__col custom-footer__col--brand">
|
||
<a href="/" class="custom-footer__logo-link" aria-label="<?php esc_attr_e( 'БИТ.WMS — на главную', 'bitwms-child' ); ?>">
|
||
<img
|
||
src="<?php echo esc_url( $theme_uri . '/img/logo.svg' ); ?>"
|
||
alt="<?php esc_attr_e( 'БИТ.WMS', 'bitwms-child' ); ?>"
|
||
width="140"
|
||
height="40"
|
||
class="custom-footer__logo"
|
||
loading="lazy"
|
||
>
|
||
</a>
|
||
<address class="custom-footer__address">
|
||
<p><?php esc_html_e( 'г. Екатеринбург, ул. Хохрякова, 10, оф. 405', 'bitwms-child' ); ?></p>
|
||
<p>
|
||
<a href="<?php echo esc_url( 'tel:+73432000000' ); ?>">
|
||
<?php esc_html_e( '+7 (343) 200-00-00', 'bitwms-child' ); ?>
|
||
</a>
|
||
</p>
|
||
<p>
|
||
<a href="<?php echo esc_url( 'mailto:wms@1bit.ru' ); ?>">
|
||
<?php esc_html_e( 'wms@1bit.ru', 'bitwms-child' ); ?>
|
||
</a>
|
||
</p>
|
||
</address>
|
||
</div>
|
||
|
||
<!-- Col 2: Разделы -->
|
||
<div class="custom-footer__col custom-footer__col--sections">
|
||
<h4><?php esc_html_e( 'Разделы', 'bitwms-child' ); ?></h4>
|
||
<ul>
|
||
<li><a href="<?php echo esc_url( '/cases/' ); ?>"><?php esc_html_e( 'Кейсы', 'bitwms-child' ); ?></a></li>
|
||
<li><a href="<?php echo esc_url( '/articles/' ); ?>"><?php esc_html_e( 'Статьи', 'bitwms-child' ); ?></a></li>
|
||
<li><a href="<?php echo esc_url( '/webinars/' ); ?>"><?php esc_html_e( 'Вебинары', 'bitwms-child' ); ?></a></li>
|
||
<li><a href="<?php echo esc_url( '/courses/' ); ?>"><?php esc_html_e( 'Курсы', 'bitwms-child' ); ?></a></li>
|
||
<li><a href="<?php echo esc_url( '/events/' ); ?>"><?php esc_html_e( 'Мероприятия', 'bitwms-child' ); ?></a></li>
|
||
<li><a href="<?php echo esc_url( '/materials/' ); ?>"><?php esc_html_e( 'Материалы', 'bitwms-child' ); ?></a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<!-- Col 3: Продукты -->
|
||
<div class="custom-footer__col custom-footer__col--products">
|
||
<h4><?php esc_html_e( 'Продукты', 'bitwms-child' ); ?></h4>
|
||
<ul>
|
||
<li><a href="<?php echo esc_url( '/bitwms/' ); ?>"><?php esc_html_e( 'БИТ.WMS', 'bitwms-child' ); ?></a></li>
|
||
<li><a href="<?php echo esc_url( '/1c-wms/' ); ?>"><?php esc_html_e( '1C:WMS', 'bitwms-child' ); ?></a></li>
|
||
<li><a href="<?php echo esc_url( '/cleverence/' ); ?>"><?php esc_html_e( 'Клеверенс', 'bitwms-child' ); ?></a></li>
|
||
<li><a href="<?php echo esc_url( '/1c-tms/' ); ?>"><?php esc_html_e( '1C:TMS', 'bitwms-child' ); ?></a></li>
|
||
</ul>
|
||
</div>
|
||
|
||
<!-- Col 4: Подписка -->
|
||
<div class="custom-footer__col custom-footer__col--subscribe">
|
||
<h4><?php esc_html_e( 'Подписка', 'bitwms-child' ); ?></h4>
|
||
<p class="custom-footer__subscribe-desc">
|
||
<?php esc_html_e( 'Получайте новые материалы на email', 'bitwms-child' ); ?>
|
||
</p>
|
||
<form class="footer-subscribe" method="post" action="<?php echo esc_url( admin_url( 'admin-post.php' ) ); ?>" novalidate>
|
||
<?php wp_nonce_field( 'bitwms_footer_subscribe', 'bitwms_subscribe_nonce' ); ?>
|
||
<input type="hidden" name="action" value="bitwms_footer_subscribe">
|
||
<input
|
||
type="email"
|
||
name="subscribe_email"
|
||
class="footer-subscribe__input"
|
||
placeholder="<?php esc_attr_e( 'ваш@email.ru', 'bitwms-child' ); ?>"
|
||
required
|
||
autocomplete="email"
|
||
aria-label="<?php esc_attr_e( 'Email для подписки', 'bitwms-child' ); ?>"
|
||
>
|
||
<button type="submit" class="btn btn--primary btn--sm footer-subscribe__btn">
|
||
<?php esc_html_e( 'OK', 'bitwms-child' ); ?>
|
||
</button>
|
||
</form>
|
||
</div>
|
||
|
||
</div><!-- .custom-footer__grid -->
|
||
|
||
<div class="custom-footer__bottom">
|
||
<p>© <?php echo esc_html( $current_year ); ?> <?php esc_html_e( 'Первый Бит. Все права защищены.', 'bitwms-child' ); ?></p>
|
||
<div class="custom-footer__legal">
|
||
<a href="<?php echo esc_url( '/privacy-policy/' ); ?>">
|
||
<?php esc_html_e( 'Политика конфиденциальности', 'bitwms-child' ); ?>
|
||
</a>
|
||
<a href="<?php echo esc_url( '/consent/' ); ?>">
|
||
<?php esc_html_e( 'Согласие на обработку данных', 'bitwms-child' ); ?>
|
||
</a>
|
||
</div>
|
||
</div><!-- .custom-footer__bottom -->
|
||
|
||
</div><!-- .container -->
|
||
</div><!-- .custom-footer -->
|
||
<?php
|
||
}, 5 );
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 6. Gated content modal (rendered in footer, priority 50)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
add_action( 'wp_footer', function () {
|
||
?>
|
||
<div id="gated-modal" class="gated-modal">
|
||
<div class="gated-modal__overlay"></div>
|
||
<div class="gated-modal__content">
|
||
<button class="gated-modal__close" aria-label="Закрыть">×</button>
|
||
<h3>Скачать материал</h3>
|
||
<p>Укажите ваши данные для получения доступа к материалу</p>
|
||
<!-- CF7 shortcode will be added here after form creation in admin -->
|
||
<!-- echo do_shortcode('[contact-form-7 id="XXX" title="Скачать материал"]'); -->
|
||
<form class="gated-form" action="#" method="post">
|
||
<input type="hidden" name="material-id" value="" />
|
||
<input type="text" name="name" placeholder="Имя *" required />
|
||
<input type="email" name="email" placeholder="Email *" required />
|
||
<label class="demo-form__consent">
|
||
<input type="checkbox" required />
|
||
Согласен на <a href="/privacy-policy/" target="_blank">обработку персональных данных</a>
|
||
</label>
|
||
<button type="submit" class="btn btn-primary">Скачать</button>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
<?php
|
||
}, 50 );
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 6. Popup Maker — настраивается в админке WP > Popup Maker > Add New
|
||
// ---------------------------------------------------------------------------
|
||
|
||
/**
|
||
* Popup Maker — настраивается в админке WP > Popup Maker > Add New:
|
||
*
|
||
* 1. Попап "Exit-intent — Подписка":
|
||
* - Содержимое: подписка на рассылку
|
||
* - Триггер: Exit Intent
|
||
* - Условия: все страницы
|
||
* - Показывать 1 раз за сессию
|
||
*
|
||
* 2. Попап "Таймер — Демо":
|
||
* - Содержимое: предложение демо БИТ.WMS
|
||
* - Триггер: Time Delay 60 сек
|
||
* - Условия: только страница БИТ.WMS
|
||
* - Показывать 1 раз за сессию
|
||
*/
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 7. JivoSite widget (placeholder — подставить реальный widget_id)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
add_action( 'wp_footer', function () {
|
||
?>
|
||
<!-- JivoSite — подставить реальный widget_id -->
|
||
<!-- <script src="//code.jivo.ru/widget/XXXXXXXX" async></script> -->
|
||
<?php
|
||
}, 99 );
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 8. Callback widget (placeholder — подставить реальный код виджета)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
add_action( 'wp_footer', function () {
|
||
?>
|
||
<!-- Callback Widget — подставить реальный код виджета -->
|
||
<!-- <script src="https://cdn.callbackhunter.com/XXXXX.js" async></script> -->
|
||
<?php
|
||
}, 99 );
|
||
|
||
// ---------------------------------------------------------------------------
|
||
// 9. Analytics — Яндекс.Метрика + GA4 (placeholder — подставить реальные ID)
|
||
// ---------------------------------------------------------------------------
|
||
|
||
add_action( 'wp_head', function () {
|
||
?>
|
||
<!-- Yandex.Metrika — подставить реальный ID счётчика -->
|
||
<!--
|
||
<script type="text/javascript">
|
||
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
||
m[i].l=1*new Date();
|
||
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
|
||
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
||
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
||
ym(XXXXXXXX, "init", {
|
||
clickmap:true,
|
||
trackLinks:true,
|
||
accurateTrackBounce:true,
|
||
webvisor:true
|
||
});
|
||
</script>
|
||
<noscript><div><img src="https://mc.yandex.ru/watch/XXXXXXXX" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
|
||
-->
|
||
|
||
<!-- Google Analytics 4 — подставить реальный ID GA4 -->
|
||
<!--
|
||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
|
||
<script>
|
||
window.dataLayer = window.dataLayer || [];
|
||
function gtag(){dataLayer.push(arguments);}
|
||
gtag('js', new Date());
|
||
gtag('config', 'G-XXXXXXXXXX');
|
||
</script>
|
||
-->
|
||
<?php
|
||
}, 1 );
|