forked from seothemes/genesis-starter-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
270 lines (218 loc) · 8.16 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
<?php
/**
* Genesis Starter Theme.
*
* @package GenesisStarter
* @link https://seothemes.com/themes/genesis-starter
* @author SEO Themes
* @copyright Copyright © 2017 SEO Themes
* @license GPL-2.0+
*/
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
die;
}
// Child theme (do not remove).
include_once( get_template_directory() . '/lib/init.php' );
// Define theme constants.
define( 'CHILD_THEME_NAME', 'Genesis Starter' );
define( 'CHILD_THEME_URL', 'https://seothemes.com/themes/genesis-starter' );
define( 'CHILD_THEME_VERSION', '2.2.4' );
// Set Localization (do not remove).
load_child_theme_textdomain( 'genesis-starter', apply_filters( 'child_theme_textdomain', get_stylesheet_directory() . '/languages', 'genesis-starter' ) );
// Remove secondary sidebar.
unregister_sidebar( 'sidebar-alt' );
// Remove unused site layouts.
genesis_unregister_layout( 'content-sidebar-sidebar' );
genesis_unregister_layout( 'sidebar-content-sidebar' );
genesis_unregister_layout( 'sidebar-sidebar-content' );
// Enable support for page excerpts.
add_post_type_support( 'page', 'excerpt' );
// Enable support for WooCommerce.
add_theme_support( 'woocommerce' );
// Enable support for structural wraps.
add_theme_support( 'genesis-structural-wraps', array(
'header',
'menu-primary',
'menu-secondary',
'footer-widgets',
'footer',
) );
// Enable Accessibility support.
add_theme_support( 'genesis-accessibility', array(
'404-page',
'drop-down-menu',
'headings',
'rems',
'search-form',
'skip-links',
) );
// Enable custom navigation menus.
add_theme_support( 'genesis-menus' , array(
'primary' => __( 'Header Menu', 'genesis-starter' ),
'secondary' => __( 'After Header Menu', 'genesis-starter' ),
) );
// Enable viewport meta tag for mobile browsers.
add_theme_support( 'genesis-responsive-viewport' );
// Enable footer widgets.
add_theme_support( 'genesis-footer-widgets', 3 );
// Enable HTML5 markup structure.
add_theme_support( 'html5', array(
'caption',
'comment-form',
'comment-list',
'gallery',
'search-form',
) );
// Enable support for post formats.
add_theme_support( 'post-formats', array(
'aside',
'audio',
'chat',
'gallery',
'image',
'link',
'quote',
'status',
'video',
) );
// Enable support for post thumbnails.
add_theme_support( 'post-thumbnails' );
// Enable automatic output of WordPress title tags.
add_theme_support( 'title-tag' );
// Enable selective refresh and Customizer edit icons.
add_theme_support( 'customize-selective-refresh-widgets' );
// Enable theme support for custom background image.
add_theme_support( 'custom-background', array(
'default-color' => 'f4f5f6',
) );
// Enable logo option in Customizer > Site Identity.
add_theme_support( 'custom-logo', array(
'height' => 60,
'width' => 240,
'flex-height' => true,
'flex-width' => true,
'header-text' => array( '.site-title', '.site-description' ),
) );
// Display custom logo in site title area.
add_action( 'genesis_site_title', 'the_custom_logo', 0 );
// Enable support for custom header image or video.
add_theme_support( 'custom-header', array(
'header-selector' => '.hero',
'default_image' => get_stylesheet_directory_uri() . '/assets/images/hero.jpg',
'header-text' => true,
'default-text-color' => '30353a',
'width' => 1920,
'height' => 1080,
'flex-height' => true,
'flex-width' => true,
'uploads' => true,
'video' => true,
'wp-head-callback' => 'genesis_starter_custom_header',
) );
// Register default header (just in case).
register_default_headers( array(
'child' => array(
'url' => '%2$s/assets/images/hero.jpg',
'thumbnail_url' => '%2$s/assets/images/hero.jpg',
'description' => __( 'Hero Image', 'genesis-starter' ),
),
) );
// Register a custom layout.
genesis_register_layout( 'custom-layout', array(
'label' => __( 'Custom Layout', 'genesis-starter' ),
'img' => get_stylesheet_directory_uri() . '/assets/images/custom-layout.gif',
) );
// Register Front Page 1 widget area.
genesis_register_sidebar( array(
'id' => 'front-page-1',
'name' => __( 'Front Page 1', 'genesis-starter' ),
'description' => __( 'Front page 1 widget area.', 'genesis-starter' ),
'before_title' => '<h1 itemprop="headline">',
'after_title' => '</h1>',
) );
// Register Front Page 2 widget area.
genesis_register_sidebar( array(
'id' => 'front-page-2',
'name' => __( 'Front Page 2', 'genesis-starter' ),
'description' => __( 'Front page 2 widget area.', 'genesis-starter' ),
) );
// Register Front Page 3 widget area.
genesis_register_sidebar( array(
'id' => 'front-page-3',
'name' => __( 'Front Page 3', 'genesis-starter' ),
'description' => __( 'Front page 3 widget area.', 'genesis-starter' ),
) );
// Register Front Page 4 widget area.
genesis_register_sidebar( array(
'id' => 'front-page-4',
'name' => __( 'Front Page 4', 'genesis-starter' ),
'description' => __( 'Front page 4 widget area.', 'genesis-starter' ),
) );
// Register Front Page 5 widget area.
genesis_register_sidebar( array(
'id' => 'front-page-5',
'name' => __( 'Front Page 5', 'genesis-starter' ),
'description' => __( 'Front page 5 widget area.', 'genesis-starter' ),
) );
// Change order of main stylesheet to override plugin styles.
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
add_action( 'wp_enqueue_scripts', 'genesis_enqueue_main_stylesheet', 99 );
// Reposition primary navigation menu.
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_after_title_area', 'genesis_do_nav' );
// Reposition the secondary navigation menu.
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_after_header_wrap', 'genesis_do_subnav' );
// Reposition footer widgets inside site footer.
remove_action( 'genesis_before_footer', 'genesis_footer_widget_areas' );
add_action( 'genesis_before_footer_wrap', 'genesis_footer_widget_areas', 5 );
// Enable shortcodes in text widgets.
add_filter( 'widget_text', 'do_shortcode' );
// Force Gravity Forms to disable CSS output.
add_filter( 'pre_option_rg_gforms_disable_css', '__return_true' );
add_action( 'wp_enqueue_scripts', 'genesis_starter_scripts_styles', 99 );
/**
* Enqueue theme scripts and styles.
*
* @return void
*/
function genesis_starter_scripts_styles() {
// Conditionally load WooCommerce styles.
if ( genesis_starter_is_woocommerce_page() ) {
wp_enqueue_style( 'starter-woocommerce', get_stylesheet_directory_uri() . '/assets/styles/min/woocommerce.min.css', array(), CHILD_THEME_VERSION );
}
// Remove Simple Social Icons CSS (included with theme).
wp_dequeue_style( 'simple-social-icons-font' );
// Google fonts.
wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,600,700', array(), CHILD_THEME_VERSION );
// Enqueue custom theme scripts.
wp_enqueue_script( 'genesis-starter', get_stylesheet_directory_uri() . '/assets/scripts/min/theme.min.js', array( 'jquery' ), CHILD_THEME_VERSION, true );
// Enqueue responsive menu script.
wp_enqueue_script( 'starter-menus', get_stylesheet_directory_uri() . '/assets/scripts/min/menus.min.js', array( 'jquery' ), CHILD_THEME_VERSION, true );
// Localize responsive menus script.
wp_localize_script( 'starter-menus', 'genesis_responsive_menu', array(
'mainMenu' => __( 'Menu', 'genesis-starter' ),
'subMenu' => __( 'Menu', 'genesis-starter' ),
'menuIconClass' => null,
'subMenuIconClass' => null,
'menuClasses' => array(
'combine' => array(
'.nav-primary',
'.nav-secondary',
),
),
) );
}
// Load helper functions.
include_once( get_stylesheet_directory() . '/includes/helpers.php' );
// Load miscellaneous functions.
include_once( get_stylesheet_directory() . '/includes/extras.php' );
// Load page header.
include_once( get_stylesheet_directory() . '/includes/header.php' );
// Load Customizer settings.
include_once( get_stylesheet_directory() . '/includes/customize.php' );
// Load default settings.
include_once( get_stylesheet_directory() . '/includes/defaults.php' );
// Load recommended plugins.
include_once( get_stylesheet_directory() . '/includes/plugins.php' );