-
Notifications
You must be signed in to change notification settings - Fork 8
/
functions.php
193 lines (152 loc) · 6.7 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
<?php
//
// Responsive Base Child Theme Functions
//
/**
* 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_xhtml' );
// recreates the doctype section, html5boilerplate.com style with conditional classes
// http://scottnix.com/html5-header-with-thematic/
function childtheme_create_doctype() {
$content = "<!doctype html>" . "\n";
$content .= '<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" dir="' . get_bloginfo ('text_direction') . '" lang="'. get_bloginfo ('language') . '"> <![endif]-->' . "\n";
$content .= '<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8" dir="' . get_bloginfo ('text_direction') . '" lang="'. get_bloginfo ('language') . '"> <![endif]-->'. "\n";
$content .= '<!--[if IE 8]> <html class="no-js lt-ie9" dir="' . get_bloginfo ('text_direction') . '" lang="'. get_bloginfo ('language') . '"> <![endif]-->' . "\n";
$content .= "<!--[if gt IE 8]><!-->" . "\n";
$content .= "<html class=\"no-js\"";
return $content;
}
add_filter('thematic_create_doctype', 'childtheme_create_doctype', 11);
// creates the head, meta charset, and viewport tags
function childtheme_head_profile() {
$content = "<!--<![endif]-->";
$content .= "\n" . "<head>" . "\n";
$content .= "<meta charset=\"utf-8\" />" . "\n";
$content .= "<meta name=\"viewport\" content=\"width=device-width\" />" . "\n";
return $content;
}
add_filter('thematic_head_profile', 'childtheme_head_profile', 11);
// remove meta charset tag, now in the above function
function childtheme_create_contenttype() {
// silence
}
add_filter('thematic_create_contenttype', 'childtheme_create_contenttype', 11);
// clear useless garbage for a polished 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 built in drop down theme javascripts
// 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 template for registering and enqueuing files
// 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, stylesheet local 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 scripts, local stylesheet 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');
// placeholder for example of conditional script loading
if (is_front_page() ) {
}
//always enqueue this last, can help with obscure conflicts
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 );
// add favicon to site, add 16x16 or 32x32 "favicon.ico" or .png image to child themes main folder
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');
// register two additional custom menu slots
function childtheme_register_menus() {
if (function_exists( 'register_nav_menu' )) {
register_nav_menu( 'secondary-menu', 'Secondary Menu' );
register_nav_menu( 'tertiary-menu', 'Tertiary Menu' );
}
}
add_action('thematic_child_init', 'childtheme_register_menus');
// completely remove nav above functionality
function childtheme_override_nav_above() {
// silence
}
// featured image thumbnail sizing, default is 100x100 set by Thematic
function childtheme_post_thumb_size($size) {
$size = array(300,300);
return $size;
}
add_filter('thematic_post_thumb_size', 'childtheme_post_thumb_size');
// add 4th subsidiary aside, currently set up to be a footer widget (#footer-widget) underneath the 3 subs
function childtheme_add_subsidiary($content) {
$content['Footer Widget Aside'] = array(
'admin_menu_order' => 550,
'args' => array (
'name' => 'Footer Aside',
'id' => '4th-subsidiary-aside',
'description' => __('The 4th bottom widget area in the footer.', 'thematic'),
'before_widget' => thematic_before_widget(),
'after_widget' => thematic_after_widget(),
'before_title' => thematic_before_title(),
'after_title' => thematic_after_title(),
),
'action_hook' => 'widget_area_subsidiaries',
'function' => 'childtheme_4th_subsidiary_aside',
'priority' => 90
);
return $content;
}
add_filter('thematic_widgetized_areas', 'childtheme_add_subsidiary');
// set structure for the 4th subsidiary aside
function childtheme_4th_subsidiary_aside() {
if ( is_active_sidebar('4th-subsidiary-aside') ) {
echo thematic_before_widget_area('footer-widget');
dynamic_sidebar('4th-subsidiary-aside');
echo thematic_after_widget_area('footer-widget');
}
}
/*
// example for hiding unused widget areas inside the WordPress admin
function childtheme_hide_areas($content) {
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');
*/