-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfunctions.php
More file actions
366 lines (303 loc) · 10.2 KB
/
functions.php
File metadata and controls
366 lines (303 loc) · 10.2 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
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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<?php
if ( ! defined( 'ABSPATH' ) ) :
exit; // Exit if accessed directly
endif;
/**
* Snowbird functions and definitions
*/
/**
* Snowbird only works in WordPress 4.5 or later.
*/
if ( version_compare( $GLOBALS['wp_version'], '4.5', '<' ) ) {
require get_template_directory() . '/inc/back-compat.php';
}
if ( ! function_exists( 'snowbird_setup' ) ) :
/**
* 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 snowbird_setup() {
/**
* Make theme available for translation.
* Translations can be filed in the /languages/ directory.
* If you're building a theme based on Snowbird, use a find and replace
* to change 'snowbird' to the name of your theme in all the template files
*/
load_theme_textdomain( 'snowbird', get_template_directory() . '/languages' );
/**
* Add default posts and comments RSS feed links to head.
*/
add_theme_support( 'automatic-feed-links' );
/**
* 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' );
/**
* Enable support for custom logo.
*/
add_theme_support( 'custom-logo', array(
'height' => 200,
'width' => 200,
'flex-width' => true,
) );
/**
* Enable support for Post Thumbnails on posts and pages.
*
* @link http://codex.wordpress.org/Function_Reference/add_theme_support#Post_Thumbnails
*/
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 1600, 600, array( 'top', 'center' ) );
/**
* Menu Locations
*/
register_nav_menus( array(
'primary' => esc_html_x( 'Primary Menu', 'admin', 'snowbird' ),
'secondary' => esc_html_x( 'Secondary Menu', 'admin', 'snowbird' ),
'social' => esc_html_x( 'Social Menu', 'admin', 'snowbird' )
) );
/**
* Switch default core markup for search form, comment form, and comments
* to output valid HTML5.
*/
add_theme_support( 'html5', array(
'search-form',
'comment-form',
'comment-list',
'gallery',
'caption',
) );
/**
* Enable support for Post Formats.
* See http://codex.wordpress.org/Post_Formats
*/
add_theme_support( 'post-formats', array(
'aside',
'image',
'video',
'quote',
'link',
'gallery',
'status',
'audio',
'chat',
) );
/**
* Supports for SuperPack
*/
add_theme_support( 'superpack', array(
'comment_avatar_size' => 70,
'enqueue_shortcodes_css' => false,
'enqueue_widgets_css' => false,
'image_size_about' => 'snowbird-thumb',
'image_size_posts' => 'snowbird-small',
'social_icons' => array(
'menu_class' => 'xf__social colors circle',
),
'contact_fields' => array(
'container_class' => 'author-links',
'action_hooks' => 'snowbird_author_bio',
),
) );
/**
* Custom Media sizes
*/
add_image_size( 'snowbird-large', 1110, 480, array( 'top', 'center' ) );
add_image_size( 'snowbird-thumb', 400, 400, array( 'top', 'center' ) );
add_image_size( 'snowbird-small', 120, 120, array( 'top', 'center' ) );
/**
* Editor Styles
*/
$ext_css = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.css' : '.min.css';
add_editor_style( array(
Snowbird()->protocol( get_template_directory_uri() . '/assets/css/font-awesome.min.css?v=4.6.3' ),
Snowbird()->protocol( get_template_directory_uri() . '/assets/css/editor-style' . $ext_css . '?v=' . Snowbird()->version() ),
admin_url( 'admin-ajax.php?action=' . Snowbird()->codename( 'editor-style' ) ),
) );
if ( snowbird_fonts_url() ) {
add_editor_style( array( snowbird_fonts_url() ) );
}
}
endif;
add_action( 'after_setup_theme', 'snowbird_setup' );
if ( ! function_exists( 'snowbird_content_width' ) ) :
/**
* Sets the content width in pixels, based on the theme's design and stylesheet.
*
* Priority 0 to make it available to lower priority callbacks.
*
* @global int $content_width
*/
function snowbird_content_width() {
$GLOBALS['content_width'] = (int) apply_filters( 'snowbird_content_width', 1110 );
}
endif;
add_action( 'after_setup_theme', 'snowbird_content_width', 0 );
/**
* Registers widget area for the theme.
*
* @link http://codex.wordpress.org/Function_Reference/register_sidebar
*/
function snowbird_widgets_init() {
register_sidebar( array(
'name' => esc_html_x( 'Sidebar', 'admin', 'snowbird' ),
'id' => 'sidebar-1',
'description' => '',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
for ( $i = 1; $i <= 4; $i ++ ) {
register_sidebar( array(
'id' => 'footer-' . $i,
'name' => sprintf( esc_html_x( 'Footer-%s', 'admin', 'snowbird' ), number_format_i18n( $i ) ),
'before_widget' => '<section id="%1$s" class="widget %2$s">',
'after_widget' => '</section>',
'before_title' => '<h3 class="widget-title"><span>',
'after_title' => '</span></h3>',
) );
}
}
add_action( 'widgets_init', 'snowbird_widgets_init' );
/**
* Enqueues scripts and styles for the theme.
*/
function snowbird_scripts() {
/**
* CSS
*/
$ext_css = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.css' : '.min.css';
if ( snowbird_fonts_url() ) {
wp_enqueue_style( 'snowbird-fonts', snowbird_fonts_url(), array(), null );
}
wp_enqueue_style( 'font-awesome',
Snowbird()->protocol( get_template_directory_uri() . '/assets/css/font-awesome.min.css' ),
array(),
'4.6.3'
);
wp_enqueue_style( 'snowbird-style',
Snowbird()->protocol( get_template_directory_uri() . '/assets/css/style' . $ext_css ),
array(),
Snowbird()->version()
);
/**
* JavaScript
*/
$ext_js = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '.js' : '.min.js';
wp_enqueue_script( 'jquery-fitvids',
Snowbird()->protocol( get_template_directory_uri() . '/assets/js/vendor/jquery.fitvids.min.js' ),
array( 'jquery' ),
'1.1',
true
);
wp_enqueue_script( 'jquery-perfect-scrollbar',
Snowbird()->protocol( get_template_directory_uri() . '/assets/js/vendor/perfect-scrollbar.jquery.min.js' ),
array( 'jquery' ),
'0.6.16',
true
);
wp_enqueue_script( 'jquery-magnific-popup',
Snowbird()->protocol( get_template_directory_uri() . '/assets/js/vendor/jquery.magnific-popup.min.js' ),
array( 'jquery' ),
'1.1.0',
true
);
wp_enqueue_script( 'snowbird-script',
Snowbird()->protocol( get_template_directory_uri() . '/assets/js/functions' . $ext_js ),
array( 'jquery', 'jquery-fitvids', 'jquery-perfect-scrollbar', 'jquery-magnific-popup' ),
Snowbird()->version(),
true
);
wp_enqueue_script( 'snowbird-skip-link-focus-fix',
Snowbird()->protocol( get_template_directory_uri() . '/assets/js/skip-link-focus-fix' . $ext_js ),
array(),
Snowbird()->version(),
true
);
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
wp_enqueue_script( 'comment-reply' );
}
if ( is_singular( array( 'attachment', 'post' ) ) || wp_attachment_is_image() ) {
wp_enqueue_script( 'snowbird-keyboard-navigation',
Snowbird()->protocol( get_template_directory_uri() . '/assets/js/keyboard-navigation' . $ext_js ),
array( 'jquery' ),
Snowbird()->version(),
true
);
}
wp_localize_script( 'snowbird-script', 'snowbirdReaderText', array(
'expand' => '<span class="screen-reader-text">' . esc_html__( 'expand child menu', 'snowbird' ) . '</span>',
'collapse' => '<span class="screen-reader-text">' . esc_html__( 'collapse child menu', 'snowbird' ) . '</span>',
) );
/**
* Remove Inline CSS from core Widget Comments
*/
add_filter( 'show_recent_comments_widget_style', '__return_false' );
}
add_action( 'wp_enqueue_scripts', 'snowbird_scripts' );
if ( ! function_exists( 'snowbird_fonts_url' ) ) :
/**
* Returns Google Fonts URL for the theme.
*
* @return string
*/
function snowbird_fonts_url() {
$fonts_url = '';
$fonts = array();
/* translators: If there are characters in your language that are not supported by Anton, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== esc_html_x( 'on', 'Anton font: on or off', 'snowbird' ) ) {
$fonts['heading'] = 'Anton';
}
/* translators: If there are characters in your language that are not supported by Droid Serif, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== esc_html_x( 'on', 'Droid Serif font: on or off', 'snowbird' ) ) {
$fonts['body'] = 'Droid Serif:400,400italic,700,700italic';
}
$fonts = (array) apply_filters( 'snowbird_google_fonts', $fonts );
$subsets = (array) apply_filters( 'snowbird_google_fonts_subsets', array( 'latin', 'latin-ext' ), $fonts );
if ( $fonts ) {
$fonts_url = add_query_arg( array(
'family' => urlencode( implode( '|', $fonts ) ),
'subset' => urlencode( implode( ',', array_unique( $subsets ) ) ),
), 'https://fonts.googleapis.com/css' );
}
return $fonts_url;
}
endif;
/**
* Core File for the theme.
*/
require get_template_directory() . '/inc/class-snowbird.php';
/**
* Implements Customizer Settings and output.
*/
require get_template_directory() . '/inc/customizer-choices.php';
require get_template_directory() . '/inc/customizer-controls.php';
require get_template_directory() . '/inc/customizer-sanitize.php';
require get_template_directory() . '/inc/customizer.php';
/**
* Functions for the color schemes.
*/
require get_template_directory() . '/inc/scheme-functions.php';
/**
* Custom template functions for the theme.
*/
require get_template_directory() . '/inc/template-functions.php';
/**
* Actions/Filters and Custom functions that act independently.
*/
require get_template_directory() . '/inc/extras.php';
/**
* Jetpack compatibility file.
*/
require get_template_directory() . '/inc/jetpack.php';
/**
* Plugins Recommendation for theme.
*/
require get_template_directory() . '/inc/class-tgm-plugin-activation.php';
require get_template_directory() . '/inc/plugins.php';