-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.php
1018 lines (931 loc) · 35.1 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
/*
* Author: Todd Motto | @toddmotto
* URL: html5blank.com | @html5blank
* Custom functions, support, custom post types and more.
*/
/*------------------------------------*\
External Modules/Files
\*------------------------------------*/
// Load any external files you have here
/*------------------------------------*\
Theme Support
\*------------------------------------*/
if (!isset($content_width))
{
$content_width = 900;
}
if (function_exists('add_theme_support'))
{
// Add Menu Support
add_theme_support('menus');
// Add Thumbnail Theme Support
add_theme_support('post-thumbnails');
add_image_size('large', 700, '', true); // Large Thumbnail
add_image_size('medium', 250, '', true); // Medium Thumbnail
add_image_size('small', 120, '', true); // Small Thumbnail
add_image_size('custom-size', 700, 200, true); // Custom Thumbnail Size call using the_post_thumbnail('custom-size');
// Add Support for Custom Backgrounds - Uncomment below if you're going to use
/*add_theme_support('custom-background', array(
'default-color' => 'FFF',
'default-image' => get_template_directory_uri() . '/img/bg.jpg'
));*/
// Add Support for Custom Header - Uncomment below if you're going to use
/*add_theme_support('custom-header', array(
'default-image' => get_template_directory_uri() . '/img/headers/default.jpg',
'header-text' => false,
'default-text-color' => '000',
'width' => 1000,
'height' => 198,
'random-default' => false,
'wp-head-callback' => $wphead_cb,
'admin-head-callback' => $adminhead_cb,
'admin-preview-callback' => $adminpreview_cb
));*/
// Enables post and comment RSS feed links to head
add_theme_support('automatic-feed-links');
// Localisation Support
load_theme_textdomain('html5blank', get_template_directory() . '/languages');
}
/*------------------------------------*\
Functions
\*------------------------------------*/
// HTML5 Blank navigation
function main_nav()
{
wp_nav_menu(
array(
'theme_location' => 'header-menu',
'menu' => '',
'container' => 'div',
'container_class' => 'menu-{menu slug}-container',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul>%3$s</ul>',
'depth' => 0,
'walker' => ''
)
);
}
function calls_to_action()
{
wp_nav_menu(
array(
'theme_location' => 'calls-to-action',
'menu' => '',
'container' => 'div',
'container_class' => 'menu-{menu slug}-container',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul>%3$s</ul>',
'depth' => 0,
'walker' => ''
)
);
}
function main_footer_menu()
{
wp_nav_menu(
array(
'theme_location' => 'main-footer-menu',
'menu' => '',
'container' => 'div',
'container_class' => 'menu-{menu slug}-container',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul>%3$s</ul>',
'depth' => 0,
'walker' => ''
)
);
}
function secondary_footer_menu()
{
wp_nav_menu(
array(
'theme_location' => 'secondary-footer-menu',
'menu' => '',
'container' => 'div',
'container_class' => 'menu-{menu slug}-container',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'before' => '',
'after' => '',
'link_before' => '',
'link_after' => '',
'items_wrap' => '<ul>%3$s</ul>',
'depth' => 0,
'walker' => ''
)
);
}
// Load HTML5 Blank scripts (header.php)
function html5blank_header_scripts()
{
if ($GLOBALS['pagenow'] != 'wp-login.php' && !is_admin()) {
wp_register_script('conditionizr', get_template_directory_uri() . '/js/lib/conditionizr-4.3.0.min.js', array(), '4.3.0'); // Conditionizr
wp_enqueue_script('conditionizr'); // Enqueue it!
wp_register_script('modernizr', get_template_directory_uri() . '/js/lib/modernizr-2.7.1.min.js', array(), '2.7.1'); // Modernizr
wp_enqueue_script('modernizr'); // Enqueue it!
wp_register_script('html5blankscripts', get_template_directory_uri() . '/js/scripts.js', array('jquery'), '1.0.0'); // Custom scripts
wp_enqueue_script('html5blankscripts'); // Enqueue it!
}
}
// Load HTML5 Blank conditional scripts
function html5blank_conditional_scripts()
{
if (is_page('pagenamehere')) {
wp_register_script('scriptname', get_template_directory_uri() . '/js/scriptname.js', array('jquery'), '1.0.0'); // Conditional script(s)
wp_enqueue_script('scriptname'); // Enqueue it!
}
}
// Load HTML5 Blank styles
function html5blank_styles()
{
wp_register_style('normalize', get_template_directory_uri() . '/normalize.css', array(), '1.0', 'all');
wp_enqueue_style('normalize'); // Enqueue it!
wp_register_style('html5blank', get_template_directory_uri() . '/style.css', array(), '1.0', 'all');
wp_enqueue_style('html5blank'); // Enqueue it!
}
// Register HTML5 Blank Navigation
function register_html5_menu()
{
register_nav_menus(array( // Using array to specify more menus if needed
'header-menu' => __('Header Menu', 'html5blank'), // Main Navigation
'calls-to-action' => __('Calls to Action', 'html5blank'), // CTA Navigation
'main-footer-menu' => __('Main Footer Menu', 'html5blank'),
'secondary-footer-menu' => __('Secondary Footer Menu', 'html5blank'),
'extra-menu' => __('Extra Menu', 'html5blank') // Extra Navigation if needed (duplicate as many as you need!)
));
}
// Remove the <div> surrounding the dynamic navigation to cleanup markup
function my_wp_nav_menu_args($args = '')
{
$args['container'] = false;
return $args;
}
// Remove Injected classes, ID's and Page ID's from Navigation <li> items
function my_css_attributes_filter($var)
{
return is_array($var) ? array() : '';
}
// Remove invalid rel attribute values in the categorylist
function remove_category_rel_from_category_list($thelist)
{
return str_replace('rel="category tag"', 'rel="tag"', $thelist);
}
// Add page slug to body class, love this - Credit: Starkers Wordpress Theme
function add_slug_to_body_class($classes)
{
global $post;
if (is_home()) {
$key = array_search('blog', $classes);
if ($key > -1) {
unset($classes[$key]);
}
} elseif (is_page()) {
$classes[] = sanitize_html_class($post->post_name);
} elseif (is_singular()) {
$classes[] = sanitize_html_class($post->post_name);
}
return $classes;
}
// If Dynamic Sidebar Exists
if (function_exists('register_sidebar'))
{
// Define Sidebar Widget Area 1
register_sidebar(array(
'name' => __('Widget Area 1', 'html5blank'),
'description' => __('Description for this widget-area...', 'html5blank'),
'id' => 'widget-area-1',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
// Define Sidebar Widget Area 2
register_sidebar(array(
'name' => __('Widget Area 2', 'html5blank'),
'description' => __('Description for this widget-area...', 'html5blank'),
'id' => 'widget-area-2',
'before_widget' => '<div id="%1$s" class="%2$s">',
'after_widget' => '</div>',
'before_title' => '<h3>',
'after_title' => '</h3>'
));
}
// Remove wp_head() injected Recent Comment styles
function my_remove_recent_comments_style()
{
global $wp_widget_factory;
remove_action('wp_head', array(
$wp_widget_factory->widgets['WP_Widget_Recent_Comments'],
'recent_comments_style'
));
}
// Pagination for paged posts, Page 1, Page 2, Page 3, with Next and Previous Links, No plugin
function html5wp_pagination()
{
global $wp_query;
$big = 999999999;
echo paginate_links(array(
'base' => str_replace($big, '%#%', get_pagenum_link($big)),
'format' => '?paged=%#%',
'current' => max(1, get_query_var('paged')),
'total' => $wp_query->max_num_pages
));
}
// Custom Excerpts
function html5wp_index($length) // Create 20 Word Callback for Index page Excerpts, call using html5wp_excerpt('html5wp_index');
{
return 20;
}
// Create 40 Word Callback for Custom Post Excerpts, call using html5wp_excerpt('html5wp_custom_post');
function html5wp_custom_post($length)
{
return 40;
}
// Create the Custom Excerpts callback
function html5wp_excerpt($length_callback = '', $more_callback = '')
{
global $post;
if (function_exists($length_callback)) {
add_filter('excerpt_length', $length_callback);
}
if (function_exists($more_callback)) {
add_filter('excerpt_more', $more_callback);
}
$output = get_the_excerpt();
$output = apply_filters('wptexturize', $output);
$output = apply_filters('convert_chars', $output);
$output = '<p>' . $output . '</p>';
echo $output;
}
// Custom View Article link to Post
function html5_blank_view_article($more)
{
global $post;
return '... <a class="view-article" href="' . get_permalink($post->ID) . '">' . __('View Article', 'html5blank') . '</a>';
}
// Remove Admin bar
function remove_admin_bar()
{
return false;
}
// Remove 'text/css' from our enqueued stylesheet
function html5_style_remove($tag)
{
return preg_replace('~\s+type=["\'][^"\']++["\']~', '', $tag);
}
// Remove thumbnail width and height dimensions that prevent fluid images in the_thumbnail
function remove_thumbnail_dimensions( $html )
{
$html = preg_replace('/(width|height)=\"\d*\"\s/', "", $html);
return $html;
}
// Custom Gravatar in Settings > Discussion
function html5blankgravatar ($avatar_defaults)
{
$myavatar = get_template_directory_uri() . '/img/gravatar.jpg';
$avatar_defaults[$myavatar] = "Custom Gravatar";
return $avatar_defaults;
}
// Threaded Comments
function enable_threaded_comments()
{
if (!is_admin()) {
if (is_singular() AND comments_open() AND (get_option('thread_comments') == 1)) {
wp_enqueue_script('comment-reply');
}
}
}
// Custom Comments Callback
function html5blankcomments($comment, $args, $depth)
{
$GLOBALS['comment'] = $comment;
extract($args, EXTR_SKIP);
if ( 'div' == $args['style'] ) {
$tag = 'div';
$add_below = 'comment';
} else {
$tag = 'li';
$add_below = 'div-comment';
}
?>
<!-- heads up: starting < for the html tag (li or div) in the next line: -->
<<?php echo $tag ?> <?php comment_class(empty( $args['has_children'] ) ? '' : 'parent') ?> id="comment-<?php comment_ID() ?>">
<?php if ( 'div' != $args['style'] ) : ?>
<div id="div-comment-<?php comment_ID() ?>" class="comment-body">
<?php endif; ?>
<div class="comment-author vcard">
<?php if ($args['avatar_size'] != 0) echo get_avatar( $comment, $args['180'] ); ?>
<?php printf(__('<cite class="fn">%s</cite> <span class="says">says:</span>'), get_comment_author_link()) ?>
</div>
<?php if ($comment->comment_approved == '0') : ?>
<em class="comment-awaiting-moderation"><?php _e('Your comment is awaiting moderation.') ?></em>
<br />
<?php endif; ?>
<div class="comment-meta commentmetadata"><a href="<?php echo htmlspecialchars( get_comment_link( $comment->comment_ID ) ) ?>">
<?php
printf( __('%1$s at %2$s'), get_comment_date(), get_comment_time()) ?></a><?php edit_comment_link(__('(Edit)'),' ','' );
?>
</div>
<?php comment_text() ?>
<div class="reply">
<?php comment_reply_link(array_merge( $args, array('add_below' => $add_below, 'depth' => $depth, 'max_depth' => $args['max_depth']))) ?>
</div>
<?php if ( 'div' != $args['style'] ) : ?>
</div>
<?php endif; ?>
<?php }
/*------------------------------------*\
Remove Unwanted Admin Menu Items
\*------------------------------------*/
function remove_admin_menu_items() {
$remove_menu_items = array(__('Links'), __('Comments'), __('Posts'));
global $menu;
end ($menu);
while (prev($menu)){
$item = explode(' ',$menu[key($menu)][0]);
if(in_array($item[0] != NULL?$item[0]:"" , $remove_menu_items)){
unset($menu[key($menu)]);}
}
}
add_action('admin_menu', 'remove_admin_menu_items');
/*------------------------------------*\
Remove textarea from pages
\*------------------------------------*/
add_action('admin_init', 'remove_textarea');
function remove_textarea() {
// remove_post_type_support( 'page', 'editor' );
}
/*------------------------------------*\
Actions + Filters + ShortCodes
\*------------------------------------*/
// Add Actions
add_action('init', 'html5blank_header_scripts'); // Add Custom Scripts to wp_head
add_action('wp_print_scripts', 'html5blank_conditional_scripts'); // Add Conditional Page Scripts
//add_action('get_header', 'enable_threaded_comments'); // Enable Threaded Comments
add_action('wp_enqueue_scripts', 'html5blank_styles'); // Add Theme Stylesheet
add_action('init', 'register_html5_menu'); // Add HTML5 Blank Menu
add_action('init', 'create_post_type_projects'); // Add our Projects Custom Post Type
add_action('init', 'create_post_type_partners'); // Add our Partners Custom Post Type
add_action('init', 'create_post_type_contributors'); // Add our Contributors Custom Post Type
add_action('init', 'create_post_type_team'); // Add our Team Custom Post Type
add_action('init', 'create_post_type_donors'); // Add our Donors Custom Post Type
add_action('init', 'create_post_type_videos'); // Add our Videos Custom Post Type
add_action('init', 'create_post_type_lexicons'); // Add our Lexicon Custom Post Type
add_action('init', 'create_post_type_blog'); // Add our News Custom Post Type
add_action('init', 'create_post_type_press'); // Add our News Custom Post Type
add_action('init', 'create_post_type_languages'); // Add our Languages Custom Post Type
add_action('init', 'create_post_type_podcast'); // Add podcasts custom post type
add_action('widgets_init', 'my_remove_recent_comments_style'); // Remove inline Recent Comment Styles from wp_head()
add_action('init', 'html5wp_pagination'); // Add our HTML5 Pagination
// Remove Actions
remove_action('wp_head', 'feed_links_extra', 3); // Display the links to the extra feeds such as category feeds
remove_action('wp_head', 'feed_links', 2); // Display the links to the general feeds: Post and Comment Feed
remove_action('wp_head', 'rsd_link'); // Display the link to the Really Simple Discovery service endpoint, EditURI link
remove_action('wp_head', 'wlwmanifest_link'); // Display the link to the Windows Live Writer manifest file.
remove_action('wp_head', 'index_rel_link'); // Index link
remove_action('wp_head', 'parent_post_rel_link', 10, 0); // Prev link
remove_action('wp_head', 'start_post_rel_link', 10, 0); // Start link
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // Display relational links for the posts adjacent to the current post.
remove_action('wp_head', 'wp_generator'); // Display the XHTML generator that is generated on the wp_head hook, WP version
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0);
remove_action('wp_head', 'rel_canonical');
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0);
// Add Filters
add_filter('avatar_defaults', 'html5blankgravatar'); // Custom Gravatar in Settings > Discussion
add_filter('body_class', 'add_slug_to_body_class'); // Add slug to body class (Starkers build)
add_filter('widget_text', 'do_shortcode'); // Allow shortcodes in Dynamic Sidebar
add_filter('widget_text', 'shortcode_unautop'); // Remove <p> tags in Dynamic Sidebars (better!)
add_filter('wp_nav_menu_args', 'my_wp_nav_menu_args'); // Remove surrounding <div> from WP Navigation
// add_filter('nav_menu_css_class', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> injected classes (Commented out by default)
// add_filter('nav_menu_item_id', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> injected ID (Commented out by default)
// add_filter('page_css_class', 'my_css_attributes_filter', 100, 1); // Remove Navigation <li> Page ID's (Commented out by default)
add_filter('the_category', 'remove_category_rel_from_category_list'); // Remove invalid rel attribute
add_filter('the_excerpt', 'shortcode_unautop'); // Remove auto <p> tags in Excerpt (Manual Excerpts only)
add_filter('the_excerpt', 'do_shortcode'); // Allows Shortcodes to be executed in Excerpt (Manual Excerpts only)
add_filter('excerpt_more', 'html5_blank_view_article'); // Add 'View Article' button instead of [...] for Excerpts
add_filter('show_admin_bar', 'remove_admin_bar'); // Remove Admin bar
add_filter('style_loader_tag', 'html5_style_remove'); // Remove 'text/css' from enqueued stylesheet
add_filter('post_thumbnail_html', 'remove_thumbnail_dimensions', 10); // Remove width and height dynamic attributes to thumbnails
add_filter('image_send_to_editor', 'remove_thumbnail_dimensions', 10); // Remove width and height dynamic attributes to post images
// Remove Filters
remove_filter('the_excerpt', 'wpautop'); // Remove <p> tags from Excerpt altogether
// Shortcodes
add_shortcode('html5_shortcode_demo', 'html5_shortcode_demo'); // You can place [html5_shortcode_demo] in Pages, Posts now.
add_shortcode('html5_shortcode_demo_2', 'html5_shortcode_demo_2'); // Place [html5_shortcode_demo_2] in Pages, Posts now.
// Shortcodes above would be nested like this -
// [html5_shortcode_demo] [html5_shortcode_demo_2] Here's the page title! [/html5_shortcode_demo_2] [/html5_shortcode_demo]
/*------------------------------------*\
Custom Post Types
\*------------------------------------*/
// Projects, aka Initiatives
function create_post_type_projects()
{
register_taxonomy_for_object_type('category', 'projects');
register_taxonomy_for_object_type('post_tag', 'projects');
register_post_type('projects',
array(
'labels' => array(
'name' => __('Projects', 'project'),
'singular_name' => __('Project', 'project'),
'add_new' => __('Add New', 'project'),
'add_new_item' => __('Add New Project', 'project'),
'edit' => __('Edit', 'project'),
'edit_item' => __('Edit Project', 'project'),
'new_item' => __('New Project', 'project'),
'view' => __('View Project', 'project'),
'view_item' => __('View Project', 'project'),
'search_items' => __('Search Projects', 'project'),
'not_found' => __('No Projects found', 'project'),
'not_found_in_trash' => __('No Projects found in Trash', 'project')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-hammer',
'has_archive' => true,
'supports' => array(
'title',
'editor'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Partners
function create_post_type_partners()
{
register_taxonomy_for_object_type('category', 'partners');
register_taxonomy_for_object_type('post_tag', 'partners');
register_post_type('partners',
array(
'labels' => array(
'name' => __('Partners', 'partner'),
'singular_name' => __('Partner', 'partner'),
'add_new' => __('Add New', 'partner'),
'add_new_item' => __('Add New Partner', 'partner'),
'edit' => __('Edit', 'partner'),
'edit_item' => __('Edit Partner', 'partner'),
'new_item' => __('New Partner', 'partner'),
'view' => __('View Partner', 'partner'),
'view_item' => __('View Partner', 'partner'),
'search_items' => __('Search Partners', 'partner'),
'not_found' => __('No Partners found', 'partner'),
'not_found_in_trash' => __('No Partners found in Trash', 'partner')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-heart',
'has_archive' => true,
'supports' => array(
'title'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Contributors
function create_post_type_contributors()
{
register_taxonomy_for_object_type('category', 'contributors');
register_taxonomy_for_object_type('post_tag', 'contributors');
register_post_type('contributors',
array(
'labels' => array(
'name' => __('Contributors', 'contributor'),
'singular_name' => __('Contributor', 'contributor'),
'add_new' => __('Add New', 'contributor'),
'add_new_item' => __('Add New contributor', 'contributor'),
'edit' => __('Edit', 'contributor'),
'edit_item' => __('Edit Contributor', 'contributor'),
'new_item' => __('New Contributor', 'contributor'),
'view' => __('View Contributor', 'contributor'),
'view_item' => __('View Contributor', 'contributor'),
'search_items' => __('Search Contributors', 'contributor'),
'not_found' => __('No Contributors found', 'contributor'),
'not_found_in_trash' => __('No Contributors found in Trash', 'contributor')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-megaphone',
'has_archive' => true,
'supports' => array(
'title'
// 'editor',
// 'excerpt',
// 'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// team
function create_post_type_team()
{
register_taxonomy_for_object_type('category', 'team');
register_taxonomy_for_object_type('post_tag', 'team');
register_post_type('team',
array(
'labels' => array(
'name' => __('Team', 'team'),
'singular_name' => __('Team', 'team'),
'add_new' => __('Add New', 'team'),
'add_new_item' => __('Add New team', 'team'),
'edit' => __('Edit', 'team'),
'edit_item' => __('Edit Team', 'team'),
'new_item' => __('New Team', 'team'),
'view' => __('View Team', 'team'),
'view_item' => __('View Team', 'team'),
'search_items' => __('Search Team', 'team'),
'not_found' => __('No Team found', 'team'),
'not_found_in_trash' => __('No Team found in Trash', 'team')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-megaphone',
'has_archive' => true,
'supports' => array(
'title'
// 'editor',
// 'excerpt',
// 'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Donors
function create_post_type_donors()
{
register_taxonomy_for_object_type('category', 'donors');
register_taxonomy_for_object_type('post_tag', 'donors');
register_post_type('donors',
array(
'labels' => array(
'name' => __('Donors', 'donor'),
'singular_name' => __('Donor', 'donor'),
'add_new' => __('Add New', 'donor'),
'add_new_item' => __('Add New Donor', 'donor'),
'edit' => __('Edit', 'donor'),
'edit_item' => __('Edit Donor', 'donor'),
'new_item' => __('New Donor', 'donor'),
'view' => __('View Donor', 'donor'),
'view_item' => __('View Donor', 'donor'),
'search_items' => __('Search Donors', 'donor'),
'not_found' => __('No Donors found', 'donor'),
'not_found_in_trash' => __('No Donors found in Trash', 'donor')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-awards',
'has_archive' => true,
'supports' => array(
'title'
// 'editor',
// 'excerpt',
// 'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Videos
function create_post_type_videos()
{
register_taxonomy_for_object_type('category', 'videos');
register_taxonomy_for_object_type('post_tag', 'videos');
register_post_type('videos',
array(
'labels' => array(
'name' => __('Videos', 'video'),
'singular_name' => __('Video', 'video'),
'add_new' => __('Add New', 'video'),
'add_new_item' => __('Add New Video', 'video'),
'edit' => __('Edit', 'video'),
'edit_item' => __('Edit Video', 'video'),
'new_item' => __('New Video', 'video'),
'view' => __('View Video', 'video'),
'view_item' => __('View Video', 'video'),
'search_items' => __('Search Videos', 'video'),
'not_found' => __('No Videos found', 'video'),
'not_found_in_trash' => __('No Videos found in Trash', 'video')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-video-alt3',
'has_archive' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Videos
function create_post_type_lexicons()
{
register_taxonomy_for_object_type('category', 'lexicons');
register_taxonomy_for_object_type('post_tag', 'lexicons');
register_post_type('lexicons',
array(
'labels' => array(
'name' => __('Lexicons', 'lexicons'),
'singular_name' => __('Lexicon', 'lexicon'),
'add_new' => __('Add New', 'lexicon'),
'add_new_item' => __('Add New Lexicon', 'lexicon'),
'edit' => __('Edit', 'lexicon'),
'edit_item' => __('Edit Lexicon', 'lexicon'),
'new_item' => __('New Lexicon', 'lexicon'),
'view' => __('View Lexicon', 'lexicon'),
'view_item' => __('View Lexicon', 'lexicon'),
'search_items' => __('Search Lexicons', 'lexicon'),
'not_found' => __('No Lexicons found', 'lexicon'),
'not_found_in_trash' => __('No Lexicon found in Trash', 'lexicon')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-format-status',
'has_archive' => true,
'supports' => array(
'title',
'editor',
'excerpt',
'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Blog Posts
function create_post_type_blog()
{
register_taxonomy_for_object_type('category', 'blog');
register_taxonomy_for_object_type('post_tag', 'blog');
register_post_type('blog',
array(
'labels' => array(
'name' => __('Blog Posts', 'blog'),
'singular_name' => __('Blog Post', 'blog'),
'add_new' => __('Add New', 'blog'),
'add_new_item' => __('Add New Blog Post', 'blog'),
'edit' => __('Edit', 'blog'),
'edit_item' => __('Edit Blog Post', 'blog'),
'new_item' => __('New Blog Post', 'blog'),
'view' => __('View Blog Post', 'blog'),
'view_item' => __('View Blog Post', 'blog'),
'search_items' => __('Search Blog Posts', 'blog'),
'not_found' => __('No Blog Posts found', 'blog'),
'not_found_in_trash' => __('No Blog Items found in Trash', 'blog')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-format-quote',
'has_archive' => true,
'supports' => array(
'title',
'editor',
'excerpt'
// 'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Press Posts
function create_post_type_press()
{
register_taxonomy_for_object_type('category', 'press');
register_taxonomy_for_object_type('post_tag', 'press');
register_post_type('press',
array(
'labels' => array(
'name' => __('Press Items', 'press'),
'singular_name' => __('Press Item', 'press'),
'add_new' => __('Add New', 'press'),
'add_new_item' => __('Add New Press Item', 'press'),
'edit' => __('Edit', 'press'),
'edit_item' => __('Edit Press Item', 'press'),
'new_item' => __('New Press Item', 'press'),
'view' => __('View Press Item', 'press'),
'view_item' => __('View Press Item', 'press'),
'search_items' => __('Search Press Items', 'press'),
'not_found' => __('No Press Items found', 'press'),
'not_found_in_trash' => __('No press Items found in Trash', 'press')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-media-text',
'has_archive' => true,
'supports' => array(
'title',
'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Language Posts
function create_post_type_languages()
{
register_taxonomy_for_object_type('category', 'languages');
register_taxonomy_for_object_type('post_tag', 'languages');
register_post_type('languages',
array(
'labels' => array(
'name' => __('Languages', 'language'),
'singular_name' => __('Language', 'language'),
'add_new' => __('Add New', 'language'),
'add_new_item' => __('Add New Language', 'language'),
'edit' => __('Edit', 'language'),
'edit_item' => __('Edit Language', 'language'),
'new_item' => __('New Language', 'language'),
'view' => __('View Language', 'language'),
'view_item' => __('View Language', 'language'),
'search_items' => __('Search Languages', 'language'),
'not_found' => __('No Languages found', 'language'),
'not_found_in_trash' => __('No language Items found in Trash', 'language')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-translation',
'has_archive' => true,
'supports' => array(
'title',
'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
// Blog Posts
function create_post_type_podcast()
{
register_taxonomy_for_object_type('category', 'podcast');
register_taxonomy_for_object_type('post_tag', 'podcast');
register_post_type('podcast',
array(
'labels' => array(
'name' => __('Podcast episodes', 'podcast'),
'singular_name' => __('Podcast episode', 'podcast'),
'add_new' => __('Add New', 'podcast'),
'add_new_item' => __('Add New Podcast episode', 'podcast'),
'edit' => __('Edit', 'podcast'),
'edit_item' => __('Edit Podcast episode', 'podcast'),
'new_item' => __('New Podcast episode', 'podcast'),
'view' => __('View Podcast episode', 'podcast'),
'view_item' => __('View Podcast episode', 'podcast'),
'search_items' => __('Search Podcast episodes', 'podcast'),
'not_found' => __('No Podcast episodes found', 'podcast'),
'not_found_in_trash' => __('No Podcast episodes found in Trash', 'podcast')
),
'public' => true,
'hierarchical' => true,
'menu_icon' => 'dashicons-microphone',
'has_archive' => true,
'supports' => array(
'title',
//'editor',
//'excerpt'
'thumbnail'
),
'can_export' => true,
'taxonomies' => array(
'post_tag',
'category'
)
));
}
/*------------------------------------*\
ShortCode Functions
\*------------------------------------*/
// Shortcode Demo with Nested Capability
function html5_shortcode_demo($atts, $content = null)
{
return '<div class="shortcode-demo">' . do_shortcode($content) . '</div>'; // do_shortcode allows for nested Shortcodes
}
// Shortcode Demo with simple <h2> tag
function html5_shortcode_demo_2($atts, $content = null) // Demo Heading H2 shortcode, allows for nesting within above element. Fully expandable.
{
return '<h2>' . $content . '</h2>';
}
/*------------------------------------*\
Query vars
\*------------------------------------*/
/**
* Register custom query vars
*
* @link https://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars
*/
function wt_register_query_vars($vars)
{
$vars[] = 'site_search';
$vars[] = 'videos_search';
$vars[] = 'languages_search';
return $vars;
}
add_filter('query_vars', 'wt_register_query_vars');
/*------------------------------------*\
Searchbar
\*------------------------------------*/
// function add_searchbar_to_nav($items, $args) {
// if ($args->menu->slug == 'calls-to-action') {
// $items .= '<li>' . get_search_form(false) . '</li>';
// return $items;
// }
// return $items;
// }
// add_filter( 'wp_nav_menu_items', 'add_searchbar_to_nav', 10, 2 );
function load_custom_search_template($template) {
if( isset($_REQUEST['site_search']) ) {
$t = locate_template('wikitongues-search.php', false);
if (!empty($t)) {
$template = $t;
}
}
return $template;
}
add_action('template_include', 'load_custom_search_template');
function set_post_types($query) {
if (isset($_REQUEST['site_search'])) {
$query->set('post_type', array('languages', 'videos'));
}
}
add_action('pre_get_posts', 'set_post_types');
/*------------------------------------*\
Custom RSS for podcast
\*------------------------------------*/
function podcast_rss() {
if (get_post_type() === 'podcast') {
get_template_part( 'feed', 'podcast' );