forked from FernE97/html5-blank-slate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
251 lines (197 loc) · 9.93 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
<?php
// Enqueue Styles
function h5bs_enqueue_styles() {
wp_register_style( 'h5bs-theme', get_template_directory_uri() . '/assets/css/theme.css', false, '3.0.3' );
wp_register_style( 'h5bs-custom', get_template_directory_uri() . '/assets/css/custom.css', false, '3.0.3' );
wp_register_style( 'slick-carousel', get_template_directory_uri() . '/bower_components/slick-carousel/slick/slick.css', false, '1.5.8' );
wp_register_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css', false, '4.4.0' );
// Optional
// wp_enqueue_style( 'slick-carousel' );
// wp_enqueue_style( 'font-awesome' );
wp_enqueue_style( 'h5bs-theme' );
wp_enqueue_style( 'h5bs-custom' ); // keep at bottom to overwrite other styles
}
add_action( 'wp_enqueue_scripts', 'h5bs_enqueue_styles' );
// Enqueue Scripts
function h5bs_enqueue_scripts() {
wp_register_script( 'modernizr', get_template_directory_uri() . '/bower_components/foundation/js/vendor/modernizr.js', array(), '2.8.3', false );
wp_register_script( 'foundation', get_template_directory_uri() . '/bower_components/foundation/js/foundation.min.js', array(), '5.5.2', true );
wp_register_script( 'slick-carousel', get_template_directory_uri() . '/bower_components/slick-carousel/slick/slick.min.js', array( 'jquery' ), '1.5.8', true );
wp_register_script( 'global-js', get_template_directory_uri() . '/assets/js/global.js', array( 'jquery' ), '3.0.3', true );
wp_enqueue_script( 'modernizr' );
wp_enqueue_script( 'foundation' );
// Optional
// wp_enqueue_script( 'slick-carousel' );
wp_enqueue_script( 'global-js' );
}
add_action( 'wp_enqueue_scripts', 'h5bs_enqueue_scripts' );
// Custom Menus
function h5bs_register_menus() {
register_nav_menus(array(
'primary' => __( 'Primary Navigation', 'h5bs' ),
'secondary' => __( 'Secondary Navigation', 'h5bs' ),
'footer' => __( 'Footer Navigation', 'h5bs' ),
'mobile' => __( 'Mobile Navigation', 'h5bs' )
));
}
add_action( 'init', 'h5bs_register_menus' );
function h5bs_primary_nav() {
wp_nav_menu(array(
'container' => false, // remove nav container
'menu' => 'Primary Nav', // nav name
'menu_id' => 'nav-main', // custom id
'menu_class' => 'nav-main nav group', // custom class
'theme_location' => 'primary', // where it's located in the theme
'before' => '', // before the menu
'after' => '', // after the menu
'link_before' => '', // before each link
'link_after' => '', // after each link
'depth' => 0, // set to 1 to disable dropdowns
'fallback_cb' => 'h5bs_nav_fallback' // fallback function
));
}
function h5bs_secondary_nav() {
wp_nav_menu(array(
'container' => false, // remove nav container
'menu' => 'Secondary Nav', // nav name
'menu_id' => 'nav-sub', // custom id
'menu_class' => 'nav-sub nav group', // custom class
'theme_location' => 'secondary', // where it's located in the theme
'before' => '', // before the menu
'after' => '', // after the menu
'link_before' => '', // before each link
'link_after' => '', // after each link
'depth' => 0, // set to 1 to disable dropdowns
'fallback_cb' => 'h5bs_nav_fallback' // fallback function
));
}
function h5bs_footer_nav() {
wp_nav_menu(array(
'container' => false, // remove nav container
'menu' => 'Footer Nav', // nav name
'menu_id' => 'nav-footer', // custom id
'menu_class' => 'nav-footer nav group', // custom class
'theme_location' => 'footer', // where it's located in the theme
'before' => '', // before the menu
'after' => '', // after the menu
'link_before' => '', // before each link
'link_after' => '', // after each link
'depth' => 0, // set to 1 to disable dropdowns
'fallback_cb' => 'h5bs_nav_fallback' // fallback function
));
}
function h5bs_mobile_nav() {
wp_nav_menu(array(
'container' => false, // remove nav container
'menu' => 'Mobile Nav', // nav name
'menu_id' => 'nav-mobile', // custom id
'menu_class' => 'nav-mobile nav group', // custom class
'theme_location' => 'mobile', // where it's located in the theme
'before' => '', // before the menu
'after' => '', // after the menu
'link_before' => '', // before each link
'link_after' => '', // after each link
'depth' => 0, // set to 1 to disable dropdowns
'fallback_cb' => 'h5bs_nav_fallback' // fallback function
));
}
function h5bs_nav_fallback() {
wp_page_menu(array(
'menu_class' => 'nav group',
'include' => '',
'exclude' => '',
'link_before' => '',
'link_after' => '',
'show_home' => true
));
}
// Image Thumbnails
add_theme_support( 'post-thumbnails' );
// html5 search form
add_theme_support( 'html5', array( 'search-form' ) );
// Add class to next/prev page links
add_filter( 'next_posts_link_attributes', 'posts_link_attributes' );
add_filter( 'previous_posts_link_attributes', 'posts_link_attributes' );
function posts_link_attributes() {
return 'class="button tiny radius"';
}
// Remove junk from head
function h5bs_remove_junk() {
// Really Simple Discovery
remove_action( 'wp_head', 'rsd_link' );
// Windows Live Writer
remove_action( 'wp_head', 'wlwmanifest_link' );
// WP Version
remove_action( 'wp_head', 'wp_generator' );
}
add_action( 'init', 'h5bs_remove_junk' );
// Sidebars & Widgetizes Areas
function h5bs_register_sidebars() {
register_sidebar(array(
'id' => 'sidebar1',
'name' => 'Sidebar 1',
'description' => 'The first (primary) sidebar.',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="widgettitle">',
'after_title' => '</h4>',
));
}
add_action( 'widgets_init', 'h5bs_register_sidebars' );
// Comments List
function h5bs_comments( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
if ( get_comment_type() == 'pingback' || get_comment_type() == 'trackback' ) : ?>
<li class="pingback" id="comment-<?php comment_ID(); ?>">
<article <?php comment_class( 'group' ); ?>>
<header class="comment-meta">
<h5><?php _e( 'Pingback:', 'h5bs' ); ?></h5>
<p><?php edit_comment_link(); ?></p>
</header>
<p><?php comment_author_link(); ?></p>
</article>
<?php // WordPress closes </li>
elseif ( get_comment_type() == 'comment' ) : ?>
<li id="comment-<?php comment_ID(); ?>">
<article <?php comment_class( 'group' ); ?>>
<header class="comment-meta">
<h5><?php comment_author_link(); ?></h5>
<p class="comment-date">on <?php comment_date(); ?> at <?php comment_time(); ?></p>
<p class="reply">
<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'h5bs' ), 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</p>
</header>
<figure class="comment-avatar">
<?php
$avatar_size = 80;
echo get_avatar( $comment, $avatar_size );
?>
</figure>
<?php if ( '0' == $comment->comment_approved ) : ?>
<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'h5bs' ); ?></p>
<?php endif; ?>
<?php comment_text(); ?>
</article>
<?php // WordPress closes </li>
endif;
}
/** https://github.com/blineberry/Improved-HTML5-WordPress-Captions **/
// Removes inline styling from wp-caption and changes to HTML5 figure/figcaption
add_filter( 'img_caption_shortcode', 'h5bs_img_caption_shortcode_filter', 10, 3 );
function h5bs_img_caption_shortcode_filter($val, $attr, $content = null) {
extract(shortcode_atts(array(
'id' => '',
'align' => '',
'width' => '',
'caption' => ''
), $attr));
if ( 1 > (int) $width || empty($caption) )
return $val;
return '<figure id="' . $id . '" class="wp-caption ' . esc_attr($align) . '" style="width: ' . $width . 'px;">'
. do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $caption . '</figcaption></figure>';
}
// Client Options Page
require_once( 'includes/client-options.php' );
add_action( 'admin_menu', 'h5bs_client_options' );
// Translation
// require_once( 'includes/lang/translation.php' ); // uncomment if needed