-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfunctions.php
1272 lines (1132 loc) · 38.3 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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/**
* jrBlog 1.0 functions and definitions
*
* Sets up the theme and provides some helper functions. Some helper functions
* are used in the theme as custom template tags. Others are attached to action and
* filter hooks in WordPress to change core functionality.
*
* The first function, jrconwayresponsiveblog_setup(), sets up the theme by registering support
* for various features in WordPress, such as post thumbnails, navigation menus, and the like.
*
* @package Wordpress
* @subpackage jrConway.jrBlog
* @since jrBlog 1.9.4
*/
#######################################
## -- START CUSTOMIZATION OPTIONS
#######################################
if ( ! function_exists( 'jrblog_custom_styles' ) ) :
/**
* Set Custom Stylesheets
*
* @since jrBlog 1.9.3
*/
function jrblog_custom_styles() {
/*
* Loads our main stylesheet.
*/
wp_enqueue_style( 'jrblog-styles', get_template_directory_uri() . '/css/style.less');
/*
* Load jQuery
*/
if (!is_admin()) {
wp_enqueue_script('jquery');
}
/*
* Load Javascript Functions
*/
wp_enqueue_script( 'modernizr', dirname(get_template_directory_uri()) . '/js/libs/modernizr-2.0.6.min.js');
wp_enqueue_script( 'twitter-bootstrap', dirname(get_template_directory_uri()) . '/js/bootstrap.min.js', array('jquery'));
wp_enqueue_script( 'jrblog-scripts', dirname(get_template_directory_uri()) . '/js/main.js', array('jquery'));
/*
* CHILD THEME:
*
* Copy this function to the functions.php file in the new child theme.
* Copy css/child.less to your child themes css folder and rename it style.less.
* Change "child" in the line below to your child theme's directory name.
* Uncomment the line below.
*/
//wp_enqueue_style( 'jrblog-styles', dirname(get_template_directory_uri()) . '/child/css/style.less');
}
endif;
add_action( 'wp_enqueue_scripts', 'jrblog_custom_styles' );
if ( ! function_exists( 'jrblog_extend_contact' ) ) :
/**
* Extend Custom Contact Fields
*
* @since jrBlog 1.0
*/
function jrblog_extend_contact($fields) {
/**
* CHILD THEME:
*
* Copy this function to the functions.php of your child theme and
* perform contact field overrides in the same way as the default.
*
* You can also override the default function, but this is NOT
* AT ALL recommended.
*/
// Add Array Overrides
// EXAMPLE: DISABLE FIELD
/*$fields['skype'] = false;*/
// EXAMPLE: ADD NEW FIELD
/*$fields['myspace] = array(
"name" => "MySpace",
"url" => "http://new.myspace.com/",
"share" => false
);*/
// Return Contact Fields
return $fields;
}
endif;
if ( ! function_exists( 'jrblog_custom_contact' ) ) :
/**
* Set Custom Contact Fields
*
* @since jrBlog 1.0
*/
function jrblog_custom_contact() {
/**
* Format in the following way:
*
* "type" => array(
* "name" => "Type", // Full name of contact type
* "url" => "http://", // URL location to personal profile
* "url" => "", // Don't set to disable follow options in theme options
* "share" => true, // Enable sharing options in theme options
* "share" => false, // Disable sharing options in theme options
* ),
*
*
* To disable existing fields:
*
* "type" => false, // Set full array to "false" to remove it entirely.
*/
// Return Array of Contact Fields
$fields = array(
"aim" => false,
"yim" => false,
"jabber" => false,
"skype" => array(
"name" => "Skype",
"url" => "",
"share" => false
),
"facebook" => array(
"name" => "Facebook",
"url" => "http://www.facebook.com/",
"share" => true
),
"twitter" => array(
"name" => "Twitter",
"url" => "http://www.twitter.com/",
"share" => true
),
"googleplus" => array(
"name" => "Google+",
"url" => "http://plus.google.com/",
"share" => true
),
"linkedin" => array(
"name" => "LinkedIn",
"url" => "http://www.linkedin.com/pub/",
"share" => true
),
"tumblr" => array(
"name" => "Tumblr",
"url" => "http://www.tumblr.com",
"share" => false,
"sub" => true
)
);
// Extend Custom Fields
$fields = jrblog_extend_contact($fields);
// Return Contact Fields
return $fields;
}
endif;
if ( ! function_exists( 'jrblog_widgets_extend' ) ) :
/**
* Extends our page widget areas.
*
* @since jrBlog 1.0
*/
function jrblog_widgets_extend() {
/**
* CHILD THEME:
*
* Copy this function into your child theme's functions.php.
*
* This will extend the jrBlog sidebar widgets without overwriting
* the existing sidebars.
*
* The commented register_sidebar function below may be used as an example.
*
* If you wish to overwrite the existing sidebars (NOT RECOMMENDED)
* you can also copy the jrblog_widgets_init() function.
*/
/*register_sidebar( array(
'name' => __( 'Right Sidebar', 'jrblog' ),
'id' => 'sidebar-1',
'description' => __( 'Right sidebar for the page. Can be used in right sidebar and three-column layouts.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );*/
}
endif;
if ( ! function_exists( 'jrblog_widgets_init' ) ) :
/**
* Registers our page widget areas.
*
* @since jrBlog 1.0
*/
function jrblog_widgets_init() {
/**
* Sidebar Widgets
*
* These are your typical, every day sidebar widgets. Instead of the usual set up,
* we'll enable the ability for a three column layout. There will be page templates
* for left sidebar, right sidebar, and two sidebars. These sidebars will be used for
* each respective side.
*/
register_sidebar( array(
'name' => __( 'Right Sidebar', 'jrblog' ),
'id' => 'sidebar-1',
'description' => __( 'Right sidebar for the page. Can be used in right sidebar and three-column layouts.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Left Sidebar', 'jrblog' ),
'id' => 'sidebar-2',
'description' => __( 'Left sidebar for the page. Can be used in left sidebar and three-column layouts.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
/**
* Header Widgets
*
* Header widgets are defined second to avoid the default widgets being inserted into them.
*
* This could technically go into Theme Options, but what if uses want to do more
* advanced features with the header area? We'll still define a header upload in the
* common location, but if that isn't enabled it'll default to this.
*/
register_sidebar( array(
'name' => __( 'Header Image', 'jrblog' ),
'id' => 'header-1',
'description' => __( 'Header area for the site logo to go.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '',
'after_title' => '',
) );
register_sidebar( array(
'name' => __( 'Header Sidebar', 'jrblog' ),
'id' => 'header-2',
'description' => __( 'Header sidebar to the right of the header image.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
/**
* Copyright Widgets
*
* The copyright area is a narrow bar at the bottom of the page separate from the main
* footer widgets. For this reason we create separate footer widgets.
*
* This could technically go into Theme Options, but what if uses want to do more
* advanced features with the copyright area? Let's allow them to change what's in here
* using widgets instead of forcing a simple line of text.
*/
register_sidebar( array(
'name' => __( 'Copyright Footer', 'jrblog' ),
'id' => 'copyright-1',
'description' => __( 'Footer area for the copyright.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h6 class="copyright-title">',
'after_title' => '</h6>',
) );
register_sidebar( array(
'name' => __( 'Copyright Sidebar', 'jrblog' ),
'id' => 'copyright-2',
'description' => __( 'Sidebar for the copyright to enable two-column copyright area', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h6 class="copyright-title">',
'after_title' => '</h6>',
) );
/**
* Content Widgets
*
* The content widgets are widgets set within the main content area but aren't
* sidebars. These can be useful to insert content above and below page content,
* or above and below the entire content area but within the main wrapper.
*/
register_sidebar( array(
'name' => __( 'Banner Image', 'jrblog' ),
'id' => 'banner-1',
'description' => __( 'Widget area for an image/slider in the content header.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Banner Sidebar', 'jrblog' ),
'id' => 'banner-2',
'description' => __( 'Widget area for the banner sidebar in the content header.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Content After Banner', 'jrblog' ),
'id' => 'content-1',
'description' => __( 'Widget area above the content columns right after the banner.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Content Before Post', 'jrblog' ),
'id' => 'content-2',
'description' => __( 'Widget area in the primary column above the post content.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Content After Post', 'jrblog' ),
'id' => 'content-3',
'description' => __( 'Widget area in the primary column below the post content.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
register_sidebar( array(
'name' => __( 'Content Before Footer', 'jrblog' ),
'id' => 'content-4',
'description' => __( 'Widget area below the content columns right before the footer.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
/**
* Footer Widgets
*
* Lastly we have our footer widgets. There are four footer widgets, and these will
* automatically be resized to fit based on how many widget areas are enabled.
*
* There will be a theme options page set up, though, to change the effects of how
* these will work. For example, these widget areas could go above the copyright or
* below the copyright. They also could be set to auto-resize based on how many widget
* areas are enabled, or just to sit at the center of the footer area with a fixed width.
*/
register_sidebar( array(
'name' => __( 'Footer 1', 'jrblog' ),
'id' => 'footer-1',
'description' => __( 'First widget area of the site footer.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="footer-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => __( 'Footer 2', 'jrblog' ),
'id' => 'footer-2',
'description' => __( 'Second widget area of the site footer.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="footer-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => __( 'Footer 3', 'jrblog' ),
'id' => 'footer-3',
'description' => __( 'Third widget area of the site footer.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="footer-title">',
'after_title' => '</h4>',
) );
register_sidebar( array(
'name' => __( 'Footer 4', 'jrblog' ),
'id' => 'footer-4',
'description' => __( 'Fourth widget area of the site footer.', 'jrblog' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h4 class="footer-title">',
'after_title' => '</h4>',
) );
// Extend Widgets
jrblog_widgets_extend();
}
endif;
add_action( 'widgets_init', 'jrblog_widgets_init' );
if ( ! function_exists( 'jrblog_class_extend' ) ) :
/**
* Extends the default jrBlog body class.
*
* @since jrBlog 1.0
*
* @param array Existing class values.
* @return array Filtered class values.
*/
function jrblog_class_extend( $classes ) {
/**
* CHILD THEME:
*
* Copy this function into your child theme's functions.php.
*
* This will extend the jrBlog body classes without overwriting
* the existing classes.
*
* If you wish to overwrite the existing classes (NOT RECOMMENDED)
* you can also copy the jrblog_class_init() function.
*/
// Return Classes (DO. NOT. REMOVE.)
return $classes;
}
endif;
if ( ! function_exists( 'jrblog_class_init' ) ) :
/**
* Extends the default WordPress body class.
*
* @since jrBlog 1.9.4
*
* @param array Existing class values.
* @return array Filtered class values.
*/
function jrblog_class_init( $classes ) {
// Check if No Sidebars or Full Width Template
if ((!is_active_sidebar( 'sidebar-1' ) && !is_active_sidebar( 'sidebar-2')) ||
is_page_template( 'templates/full-width.php' ) ) {
// Add Full Width Class
$classes[] = 'full-width';
}
// Check for Only Right Sidebar or Right Sidebar Template
elseif (( is_active_sidebar( 'sidebar-1' ) && !is_active_sidebar( 'sidebar-2' ) )
|| is_page_template( 'templates/right-sidebar.php' )) {
// Add Right Sidebar Class
$classes[] = 'right-sidebar';
}
// Check for Only Left Sidebar or Left Sidebar Template
elseif (( !is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-2' ) )
|| is_page_template( 'templates/left-sidebar.php' )) {
// Add Left Sidebar Class
$classes[] = 'left-sidebar';
}
// Check for Two Sidebars or Two Sidebar Template
elseif (( is_active_sidebar( 'sidebar-1' ) && is_active_sidebar( 'sidebar-2' ) )
|| is_page_template( 'templates/two-sidebar.php' )) {
// Add Two Sidebars Class
$classes[] = 'two-sidebars';
}
// Count Footer Areas Available
$footers = 0;
if (is_active_sidebar( 'footer-1' )) {
$footers++;
}
if (is_active_sidebar( 'footer-2' )) {
$footers++;
}
if (is_active_sidebar( 'footer-3' )) {
$footers++;
}
if (is_active_sidebar( 'footer-4' )) {
$footers++;
}
// Add Number of Footers Class
$classes[] = 'footers-'.$footers;
// Check for Follow Icons or Copyright Sidebar
if ( is_active_sidebar( 'header-2' ) ) {
// Add Copyright Columns Class
$classes[] = 'header-columns';
}
// Check for Follow Icons or Copyright Sidebar
if ( is_active_sidebar( 'copyright-2' ) || jrblog_follow_icons()) {
// Add Copyright Columns Class
$classes[] = 'copyright-columns';
}
// Banner Sidebar Enabled
if ( is_active_sidebar( 'banner-2' ) ) {
// Add Copyright Columns Class
$classes[] = 'banner-sidebar';
}
// Check for Share Buttons
if ( jrblog_share_buttons() ) {
// Add Share Posts Class
$classes[] = 'share-posts';
}
// Check for Blog Template
if ( is_page_template( 'blog.php' ) || is_category() || is_search() ||
is_single() || is_tag() ) {
// Add Blog Class
$classes[] = 'blog';
}
// Check for Default Template
if ( is_page_template( 'page.php' ) ) {
// Add Front Page Class
$classes[] = 'template-front-page';
// Check for Post Thumbnail
if ( has_post_thumbnail() ) {
// Add Has Post Thumbnail Class
$classes[] = 'has-post-thumbnail';
}
}
// Check for Multi Author
if ( ! is_multi_author() ) {
// Add Single Author Class
$classes[] = 'single-author';
}
// Extend Body Classes
$classes = jrblog_class_extend($classes);
return $classes;
}
endif;
add_filter( 'body_class', 'jrblog_class_init' );
if ( ! function_exists( 'jrblog_excerpt_more' ) ) :
/**
* Change Read More Text on Excerpts
*
* @since jrBlog 1.9.3
*
* @param array Existing class values.
* @return array Filtered class values.
*/
function jrblog_excerpt_more($output) {
return $output . '<p><a class="moretag" href="'. get_permalink( get_the_ID() ) . '">Read More</a></p>';
}
endif;
add_filter('the_excerpt', 'jrblog_excerpt_more');
#######################################
## -- END CUSTOMIZATION OPTIONS
#######################################
#######################################
## -- START INITIALIZATION FUNCTIONS
#######################################
/**
* Sets up theme defaults and registers the various WordPress features that
* jrBlog supports.
*
* @uses load_theme_textdomain() For translation/localization support.
* @uses add_editor_style() To add a Visual Editor stylesheet.
* @uses add_theme_support() To add support for post thumbnails, automatic feed links,
* custom background, and post formats.
* @uses register_nav_menu() To add support for navigation menus.
* @uses set_post_thumbnail_size() To set a custom post thumbnail size.
*
* @since jrBlog 1.0
*/
function jrblog_setup() {
/*
* Import WP Less
*
* This will be used for all available stylesheets.
*/
require_once( 'wp-less/wp-less.php' );
/*
* Makes Template available for translation.
*
* Translations can be added to the /languages/ directory.
*/
load_theme_textdomain( 'jrblog', get_template_directory() . '/languages' );
// This theme styles the visual editor with editor-style.css to match the theme style.
add_editor_style();
// Adds RSS feed links to <head> for posts and comments.
add_theme_support( 'automatic-feed-links' );
// This theme supports a variety of post formats.
add_theme_support( 'post-formats', array( 'aside', 'image', 'link', 'quote', 'status' ) );
// This theme uses wp_nav_menu() in five locations.
register_nav_menu( 'primary', __( 'Primary Menu', 'jrblog' ) );
register_nav_menu( 'footer-1', __( 'Footer 1', 'jrblog' ) );
register_nav_menu( 'footer-2', __( 'Footer 2', 'jrblog' ) );
register_nav_menu( 'footer-3', __( 'Footer 3', 'jrblog' ) );
register_nav_menu( 'footer-4', __( 'Footer 4', 'jrblog' ) );
// This theme uses a custom image size for featured images, displayed on "standard" posts.
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 624, 9999 ); // Unlimited height, soft crop
}
add_action( 'after_setup_theme', 'jrblog_setup' );
/*
* Loads the Options Panel
*
* If you're loading from a child theme use stylesheet_directory
* instead of template_directory
*/
if ( !function_exists( 'optionsframework_init' ) ) {
define( 'OPTIONS_FRAMEWORK_DIRECTORY', get_template_directory_uri() . '/inc/' );
require_once dirname( __FILE__ ) . '/inc/options-framework.php';
}
/**
* Enqueues scripts and styles for front-end.
*
* @since jrBlog 1.0
*/
function jrblog_scripts_styles() {
global $wp_styles;
/*
* Adds JavaScript to pages with the comment form to support
* sites with threaded comments (when in use).
*/
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) )
wp_enqueue_script( 'comment-reply' );
/*
* Adds JavaScript for handling the navigation menu hide-and-show behavior.
*/
wp_enqueue_script( 'jrblog-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '1.0', true );
/*
* Loads our special font CSS file.
*
* The use of Open Sans by default is localized. For languages that use
* characters not supported by the font, the font can be disabled.
*
* To disable in a child theme, use wp_dequeue_style()
* function mytheme_dequeue_fonts() {
* wp_dequeue_style( 'jrblog-fonts' );
* }
* add_action( 'wp_enqueue_scripts', 'mytheme_dequeue_fonts', 11 );
*/
/* translators: If there are characters in your language that are not supported
by Open Sans, translate this to 'off'. Do not translate into your own language. */
if ( 'off' !== _x( 'on', 'Open Sans font: on or off', 'jrblog' ) ) {
$subsets = 'latin,latin-ext';
/* translators: To add an additional Open Sans character subset specific to your language, translate
this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language. */
$subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)', 'jrblog' );
if ( 'cyrillic' == $subset )
$subsets .= ',cyrillic,cyrillic-ext';
elseif ( 'greek' == $subset )
$subsets .= ',greek,greek-ext';
elseif ( 'vietnamese' == $subset )
$subsets .= ',vietnamese';
$protocol = is_ssl() ? 'https' : 'http';
$query_args = array(
'family' => 'Open+Sans:400italic,700italic,400,700',
'subset' => $subsets,
);
wp_enqueue_style( 'jrblog-fonts', add_query_arg( $query_args, "$protocol://fonts.googleapis.com/css" ), array(), null );
}
/*
* Loads all required Javascript files.
*/
wp_enqueue_script( 'modernizr', get_template_directory_uri() . '/js/libs/modernizr-2.0.6.min.js', array( 'jquery' ), '2.0.6' );
wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array( 'jquery' ), '2.3.0' );
}
add_action( 'wp_enqueue_scripts', 'jrblog_scripts_styles' );
/**
* Creates a nicely formatted and more specific title element text
* for output in head of document, based on current view.
*
* @since jrBlog 1.0
*
* @param string $title Default title text for current view.
* @param string $sep Optional separator.
* @return string Filtered title.
*/
function jrblog_wp_title( $title, $sep ) {
global $paged, $page;
if ( is_feed() )
return $title;
// Add the site name.
$title .= get_bloginfo( 'name' );
// Add the site description for the home/front page.
$site_description = get_bloginfo( 'description', 'display' );
if ( $site_description && ( is_home() || is_front_page() ) )
$title = "$title $sep $site_description";
// Add a page number if necessary.
if ( $paged >= 2 || $page >= 2 )
$title = "$title $sep " . sprintf( __( 'Page %s', 'jrblog' ), max( $paged, $page ) );
return $title;
}
add_filter( 'wp_title', 'jrblog_wp_title', 10, 2 );
/**
* Makes our wp_nav_menu() fallback -- wp_page_menu() -- show a home link.
*
* @since jrBlog 1.0
*/
function jrblog_page_menu_args( $args ) {
if ( ! isset( $args['show_home'] ) )
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'jrblog_page_menu_args' );
if ( ! function_exists( 'jrblog_content_nav' ) ) :
/**
* Displays navigation to next/previous pages when applicable.
*
* @since jrBlog 1.0
*/
function jrblog_content_nav( $html_id ) {
global $wp_query;
$html_id = esc_attr( $html_id );
if ( $wp_query->max_num_pages > 1 ) : ?>
<nav id="<?php echo $html_id; ?>" class="navigation" role="navigation">
<h3 class="assistive-text"><?php _e( 'Post navigation', 'jrblog' ); ?></h3>
<div class="nav-previous alignleft"><?php next_posts_link( __( '<span class="meta-nav">←</span> Older posts', 'jrblog' ) ); ?></div>
<div class="nav-next alignright"><?php previous_posts_link( __( 'Newer posts <span class="meta-nav">→</span>', 'jrblog' ) ); ?></div>
<div class="clear"> </div>
</nav><!-- #<?php echo $html_id; ?> .navigation -->
<?php endif;
}
endif;
if ( ! function_exists( 'jrblog_comment' ) ) :
/**
* Template for comments and pingbacks.
*
* To override this walker in a child theme without modifying the comments template
* simply create your own jrblog_comment(), and that function will be used instead.
*
* Used as a callback by wp_list_comments() for displaying the comments.
*
* @since jrBlog 1.0
*/
function jrblog_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $comment;
switch ( $comment->comment_type ) :
case 'pingback' :
case 'trackback' :
// Display trackbacks differently than normal comments.
?>
<li <?php comment_class(); ?> id="comment-<?php comment_ID(); ?>">
<p><?php _e( 'Pingback:', 'jrblog' ); ?> <?php comment_author_link(); ?> <?php edit_comment_link( __( '(Edit)', 'jrblog' ), '<span class="edit-link">', '</span>' ); ?></p>
<?php
break;
default :
// Proceed with normal comments.
global $post;
?>
<li <?php comment_class(); ?> id="li-comment-<?php comment_ID(); ?>">
<article id="comment-<?php comment_ID(); ?>" class="comment">
<header class="comment-meta comment-author vcard">
<?php
echo get_avatar( $comment, 44 );
printf( '<cite class="fn">%1$s %2$s</cite>',
get_comment_author_link(),
// If current post author is also comment author, make it known visually.
( $comment->user_id === $post->post_author ) ? '<span> ' . __( 'Post author', 'jrblog' ) . '</span>' : ''
);
printf( '<a href="%1$s"><time datetime="%2$s">%3$s</time></a>',
esc_url( get_comment_link( $comment->comment_ID ) ),
get_comment_time( 'c' ),
/* translators: 1: date, 2: time */
sprintf( __( '%1$s at %2$s', 'jrblog' ), get_comment_date(), get_comment_time() )
);
?>
</header><!-- .comment-meta -->
<?php if ( '0' == $comment->comment_approved ) : ?>
<p class="comment-awaiting-moderation"><?php _e( 'Your comment is awaiting moderation.', 'jrblog' ); ?></p>
<?php endif; ?>
<section class="comment-content comment">
<?php comment_text(); ?>
<?php edit_comment_link( __( 'Edit', 'jrblog' ), '<p class="edit-link">', '</p>' ); ?>
</section><!-- .comment-content -->
<div class="reply">
<?php comment_reply_link( array_merge( $args, array( 'reply_text' => __( 'Reply', 'jrblog' ), 'after' => ' <span>↓</span>', 'depth' => $depth, 'max_depth' => $args['max_depth'] ) ) ); ?>
</div><!-- .reply -->
</article><!-- #comment-## -->
<?php
break;
endswitch; // end comment_type check
}
endif;
if ( ! function_exists( 'jrblog_entry_meta' ) ) :
/**
* Prints HTML with meta information for current post: categories, tags, permalink, author, and date.
*
* Create your own jrblog_entry_meta() to override in a child theme.
*
* @since jrBlog 1.0
*/
function jrblog_entry_meta() {
// Translators: used between list items, there is a space after the comma.
$categories_list = get_the_category_list( __( ', ', 'jrblog' ) );
// Translators: used between list items, there is a space after the comma.
$tag_list = get_the_tag_list( '', __( ', ', 'jrblog' ) );
$date = sprintf( '<a href="%1$s" title="%2$s" rel="bookmark"><time class="entry-date" datetime="%3$s">%4$s</time></a>',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() )
);
$author = sprintf( '<span class="author vcard"><a class="url fn n" href="%1$s" title="%2$s" rel="author">%3$s</a></span>',
esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
esc_attr( sprintf( __( 'View all posts by %s', 'jrblog' ), get_the_author() ) ),
get_the_author()
);
// Translators: 1 is category, 2 is tag, 3 is the date and 4 is the author's name.
if ( $tag_list ) {
$utility_text = __( 'Posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'jrblog' );
} elseif ( $categories_list ) {
$utility_text = __( 'Posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'jrblog' );
} else {
$utility_text = __( 'Posted on %3$s<span class="by-author"> by %4$s</span>.', 'jrblog' );
}
printf(
$utility_text,
$categories_list,
$tag_list,
$date,
$author
);
}
endif;
/**
* Add postMessage support for site title and description for the Theme Customizer.
*
* @since jrBlog 1.0
*
* @param WP_Customize_Manager $wp_customize Theme Customizer object.
* @return void
*/
function jrblog_customize_register( $wp_customize ) {
$wp_customize->get_setting( 'blogname' )->transport = 'postMessage';
$wp_customize->get_setting( 'blogdescription' )->transport = 'postMessage';
}
add_action( 'customize_register', 'jrblog_customize_register' );
/**
* Binds JS handlers to make Theme Customizer preview reload changes asynchronously.
*
* @since jrBlog 1.0
*/
function jrblog_customize_preview_js() {
wp_enqueue_script( 'jrblog-customizer', get_template_directory_uri() . '/js/theme-customizer.js', array( 'customize-preview' ), '20120827', true );
}
add_action( 'customize_preview_init', 'jrblog_customize_preview_js' );
if ( ! function_exists( 'jrblog_schema' ) ):
/**
* Gets Site Schema From Theme Options
*
* @since jrBlog 1.0
*/
function jrblog_schema() {
// Get Theme Options
//$theme_options = jrblog_get_theme_options();
$theme_options = array();
// Output Schema
if(!empty($theme_options['schema'])) {
echo $theme_options['schema'];
}
else {
echo "Blog";
}
}
endif; // jrblog_schema
/**
* Add Extra Contact Fields
*
* @since jrBlog 1.0
*/
function jrblog_contact_info($contactmethods) {
// Get Social Sites
$fields = jrblog_custom_contact();
// Loop Social Sites
foreach($fields as $code => $field) {
// Valid Site?
if(!empty($field) && is_array($field) && count($field)) {
// Add to Contact Methods
$contactmethods[$code] = $field['name'];
}
elseif(empty($field['name'])) {
// Delete from Contact Methods
unset($contactmethods[$code]);
}
}
// Return Contact Methods
return $contactmethods;
}
add_filter('user_contactmethods', 'jrblog_contact_info');
#######################################
## -- END INITIALIZATION FUNCTIONS
#######################################
#######################################
## -- START SOCIAL FUNCTIONS
#######################################
/**
* Create Social Share Buttons
*
* @author David A Conway Jr.
* @param string $url : the url to share; defaults to current page's url
* @param string $text : the text in the share popup; defaults to current page's title
* @since jrBlog 1.0
*/
function jrblog_share_buttons($url = '', $text = '') {
// All Sharing Disabled?
if(of_get_option('share_disable')) {
return '';
}
// Get Social Sites
$fields = jrblog_custom_contact();
$html = '';
// Loop Social Sites
foreach($fields as $code => $field) {
// Valid Site?
if(!empty($field) && is_array($field) && count($field)) {
// Set Unique Variables
$share = of_get_option($code . '_share');
$func = 'jrblog_' . $code . '_button';
// Add to Contact Methods
if(!empty($share) && function_exists($func)) {
// Get Share Button
$html .= $func($url, $text);
}
}
}
// Return Share HTML
return $html;
}
/**
* Create Facebook Share Button
*
* @author David A Conway Jr.
* @param string $url : the url to share; defaults to current page's url