-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfunctions.php
280 lines (244 loc) · 8.73 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
<?php
/**
* Force Thematic HTML5
*
* New Thematic feature that allows the child theme control of the HTML mode. This was previously
* controlled from inside the WordPress Admin.
*
* https://github.com/ThematicTheme/Thematic/pull/113
*
*/
add_theme_support( 'thematic_html5' );
/**
* Remove Thematic Menu JavaScript
*
* Removes the default Thematic JS scripts (Superfish) completely.
*
* Reference http://thematictheme.com/forums/topic/correct-way-to-prevent-loading-thematic-scripts/
*
*/
function childtheme_remove_superfish() {
remove_theme_support('thematic_superfish');
}
add_action('wp_enqueue_scripts','childtheme_remove_superfish', 9);
/**
* Script Manager
*
* Setup for adding and removing scripts and styling. The deregister styles & scripts sections can
* be used for conditional loading plugin scripts to only load where they are used.s
*
* Reference http://wpcandy.com/teaches/how-to-load-scripts-in-wordpress-themes/
*
*/
function childtheme_script_manager() {
// wp_register_script template ( $handle, $src, $deps, $ver, $in_footer );
// registers modernizr script, childtheme path, no dependency, no version, loads in header
wp_register_script('modernizr-js', get_stylesheet_directory_uri() . '/js/modernizr.js', false, false, false);
// registers misc custom script, childtheme path, yes dependency is jquery, no version, loads in footer
wp_register_script('custom-js', get_stylesheet_directory_uri() . '/js/custom.js', array('jquery'), false, true);
// enqueue the scripts for use in theme
wp_enqueue_script ('modernizr-js');
wp_enqueue_script('custom-js');
}
add_action('wp_enqueue_scripts', 'childtheme_script_manager');
// deregister styles
function childtheme_deregister_styles() {
}
add_action('wp_print_styles', 'childtheme_deregister_styles', 100);
// deregister scripts
function childtheme_deregister_scripts() {
// removes themaitc-js which has more superfish scripts
wp_dequeue_script('thematic-js');
}
add_action( 'wp_print_scripts', 'childtheme_deregister_scripts', 100 );
/**
* Modernizr add 'no-js' class
*
* This filter adds the 'no-js' class to the HTML tag, which Modernizr will remove
* (if Javascript is enabled) and replace it with a "js" class. This is super useful
* for providing CSS fallbacks, but Modernizr does a ton more.
*
* Reference http://modernizr.com/docs/
*
*/
function childtheme_html_class( $class_att ) {
$class_att = "no-js";
return $class_att;
}
add_filter( 'thematic_html_class', 'childtheme_html_class' );
/**
* Add Favicon
*
* The Favicon is actually really complicated, but a quick and dirty method is to at
* least add a 32x32 ,ico file (at the least).
*
* Reference http://www.jonathantneal.com/blog/understand-the-favicon/
* Photoshop Plugin to save ICO files http://www.telegraphics.com.au/sw/
*
*/
function childtheme_add_favicon() { ?>
<link rel="shortcut icon" href="<?php echo get_stylesheet_directory_uri(); ?>/favicon.ico" />
<?php }
add_action('wp_head', 'childtheme_add_favicon');
/**
* Clean up <head> of Site
*
* Wordpress by default throws in all kinds of relational links, for SEO purposes,
* sometimes they work and sometimes they don't. A Plugin like WordPress SEO can
* handle some of these also, but others are not included.
*
* Reference http://scottnix.com/polishing-thematics-head/
*
*/
// remove really simple discovery
remove_action('wp_head', 'rsd_link');
// remove windows live writer xml
remove_action('wp_head', 'wlwmanifest_link');
// remove index relational link
remove_action('wp_head', 'index_rel_link');
// remove parent relational link
remove_action('wp_head', 'parent_post_rel_link');
// remove start relational link
remove_action('wp_head', 'start_post_rel_link');
// remove prev/next relational link
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
// remove short link
remove_action('wp_head', 'wp_shortlink_wp_head');
/**
* Register Two Additional Menus
*
* Not always needed, but a lifesaver if you need more custom menus for widget areas.
*
*/
function childtheme_register_menus() {
register_nav_menu('secondary-menu', 'Secondary Menu');
register_nav_menu('tertiary-menu', 'Tertiary Menu');
}
add_action('thematic_child_init', 'childtheme_register_menus');
/**
* Remove Widgets in Admin.
*
* All this does is removes the widgets from being selected in the admin. This is helpful
* if you aren't using the widgets, no point in looking at them or having to explain why
* they are there.
*
* update: 0.1.1 no longer hidding widget areas that are not often used by default, tech
* savvy pepole (who dig into the php) weren't aware they are an option.
*/
function childtheme_hide_areas( $content ) {
// often used
// unset( $content['Primary Aside'] );
// unset( $content['Secondary Aside'] );
// unset( $content['1st Subsidiary Aside'] );
// unset( $content['2nd Subsidiary Aside'] );
// unset( $content['3rd Subsidiary Aside'] );
// not often used
// unset( $content['Index Top'] );
// unset( $content['Index Insert'] );
// unset( $content['Index Bottom'] );
// unset( $content['Single Top'] );
// unset( $content['Single Insert'] );
// unset( $content['Single Bottom'] );
// unset( $content['Page Top'] );
// unset( $content['Page Bottom'] );
return $content;
}
add_filter('thematic_widgetized_areas', 'childtheme_hide_areas');
/**
* Responsive Menu Structure
*
* Modified to add toggle in link format instead of <h3> that is defaulted from the parent
* theme. his basic structure comes from a mobile pattern from the link below.
*
* Reference http://codepen.io/bradfrost/pen/vljdx
*
*/
function childtheme_override_access() {
?>
<div id="access" role="navigation">
<a class="menu-toggle" href="#">Menu</a>
<?php
if ( ( function_exists( 'has_nav_menu' ) ) && ( has_nav_menu( apply_filters( 'thematic_primary_menu_id', 'primary-menu' ) ) ) ) {
echo wp_nav_menu( thematic_nav_menu_args () );
} else {
echo thematic_add_menuclass( wp_page_menu( thematic_page_menu_args () ) );
}
?>
</div><!-- #access -->
<?php
}
/**
* Modify Navigational Elements
*
* The Navigation Above feature of Thematic is pretty silly (and ugly), so that is
* completely removed. The second function removes the functionality on single posts
* there are much better ways to handle this (plugins).
*
*/
// override completely removes nav above functionality
function childtheme_override_nav_above() {
// silence
}
function childtheme_override_nav_below() {
if ( !is_single() ) { ?>
<nav id="nav-below" class="navigation" role="navigation">
<?php if ( function_exists( 'wp_pagenavi' ) ) {
wp_pagenavi();
} else { ?>
<div class="nav-previous"><?php next_posts_link( sprintf ('<span class="meta-nav">«</span> %s', __('Older posts', 'thematic') ) ) ?></div>
<div class="nav-next"><?php previous_posts_link( sprintf ('%s <span class="meta-nav">»</span>',__( 'Newer posts', 'thematic') ) ) ?></div>
<?php } ?>
</nav>
<?php }
}
/**
* Thematic Featured Image Size
*
* Appears on anything with an excerpt set, the default is 100x100 which is ridiculously
* small, this swaps it out for a more manageable 300x300, but can be easily changed by
* modifying the sizes.
*
*/
function childtheme_post_thumb_size( $size ) {
$size = array(300,300);
return $size;
}
add_filter('thematic_post_thumb_size', 'childtheme_post_thumb_size');
/*
* Modify Widget Titles
*
* Thematic now inputs an H1 for the asides, in HTML5 this is ok, but SEO's will cringe.
* I haven't really seen any data showing that using multiple H1's for what is essentially
* aside or off topic is fine for search engines, and from what I have seen no one has
* really been bold enough to jump on that bandwagon, so this reverts them back to H5's instead.
*
*/
function childtheme_before_widgettitle( $content ) {
$content = "<h5 class=\"widgettitle\">";
return $content;
}
add_filter( 'thematic_before_title', 'childtheme_before_widgettitle');
function childtheme_after_widgettitle( $content ) {
$content = "</h5>\n";
return $content;
}
add_filter( 'thematic_after_title', 'childtheme_after_widgettitle');
/*
* Modify Search Widget
*
* This is pretty much required for responsive sites, you can set it with CSS, but this
* is a backup to make sure the box isn't super big. Also the second function allows you
* to change the text, the default text is sub optimal, "Type to search and hit enter" or
* something like that, way too long.
*
*/
// shorten the input box length
function childtheme_search_form_length() {
return "16";
}
add_filter('thematic_search_form_length', 'childtheme_search_form_length');
// change the default search box text
function childtheme_search_field_value() {
return "Search";
}
add_filter('search_field_value', 'childtheme_search_field_value');