-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathfunctions.php
383 lines (306 loc) · 9.97 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
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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
<?php
/*
A demonstration responsive child theme for the Wonderflux WordPress theme framework (requires Wonderflux version 2 minimum)
Could be used as a starter child theme, take a look at the code - lots of comments for you to learn how to use Wonderflux!
REQUIRES the free, Open Source Wonderflux theme framework - available from https://github.com/Jonnyauk/Wonderflux
PLEASE view readme file for more info.
Every Wonderflux framework function begins with wfx_ and is documented in wonderflux/functions.php
//// CONTENTS
1 - Wonderflux theme building functions
2 - Manipulate Wonderflux from child theme examples
3 - WordPress theme configuration
4 - External scripts
//// OTHER NOTES
- Text domain for translation: 'wfx-girder'
/*
#
##
# #
#
#
#
#####
Wonderflux theme building functions
*/
/**
*
* Wonderflux debug functionality
* Uncomment this (and be logged in as admin level user) to turn on debug mode in Wonderflux.
* 1) Reveals all hooks in layout
* 2) New menu under top admin menu - Wonderflux > Files in use - shows template files and source
*
*/
//define( 'WF_DEBUG', true );
/**
*
* Setup some Wonderflux layout options
*
*/
function my_wfx_layout() {
// Configure background divs as required.
// Increase depth to add for for multi-layered backgrounds.
wfx_background_divs('depth=1&location=site');
wfx_background_divs('depth=1&location=main');
wfx_background_divs('depth=1&location=header');
wfx_background_divs('depth=1&location=footer');
// Remove the sidebar using filter
//layout div's around main content adapt automatically - cool!
//add_filter('wflux_sidebar_1_display', 'wfx__N' );
// Inserts JQuery and Cycle Javascript
//Configure using file js/cycle/jquery.cycle.config.js
// Removed - need to make responsive with Cycle2 upgrade
//wfx_js_cycle('config=theme');
}
add_action('get_header', 'my_wfx_layout', 1);
/**
*
* Defines and automatically inserts widget areas using the Wonderflux display hook system.
* If no 'location' set, you insert widget area as normal in theme file.
*
*/
function my_wfx_widgets() {
wfx_widgets(
array (
/* All parameters - hooked into wfsidebar_before_all, so no template code */
array (
"name" => __( 'Above sidebar', 'wfxgider' ),
"description" => __( 'Drag widgets here to be shown above the sidebar on all pages.', 'wfxgider' ),
"location" => "wfsidebar_before_all",
"container" => "div",
"containerclass" => "widget-box",
"titlestyle" => "h4",
"titleclass" => "sidebar-title",
"before" => "",
"after" => ""
),
/* Special - hooked into wfsidebar_after_home, so no template code */
array (
"name" => __( 'Below homepage sidebar', 'wfxgider' ),
"description" => __( 'Drag widgets here to be shown below the sidebar, ONLY on the homepage.', 'wfxgider' ),
"location" => "wfsidebar_after_home",
"titleclass" => "sidebar-title",
"containerclass" => "widget-box",
"titlestyle" => "h4"
),
/* Special - hooked into wfloop_after_found_posts_home, so no template code */
array (
"name" => __( 'Below content', 'wfxgider' ),
"location" => "wfloop_after_found_posts_home",
"description" => __( 'Drag widgets here to be shown below the main content, ONLY on the homepage.', 'wfxgider' ),
"containerclass" => "box-1-1 widget-box widget-box-below-content",
"titlestyle" => "h2"
),
/* Simple example - no auto insertion (no $location param) so have to put standard WP code in footer to appear */
array (
"name" => __( 'Footer primary 1', 'wfxgider' ),
"description" => __( 'Drag widgets here to be shown in the footer area (small left area)', 'wfxgider' ),
"titleclass" => "sidebar-title",
"containerclass" => "widget-box",
"titlestyle" => "h4"
),
/* Simple example - no auto insertion (no $location param) so have to put standard WP code in footer to appear */
array (
"name" => __( 'Footer primary 2', 'wfxgider' ),
"description" => __( 'Drag widgets here to be shown in the footer area (small right area)', 'wfxgider' ),
"titleclass" => "sidebar-title",
"containerclass" => "widget-box",
"titlestyle" => "h4"
)
)
);
}
add_action( 'widgets_init', 'my_wfx_widgets' );
/*
#####
# #
#
#####
#
#
#######
Manipulate Wonderflux from child theme examples
*/
/**
*
* EXAMPLE 1 - ADDING A FILTER
* Core Wonderflux functionality can be filtered from child theme
*
*/
function my_wfx_filter_my_wf_functions() {
// Appears at the bottom of the page as a HTML comment (view source)
return 'Designed by me! Powered by WordPress and the Wonderflux theme framework - GPL ROCKS!';
}
add_filter( 'wflux_comment_code_credit', 'my_wfx_filter_my_wf_functions' );
/**
*
* EXAMPLE 3 - UNHOOKING A CORE WONDERFLUX FUNCTION
* Displays sizing configuration as comment in <head> of document output
* TODO: Core functionality needs updating for Wonderflux v2
*
*/
function my_wfx_unhook_core_functions() {
remove_action('wf_head_meta', 'wfx_display_css_info');
}
add_action('init','my_wfx_unhook_core_functions');
/**
* EXAMPLE 4 - REPLACING A CORE WONDERFLUX FUNCTION (Remove comment to activate)
* By using the same function name as used in the Wonderflux functions.php file,
* we can override the existing core Wonderflux function. Often filters will be
* your best choice for tasks like this rather than replacing the whole function.
*
* Wonderflux also is fully OOP structured for more advanced modification,
* please see Wonderflux source files for more information (wf-includes directory)
*/
// function wfx_display_head_title() {
// $this_title = esc_attr( get_bloginfo( 'title', 'display' ) );
// $this_desc = esc_attr( get_bloginfo( 'description', 'display' ) );
// $output = '<title>';
// $output .= $this_title.' - All about '.$this_desc;
// $output .= '</title>';
// echo $output;
// }
/**
* EXAMPLE 5 - FILTER AND CHANGE SIZE DEFINITIONS (Remove comment to activate)
* Needs updating and checking for Flux Layout (Wonderflux v2)
*
* Un-comment the code below to override the options set in admin > Wonderflux > Stylelab
* NOTE THAT FILTERS ALWAYS TAKE PRIORITY over saved admin options
*/
// function my_wfx_size_sidebar() { return 'quarter'; }
// function my_wfx_size_content() { return 'three_quarter'; }
// add_filter('wflux_sidebar_1_size', 'my_wfx_size_sidebar');
// add_filter('wflux_content_1_size', 'my_wfx_size_content');
/*
#####
# #
#
#####
#
# #
#####
WordPRess theme configuration
*/
/**
* Add editor style.
* A bit lazy, but at-least it should be consistent with front-end!
*/
add_editor_style( 'style.css' );
$background_defaults = array(
'default-color' => '003e51',
'wp-head-callback' => '_custom_background_cb',
);
add_theme_support( 'custom-background', $background_defaults );
/**
* Setup translation.
*/
function my_wfx_lang_setup() {
load_theme_textdomain( 'wfx-girder', WF_THEME_URL . '/assets/languages' );
}
add_action( 'after_setup_theme', 'my_wfx_lang_setup' );
/**
* Setup menus.
* Menus will not show automatically unless you configure them in:
* admin > Appearance > Menus > Manage locations
*
* WordPress normally defaults to showing all of your page links when a menu
* is not configured. This theme will simply not show anything - much neater!
*/
function my_wfx_register_nav(){
register_nav_menus( array(
'primary' => __( 'Primary navigation', 'wfx-girder' ),
'secondary' => __( 'Secondary navigation', 'wfx-girder' ),
) );
}
add_action( 'after_setup_theme', 'my_wfx_register_nav' );
/**
*
* Insert primary navigation in a fancy way by hooking into layout
* outside of main container (for full screen width)
* NOTE: Won't render a menu if not set (or menu is empty)
* admin > Appearance > Menus / Manage locations
*
*/
function my_wfx_insert_primary_nav() {
// Setup menu data
// Check if it has been set or is empty - no-one likes showing all links!
$this_menu = wp_nav_menu(
array(
'container_class' => 'header-navigation clearfix',
'menu_id' => 'primary-header-nav', /*Need to add ID to target for slicknav.js*/
'theme_location' => 'primary',
'echo' => false,
'fallback_cb' => '__return_false'
)
);
if ( !empty($this_menu) ){
echo '<div class="wrapper header-navigation-container">';
echo '<div class="container">';
echo $this_menu;
echo '</div>';
echo '</div>';
}
}
add_action('wfmain_before_all_container','my_wfx_insert_primary_nav', 2);
/**
*
* Insert footer navigation by using a Wonderflux hook
* Could be removed and just inserted straight into template file as normal
* NOTE: Won't render a menu if not set (or menu is empty)
* Admin > Appearance > Menus / Manage locations
*
*/
function my_wfx_insert_footer_nav() {
// Setup menu data
// Check if it has been set or is empty - no-one likes showing all links!
$this_menu = wp_nav_menu(
array(
'container_class' => 'footer-navigation clearfix',
'theme_location' => 'secondary',
'echo' => false,
'fallback_cb' => '__return_false'
)
);
echo ( !empty($this_menu) ) ? $this_menu : '';
}
add_action('wffooter_before_content','my_wfx_insert_footer_nav', 2);
/*
#
# #
# #
# #
#######
#
#
External scripts
*/
/**
*
* Enqueue all additional CSS.
* You could enqueue further files here.
*
*/
function my_wfx_enqueue_css() {
wp_register_style(
'g-font-1',
'http://fonts.googleapis.com/css?family=Signika',
'',
null,
'screen, projection'
);
// Signika Google font
wp_enqueue_style( 'g-font-1' );
}
add_action( 'wp_enqueue_scripts', 'my_wfx_enqueue_css' );
/**
*
* Enqueue all js... do it!
*
*/
function mywfx_enqueue_scripts() {
$this_theme = wp_get_theme()->get( 'Version' );
$this_theme = (empty($this_theme)) ? '1.0' : $this_theme;
wp_enqueue_script( 'slicknav', WF_THEME_URL . '/assets/js/jquery.slicknav.min.js', array( 'jquery' ), $this_theme, true );
wp_enqueue_script( 'theme-js', WF_THEME_URL . '/assets/js/functions.js', array( 'jquery' ), $this_theme, true );
}
add_action( 'wp_enqueue_scripts', 'mywfx_enqueue_scripts' );
?>