You've already forked wp-bootstrap
96 lines
2.8 KiB
PHP
96 lines
2.8 KiB
PHP
|
|
<?php
|
||
|
|
/**
|
||
|
|
* WP Bootstrap functions and definitions.
|
||
|
|
*
|
||
|
|
* @link https://developer.wordpress.org/themes/basics/theme-functions/
|
||
|
|
*
|
||
|
|
* @package WPBootstrap
|
||
|
|
* @since 0.0.1
|
||
|
|
*/
|
||
|
|
|
||
|
|
// Prevent direct access.
|
||
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
||
|
|
exit;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Load Composer autoloader.
|
||
|
|
if ( file_exists( get_template_directory() . '/vendor/autoload.php' ) ) {
|
||
|
|
require_once get_template_directory() . '/vendor/autoload.php';
|
||
|
|
}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Sets up theme defaults and registers support for various WordPress features.
|
||
|
|
*/
|
||
|
|
if ( ! function_exists( 'wp_bootstrap_setup' ) ) :
|
||
|
|
function wp_bootstrap_setup() {
|
||
|
|
// Add support for post formats.
|
||
|
|
add_theme_support( 'post-formats', array(
|
||
|
|
'aside', 'audio', 'chat', 'gallery', 'image',
|
||
|
|
'link', 'quote', 'status', 'video',
|
||
|
|
) );
|
||
|
|
|
||
|
|
// Make theme available for translation.
|
||
|
|
load_theme_textdomain( 'wp-bootstrap', get_template_directory() . '/languages' );
|
||
|
|
|
||
|
|
// Add editor styles.
|
||
|
|
add_editor_style( 'assets/css/editor-style.css' );
|
||
|
|
}
|
||
|
|
endif;
|
||
|
|
add_action( 'after_setup_theme', 'wp_bootstrap_setup' );
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Enqueue theme scripts and styles.
|
||
|
|
*/
|
||
|
|
if ( ! function_exists( 'wp_bootstrap_enqueue_scripts' ) ) :
|
||
|
|
function wp_bootstrap_enqueue_scripts() {
|
||
|
|
$theme_version = wp_get_theme()->get( 'Version' );
|
||
|
|
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||
|
|
|
||
|
|
// Enqueue the compiled Bootstrap + custom CSS.
|
||
|
|
wp_enqueue_style(
|
||
|
|
'wp-bootstrap-style',
|
||
|
|
get_template_directory_uri() . '/assets/css/style' . $suffix . '.css',
|
||
|
|
array(),
|
||
|
|
$theme_version
|
||
|
|
);
|
||
|
|
|
||
|
|
// Enqueue Bootstrap JS bundle (includes Popper).
|
||
|
|
wp_enqueue_script(
|
||
|
|
'wp-bootstrap-js',
|
||
|
|
get_template_directory_uri() . '/assets/js/bootstrap.bundle.min.js',
|
||
|
|
array(),
|
||
|
|
$theme_version,
|
||
|
|
true
|
||
|
|
);
|
||
|
|
}
|
||
|
|
endif;
|
||
|
|
add_action( 'wp_enqueue_scripts', 'wp_bootstrap_enqueue_scripts' );
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Register block pattern categories.
|
||
|
|
*/
|
||
|
|
if ( ! function_exists( 'wp_bootstrap_pattern_categories' ) ) :
|
||
|
|
function wp_bootstrap_pattern_categories() {
|
||
|
|
register_block_pattern_category(
|
||
|
|
'wp-bootstrap_page',
|
||
|
|
array(
|
||
|
|
'label' => __( 'Pages', 'wp-bootstrap' ),
|
||
|
|
'description' => __( 'A collection of full page layouts.', 'wp-bootstrap' ),
|
||
|
|
)
|
||
|
|
);
|
||
|
|
}
|
||
|
|
endif;
|
||
|
|
add_action( 'init', 'wp_bootstrap_pattern_categories' );
|
||
|
|
|
||
|
|
/**
|
||
|
|
* Initialize Twig template engine.
|
||
|
|
*/
|
||
|
|
if ( ! function_exists( 'wp_bootstrap_init_twig' ) ) :
|
||
|
|
function wp_bootstrap_init_twig() {
|
||
|
|
if ( class_exists( '\\WPBootstrap\\Twig\\TwigService' ) ) {
|
||
|
|
\WPBootstrap\Twig\TwigService::getInstance();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
endif;
|
||
|
|
add_action( 'after_setup_theme', 'wp_bootstrap_init_twig' );
|