-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
240 lines (164 loc) · 4.63 KB
/
functions.php
File metadata and controls
240 lines (164 loc) · 4.63 KB
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
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<?php
/**
* Genesis Custom.
*
* This file adds functions to the Genesis Custom Theme.
*
* @package Genesis Custom
* @author Daniel Bissinger
* @license GPL-2.0+
* @link https://danielbissinger.com/
*/
/**********************
INCLUDES
**********************/
//* Load Genesis Framework
require_once get_template_directory() . '/lib/init.php';
//* Load theme functions
require_once get_stylesheet_directory() . '/lib/cleanup.php';
require_once get_stylesheet_directory() . '/lib/functionality.php';
/**********************
WORDPRESS
**********************/
//* Setup localization
add_action( 'after_setup_theme', 'genesis_custom_localization_setup', 9 );// Prio 9 so textdomain loads before genesis functions
function genesis_custom_localization_setup() {
load_child_theme_textdomain( 'genesis-custom', get_stylesheet_directory() . '/languages' );
}
//* Set the content width based on the theme's design and stylesheet.
if ( ! isset( $content_width ) ) {
$content_width = 702; // Pixels.
}
//* Add support for HTML5 markup structure.
add_theme_support(
'html5', array(
'caption',
'comment-form',
'comment-list',
'gallery',
'search-form',
)
);
//* Add custom logo in Customizer > Site Identity.
add_theme_support(
'custom-logo', array(
'flex-width' => true,
'flex-height' => true,
)
);
//* Add WP 5.0 alignwide and alignfull support
add_theme_support( 'align-wide' );
add_filter( 'upload_mimes', 'genesis_custom_svg_support' );
function genesis_custom_svg_support($mimes) {
if( current_user_can( 'manage_options' ) ) {
$mimes['svg'] = 'image/svg+xml';
}
return $mimes;
}
/**********************
GENESIS
**********************/
//* Add viewport meta tag for mobile browsers.
add_theme_support(
'genesis-responsive-viewport'
);
//* Add support for accessibility features.
add_theme_support(
'genesis-accessibility', array(
'404-page',
// 'drop-down-menu',// This enqueues hoverIntent/superFish
'headings',
'search-form',
'skip-links',
)
);
//* Add support for structural wraps.
add_theme_support(
'genesis-structural-wraps', array(
'header',
// 'menu-primary',
// 'menu-secondary',
// 'footer-widgets',
'footer'
)
);
/**********************
GENERAL
**********************/
//* Google Fonts
add_action( 'wp_enqueue_scripts', 'genesis_custom_add_google_fonts' );
function genesis_custom_add_google_fonts() {
wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Fira+Sans:400');
}
/**********************
HEADER
**********************/
//* Display the custom logo.
add_action( 'genesis_site_title', 'the_custom_logo', 0 );
//* Add responsive menu script.
add_action( 'wp_enqueue_scripts', 'genesis_custom_add_menu_script' );
function genesis_custom_add_menu_script() {
wp_enqueue_script(
'genesis-custom-menu',
get_stylesheet_directory_uri() . "/js/menu.js",
array(),
false,
true
);
}
//* Rename primary and remove secondary navigation menu.
add_action( 'after_setup_theme', 'genesis_custom_menus', 9 );// Prio 9 so it runs before genesis registers menus
function genesis_custom_menus() {
add_theme_support(
'genesis-menus', array(
'primary' => __( 'Main Menu', 'genesis-custom' ),
)
);
}
//* Force primary navigation to one level depth.
// add_filter( 'wp_nav_menu_args', 'genesis_custom_primary_menu_depth' );
function genesis_custom_primary_menu_depth( $args ) {
if ( 'primary' !== $args['theme_location'] ) {
return $args;
}
$args['depth'] = 1;
return $args;
}
//* Reposition primary navigation menu.
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_header', 'genesis_do_nav', 12 );
//* Add toggle button markup to primary navigation menu.
add_filter( 'genesis_markup_nav-primary_open', 'genesis_custom_menu_add_toggle', 10, 2 );
function genesis_custom_menu_add_toggle( $open, $args ) {
ob_start();
?>
<button
class="menu-toggle"
id="nav-primary-toggle"
aria-hidden="true">
<span class="menu-toggle-box">
<span class="menu-toggle-inner">
</span>
</span>
</button>
<?php
return $open.ob_get_clean();
}
//* Force 'primary-menu' element id.
// add_filter( 'wp_nav_menu_args', 'genesis_custom_force_primary_menu_id' );
function genesis_custom_force_primary_menu_id( $args ) {
if( $args[ 'theme_location' ] == 'primary' ) {
$args[ 'menu_id' ] = 'primary-menu';
}
return $args;
}
/**********************
FOOTER
**********************/
//* Add footer widget areas
// add_theme_support( 'genesis-footer-widgets', 3 );
// //* Override footer creds text
// add_filter( 'genesis_footer_creds_text', 'genesis_custom_footer_creds' );
// function genesis_custom_footer_creds( $creds ) {
// return $creds;
// }