-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
137 lines (111 loc) · 4.25 KB
/
functions.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
<?php
/**
* Lily Pad Consulting functions and definitions
*
* @link https://developer.wordpress.org/themes/basics/theme-functions/
*
* @package WordPress
* @subpackage Lily_Pad_Consulting
* @since 1.0.0
*/
/**
* Table of Contents:
* Theme Support
* Required Files
* Register Styles
* Register Scripts
* Register Menus
* Custom Logo
* WP Body Open
* Register Sidebars
* Enqueue Block Editor Assets
* Enqueue Classic Editor Styles
* Block Editor Settings
*/
/**
* Sets up theme defaults and registers support for various WordPress features.
*
* Note that this function is hooked into the after_setup_theme hook, which
* runs before the init hook. The init hook is too late for some features, such
* as indicating support for post thumbnails.
*/
function lilypadconsulting_theme_support() {
// Add default posts and comments RSS feed links to head.
add_theme_support( 'automatic-feed-links' );
// Custom logo.
$logo_width = 204;
$logo_height = 48;
// If the retina setting is active, double the recommended width and height.
if ( get_theme_mod( 'retina_logo', false ) ) {
$logo_width = floor( $logo_width * 2 );
$logo_height = floor( $logo_height * 2 );
}
add_theme_support(
'custom-logo',
array(
'height' => $logo_height,
'width' => $logo_width,
'flex-height' => true,
'flex-width' => true,
)
);
/*
* Let WordPress manage the document title.
* By adding theme support, we declare that this theme does not use a
* hard-coded <title> tag in the document head, and expect WordPress to
* provide it for us.
*/
add_theme_support( 'title-tag' );
}
add_action( 'after_setup_theme', 'lilypadconsulting_theme_support' );
/**
* Register and Enqueue Styles.
*/
function lilypadconsulting_register_styles() {
$theme_version = wp_get_theme()->get( 'Version' );
// Add Bootstrap CSS.
wp_enqueue_style( 'bootstrap-css', get_template_directory_uri() . '/assets/css/bootstrap/bootstrap.css' );
// Add Typekit CSS.
wp_enqueue_style( 'typekit-css', '//use.typekit.net/ejh1xue.css' );
wp_enqueue_style( 'lilypadconsulting-style', get_stylesheet_uri(), array(), $theme_version );
// // Add output of Customizer settings as inline style.
// wp_add_inline_style( 'lilypadconsulting-style', lilypadconsulting_get_customizer_css( 'front-end' ) );
// // Add print CSS.
// wp_enqueue_style( 'lilypadconsulting-print-style', get_template_directory_uri() . '/print.css', null, $theme_version, 'print' );
}
add_action( 'wp_enqueue_scripts', 'lilypadconsulting_register_styles' );
/**
* Register and Enqueue Scripts.
*/
function lilypadconsulting_register_scripts() {
$theme_version = wp_get_theme()->get( 'Version' );
// Add jQuery JS.
wp_enqueue_script( 'jquery-js', '//code.jquery.com/jquery-3.4.1.min.js' );
wp_script_add_data( 'jquery-js', 'async', true );
// Add Bootstrap JS.
wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/assets/js/bootstrap/bootstrap.js' );
wp_script_add_data( 'bootstrap-js', 'async', true );
if ( ( ! is_admin() ) && is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
wp_enqueue_script( 'lilypadconsulting-js', get_template_directory_uri() . '/assets/js/index.js', array(), $theme_version, false );
wp_script_add_data( 'lilypadconsulting-js', 'async', true );
}
add_action( 'wp_enqueue_scripts', 'lilypadconsulting_register_scripts' );
/**
* 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 lilypadconsulting_skip_link_focus_fix() {
// The following is minified via `terser --compress --mangle -- assets/js/skip-link-focus-fix.js`.
?>
<script>
/(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);
</script>
<?php
}
add_action( 'wp_print_footer_scripts', 'lilypadconsulting_skip_link_focus_fix' );