/
theme-setup.php
executable file
·212 lines (189 loc) · 5.7 KB
/
theme-setup.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
<?php
/**
* This file contains theme setup such as sidebars, widgets, enqueing, etc.
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WordPress
* @subpackage Basetheme
* @since 1.0
* @version 2.7
*/
/**
* Set the content width.
*/
if ( ! isset( $content_width ) ) {
$content_width = 960;
}
if ( ! function_exists( 'bt_setup' ) ) {
/**
* Setup scripts, sidebars, menus, etc.
*/
function bt_setup() {
/**
* Text domain
*/
load_theme_textdomain( 'basetheme', get_template_directory() . '/languages' );
/**
* Match the default post thumbnail size to the $content_width.
* Add additional image sizes here if desired.
*/
global $content_width;
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( $content_width, 9999, false );
// add_image_size( 'another-image-size', '250', '250', true );
/**
* Class to handle bootstrap-style breadacrumbs.
* You can modify this class as needed if using breadcrumbs on this site.
*
* Usage:
* $breadcrumbs = new Bootstrap_Breadcrumbs();
* echo $breadcrumbs->bootstrap_breadcrumb();
*/
require_once get_template_directory() . '/lib/class-wp-bootstrap-breadcrumbs.php';
/**
* Bootstrap Nav Walker
*/
require_once get_template_directory() . '/lib/class-wp-bootstrap-navwalker.php';
/**
* Register a main, utility and footer nav.
* Consider disabling utility navigation if not in use.
*/
register_nav_menus(
array(
'site-header-utility-nav' => esc_attr__( 'Utility Navigation', 'basetheme' ),
'site-header-main-nav' => esc_attr__( 'Main Navigation', 'basetheme' ),
'site-footer-main-nav' => esc_attr__( 'Footer Navigation', 'basetheme' ),
)
);
/**
* Add HTML5 theme support.
*/
add_theme_support(
'html5',
array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
)
);
/**
* Post Formats example. Not in use.
* add_theme_support( 'post-formats', array('aside', 'image', 'video', 'quote', 'link', 'gallery', 'status', 'audio', 'chat') );
*/
/**
* Add Automatic Feed Links.
*/
add_theme_support( 'automatic-feed-links' );
/**
* WordPress should handle <title></title>, not our header.php.
*/
add_theme_support( 'title-tag' );
}
}
add_action( 'after_setup_theme', 'bt_setup' );
if ( ! function_exists( 'bt_widgets_init' ) ) {
/**
* Register widgetized areas.
*/
function bt_widgets_init() {
register_sidebar(
array(
'name' => esc_attr__( 'Blog Sidebar Widget Area', 'basetheme' ),
'id' => 'blog-sidebar-widget-area',
'description' => esc_attr__( 'The blog widget area', 'basetheme' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
)
);
register_sidebar(
array(
'name' => esc_attr__( 'Page Sidebar Widget Area', 'basetheme' ),
'id' => 'page-sidebar-widget-area',
'description' => esc_attr__( 'The page widget area', 'basetheme' ),
'before_widget' => '<li id="%1$s" class="widget-container %2$s">',
'after_widget' => '</li>',
'before_title' => '<h4 class="widget-title">',
'after_title' => '</h4>',
)
);
}
}
add_action( 'widgets_init', 'bt_widgets_init' );
if ( ! function_exists( 'bt_fonts' ) ) {
/**
* Enqueue fonts by adding URLs to the $fonts array.
* Use a single function because these will load in the admin and front-end.
* Call this function from your enqueue functions.
*/
function bt_fonts() {
/**
* An array of URLs.
*/
$fonts = array(
// 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,600,600i&display=swap',
);
if ( ! empty( $fonts ) ) {
$i = 1;
foreach ( $fonts as $url ) {
wp_enqueue_style( 'bt-fonts-' . $i, $url, array(), '1.0' );
$i++;
}
}
}
}
if ( ! function_exists( 'bt_enqueue' ) ) {
/**
* Enqueue scripts and styles.
*/
function bt_enqueue() {
/**
* Enqueue fonts. Add wp_enqueue_style lines above.
*/
bt_fonts();
wp_enqueue_style( 'bt-base-style', get_template_directory_uri() . '/dist/css/style.css', array(), '1.0' );
/**
* Use latest jQuery.
*/
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', get_template_directory_uri() . '/dist/js/jquery.min.js', array(), '3.4.1', false );
wp_enqueue_script( 'jquery' );
/**
* Previously, Gravity Forms would throw an error without jQuery Migrate.
* That doesn't seem to be the case any longer? Leaving this comment here until it's confirmed there are no issues.
*/
// wp_enqueue_script( 'jquery-migrate' );
/**
* Enqueue comment-reply script if needed.
*/
if ( is_singular() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
/**
* Enqueue scripts in head.
* This is a concatinated, minified file of scripts from ./src/js/head/
*/
wp_enqueue_script( 'bt-head', get_template_directory_uri() . '/dist/js/head.min.js', array(), '1.0', false );
/**
* Enqueue scripts in footer.
* This is a concatinated, minified file of scripts from ./src/js/footer/
*/
wp_enqueue_script( 'bt-scripts', get_template_directory_uri() . '/dist/js/scripts.min.js', array(), '1.0', true );
}
}
add_action( 'wp_enqueue_scripts', 'bt_enqueue' );
if ( ! function_exists( 'bt_enqueue_block_editor_assets' ) ) {
/**
* Enqueue scripts and styles in admin.
*/
function bt_enqueue_block_editor_assets() {
// Enqueue fonts.
bt_fonts();
wp_enqueue_style( 'bt-editor-styles', get_template_directory_uri() . '/dist/css/editor-styles.css', null, '1.0' );
}
}
add_action( 'enqueue_block_editor_assets', 'bt_enqueue_block_editor_assets' );