14
14
* Initiate Foundation, for WordPress
15
15
*/
16
16
17
+ if ( ! function_exists ( 'foundation_setup ' ) ) :
18
+
17
19
function foundation_setup () {
18
20
19
21
// Language Translations
@@ -43,23 +45,31 @@ function foundation_setup() {
43
45
) );
44
46
45
47
}
48
+
46
49
add_action ( 'after_setup_theme ' , 'foundation_setup ' );
47
50
51
+ endif ;
52
+
48
53
/**
49
54
* Enqueue Scripts and Styles for Front-End
50
55
*/
51
56
57
+ if ( ! function_exists ( 'foundation_assets ' ) ) :
58
+
52
59
function foundation_assets () {
53
60
54
61
if (!is_admin ()) {
55
62
63
+ /**
64
+ * Deregister jQuery in favour of ZeptoJS
65
+ * jQuery will be used as a fallback if ZeptoJS is not compatible
66
+ * @see foundation_compatibility & http://foundation.zurb.com/docs/javascript.html
67
+ */
56
68
wp_deregister_script ('jquery ' );
57
69
58
70
// Load JavaScripts
59
- wp_enqueue_script ( 'foundation ' , get_template_directory_uri () . '/js/foundation.min.js ' , array ('zepto ' ), '4.0 ' , true );
60
- wp_enqueue_script ('foundation-init ' , get_template_directory_uri ().'/js/foundation-init.js ' , array (), false , true );
71
+ wp_enqueue_script ( 'foundation ' , get_template_directory_uri () . '/js/foundation.min.js ' , null , '4.0 ' , true );
61
72
wp_enqueue_script ( 'modernizr ' , get_template_directory_uri ().'/js/vendor/custom.modernizr.js ' , null , '2.1.0 ' );
62
- wp_enqueue_script ( 'zepto ' , get_template_directory_uri ().'/js/vendor/zepto.js ' , null , '2.1.0 ' , true );
63
73
64
74
// Load Stylesheets
65
75
wp_enqueue_style ( 'normalize ' , get_template_directory_uri ().'/css/normalize.css ' );
@@ -75,25 +85,50 @@ function foundation_assets() {
75
85
76
86
add_action ( 'wp_enqueue_scripts ' , 'foundation_assets ' );
77
87
78
- <<<<<<< HEAD
79
-
80
88
endif ;
81
- =======
89
+
82
90
/**
83
91
* Initialise Foundation JS
92
+ * @see: http://foundation.zurb.com/docs/javascript.html
84
93
*/
85
94
86
- function foundationjs () {
95
+ if ( ! function_exists ( 'foundation_js_init ' ) ) :
96
+
97
+ function foundation_js_init () {
87
98
echo '<script>$(document).foundation();</script> ' ;
88
99
}
89
100
90
- add_action ('wp_footer ' , 'foundationjs ' ,100 );
91
- >>>>>>> Fixes
101
+ add_action ('wp_footer ' , 'foundation_js_init ' , 50 );
102
+
103
+ endif ;
104
+
105
+ /**
106
+ * ZeptoJS and jQuery Fallback
107
+ * @see: http://foundation.zurb.com/docs/javascript.html
108
+ */
109
+
110
+ if ( ! function_exists ( 'foundation_comptability ' ) ) :
111
+
112
+ function foundation_comptability () {
113
+
114
+ echo "<script> " ;
115
+ echo "document.write('<script src=' + " ;
116
+ echo "('__proto__' in {} ? ' " . get_template_directory_uri () . "/js/vendor/zepto " . "' : ' " . get_template_directory_uri () . "/js/vendor/jquery " . "') + " ;
117
+ echo "'.js><\/script>') " ;
118
+ echo "</script> " ;
119
+
120
+ }
121
+
122
+ add_action ('wp_footer ' , 'foundation_comptability ' , 10 );
123
+
124
+ endif ;
92
125
93
126
/**
94
127
* Register Navigation Menus
95
128
*/
96
129
130
+ if ( ! function_exists ( 'foundation_menus ' ) ) :
131
+
97
132
// Register wp_nav_menus
98
133
function foundation_menus () {
99
134
@@ -104,9 +139,13 @@ function foundation_menus() {
104
139
);
105
140
106
141
}
142
+
107
143
add_action ( 'init ' , 'foundation_menus ' );
108
144
109
- // Create a graceful fallback to wp_page_menu
145
+ endif ;
146
+
147
+ if ( ! function_exists ( 'foundation_page_menu ' ) ) :
148
+
110
149
function foundation_page_menu () {
111
150
112
151
$ args = array (
@@ -124,11 +163,12 @@ function foundation_page_menu() {
124
163
125
164
}
126
165
166
+ endif ;
167
+
127
168
/**
128
169
* Navigation Menu Adjustments
129
170
*/
130
171
131
-
132
172
// Add class to navigation sub-menu
133
173
class foundation_navigation extends Walker_Nav_Menu {
134
174
@@ -150,6 +190,8 @@ function display_element( $element, &$children_elements, $max_depth, $depth=0, $
150
190
* Create pagination
151
191
*/
152
192
193
+ if ( ! function_exists ( 'foundation_pagination ' ) ) :
194
+
153
195
function foundation_pagination () {
154
196
155
197
global $ wp_query ;
@@ -174,10 +216,14 @@ function foundation_pagination() {
174
216
175
217
}
176
218
219
+ endif ;
220
+
177
221
/**
178
222
* Register Sidebars
179
223
*/
180
224
225
+ if ( ! function_exists ( 'foundation_widgets ' ) ) :
226
+
181
227
function foundation_widgets () {
182
228
183
229
// Sidebar Right
@@ -239,40 +285,30 @@ function foundation_widgets() {
239
285
240
286
add_action ( 'widgets_init ' , 'foundation_widgets ' );
241
287
242
- /**
243
- * HTML5 IE Shim
244
- */
245
-
246
- function foundation_shim () {
247
- echo '<!--[if lt IE 9]> ' ;
248
- echo '<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> ' ;
249
- echo '<![endif]--> ' ;
250
- }
251
-
252
- add_action ('wp_head ' , 'foundation_shim ' );
288
+ endif ;
253
289
254
290
/**
255
291
* Custom Avatar Classes
256
292
*/
257
293
294
+ if ( ! function_exists ( 'foundation_avatar_css ' ) ) :
295
+
258
296
function foundation_avatar_css ($ class ) {
259
297
$ class = str_replace ("class='avatar " , "class='author_gravatar left " , $ class ) ;
260
298
return $ class ;
261
299
}
262
300
263
301
add_filter ('get_avatar ' ,'foundation_avatar_css ' );
264
302
303
+ endif ;
304
+
265
305
/**
266
306
* Custom Post Excerpt
267
307
*/
268
308
269
- <<<<<<< HEAD
270
309
if ( ! function_exists ( 'foundation_excerpt ' ) ) :
271
- function improved_trim_excerpt($ text ) {
272
310
273
- =======
274
311
function foundation_excerpt ($ text ) {
275
- >>>>>>> Fixes
276
312
global $ post ;
277
313
if ( '' == $ text ) {
278
314
$ text = get_the_content ('' );
@@ -284,7 +320,7 @@ function foundation_excerpt($text) {
284
320
$ words = explode (' ' , $ text , $ excerpt_length + 1 );
285
321
if (count ($ words )> $ excerpt_length ) {
286
322
array_pop ($ words );
287
- array_push ($ words , '<br><br><a href=" ' .get_permalink ($ post ->ID ) .'" class="button secondary small">Continue Reading</a> ' );
323
+ array_push ($ words , '<br><br><a href=" ' .get_permalink ($ post ->ID ) .'" class="button secondary small"> ' . __ ( ' Continue Reading ' , ' foundation ' ) . ' </a> ' );
288
324
$ text = implode (' ' , $ words );
289
325
}
290
326
}
@@ -294,68 +330,8 @@ function foundation_excerpt($text) {
294
330
remove_filter ('get_the_excerpt ' , 'wp_trim_excerpt ' );
295
331
add_filter ('get_the_excerpt ' , 'foundation_excerpt ' );
296
332
297
- /**
298
- * Comments Template
299
- */
300
-
301
- if ( ! function_exists ( 'foundation_comment ' ) ) :
302
-
303
- function foundation_comment ( $ comment , $ args , $ depth ) {
304
- $ GLOBALS ['comment ' ] = $ comment ;
305
- switch ( $ comment ->comment_type ) :
306
- case 'pingback ' :
307
- case 'trackback ' :
308
- // Display trackbacks differently than normal comments.
309
- ?>
310
- <li <?php comment_class (); ?> id="comment-<?php comment_ID (); ?> ">
311
- <p><?php _e ( 'Pingback: ' , 'foundation ' ); ?> <?php comment_author_link (); ?> <?php edit_comment_link ( __ ( '(Edit) ' , 'foundation ' ), '<span> ' , '</span> ' ); ?> </p>
312
- <?php
313
- break ;
314
- default :
315
- global $ post ;
316
- ?>
317
- <li <?php comment_class (); ?> id="li-comment-<?php comment_ID (); ?> ">
318
- <article id="comment-<?php comment_ID (); ?> " class="comment">
319
- <header>
320
- <?php
321
- echo "<span class='th alignleft' style='margin-right:1rem;'> " ;
322
- echo get_avatar ( $ comment , 44 );
323
- echo "</span> " ;
324
- printf ( '%2$s %1$s ' ,
325
- get_comment_author_link (),
326
- ( $ comment ->user_id === $ post ->post_author ) ? '<span class="label"> ' . __ ( 'Post Author ' , 'foundation ' ) . '</span> ' : ''
327
- );
328
- printf ( '<br><a href="%1$s"><time datetime="%2$s">%3$s</time></a> ' ,
329
- esc_url ( get_comment_link ( $ comment ->comment_ID ) ),
330
- get_comment_time ( 'c ' ),
331
- sprintf ( __ ( '%1$s at %2$s ' , 'foundation ' ), get_comment_date (), get_comment_time () )
332
- );
333
- ?>
334
- </header>
335
-
336
- <?php if ( '0 ' == $ comment ->comment_approved ) : ?>
337
- <p><?php _e ( 'Your comment is awaiting moderation. ' , 'foundation ' ); ?> </p>
338
- <?php endif ; ?>
339
-
340
- <section>
341
- <?php comment_text (); ?>
342
- </section><!-- .comment-content -->
343
-
344
- <div class="reply">
345
- <?php comment_reply_link ( array_merge ( $ args , array ( 'reply_text ' => __ ( 'Reply ' , 'foundation ' ), 'after ' => ' ↓ <br><br> ' , 'depth ' => $ depth , 'max_depth ' => $ args ['max_depth ' ] ) ) ); ?>
346
-
347
- </div>
348
- </article>
349
- <?php
350
- break ;
351
- endswitch ;
352
- }
353
333
endif ;
354
334
355
-
356
- remove_filter ('get_the_excerpt ' , 'wp_trim_excerpt ' );
357
- add_filter ('get_the_excerpt ' , 'improved_trim_excerpt ' );
358
-
359
335
/**
360
336
* Comments Template
361
337
*/
@@ -414,81 +390,15 @@ function foundation_comment( $comment, $args, $depth ) {
414
390
}
415
391
endif ;
416
392
417
- /**
418
- * Comment-Reply Script
419
- **/
420
- function foundation_comment_reply (){
421
- if ( is_singular () && comments_open () && get_option ( 'thread_comments ' ) ) {
422
- wp_enqueue_script ( 'comment-reply ' );
423
- }
424
- }
425
-
426
- add_action ( 'wp_enqueue_scripts ' , 'foundation_comment_reply ' );
427
-
428
393
/**
429
394
* Retrieve Shortcodes
395
+ * @see: http://fwp.drewsymo.com/shortcodes/
430
396
*/
431
397
432
- require ( get_template_directory () . '/ inc/shortcodes.php ' ) ;
398
+ $ foundation_shortcodes = trailingslashit ( get_template_directory () ) . 'inc/shortcodes.php ' ;
433
399
434
- /**
435
- * Set the content width based on the theme's design and stylesheet.
436
- */
437
- if ( ! isset ( $ content_width ) )
438
- $ content_width = 640 ; /* pixels */
439
- /**
440
- * Additional Header options
441
- **/
442
-
443
- // add custom header options hook
444
- add_action ('custom_header_options ' , 'foundation_image_options ' );
445
-
446
- /* Adds two new text fields, custom_option_one and custom_option_two to the Custom Header options screen */
447
- function foundation_image_options ()
448
- {
449
- ?>
450
- <table class="form-table">
451
- <tbody>
452
- <tr valign="top" class="hide-if-no-js">
453
- <th scope="row"><?php _e ( 'Custom Option One: ' ); ?> </th>
454
- <td><input id="custom_option_one" name="custom_option_one" type="checkbox" value="1" />
455
-
456
- <label for="custom_option_one"><?php _e ( 'option 1 ' ); ?> </label></td>
457
-
458
- </tr>
459
- <tr valign="top" class="hide-if-no-js">
460
- <th scope="row"><?php _e ( 'Custom Option Two: ' ); ?> </th>
461
- <td><input id="custom_option_two" name="custom_option_two" type="checkbox" value="1" />
462
-
463
- <label for="custom_option_two"><?php _e ( 'option 2 ' ); ?> </label></td>
464
-
465
- </tr>
466
-
400
+ if (file_exists ($ foundation_shortcodes )) {
401
+ require ( $ foundation_shortcodes );
402
+ }
467
403
468
-
469
- </tbody>
470
- </table>
471
- <?php
472
- } // end foundation_image_options
473
-
474
-
475
- add_action ('admin_head ' , 'foundation_custom_options ' );
476
- function foundation_custom_options ()
477
- {
478
- if ( isset ( $ _POST ['custom_option_one ' ] ) && isset ( $ _POST ['custom_option_two ' ] ) )
479
- {
480
- // validate the request itself by verifying the _wpnonce-custom-header-options nonce
481
- // (note: this nonce was present in the normal Custom Header form already, so we didn't have to add our own)
482
- check_admin_referer ( 'custom-header-options ' , '_wpnonce-custom-header-options ' );
483
-
484
- // be sure the user has permission to save theme options (i.e., is an administrator)
485
- if ( current_user_can ('manage_options ' ) ) {
486
-
487
- // NOTE: Add your own validation methods here
488
- set_theme_mod ( 'custom_option_one ' , $ _POST ['custom_option_one ' ] );
489
- set_theme_mod ( 'custom_option_two ' , $ _POST ['custom_option_two ' ] );
490
- }
491
- }
492
- return ;
493
- }
494
404
?>
0 commit comments