forked from UCF/TBHC-Theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshortcodes.php
1869 lines (1692 loc) · 62.4 KB
/
shortcodes.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
/**
* Create a javascript slideshow of each top level element in the
* shortcode. All attributes are optional, but may default to less than ideal
* values. Available attributes:
*
* height => css height of the outputted slideshow, ex. height="100px"
* width => css width of the outputted slideshow, ex. width="100%"
* transition => length of transition in milliseconds, ex. transition="1000"
* cycle => length of each cycle in milliseconds, ex cycle="5000"
* animation => The animation type, one of: 'slide' or 'fade'
*
* Example:
* [slideshow height="500px" transition="500" cycle="2000"]
* <img src="http://some.image.com" .../>
* <div class="robots">Robots are coming!</div>
* <p>I'm a slide!</p>
* [/slideshow]
**/
function sc_slideshow($attr, $content=null){
$content = cleanup(str_replace('<br />', '', $content));
$content = DOMDocument::loadHTML($content);
$html = $content->childNodes->item(1);
$body = $html->childNodes->item(0);
$content = $body->childNodes;
# Find top level elements and add appropriate class
$items = array();
foreach($content as $item){
if ($item->nodeName != '#text'){
$classes = explode(' ', $item->getAttribute('class'));
$classes[] = 'slide';
$item->setAttribute('class', implode(' ', $classes));
$items[] = $item->ownerDocument->saveXML($item);
}
}
$animation = ($attr['animation']) ? $attr['animation'] : 'slide';
$height = ($attr['height']) ? $attr['height'] : '100px';
$width = ($attr['width']) ? $attr['width'] : '100%';
$tran_len = ($attr['transition']) ? $attr['transition'] : 1000;
$cycle_len = ($attr['cycle']) ? $attr['cycle'] : 5000;
ob_start();
?>
<div
class="slideshow <?=$animation?>"
data-tranlen="<?=$tran_len?>"
data-cyclelen="<?=$cycle_len?>"
style="height: <?=$height?>; width: <?=$width?>;"
>
<?php foreach($items as $item):?>
<?=$item?>
<?php endforeach;?>
</div>
<?php
$html = ob_get_clean();
return $html;
}
add_shortcode('slideshow', 'sc_slideshow');
function sc_search_form() {
ob_start();
?>
<div class="search">
<?get_search_form()?>
</div>
<?
return ob_get_clean();
}
add_shortcode('search_form', 'sc_search_form');
/**
* Include the defined publication, referenced by pub title:
*
* [publication name="Where are the robots Magazine"]
**/
function sc_publication($attr, $content=null){
$pub = @$attr['pub'];
$pub_name = @$attr['name'];
$pub_id = @$attr['id'];
// Get the post data
if (!$pub and is_numeric($pub_id)){
$pub = get_post($pub);
}
if (!$pub and $pub_name){
$pub = get_page_by_title($pub_name, OBJECT, 'publication');
}
$url = get_post_meta($pub->ID, "publication_url", True);
//$url = str_replace('https:', 'http:', $url); // Force http // y?
// Get the Issuu DocumentID from the url provided
$docID = json_decode(file_get_contents($url.'?issuu-data=docID'));
$docID = $docID->docID;
// If no docID is found, assume that the publication url is invalid
if ($docID == NULL) { return 'DocID not found. Is the publication URL valid? Please use URLs from http://publications.ucf.edu.'; }
// Output for an Issuu thumbnail, based on docID
$issuu_thumb = "<img src='http://image.issuu.com/".$docID."/jpg/page_1_thumb_large.jpg' alt='".$pub->post_title."' title='".$pub->post_title."' />";
// If a featured image is set, use it; otherwise, get the thumbnail from issuu
$thumb = (get_the_post_thumbnail($pub->ID, 'publication_thumb', TRUE) !== '') ? get_the_post_thumbnail($pub->ID, 'publication_thumb', TRUE) : $issuu_thumb;
ob_start(); ?>
<div class="pub">
<a class="track pub-track" title="<?=$pub->post_title?>" data-toggle="modal" href="#pub-modal-<?=$pub->ID?>">
<?=$thumb?>
</a>
<p class="pub-desc"><?=$pub->post_content?></p>
<div class="modal fade" id="pub-modal-<?php echo $pub->ID; ?>" tabindex="-1" role="dialog" aria-labelledby="<?php echo $pub->post_title; ?>" aria-hidden="true" style="height:auto !important;">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-body">
<iframe src="<?php echo $url; ?>" style="width:100% !important; height:100% !important;" scrolling="no"></iframe>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<?php
return ob_get_clean();
}
add_shortcode('publication', 'sc_publication');
/**
* Include the defined YouTube video, referenced by video title.
*
* [video name="Where are the robots? (VIDEO!)"]
**/
function sc_video($attr, $content=null){
$video_name = @$attr['name'];
$video_id = @$attr['id'];
$display = $attr['display'] ? $attr['display'] : 'modal';
if (!$video and is_numeric($video_id)){
$video = get_post($video_id);
}
if (!$video and $video_name){
$video = get_page_by_title($video_name, 'OBJECT', 'video');
}
$video_url = get_post_meta($video->ID, "video_url", true);
$video_yt_id = get_youtube_id($video_url);
$video_description = $video->post_content;
$video_thumbnail = wp_get_attachment_image(get_post_thumbnail_id($video->ID, 'medium'));
$embed_url = 'http://www.youtube.com/embed/'.$video_yt_id.'?wmode=transparent';
switch ($display) {
default:
ob_start(); ?>
<div class="video">
<div class="icon">
<a title="Watch <?php echo $video->post_title; ?>" alt="Watch <?php echo $video->post_title; ?>" data-toggle="modal" class="video-link" href="#modal-vid<?php echo $video->ID; ?>">
<?php echo $video_thumbnail; ?>
</a>
</div>
<div class="modal video-modal fade" id="modal-vid<?php echo $video->ID; ?>" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<a class="close" data-dismiss="modal">×</a>
<h3><?php echo $video->post_title; ?></h3>
</div>
<div class="modal-body" data-src="<?php echo $embed_url; ?>">
</div>
</div>
</div>
</div>
<h4>
<a title="Watch <?php echo $video->post_title; ?>" alt="Watch <?php echo $video->post_title; ?>" data-toggle="modal" class="video-link" href="#modal-vid<?php echo $video->ID; ?>">
<?php echo $video->post_title; ?>
</a>
</h4>
<div class="video-desc"><?php echo $video_description; ?></div>
</div>
<?php
return ob_get_clean();
break;
case 'embed':
ob_start(); ?>
<iframe type="text/html" width="640" height="390" src="<?php echo $embed_url; ?>" frameborder="0"></iframe>
<?php
return ob_get_clean();
break;
}
}
add_shortcode('video', 'sc_video');
/**
* Person picture lists
**/
// sort by job title deans -> directors -> coordinators
function sc_person_picture_list($atts) {
$atts['type'] = ($atts['type']) ? $atts['type'] : null;
$row_size = ($atts['row_size']) ? (intval($atts['row_size'])) : 5;
$categories = ($atts['categories']) ? $atts['categories'] : null;
$org_groups = ($atts['org_groups']) ? $atts['org_groups'] : null;
$limit = ($atts['limit']) ? (intval($atts['limit'])) : -1;
$join = ($atts['join']) ? $atts['join'] : 'or';
$people = sc_object_list(
array(
'type' => 'person',
'limit' => $limit,
'join' => $join,
'categories' => $categories,
'org_groups' => $org_groups
),
array(
'objects_only' => True,
));
ob_start();
?><div class="person-picture-list"><?
$count = 0;
foreach($people as $person) {
$image_url = get_featured_image_url($person->ID);
$link = ($person->post_content != '') ? True : False;
if( ($count % $row_size) == 0) {
if($count > 0) {
?></div><?
}
?><div class="row"><?
}
?>
<div class="col-md-2 col-sm-2 person-picture-wrap">
<? if($link) {?><a href="<?=get_permalink($person->ID)?>"><? } ?>
<img src="<?=$image_url ? $image_url : get_bloginfo('stylesheet_directory').'/static/img/no-photo.jpg'?>" />
<div class="name"><?=Person::get_name($person)?></div>
<div class="title"><?=get_post_meta($person->ID, 'person_jobtitle', True)?></div>
<? if($link) {?></a><?}?>
</div>
<?
$count++;
}
?> </div>
</div>
<?
return ob_get_clean();
}
add_shortcode('person-picture-list', 'sc_person_picture_list');
function specCharEscCallback($buffer){
return htmlentities($buffer);
}
/**
* Custom Person List by Erik
**/
function sc_person_profile_grid($atts) {
$atts = array_map('specCharEscCallback', $atts);
//remove_filter('the_content','wpautop');
$atts['type'] = ($atts['type']) ? $atts['type'] : null;
$row_size = ($atts['row_size']) ? (intval($atts['row_size'])) : 5;
$mobile_row_size = ($atts['mobile_row_size']) ? (intval($atts['mobile_row_size'])) : 3;
$categories = ($atts['categories']) ? $atts['categories'] : null;
$org_groups = ($atts['org_groups']) ? $atts['org_groups'] : null;
$org_groups2 = ($atts['org_groups2']) ? $atts['org_groups2'] : null;
$limit = ($atts['limit']) ? (intval($atts['limit'])) : -1;
$join = ($atts['join']) ? $atts['join'] : 'or';
$dropdown = ($atts['dropdown']) ? $atts['dropdown'] : false;
$dd_org_groups = ($atts['dd_org_groups']) ? $atts['dd_org_groups'] : $org_groups;
$dropdown2 = ($atts['dropdown2']) ? $atts['dropdown2'] : false;
$dd2_org_groups = ($atts['dd2_org_groups']) ? $atts['dd2_org_groups'] : NULL;
$show_org_groups = ($atts['show_org_groups']) ? $atts['show_org_groups'] : false;
$OGID = get_term_by('slug', $dd_org_groups, 'org_groups')->term_id;
$OGID2 = get_term_by('slug', $dd2_org_groups, 'org_groups');
$OGID2 = $OGID2 ? $OGID2->term_id : false;
$show_option_all = ($atts['show_option_all']) ? $atts['show_option_all'] : null;
$show_option_all2 = ($atts['show_option_all2']) ? $atts['show_option_all2'] : null;
$operator = ($atts['operator']) ? $atts['operator'] : NULL;
$people = sc_object_list(
array(
'type' => 'person',
'limit' => $limit,
'join' => $join,
'categories' => $categories,
'org_groups' => $org_groups2 ? $org_groups.' '.$org_groups2 : $org_groups,
'orderby' => 'person_orderby_name',
'order' => 'ASC',
'operator' => $operator
),
array(
'objects_only' => True,
));
if(strpos($org_groups, "dist") > -1){
usort($people, function($a, $b){
$a_date = new DateTime(get_post_meta($a->ID, 'dist_speaker_date', true));
$b_date = new DateTime(get_post_meta($b->ID, 'dist_speaker_date', true));
$a_title = get_post_meta($a->ID, 'person_jobtitle', true);
$b_title = get_post_meta($b->ID, 'person_jobtitle', true);
$a_date = $a_date->getTimestamp();
$b_date = $b_date->getTimestamp();
if($a_date == $b_date){
return strcmp($a_title, $b_title);
}
return $a_date < $b_date ? -1 : 1;
});
}else if(strpos($org_groups, "ambass") > -1){
usort($people, function($a, $b){ // tentative peer-ambassador name sort
$res = strcmp($a->post_title, $b->post_title);
//echo "\n".$a->post_title." is ".$res." than ".$b->post_title;
return $res;
});
}else{
usort($people, function($a, $b){
$a_title = get_post_meta($a->ID, 'person_jobtitle', true);
$b_title = get_post_meta($b->ID, 'person_jobtitle', true);
$haystack = ["Dean", "Director", "Coordinator"];
$res = 0;
if(preg_match('/Dean|Director|Coordinator/', $a_title) || preg_match('/Dean|Director|Coordinator/', $b_title)){
foreach ($haystack as $item) {
$a_r = strpos($a_title, $item);
$b_r = strpos($b_title, $item);
if($a_r >= 0 && $a_r !== false){
if($b_r >= 0 && $b_r !== false){
//print($a_title." and ".$b_title." contain ".$item.".\n");
$res = $a_r < $b_r ? -1 : $a_r == $b_r ? 0 : 1; // both contain
break;
}else{
//print("Only ".$a_title." contains ".$item.".\n");
$res = -1; // only a contains
break;
}
}else{
if($b_r >= 0 && $b_r !== false){
//print("Only ".$b_title." contains ".$item.".\n");
$res = 1; // only b contains
break;
}
}
}
}else{
// neither contains
//print("Neither ".$a_title." nor ".$b_title." contain ".$item.".\n");
$res = $a_title < $b_title ? -1 : $a_title == $b_title ? 0 : 1;
}
return $res;
});
}
ob_start("specCharEscCallback");
// Added row_size attribute to end of line below (omj it's soooo long...)
?><div class="person-profile-grid" data-url="<?=admin_url( 'admin-ajax.php' )?>" data-group="<?=esc_attr($dd_org_groups)?>" data-group2="<?=esc_attr($dd2_org_groups)?>" data-shwgrp="<?=esc_attr($show_org_groups)?>" data-jn="<?=esc_attr($join)?>" data-oprtr="<?=esc_attr($operator)?>" data-allopt="<?=esc_attr($show_option_all)?>" data-allopt2="<?=esc_attr($show_option_all2)?>" data-rowsize="<?=esc_attr($row_size)?>">
<? if($dropdown){
$args = array(
'taxonomy' => 'org_groups',
'value_field' => 'slug',
'class' => 'person-profile-grid-dropdown form-control',
'id' => 'dd_org_groups',
'name' => 'dd_org_groups',
'echo' => false,
'selected' => $org_groups,
'child_of' => $OGID,
);
if(!empty($show_option_all)){
$args['show_option_all'] = $show_option_all;
}
echo str_replace(
'<select',
'<select onchange="getProfilesForGrid(this.value'.($dropdown2 ? ', $(\'#dd2_org_groups\').val()' : '').')"',
wp_dropdown_categories($args)
);
}
if($dropdown2 && $OGID2){
$args2 = array(
'taxonomy' => 'org_groups',
'value_field' => 'slug',
'class' => 'person-profile-grid-dropdown form-control',
'id' => 'dd2_org_groups',
'name' => 'dd2_org_groups',
'echo' => false,
'selected' => $org_groups2,
'child_of' => $OGID2,
);
if(!empty($show_option_all2)){
$args['show_option_all2'] = $show_option_all2;
}
echo str_replace(
'<select',
'<select onchange="getProfilesForGrid($(\'#dd_org_groups\').val(), this.value)"',
wp_dropdown_categories($args2)
);
}
$count = 0;
foreach($people as $person) {
if(strtolower($show_org_groups) == "true"){
$term_list = wp_get_post_terms($person->ID, 'org_groups');
$terms = array_filter($term_list, function($thng) use($OGID, $OGID2) {
return !empty($thng->parent) && ($thng->parent == $OGID || ($OGID2 != false && $thng->parent == $OGID2));
});
$terms = implode(", ", array_map(function($blrp){
return $blrp->name;
}, $terms));
}
$imageT = get_image_tag(get_post_thumbnail_id($person->ID), 'alt text', 'title text', 'None', 'profile-grid-image');
$imageT = preg_replace( '/(width)=\"\d*\"\s/', "width=\"100%\"", $imageT );
$imageT = preg_replace( '/(height)=\"\d*\"\s/', "", $imageT );
$image = wp_get_attachment_image_src(get_post_thumbnail_id($person->ID), 'profile-grid-image', false);
$image_url = get_featured_image_url($person->ID);
$link = ($person->post_content != '') ? True : False;
$wdth = round((float)1 / $row_size, 3) * 100;
if( ($count % $row_size) == 0) {
if($count > 0) {
?></div><?
}
?><div class="row"><?
}
?>
<div class="person-profile-wrap" style="width: <?= $wdth ?>%; padding-bottom: <?= $wdth ?>%; position: relative; float: left; overflow: hidden;">
<div class="person-inner-wrap" style="position: absolute; left: 0; top: 0; max-width: 100%; max-height: 100%;">
<? if($link) {?><a href="<?=esc_attr(get_permalink($person->ID))?>"><? } ?>
<?= $imageT ?>
<div class="profile-short">
<h4 class="title">
<?=Person::get_name($person);?>
<br/>
<!-- this whole bit is for majors and hometown for peer ambassador check-->
<?if(has_term('peer-ambassador','org_groups',$person->ID)){
echo '<small>'.get_post_meta($person->ID, 'peer_ambassador_major', True).'</small><br/><small>'.get_post_meta($person->ID, 'peer_ambassador_hometown', True).'</small>';
}else{
echo '<small>'.get_post_meta($person->ID, 'person_jobtitle', True).'</small>';
}?>
</h4>
</div>
<div class="group">
<span class="group-inner">
<?php if(strtolower($show_org_groups) == "true"){ print($terms); } ?>
</span>
</div>
<div class="overlay"></div>
<? if($link) {?></a><?}?>
</div>
</div>
<?
$count++;
}
?> <!--</div> attempt to get left sidebar back onto grid pages-->
</div>
</div>
<?
return ob_get_clean();
//add_filter('the_content','wpautop');
}
add_shortcode('person-profile-grid', 'sc_person_profile_grid');
/**
* Custom Opp List by Erik
**/
function sc_opportunity_grid($atts) {
$atts = array_map('specCharEscCallback', $atts);
//remove_filter('the_content','wpautop');
$atts['type'] = ($atts['type']) ? $atts['type'] : null;
$categories = ($atts['categories']) ? $atts['categories'] : null;
$event_groups = ($atts['event_groups']) ? $atts['event_groups'] : null;
$event_groups2 = ($atts['event_groups2']) ? $atts['event_groups2'] : null;
$limit = ($atts['limit']) ? (intval($atts['limit'])) : -1;
$join = ($atts['join']) ? $atts['join'] : 'or';
$dropdown = ($atts['dropdown']) ? $atts['dropdown'] : false;
$dd_event_groups = ($atts['dd_event_groups']) ? $atts['dd_event_groups'] : $event_groups;
$dropdown2 = ($atts['dropdown2']) ? $atts['dropdown2'] : false;
$dd2_event_groups = ($atts['dd2_event_groups']) ? $atts['dd2_event_groups'] : NULL;
$show_option_all = ($atts['show_option_all']) ? $atts['show_option_all'] : null;
$show_option_all2 = ($atts['show_option_all2']) ? $atts['show_option_all2'] : null;
$EGID = get_term_by('slug', $dd_event_groups, 'event_groups')->term_id;
$EGID2 = get_term_by('slug', $dd2_event_groups, 'event_groups');
$EGID2 = $EGID2 ? $EGID2->term_id : false;
$operator = ($atts['operator']) ? $atts['operator'] : NULL;
$opps = sc_object_list(
array(
'type' => 'opportunity',
'limit' => $limit,
'join' => $join,
//'categories' => $categories,
'event_groups' => $event_groups2 ? $event_groups.' '.$event_groups2 : $event_groups,
//'orderby' => 'meta_value_num',
//'order' => 'DESC',
//'meta_key' => 'opportunity_end',
'operator' => $operator,
'meta_query' => array(
array(
'key' => 'opportunity_start',
'value' => date('Ymd', mktime(23,59,59)), // this might work? set time as 23:59:59?
'compare' => '<=',
),
array(
'key' => 'opportunity_end',
'value' => date('Ymd', mktime(0,0,0)),
'compare' => '>=',
),
),
),
array(
'objects_only' => True,
));
usort($opps, function($a, $b){
$a_dt = new DateTime(get_post_meta($a->ID, 'opportunity_end', TRUE));
$b_dt = new DateTime(get_post_meta($b->ID, 'opportunity_end', TRUE));
$a_dt = $a_dt->getTimestamp();
$b_dt = $b_dt->getTimestamp();
if ($a_dt == $b_dt){
// If they have the same depth, compare titles
return strcmp($a->post_title, $b->post_title);
}
// If depth_a is smaller than depth_b, return -1; otherwise return 1
$res = ($a_dt > $b_dt) ? -1 : 1;
return $res;
});
ob_start();
?><div class="opportunity-grid" data-url="<?=admin_url( 'admin-ajax.php' )?>" data-group="<?=esc_attr($dd_event_groups)?>" data-group2="<?=esc_attr($dd2_event_groups)?>" data-jn="<?=esc_attr($join)?>" data-oprtr="<?=esc_attr($operator)?>" data-allopt="<?=esc_attr($show_option_all)?>" data-allopt2="<?=esc_attr($show_option_all2)?>">
<? if($dropdown){
$prntTrm = get_term_by('slug', 'event-category','event_groups');
$ids = array_map(function($blrp)use($prntTrm){
$trms = wp_get_post_terms($blrp->ID, 'event_groups');
$otpt = "";
foreach($trms as $trm){
if($trm->parent && $trm->parent == $prntTrm->term_id){
$otpt .= $trm->term_id;
}
}
return $otpt;
}, $opps);
$args = array(
'taxonomy' => 'event_groups',
'value_field' => 'slug',
'class' => 'opportunity-grid-dropdown form-control',
'id' => 'dd_event_groups',
'name' => 'dd_event_groups',
'echo' => false,
'selected' => $event_groups,
'child_of' => $EGID,
'include' => implode(",", $ids),
);
if(!empty($show_option_all)){
$args['show_option_all'] = $show_option_all;
}
echo str_replace(
'<select',
'<select onchange="getOppsForGrid(this.value'.($dropdown2 ? ', $(\'#dd2_event_groups\').val()' : '').')"',
wp_dropdown_categories($args)
);
}
if($dropdown2 && $EGID2){
$args2 = array(
'taxonomy' => 'event_groups',
'value_field' => 'slug',
'class' => 'opportunity-grid-dropdown form-control',
'id' => 'dd2_event_groups',
'name' => 'dd2_event_groups',
'echo' => false,
'selected' => $event_groups2,
'child_of' => $EGID2,
);
if(!empty($show_option_all2)){
$args2['show_option_all2'] = $show_option_all2;
}
echo str_replace(
'<select',
'<select onchange="getOppsForGrid($(\'#dd_event_groups\').val(), this.value)"',
wp_dropdown_categories($args2)
);
}
?>
<ul class="opportunity-list">
<?php
//rsort($opps);
$matches = "";
foreach ($opps as $opportunity) {
$start_date; //= get_post_meta($opportunity->ID, 'opportunity_start', TRUE);
$end_date = get_post_meta($opportunity->ID, 'opportunity_end', TRUE);
$cPost = get_post_meta($opportunity->ID, 'opportunity_url_redirect', true);
preg_match('/(?:http|https):\/\/tbhccmsdev.smca.ucf.edu\/(?<url>\S*)(?:\/*)/', $cPost, $matches);
$cPost = $matches['url'];
$cPost = get_page_by_path($cPost, OBJECT, 'post');
$cPost = wp_trim_words($cPost->post_content, 50); // was 75, dropped to 50
$time = '';
$location = '';
if($ext_link){
$link = $ext_link;
}
if($start_date){
$start_date = new DateTime($start_date);
}
if($end_date){
$end_date = new DateTime($end_date);
}
$link = get_post_meta($opportunity->ID, 'opportunity_url_redirect', TRUE);
// added these lines to retrieve taxonomy terms instead of using the meta field we had
$parntCat = get_term_by('slug', 'event-category','event_groups');
$postCats = wp_get_post_terms($opportunity->ID, 'event_groups');
$catTerms = '';
foreach($postCats as $cat){
$catTerms.= $cat->parent == $parntCat->term_id ? $cat->name : '';
}
?>
<li>
<a href="<?=$link?>">
<?=$opportunity->post_title?>
</a>
<br/>
<?=$cPost?>
<? if($end_date){ ?>
<div class="opportunity_info">
<b>Date Close: <?=$end_date->format('l, F jS, Y')?></b> <!-- Added these here b tags -->
</div>
<? } ?>
<? if($time){ ?>
<div class="opportunity_info">
Time: <?=get_post_meta($opportunity->ID, 'opportunity_time', true)?>
</div>
<? } ?>
<? if($location){ ?>
<div class="opportunity_info">
Location: <?=get_post_meta($opportunity->ID, 'opportunity_location', true)?>
</div>
<? } ?>
<div class="text-right opportunity_category">
Category: <?=$catTerms?> <!-- switched this bugger out -->
</div>
</li>
<?php
}
?>
</ul>
</div>
<?
return ob_get_clean();
//add_filter('the_content','wpautop');
}
add_shortcode('opportunity-grid', 'sc_opportunity_grid');
function sc_spotlight_grid($atts) {
$atts = array_map('specCharEscCallback', $atts);
//remove_filter('the_content','wpautop');
$atts['type'] = ($atts['type']) ? $atts['type'] : null;
$categories = ($atts['categories']) ? $atts['categories'] : null;
$event_groups = ($atts['event_groups']) ? $atts['event_groups'] : null;
$event_groups2 = ($atts['event_groups2']) ? $atts['event_groups2'] : null;
$limit = ($atts['limit']) ? (intval($atts['limit'])) : -1;
$join = ($atts['join']) ? $atts['join'] : 'or';
$dropdown = ($atts['dropdown']) ? $atts['dropdown'] : false;
$dd_event_groups = ($atts['dd_event_groups']) ? $atts['dd_event_groups'] : $event_groups;
$dropdown2 = ($atts['dropdown2']) ? $atts['dropdown2'] : false;
$dd2_event_groups = ($atts['dd2_event_groups']) ? $atts['dd2_event_groups'] : NULL;
$show_option_all = ($atts['show_option_all']) ? $atts['show_option_all'] : null;
$show_option_all2 = ($atts['show_option_all2']) ? $atts['show_option_all2'] : null;
$EGID = get_term_by('slug', $dd_event_groups, 'event_groups')->term_id;
$EGID2 = get_term_by('slug', $dd2_event_groups, 'event_groups');
$EGID2 = $EGID2 ? $EGID2->term_id : false;
$operator = ($atts['operator']) ? $atts['operator'] : NULL;
$spots = sc_object_list(
array(
'type' => 'spotlight',
'limit' => $limit,
'join' => $join,
'categories' => $categories,
'event_groups' => $event_groups2 ? $event_groups.' '.$event_groups2 : $event_groups,
'orderby' => 'meta_value_num',
'order' => 'DESC',
'meta_key' => 'spotlight_end',
'operator' => $operator,
'meta_query' => array(
array(
'key' => 'spotlight_start',
'value' => date('Ymd'),
'compare' => '<=',
),
),
),
array(
'objects_only' => True,
)
);
usort($spots, function($a, $b){
$a_dt = new DateTime(get_post_meta($a->ID, 'spotlight_end', TRUE));
$b_dt = new DateTime(get_post_meta($b->ID, 'spotlight_end', TRUE));
$a_dt = $a_dt->getTimestamp();
$b_dt = $b_dt->getTimestamp();
if ($a_dt == $b_dt){
// If they have the same depth, compare titles
return strcmp($a->post_title, $b->post_title) * -1;
}
// If depth_a is smaller than depth_b, return -1; otherwise return 1
$res = ($a_dt > $b_dt) ? -1 : 1;
return $res;
});
//var_dump($spots);
ob_start();
?><div class="spotlight-grid" data-url="<?=admin_url( 'admin-ajax.php' )?>" data-group="<?=esc_attr($dd_event_groups)?>" data-group2="<?=esc_attr($dd2_event_groups)?>" data-jn="<?=esc_attr($join)?>" data-oprtr="<?=esc_attr($operator)?>" data-allopt="<?=esc_attr($show_option_all)?>" data-allopt2="<?=esc_attr($show_option_all2)?>">
<? if($dropdown){
$args = array(
'taxonomy' => 'event_groups',
'value_field' => 'slug',
'class' => 'spotlight-grid-dropdown form-control',
'id' => 'dd_event_groups',
'name' => 'dd_event_groups',
'echo' => false,
'selected' => $event_groups,
'child_of' => $EGID,
);
if(!empty($show_option_all)){
$args['show_option_all'] = $show_option_all;
}
// filter hooks from http://wordpress.stackexchange.com/a/72562, get_terms_orderby_semester_year function exists in functions.php
add_filter('get_terms_orderby', 'get_terms_orderby_semester_year',10,2);
$wp1Args = wp_dropdown_categories($args);
remove_filter('get_terms_orderby', 'get_terms_orderby_semester_year');
//
rsort($wp1Args);
echo str_replace(
'<select',
'<select onchange="getSpotsForGrid(this.value'.($dropdown2 ? ', $(\'#dd2_event_groups\').val()' : '').')"',
$wp1Args
);
}
if($dropdown2 && $EGID2){
$args2 = array(
'taxonomy' => 'event_groups',
'value_field' => 'slug',
'class' => 'spotlight-grid-dropdown form-control',
'id' => 'dd2_event_groups',
'name' => 'dd2_event_groups',
'echo' => false,
'selected' => $event_groups2,
'child_of' => $EGID2,
);
if(!empty($show_option_all2)){
$args2['show_option_all2'] = $show_option_all2;
}
echo str_replace(
'<select',
'<select onchange="getSpotsForGrid($(\'#dd_event_groups\').val(), this.value)"',
wp_dropdown_categories($args2)
);
}
?>
<ul class="spotlight-list">
<?php
//rsort($opps);
foreach ($spots as $spotlight) {
$start_date; //= get_post_meta($spotlight->ID, 'spotlight_start', TRUE);
$end_date; //= get_post_meta($spotlight->ID, 'spotlight_end', TRUE);
$link = get_post_meta($spotlight->ID, 'spotlight_url_redirect', TRUE);
$time = '';
$location = '';
if($start_date){
$start_date = new DateTime($start_date);
}
if($end_date){
$end_date = new DateTime($end_date);
}
// added these lines to retrieve taxonomy terms instead of using the meta field we had
$parntCat = get_term_by('slug', 'event-category','event_groups');
$postCats = wp_get_post_terms($spotlight->ID, 'event_groups');
$catTerms = '';
foreach($postCats as $cat){
$catTerms.= $cat->parent == $parntCat->term_id ? $cat->name : '';
}
?>
<li>
<a href="<?=$link?>">
<?=$spotlight->post_title?>
</a>
<? if($end_date){ ?>
<div class="spotlight_info">
Date Available: <?=$start_date->format('l, F jS, Y')?>
<br/>
Date Close: <?=$end_date->format('l, F jS, Y')?>
</div>
<? } ?>
<? if($time){ ?>
<div class="spotlight_info">
Time: <?=get_post_meta($spotlight->ID, 'spotlight_time', true)?>
</div>
<? } ?>
<? if($location){ ?>
<div class="spotlight_info">
Location: <?=get_post_meta($spotlight->ID, 'spotlight_location', true)?>
</div>
<? } ?>
<div class="text-right spotlight_category">
Category: <?=$catTerms?> <!-- silly bugger -->
</div>
</li>
<?php
}
?>
</ul>
</div>
<?
return ob_get_clean();
//add_filter('the_content','wpautop');
}
add_shortcode('spotlight-grid', 'sc_spotlight_grid');
/**
* Centerpiece Slider
**/
function sc_centerpiece_slider( $atts, $content = null ) {
$atts = array_map('specCharEscCallback', $atts);
extract( shortcode_atts( array(
'id' => '',
), $atts ) );
global $post;
$args = array('p' => esc_attr( $id ),
'post_type' => 'centerpiece',
'posts_per_page' => '1'
);
query_posts( $args );
if( have_posts() ) while ( have_posts() ) : the_post();
$slide_order = trim(get_post_meta($post->ID, 'ss_slider_slideorder', TRUE), ',');
$slide_order = explode("," , $slide_order);
$slide_count = count($slide_order);
$slide_title = get_post_meta($post->ID, 'ss_slide_title', TRUE);
$slide_content_type = get_post_meta($post->ID, 'ss_type_of_content', TRUE);
$slide_image = get_post_meta($post->ID, 'ss_slide_image', TRUE);
$slide_video = get_post_meta($post->ID, 'ss_slide_video', TRUE);
$slide_video_thumb_def = THEME_IMG_URL.'/video_thumb_default.jpg';
$slide_video_thumb = get_post_meta($post->ID, 'ss_slide_video_thumb', TRUE);
$slide_content = get_post_meta($post->ID, 'ss_slide_content', TRUE);
$slide_links_to = get_post_meta($post->ID, 'ss_slide_links_to', TRUE);
$slide_newtab = get_post_meta($post->ID, 'ss_slide_link_newtab', TRUE);
$slide_duration = get_post_meta($post->ID, 'ss_slide_duration', TRUE);
$slide_display_tit = get_post_meta($post->ID, 'ss_display_title', TRUE);
$slide_tit_off_top = get_post_meta($post->ID, 'ss_title_top_offset', TRUE);
$slide_tit_off_left = get_post_meta($post->ID, 'ss_title_left_offset', TRUE);
$slide_tit_font_sz = get_post_meta($post->ID, 'ss_title_font_size', TRUE);
$slide_tit_font_col = get_post_meta($post->ID, 'ss_title_font_color', TRUE);
$slide_tit_bg_color = get_post_meta($post->ID, 'ss_title_background_color', TRUE);
$slide_tit_opacity = get_post_meta($post->ID, 'ss_title_opacity', TRUE);
// id have made a param array (literals in js), debug gets ezier
if(DEBUG){
$a = array($slide_display_tit,$slide_tit_off_top,$slide_tit_off_left,$slide_tit_font_sz,$slide_tit_font_col,$slide_tit_bg_color,$slide_tit_opacity);
print_r($a);
}
// #centerpiece_slider must contain an image placeholder set to the max
// slide width in order to trigger responsive styles properly--
// http://www.bluebit.co.uk/blog/Using_jQuery_Cycle_in_a_Responsive_Layout
$output .= '<div id="centerpiece_slider">
<ul>
<img src="'.get_bloginfo('stylesheet_directory').'/static/img/blank_slide.png" style="max-width: 100%; height: auto;">';
foreach ($slide_order as $s) {
if ( ($s !== '') && ($s !== NULL) ) {
$s = (int)$s;
$slide_image_url = wp_get_attachment_image_src($slide_image[$s], 'centerpiece-image-wide');
$slide_video_thumb_url = wp_get_attachment_image_src($slide_video_thumb[$s], 'centerpiece-image-wide');
$slide_single_duration = (!empty($slide_duration[$s]) ? $slide_duration[$s] : '6');
// Start <li>
$output .= '<li class="centerpiece_single" id="centerpiece_single_'.$s.'" data-duration="'.$slide_single_duration.'">';
// Add <a> tag and target="_blank" if applicable:
if ($slide_links_to[$s] !== '' && $slide_content_type[$s] == 'image') {
$output .= '<a href="'.$slide_links_to[$s];
if ($slide_newtab == 'on') {
$output .= ' target="_blank"';
}
$output .= '">';
}
// Image output:
if ($slide_content_type[$s] == 'image') {
$output .= '<img class="centerpiece_single_img" src="'.$slide_image_url[0].'" title="'.$slide_title[$s].'" alt="'.$slide_title[$s].'"';
$output .= '/>';
if($slide_display_tit[$s] == 'on'){
$output .= '<div style="position:absolute;top:'.$slide_tit_off_top[$s].';left:'.$slide_tit_off_left[$s].';font-size:'.$slide_tit_font_sz[$s].';color:'.$slide_tit_font_col[$s].';background-color:'.$slide_tit_bg_color[$s].';opactiy:'.$slide_tit_opacity[$s].';">'.$slide_title[$s].'</div>';
}
if ($slide_links_to[$s] !== '' && $slide_content_type[$s] == 'image') {
$output .= '</a>';
}
if ($slide_content[$s] !== '') {
$output .= '<div class="slide_contents">'.apply_filters('the_content', $slide_content[$s]).'</div>';
}
}
// Video output:
if ($slide_content_type[$s] == 'video') {
// if a video thumbnail is not set and this is not a
// single slide centerpiece, use the default video thumb
// (single slide centerpieces w/video should have an
// optional thumbnail for autoplay purposes)
if ($slide_count > 1) {
if (!$slide_video_thumb[$s]) {
$slide_video_thumb_url[0] = $slide_video_thumb_def;
}
}
$filtered_video_metadata = strip_tags(apply_filters('the_content', $slide_video[$s]), '<iframe><object><embed>');
if ($slide_video_thumb_url[0] !== NULL) {
$output .= '<img class="centerpiece_single_vid_thumb" src="'.$slide_video_thumb_url[0].'" alt="Click to Watch" title="Click to Watch" />';
$output .= '<div class="centerpiece_single_vid_hidden">'.$filtered_video_metadata.'</div>';
}
else {
$output .= $filtered_video_metadata;
}
}
// End <li>
$output .= '</li>';
}
}
$output .= '</ul>';
// Apply rounded corners:
if ($rounded_corners == 'on') {
$output .= '<div class="thumb_corner_tl"></div><div class="thumb_corner_tr"></div><div class="thumb_corner_bl"></div><div class="thumb_corner_br"></div>';
}
$output .= '
<div id="centerpiece_control"></div>
</div>';
endwhile;
wp_reset_query();
return $output;
}
add_shortcode('centerpiece', 'sc_centerpiece_slider');
/**
* Output Upcoming Events via shortcode.
**/
function sc_events_widget() {
display_events();
print /*'<p class="events_icons"><a class="icsbtn" href="http://events.ucf.edu/upcoming/feed.ics">ICS Format for upcoming events</a><a class="rssbtn" href="http://events.ucf.edu/upcoming/feed.rss">RSS Format for upcoming events</a></p>*/
'<div class="moreBtnPad"><div class="screen-only moreBtn"><a href="https://events.ucf.edu/calendar/2862/the-burnett-honors-college/upcoming/" class="home_col_morelink">More Events</a>'.output_weather_data().'</div></div>';
}
add_shortcode('events-widget', 'sc_events_widget');
/**
* Post search
*
* @return string
* @author Chris Conover
* */
function sc_post_type_search( $params=array(), $content='' ) {
$defaults = array(
'post_type_name' => 'post',
'taxonomy' => 'category',
'meta_key' => '',
'meta_value' => '',
'show_empty_sections' => false,
'non_alpha_section_name' => 'Other',
'column_width' => 'col-md-4 col-sm-4',
'column_count' => '3',
'order_by' => 'title',
'order' => 'ASC',
'show_sorting' => true,
'default_sorting' => 'term',
'show_sorting' => true,
'show_uncategorized' => false,
'uncategorized_term_name' => 'Uncategorized'
);