-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
executable file
·239 lines (195 loc) · 5.85 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
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
231
232
233
234
235
236
237
238
239
<?php
/**
* ChurchPress Genesis Starter.
*
* This file adds functions to the ChurchPress Genesis Starter Theme.
*
* @package ChurchPress Genesis Starter
* @author ChurchPress
* @license GPL-3.0+
* @link https://ChurchPress.co
*/
// Starts the engine.
require_once get_template_directory() . '/lib/init.php';
add_action( 'after_setup_theme', 'genesis_sample_localization_setup' );
/**
* Sets localization (do not remove).
*
* @since 1.0.0
*/
function genesis_sample_localization_setup() {
load_child_theme_textdomain( 'cp-genesis-starter', get_stylesheet_directory() . '/languages' );
}
// Defines the child theme (do not remove).
define( 'CHILD_THEME_NAME', 'ChurchPress Genesis Starter' );
define( 'CHILD_THEME_URL', 'https://ChurchPress.co' );
define( 'CHILD_THEME_VERSION', '1.0.0' );
add_action( 'init', 'cp_includes' );
/**
* Load additional functions and helpers (/includes/*)
*/
function cp_includes() {
$includes_dir = get_stylesheet_directory() . '/lib';
//* Load required theme files in the includes directory.
foreach ( glob( $includes_dir . '/*.php' ) as $file ) {
require_once $file;
}
//* Load required files in subdirectories of the includes directory.
foreach ( glob( $includes_dir . '/*/*.php' ) as $file ) {
require_once $file;
}
}
/**
* Defines responsive menu settings.
*
* @since 2.3.0
*/
function genesis_sample_responsive_menu_settings() {
$settings = array(
'mainMenu' => __( 'Menu', 'cp-genesis-starter' ),
'menuIconClass' => 'dashicons-before dashicons-menu',
'subMenu' => __( 'Submenu', 'cp-genesis-starter' ),
'subMenuIconClass' => 'dashicons-before dashicons-arrow-down-alt2',
'menuClasses' => array(
'combine' => array(
'.nav-primary',
),
'others' => array(),
),
);
return $settings;
}
// Sets the content width based on the theme's design and stylesheet.
if ( ! isset( $content_width ) ) {
$content_width = 702; // Pixels.
}
// Adds support for HTML5 markup structure.
add_theme_support(
'html5', array(
'caption',
'comment-form',
'comment-list',
'gallery',
'search-form',
)
);
// Adds support for accessibility.
add_theme_support(
'genesis-accessibility', array(
'404-page',
'drop-down-menu',
'headings',
'rems',
'search-form',
'skip-links',
)
);
// Adds viewport meta tag for mobile browsers.
add_theme_support(
'genesis-responsive-viewport'
);
// Adds custom logo in Customizer > Site Identity.
add_theme_support(
'custom-logo', array(
'height' => 120,
'width' => 700,
'flex-height' => true,
'flex-width' => true,
)
);
// Renames primary and secondary navigation menus.
add_theme_support(
'genesis-menus', array(
'primary' => __( 'Header Menu', 'cp-genesis-starter' ),
'secondary' => __( 'Footer Menu', 'cp-genesis-starter' ),
)
);
// Adds support for after entry widget.
add_theme_support( 'genesis-after-entry-widget-area' );
// Adds support for 3-column footer widgets.
add_theme_support( 'genesis-footer-widgets', 3 );
// Removes header right widget area.
unregister_sidebar( 'header-right' );
// Removes secondary sidebar.
unregister_sidebar( 'sidebar-alt' );
// Removes site layouts.
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
// Removes output of primary navigation right extras.
remove_filter( 'genesis_nav_items', 'genesis_nav_right', 10, 2 );
remove_filter( 'wp_nav_menu_items', 'genesis_nav_right', 10, 2 );
add_action( 'genesis_theme_settings_metaboxes', 'genesis_sample_remove_metaboxes' );
/**
* Removes output of unused admin settings metaboxes.
*
* @since 2.6.0
*
* @param string $_genesis_admin_settings The admin screen to remove meta boxes from.
*/
function genesis_sample_remove_metaboxes( $_genesis_admin_settings ) {
remove_meta_box( 'genesis-theme-settings-header', $_genesis_admin_settings, 'main' );
remove_meta_box( 'genesis-theme-settings-nav', $_genesis_admin_settings, 'main' );
}
add_filter( 'genesis_customizer_theme_settings_config', 'genesis_sample_remove_customizer_settings' );
/**
* Removes output of header settings in the Customizer.
*
* @since 2.6.0
*
* @param array $config Original Customizer items.
* @return array Filtered Customizer items.
*/
function genesis_sample_remove_customizer_settings( $config ) {
unset( $config['genesis']['sections']['genesis_header'] );
return $config;
}
// Displays custom logo.
add_action( 'genesis_site_title', 'the_custom_logo', 0 );
// Repositions primary navigation menu.
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_header', 'genesis_do_nav', 12 );
// Repositions the secondary navigation menu.
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_footer', 'genesis_do_subnav', 10 );
add_filter( 'wp_nav_menu_args', 'genesis_sample_secondary_menu_args' );
/**
* Reduces secondary navigation menu to one level depth.
*
* @since 2.2.3
*
* @param array $args Original menu options.
* @return array Menu options with depth set to 1.
*/
function genesis_sample_secondary_menu_args( $args ) {
if ( 'secondary' !== $args['theme_location'] ) {
return $args;
}
$args['depth'] = 1;
return $args;
}
add_filter( 'genesis_author_box_gravatar_size', 'genesis_sample_author_box_gravatar' );
/**
* Modifies size of the Gravatar in the author box.
*
* @since 2.2.3
*
* @param int $size Original icon size.
* @return int Modified icon size.
*/
function genesis_sample_author_box_gravatar( $size ) {
return 90;
}
add_filter( 'genesis_comment_list_args', 'genesis_sample_comments_gravatar' );
/**
* Modifies size of the Gravatar in the entry comments.
*
* @since 2.2.3
*
* @param array $args Gravatar settings.
* @return array Gravatar settings with modified size.
*/
function genesis_sample_comments_gravatar( $args ) {
$args['avatar_size'] = 60;
return $args;
}