Files
bit-wms-site/wp-content/themes/bitwms-child/functions.php
T

74 lines
2.2 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 );