forked from eddiemachado-zz/bones-genesis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
executable file
·323 lines (248 loc) · 10.4 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
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
<?php
/*
Child Theme Name: Bones for Genesis
Author: Eddie Machado
Version: 1.03
URL: htp://themble.com/genesis/bones/
For more information, check the log.txt file.
*/
/************* REGISTER CHILD THEME (You can Change This) ******/
define( 'CHILD_THEME_NAME', 'Bones for Genesis' );
define( 'CHILD_THEME_URL', 'http://www.themble.com/genesis/bones' );
// THEME SETUP TIME **************************************
// we're going to fire this off when we activate the child theme
add_action('genesis_setup','bfg_theme_setup', 15);
/*
we're putting all our core stuff in this function so
things are neater and WordPress runs quicker. I just
made that last part up, but it sounded good huh?
*/
function bfg_theme_setup() {
/*
this is where we clean up wordpress and genesis and
remove things we don't really need and add things
like our stylesheets and javascript libraries.
be very careful when editing this file
*/
include_once( CHILD_DIR . '/library/bones.php');
/*
bones for genesis uses some custom comment markup
and in order to keep this file minimal, we're moving
it to another file. to edit comments, check out this file:
*/
include_once( CHILD_DIR . '/library/comments.php');
/*
if you're using custom post types, you can use this example
to create your own. You can also use the example templates
if you want to customize the look of your custom post type
pages
*/
include_once( CHILD_DIR . '/library/custom-post-types.php');
/*
if you want to customize the backend for your clients, use this
admin file to keep your functions neat and clean.
*/
include_once( CHILD_DIR . '/library/admin.php');
// don't update theme (it's custom right? so you don't need updates)
add_filter( 'http_request_args', 'bfg_dont_update', 5, 2 );
// THEME SUPPORT *************************************
// adding custom background support
add_theme_support( 'custom-background' );
// adding post format support
add_theme_support( 'post-formats', array( 'aside', 'chat', 'gallery', 'image', 'link', 'quote', 'status', 'video', 'audio' ));
// adding support for post format images
add_theme_support( 'genesis-post-format-images' );
// adding custom header support (change width if you change the width of the container)
// add_theme_support( 'genesis-custom-header', array( 'width' => 960, 'height' => 90 ) );
// if you want widgets in the footer, you can use this
// add_theme_support( 'genesis-footer-widgets', 3 );
// CUSTOMIZING GENESIS *******************************
// adding the mobile friendly meta
add_action( 'genesis_meta', 'bfg_viewport_meta' );
/*
you can unregister layouts if your child theme will mantain
the same layout on every page and you don't want to offer
your clients the option to change.
*/
// genesis_unregister_layout( 'content-sidebar' );
// genesis_unregister_layout( 'sidebar-content' );
// genesis_unregister_layout( 'content-sidebar-sidebar' );
// genesis_unregister_layout( 'sidebar-sidebar-content' );
// genesis_unregister_layout( 'sidebar-content-sidebar' );
// genesis_unregister_layout( 'full-width-content' );
/*
if you want to remove some of the default widgets that come
with genesis, you can use this function.
*/
// add_action( 'widgets_init', 'remove_genesis_widgets', 20 );
// SCRIPTS, STYLES, & WP_HEAD ************************
// remove default stylesheet
remove_action( 'genesis_meta', 'genesis_load_stylesheet' );
// enqueue base scripts and styles
add_action('wp_enqueue_scripts', 'bfg_scripts_and_styles', 999);
// ie conditional wrapper
add_filter( 'style_loader_tag', 'bones_ie_conditional', 10, 2 );
// who uses the rsd link anyway? axe it
remove_action( 'wp_head', 'rsd_link' );
// remove Windows Live Writer
remove_action( 'wp_head', 'wlwmanifest_link' );
// index link
remove_action( 'wp_head', 'index_rel_link' );
// previous link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
// start link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
// Links for Adjacent Posts
remove_action( 'wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );
// remove WP version
remove_action( 'wp_head', 'wp_generator' );
// cleaning up wordpress (it's pretty messy)
// remove p around images
add_filter('the_content', 'bfg_filter_ptags_on_images');
// remove pesky injected css for recent comments widget
add_filter( 'wp_head', 'bfg_remove_wp_widget_recent_comments_style', 1 );
// clean up comment styles in the head
add_action('wp_head', 'bfg_remove_recent_comments_style', 1);
// clean up gallery output in wp
add_filter('gallery_style', 'bfg_gallery_style');
// CHILD THEME IMAGE SIZES ***************************
add_image_size( 'bfg_large_img', 620, 240, TRUE );
add_image_size( 'bfg_medium_img', 225, 225, TRUE );
add_image_size( 'bfg_small_img', 45, 45, TRUE );
/*
to add more sizes, simply copy a line from above
and change the dimensions & name. As long as you
upload a "featured image" as large as the biggest
set width or height, all the other sizes will be
auto-cropped.
To call a different size, simply change the text
inside the thumbnail function.
For example, to call the 225 x 225 sized image,
we would use the function:
<?php the_post_thumbnail( 'bfg_medium_img' ); ?>
You can change the names and dimensions to whatever
you like.
*/
// CONTENT AREA **************************************
// SIDEBARS AND ASIDES *******************************
/*
if you want to remove sidebars, you can use the functions
below. to add a sidebar, you can just register another.
*/
// unregister_sidebar( 'sidebar' );
// unregister_sidebar( 'sidebar-alt' );
/*
to register another sidebar you can use a function similar
to the one below.
// register a sidebar for a specific page
genesis_register_sidebar(array(
'name'=>'Sidebar Special',
'id' => 'sidebar-special',
'description' => 'An Example Special Sidebar.',
'before_widget' => '<div id="%1$s" class="widget %2$s">',
'after_widget' => "</div>",
'before_title' => '<h4 class="widgettitle">',
'after_title' => "</h4>"
));
*/
// COMMENTS & PINGBACKS ******************************
// custom comment layout
add_filter( 'genesis_comment_form_args','bfg_custom_comment_form' );
// trackback argument & layout
add_filter( 'genesis_ping_list_args', 'bfg_ping_list_args' );
// comments & trackbacks
add_filter( 'genesis_comment_list_args', 'bfg_comment_list_args' );
// FOOTER AREA ***************************************
// custom back to top text
add_filter( 'genesis_footer_backtotop_text', 'bfg_backtotop_text' );
// footer credit & attribution text
add_filter('genesis_footer_creds_text', 'bfg_footer_cred');
/*
if you want to add widgets to your footer, you can use this function
*/
// add_theme_support( 'genesis-footer-widgets', 3 );
} /* DO NOT DELETE (YOUR CHILD THEME WILL IMPLODE!) */
// UNREGISTER GENESIS WIDGETS ****************************
/*
to use this function, make sure to uncomment it out in
the theme setup function above.
*/
function remove_genesis_widgets() {
unregister_widget( 'Genesis_eNews_Updates' );
unregister_widget( 'Genesis_Featured_Page' );
unregister_widget( 'Genesis_User_Profile_Widget' );
unregister_widget( 'Genesis_Menu_Pages_Widget' );
unregister_widget( 'Genesis_Widget_Menu_Categories' );
unregister_widget( 'Genesis_Featured_Post' );
unregister_widget( 'Genesis_Latest_Tweets_Widget' );
}
// USING GENESIS HOOKS /**********************************
/*
The Genesis Framework uses hooks to move content around.
Instead of listing them all out, I'll show you a quick example
so you can get a quick idea of how they work.
In this example, we're going to move the nav from underneath the
header to above the header. A very common practice.
First we identify the element or function we want to move. We can
view a list of all the hooks here:
http://dev.studiopress.com/hook-reference
Once we identify the one we want to target, we remove the action:
remove_action( 'genesis_after_header', 'genesis_do_nav' );
Great, now it's gone. But we want it to display somewhere else. So
let's add it back in before the header:
add_action('genesis_before_header', 'genesis_do_nav');
That's it. reload your page and you should see it in it's new
position. For an easier visual look of all the hooks in action,
check out this page:
http://www.nothingcliche.com/genesis-theme-framework-visual-hook-reference/
Here's an example function with an alert. Try to add this
example function in different spots to see where they land
in your child theme. It can help you visualize better.
*/
function genesis_do_example() {
// enter your function here
?> <div class="alert help">
<p>This is an example function. Please replace this with your own custom function.</p>
</div>
<?php }
/*
To add it, just use the above example and replace the last function
with "genesis_do_example". So to add this example above the header,
you would use:
add_action('genesis_before_header', 'genesis_do_example');
// USING GENESIS FILTERS /******************************
Aside from hooks, Genesis uses filters to replace the
content contained inside functions. While not as
flexible as hooks, filters can add an extra layer of
detail to your child themes.
You can find a list of all the filters here:
http://dev.studiopress.com/filter-reference
Let's use a live example to show how filters work. We're
going to change the attribution text as well as the
"Back to Top" link located in the footer.
*/
// changing the footer attribution
function bfg_footer_cred($bfg_ft) {
$bfg_ft = '© ' . date("Y") . ' ' . get_bloginfo("name") .' · Built Using <a href="http://themble.com/genesis/bones">Bones for Genesis</a>.';
return $bfg_ft;
}
// customizing text from back to top link
function bfg_backtotop_text($backtotop) {
// simply replace what's inside the "..."
$backtotop = '[footer_backtotop text="Back To Top"]';
return $backtotop;
}
/*
We added the add_filter function to the after theme setup
function up top.
That's it. It's way more complex than using hooks and sometimes
it can be pretty darn confusing to be quite honest. Luckily,
you can get by using mostly hooks.
// CUSTOM CHILD THEME FUNCTIONS /***********************
/*
Here's where you can add your functions for you
child theme. remember to add / remove your actions
up top in the theme setup function so we can keep
things organized.
*/
?>