tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
/**
* Default custom header.
*/
add_theme_support( 'custom-header' );
/**
* Default custom backgrounds.
*/
add_theme_support( 'custom-background' );
/*
* Enable support for Post Thumbnails on posts and pages.
*
* @link https://developer.wordpress.org/themes/functionality/featured-images-post-thumbnails/
*/
add_theme_support( 'post-thumbnails' );
/*
* Enable support for wide images on Gutenberg.
*
*/
add_theme_support( 'align-wide' );
// This theme uses wp_nav_menu() in one location.
register_nav_menus(
array(
'menu-1' => esc_html__( 'Primary', 'billow' ),
'menu-2' => esc_html__( 'Mobile Menu (Optional)', 'billow' ),
)
);
/*
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
'style',
'script',
)
);
// Set up the WordPress core custom background feature.
add_theme_support(
'custom-background',
apply_filters(
'billow_custom_background_args',
array(
'default-color' => 'ffffff',
'default-image' => '',
)
)
);
// Add theme support for selective refresh for widgets.
add_theme_support( 'customize-selective-refresh-widgets' );
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support(
'custom-logo',
array(
'height' => 250,
'width' => 250,
'flex-width' => true,
'flex-height' => true,
)
);
}
endif;
add_action( 'after_setup_theme', 'billow_setup' );
/**
* Set the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width // phpcs:ignore WPThemeReview.CoreFunctionality.PrefixAllGlobals.NonPrefixedVariableFound
*/
function billow_content_width() {
// This variable is intended to be overruled from themes.
// Open WPCS issue: {@link https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards/issues/1043}.
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
$GLOBALS['content_width'] = apply_filters( 'billow_content_width', 640 ); // phpcs:ignore WPThemeReview.CoreFunctionality.PrefixAllGlobals.NonPrefixedVariableFound
}
add_action( 'after_setup_theme', 'billow_content_width', 0 );
/**
* Register widget area.
*
* @link https://developer.wordpress.org/themes/functionality/sidebars/#registering-a-sidebar
*/
function billow_sidebars_widgets_init() {
register_sidebar(
array(
'name' => esc_html__( 'Sidebar', 'billow' ),
'id' => 'sidebar-1',
'description' => esc_html__( 'Add widgets here.', 'billow' ),
'before_widget' => '',
'before_title' => '
',
)
);
}
add_action( 'widgets_init', 'billow_sidebars_widgets_init' );
/**
* Enqueue scripts and styles.
*/
function billow_scripts() {
wp_enqueue_style( 'billow-style', get_stylesheet_uri(), array() );
wp_enqueue_style( 'billow-fontawesome-all-css', get_stylesheet_uri() . 'inc/customizer/custom-controls/css/fontawesome-all.min.css', array(), '5.15.4', 'all' );
wp_style_add_data( 'billow-style', 'rtl', 'replace' );
wp_enqueue_script( 'billow-main', get_template_directory_uri() . '/js/main.js', array( 'jquery' ), filemtime( get_template_directory() . '/js/main.js' ) );
wp_enqueue_script( 'billow-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '1.0.0', true );
wp_enqueue_script( 'billow-preloader', get_template_directory_uri() . '/js/preloader.js', array(), '1.0.0', true );
wp_enqueue_script( 'billow-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js' );
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
}
add_action( 'wp_enqueue_scripts', 'billow_scripts' );
/*
* Enqueue Font Awesome 5
*/
function billow_load_fontawesome() {
wp_enqueue_style( 'billow-fontawesome-free-css', 'https://use.fontawesome.com/releases/v5.15.4/css/all.css' );
}
add_action( 'wp_enqueue_scripts', 'billow_load_fontawesome' );
/**
* Font Awesome CDN Setup Webfont
*
* This will load Font Awesome from the Font Awesome Free or Pro CDN.
*/
if ( ! function_exists( 'billow_fontawesome_cdn_webfont' ) ) {
function billow_fontawesome_cdn_webfont( $cdn_url = '', $integrity = null ) {
$matches = [];
$match_result = preg_match( '|/([^/]+?)\.css$|', $cdn_url, $matches );
$resource_handle_uniqueness = ( $match_result === 1 ) ? $matches[1] : md5( $cdn_url );
$resource_handle = "font-awesome-cdn-webfont-$resource_handle_uniqueness";
foreach ( [ 'wp_enqueue_scripts', 'admin_enqueue_scripts', 'login_enqueue_scripts' ] as $action ) {
add_action(
$action,
function () use ( $cdn_url, $resource_handle ) {
wp_enqueue_style( $resource_handle, $cdn_url, [], null );
}
);
}
if( $integrity ) {
add_filter(
'style_loader_tag',
function( $html, $handle ) use ( $resource_handle, $integrity ) {
if ( in_array( $handle, [ $resource_handle ], true ) ) {
return preg_replace(
'/\/>$/',
'integrity="' . $integrity .
'" crossorigin="anonymous" />',
$html,
1
);
} else {
return $html;
}
},
10,
2
);
}
}
}
billow_fontawesome_cdn_webfont(
'https://use.fontawesome.com/releases/v5.15.4/css/all.css',
'sha384-DyZ88mC6Up2uqS4h/KRgHuoeGwBcD4Ng9SiP4dIRy0EXTlnuz47vAwmeGwVChigm'
);
/**
* Admin and Editor Styling.
*/
function billow_editor_scripts() {
$editor_style_path = '/editor-styles.css';
wp_enqueue_style(
'billow-editor-style',
get_template_directory_uri() . $editor_style_path,
array(),
filemtime( get_template_directory() . $editor_style_path )
);
}
add_action( 'enqueue_block_editor_assets', 'billow_editor_scripts' );
/**
* Main Theme File: Contains most theme-related functionality.
*/
require_once get_theme_file_path('inc/theme.php');
/**
* Implement the Custom Header feature.
*/
require get_template_directory() . '/inc/custom-header.php';
/**
* Custom template tags for this theme.
*/
require get_template_directory() . '/inc/template-tags.php';
/**
* Functions which enhance the theme by hooking into WordPress.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Customizer additions.
*/
require get_template_directory() . '/inc/customizer.php';
/**
* Load Widgets.
*/
require get_template_directory() . '/inc/widgets.php';
/**
* This is temporary, not sure where.
*/
require get_template_directory() . '/inc/body_classes.php';
/**
* Load WooCommerce compatibility file.
*/
if ( function_exists( 'is_woocommerce' ) ) {
require get_template_directory() . '/inc/woocommerce.php';
}
/**
* Load Customizer styles to wp_head.
*/
if ( ! function_exists( 'billow_load_customizer_styles' ) ) {
function billow_load_customizer_styles() {
require trailingslashit( get_template_directory() ) . '/template-parts/customizer-styles.php';
}
add_action( 'wp_head', 'billow_load_customizer_styles', 9999 );
}
/**
* Load Jetpack compatibility file.
*/
function billow_footer_widgets_init() {
register_sidebar(
array(
'name' => esc_html_x( 'Footer Widgets', 'Admin', 'billow' ),
'id' => 'billow-footer',
'description' => esc_html_x( 'Add three widgets for the footer area. (Optional)', 'Admin', 'billow' ),
'before_title' => '',
'before_widget' => '',
'after_widget' => ''
)
);
}
add_action( 'widgets_init', 'billow_footer_widgets_init' );
/**
* Fix skip link focus in IE11.
*
* This does not enqueue the script because it is tiny and because it is only for IE11,
* thus it does not warrant having an entire dedicated blocking script being loaded.
*
* @link https://git.io/vWdr2
*/
function billow_skip_link_focus_fix() {
// The following is minified via `terser --compress --mangle -- assets/js/skip-link-focus-fix.js`.
?>