forked from studiopress/genesis-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·284 lines (225 loc) · 7.98 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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
<?php
/**
* Genesis Sample.
*
* This file adds functions to the Genesis Sample Theme.
*
* @package Genesis Sample
* @author StudioPress
* @license GPL-2.0-or-later
* @link https://www.studiopress.com/
*/
// Starts the engine.
require_once get_template_directory() . '/lib/init.php';
// Defines constants to help enqueue scripts and styles.
define( 'CHILD_THEME_HANDLE', sanitize_title_with_dashes( wp_get_theme()->get( 'Name' ) ) );
define( 'CHILD_THEME_VERSION', wp_get_theme()->get( 'Version' ) );
// Sets up the Theme.
require_once get_stylesheet_directory() . '/lib/theme-defaults.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( 'genesis-sample', get_stylesheet_directory() . '/languages' );
}
// Adds helper functions.
require_once get_stylesheet_directory() . '/lib/helper-functions.php';
// Adds image upload and color select to Customizer.
require_once get_stylesheet_directory() . '/lib/customize.php';
// Includes Customizer CSS.
require_once get_stylesheet_directory() . '/lib/output.php';
// Adds WooCommerce support.
require_once get_stylesheet_directory() . '/lib/woocommerce/woocommerce-setup.php';
// Adds the required WooCommerce styles and Customizer CSS.
require_once get_stylesheet_directory() . '/lib/woocommerce/woocommerce-output.php';
// Adds the Genesis Connect WooCommerce notice.
require_once get_stylesheet_directory() . '/lib/woocommerce/woocommerce-notice.php';
add_action( 'after_setup_theme', 'genesis_child_gutenberg_support' );
/**
* Adds Gutenberg opt-in features and styling.
*
* @since 2.7.0
*/
function genesis_child_gutenberg_support() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound -- using same in all child themes to allow action to be unhooked.
require_once get_stylesheet_directory() . '/lib/gutenberg/init.php';
}
add_action( 'wp_enqueue_scripts', 'genesis_sample_enqueue_scripts_styles' );
/**
* Enqueues scripts and styles.
*
* @since 1.0.0
*/
function genesis_sample_enqueue_scripts_styles() {
wp_enqueue_style(
'genesis-sample-fonts',
'//fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,700',
array(),
CHILD_THEME_VERSION
);
wp_enqueue_style( 'dashicons' );
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_enqueue_script(
'genesis-sample-responsive-menu',
get_stylesheet_directory_uri() . "/js/responsive-menus{$suffix}.js",
array( 'jquery' ),
CHILD_THEME_VERSION,
true
);
wp_localize_script(
'genesis-sample-responsive-menu',
'genesis_responsive_menu',
genesis_sample_responsive_menu_settings()
);
wp_enqueue_script(
'genesis-sample',
get_stylesheet_directory_uri() . '/js/genesis-sample.js',
array( 'jquery' ),
CHILD_THEME_VERSION,
true
);
}
/**
* Defines responsive menu settings.
*
* @since 2.3.0
*/
function genesis_sample_responsive_menu_settings() {
$settings = array(
'mainMenu' => __( 'Menu', 'genesis-sample' ),
'menuIconClass' => 'dashicons-before dashicons-menu',
'subMenu' => __( 'Submenu', 'genesis-sample' ),
'subMenuIconClass' => 'dashicons-before dashicons-arrow-down-alt2',
'menuClasses' => array(
'combine' => array(
'.nav-primary',
),
'others' => array(),
),
);
return $settings;
}
// Adds support for HTML5 markup structure.
add_theme_support( 'html5', genesis_get_config( 'html5' ) );
// Adds support for accessibility.
add_theme_support( 'genesis-accessibility', genesis_get_config( 'accessibility' ) );
// 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', genesis_get_config( 'custom-logo' ) );
add_filter( 'genesis_seo_title', 'genesis_sample_header_title', 10, 3 );
/**
* Removes the link from the hidden site title if a custom logo is in use.
*
* Without this filter, the site title is hidden with CSS when a custom logo
* is in use, but the link it contains is still accessible by keyboard.
*
* @since 1.2.0
*
* @param string $title The full title.
* @param string $inside The content inside the title element.
* @param string $wrap The wrapping element name, such as h1.
* @return string The site title with anchor removed if a custom logo is active.
*/
function genesis_sample_header_title( $title, $inside, $wrap ) {
if ( has_custom_logo() ) {
$inside = get_bloginfo( 'name' );
}
return sprintf( '<%1$s class="site-title">%2$s</%1$s>', $wrap, $inside );
}
// Renames primary and secondary navigation menus.
add_theme_support( 'genesis-menus', genesis_get_config( 'menus' ) );
// Adds image sizes.
add_image_size( 'sidebar-featured', 75, 75, true );
// 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 and front page breadcrumb 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'] );
unset( $config['genesis']['sections']['genesis_breadcrumbs']['controls']['breadcrumb_front_page'] );
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;
}