-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwp-proud-meeting.php
More file actions
1047 lines (907 loc) · 34.5 KB
/
wp-proud-meeting.php
File metadata and controls
1047 lines (907 loc) · 34.5 KB
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
/**
Plugin Name: Proud Meeting
Plugin URI: http://proudcity.com/
Description: Declares an Meeting custom post type.
Version: 2026.01.19.1156
Author: ProudCity
Author URI: http://proudcity.com/
License: Affero GPL v3
*/
namespace Proud\Meeting;
if (! defined('ABSPATH')) exit;
// Load Extendible
// -----------------------
if (! class_exists('ProudPlugin')) {
require_once(plugin_dir_path(__FILE__) . '../wp-proud-core/proud-plugin.class.php');
}
require_once plugin_dir_path(__FILE__) . '/inc/meeting-settings.php';
class ProudMeeting extends \ProudPlugin
{
public function __construct()
{
parent::__construct(array(
'textdomain' => 'wp-proud-meeting',
'plugin_path' => __FILE__,
));
//$this->post_type = 'meeting';
//$this->taxonomy = 'meeting-taxonomy';
$this->hook('init', 'create_meeting');
$this->hook('rest_api_init', 'meeting_rest_support');
$this->hook('init', 'create_taxonomy');
add_action('init', array($this, 'add_meeting_feed'), 10);
add_filter('wp_insert_post_data', array($this, 'meeting_presave'), '99', 2);
add_filter('manage_meeting_posts_columns', array($this, 'set_meeting_columns'));
add_action('manage_meeting_posts_custom_columns', array($this, 'set_meeting_author'), 10, 2);
add_action('save_post_meeting', array($this, 'track_meeting_modified'));
}
/**
* Saves our meeting modified logs
*
* @since 2025.01.12
* @author Curtis <curtis@proudcity.com>
*/
public function track_meeting_modified($post_id)
{
// If this is a revision, get real post ID.
$parent_id = wp_is_post_revision($post_id);
if (false !== $parent_id) {
$post_id = $parent_id;
}
$meta_key_array = array();
update_option('sfn_test', $_POST['form-meeting_agenda'][1]['agenda_updated']);
if (isset($_POST['form-meeting_agenda'][1]['agenda_updated']) && true == $_POST['form-meeting_agenda'][1]['agenda_updated']) {
$meta_key_array[] = '_proud_meeting_agenda_modified';
}
if (isset($_POST['form-meeting_agenda_packet'][1]['agenda_packet_updated']) && true == $_POST['form-meeting_agenda_packet'][1]['agenda_packet_updated']) {
$meta_key_array[] = '_proud_meeting_agenda_packet_modified';
}
if (isset($_POST['form-meeting_minutes'][1]['minutes_updated']) && true == $_POST['form-meeting_minutes'][1]['minutes_updated']) {
$meta_key_array[] = '_proud_meeting_minutes_modified';
}
foreach ($meta_key_array as $meta_key) {
$timestamp = (int) current_time('timestamp', true);
$history = get_post_meta(absint($post_id), sanitize_key($meta_key), true);
// Normalize to array.
if (empty($history)) {
$history = [];
} elseif (is_string($history)) {
// In case legacy code stored a single timestamp string.
$history = [(int) $history];
} elseif (! is_array($history)) {
// Any unexpected shape: reset to empty to avoid corrupting data.
$history = [];
}
// Ensure we only have ints.
$history = array_values(array_filter(array_map('intval', $history)));
$history[] = $timestamp;
update_post_meta(absint($post_id), sanitize_key($meta_key), $history);
}
}
public static function display_meeting_advanced_meeting_updates($post_id, $meta_key)
{
// exit early if we are not displaying advanced meeting update information
if ('on' !== get_option('advanced_meetings_time_display')) {
return;
}
$html = '';
$html .= '<div class="meeting-published-modified-date">';
$html .= '<p class="text-muted" id="published-date">Published on: ' . esc_html(get_the_time('F d, Y \a\t g:ia', absint($post_id))) . '</p>';
$html .= self::get_modified_array(absint($post_id), sanitize_key($meta_key));
$html .= '</div>';
return $html;
}
/**
* Returns the HTML for our dates modified
*
* @since 2026.01.13
* @author Curtis <curtis@proudcity.com>
*/
private static function get_modified_array($post_id, $meta_key)
{
$modified_array = get_post_meta(absint($post_id), sanitize_key($meta_key), true);
$html = '';
if (! is_array($modified_array)) {
return '';
}
// Show most recent updates first
rsort($modified_array, SORT_NUMERIC);
$html .= '<p class="text-muted" id="published-date">Modified on:</p>';
$html .= '<ul>';
foreach ($modified_array as $modified_time) {
$html .= '<li class="text-muted">' . esc_html(wp_date('F d, Y \a\t g:i a', $modified_time)) . '</li>';
}
$html .= '</ul>';
return $html;
}
/**
* Conditional return true if we should display advanced meeting logs
*/
public static function display_advanced_meeting_logs()
{
$display = false;
// exit early if we are not displaying advanced meeting update information
if ('on' === get_option('advanced_meetings_time_display')) {
$display = true;
}
return (bool) $display;
}
public function add_meeting_feed()
{
add_feed('proudcity-meetings', array($this, 'generate_meeting_feed'));
}
public function generate_meeting_feed()
{
include_once 'feed-meeting.php';
}
/**
* Adds custom column to meetings so we can display who is hosting the meeting
*
* @since 2022.12.08
* @author Curtis
*
* @param array $columns required Array of columns
* @return array $columns Our modified array
*/
public function set_meeting_columns($columns)
{
$columns['author'] = 'Meeting Host';
return $columns;
}
/**
* Sets the content in our custom column
*
* @since 2022.12.08
* @author Curtis
*
* @param string $column required The column we need data for
* @param int $post_id required the post we're currently looping through
* @uses get_post_field() Retrieves field from wp_posts given value and post_id
* @uses get_the_author_meta() Returns author meta given value and author_id
* @uses absint() no negative numbers
*/
public function set_meeting_author($column, $post_id)
{
if ('author' === $column) {
$author_id = get_post_field('post_author', absint($post_id));
echo esc_attr(get_the_author_meta('display_name', absint($author_id)));
}
}
public function create_meeting()
{
$labels = array(
'name' => _x('Meetings', 'post name', 'wp-meeting'),
'singular_name' => _x('Meeting', 'post type singular name', 'wp-meeting'),
'menu_name' => _x('Meetings', 'admin menu', 'wp-meeting'),
'name_admin_bar' => _x('Meeting', 'add new on admin bar', 'wp-meeting'),
'add_new' => _x('Add New', 'meeting', 'wp-meeting'),
'add_new_item' => __('Add New Meeting', 'wp-meeting'),
'new_item' => __('New Meeting', 'wp-meeting'),
'edit_item' => __('Edit Meeting', 'wp-meeting'),
'view_item' => __('View Meeting', 'wp-meeting'),
'all_items' => __('All Meetings', 'wp-meeting'),
'search_items' => __('Search meeting', 'wp-meeting'),
'parent_item_colon' => __('Parent meeting:', 'wp-meeting'),
'not_found' => __('No meetings found.', 'wp-meeting'),
'not_found_in_trash' => __('No meetings found in Trash.', 'wp-meeting')
);
$args = array(
'labels' => $labels,
'description' => __('Description.', 'wp-meeting'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_icon' => 'dashicons-groups',
'query_var' => true,
'rewrite' => array('slug' => 'meetings', 'feeds' => true, 'with_front' => false),
'capability_type' => 'post',
'has_archive' => false,
'hierarchical' => false,
'menu_position' => null,
'show_in_rest' => true,
'rest_base' => 'meetings',
'rest_controller_class' => 'WP_REST_Posts_Controller',
'supports' => array('title', 'thumbnail',)
);
register_post_type('meeting', $args);
}
public function create_taxonomy()
{
register_taxonomy(
'meeting-taxonomy',
'meeting',
array(
'labels' => array(
'name' => 'Meeting Categories',
'add_new_item' => 'Add New Meeting Category',
'new_item_name' => "New Meeting"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true
)
);
}
public function meeting_rest_support()
{
register_rest_field(
'meeting',
'meta',
array(
'get_callback' => array($this, 'meeting_rest_metadata'),
'update_callback' => null,
'schema' => null,
)
);
}
/**
* Alter the REST endpoint.
* Add metadata to the post response
*/
public function meeting_rest_metadata($object, $field_name, $request) {}
/**
* Alter the post_content pre-save to add all of our metafields for searching
*/
public function meeting_presave($data, $postarr)
{
if ($data['post_type'] !== 'meeting') {
return $data;
}
// These are the fieldsets we care about
foreach (['datetime', 'agenda', 'agenda_packet', 'minutes'] as $field) {
if (isset($postarr["form-meeting_$field"])) {
$fields = reset($postarr["form-meeting_$field"]);
$title = ucfirst(str_replace('_', ' ', $field));
switch ($field) {
case 'datetime':
$data['post_content'] .= "Date and time: " . $fields['datetime'] . '<br/>';
$obj_location = get_post($fields['location']);
if (!empty($obj_location)) {
$data['post_content'] .= "Location: " . $obj_location->post_title . '<br/>';
}
$obj_agency = get_post($fields['agency']);
if (!empty($obj_agency)) {
$data['post_content'] .= "Department: " . $obj_agency->post_title . '<br/>';
}
break;
default:
$text = $fields[$field];
if (!empty($text)) {
$data['post_content'] .= '<h2>' . $title . '</h2>' . $text;
}
$attachment = $fields[$field . '_attachment'];
if (!empty($text)) {
// @todo Alex save attachment to elastic
}
break;
} //switch
} // isset
} // foreach
return $data;
}
} // class
new ProudMeeting();
// MeetingAddress meta box
if (class_exists('ProudMetaBox')) {
class MeetingDetails extends \ProudMetaBox
{
public $options = [ // Meta options, key => default
'datetime' => '',
'location' => '',
'agency' => '',
];
public function __construct()
{
parent::__construct(
'meeting_datetime', // key
'Details', // title
'meeting', // screen
'normal', // position
'high' // priority
);
}
/**
* Called on form creation
* @param $displaying : false if just building form, true if about to display
* Use displaying:true to do any difficult loading that should only occur when
* the form actually will display
*/
public function set_fields($displaying)
{
// Already set, no loading necessary
if ($displaying) {
return;
}
// Get locations
$locations = get_posts([
'post_type' => 'proud_location',
'orderby' => 'post_title',
'posts_per_page' => 1000
]);
$location_options = ['' => '- Select one -'];
if (!empty($locations) && empty($locations['errors'])) {
foreach ($locations as $location) {
$location_options[$location->ID] = $location->post_title;
}
}
// Get Agencies
$agencies = get_posts([
'post_type' => 'agency',
'orderby' => 'post_title',
'posts_per_page' => 1000
]);
$agency_options = ['' => '- Select one -'];
if (!empty($agencies) && empty($agencies['errors'])) {
foreach ($agencies as $agency) {
$agency_options[$agency->ID] = $agency->post_title;
}
}
$this->fields = [
'datetime' => [
'#type' => 'text',
'#title' => __pcHelp('Date and Time'),
],
'location' => [
'#type' => 'select',
'#options' => $location_options,
'#title' => __pcHelp('Location'),
'#description' => __pcHelp('<a href="/wp-admin/edit.php?post_type=proud_location" target="_blank">Manage Locations</a>'),
],
'agency' => [
'#type' => 'select',
'#options' => $agency_options,
'#title' => _x('Agency', 'post type singular name', 'wp-agency'),
'#description' => __pcHelp('<a href="/wp-admin/edit.php?post_type=agency" target="_blank">Manage ' . _x('Agencies', 'post name', 'wp-agency') . '</a>'),
],
//@todo: location
];
}
/**
* Saves form values
*/
public function save_meta($post_id, $post, $update)
{
// Grab form values from Request
$values = $this->validate_values($post);
// let's make sure we have a value before we try to do anything with it
if (isset($values['datetime']) && ! empty($values['datetime'])) {
$values['datetime'] = !empty(strtotime($values['datetime'])) ? date('Y-m-d H:i', strtotime($values['datetime'])) : '';
}
if (!empty($values)) {
$this->save_all($values, $post_id);
}
}
}
if (is_admin()) {
new MeetingDetails();
}
}
// MeetingAddress meta box
if (class_exists('ProudMetaBox')) {
class MeetingAgenda extends \ProudMetaBox
{
public $options = [ // Meta options, key => default
'agenda' => '',
'agenda_attachment' => '',
'agenda_attachment_meta' => '',
'agenda_attachment_preview' => '1',
];
public function __construct()
{
parent::__construct(
'meeting_agenda', // key
'Agenda', // title
'meeting', // screen
'normal', // position
'high' // priority
);
}
/**
* Called on form creation
* @param $displaying : false if just building form, true if about to display
* Use displaying:true to do any difficult loading that should only occur when
* the form actually will display
*/
public function set_fields($displaying)
{
// Already set, no loading necessary
if ($displaying) {
return;
}
$this->fields = [
// 'agenda_wrapper' => [
// '#type' => 'html',
// '#html' => '<div id="agenda-wrapper"></div>'
// ],
'agenda' => [
'#type' => 'editor',
'#title' => __pcHelp('Agenda Text'),
],
'agenda_updated' => [
'#type' => 'hidden',
'#class' => 'updated',
],
'agenda_attachment' => [
'#type' => 'select_file',
'#title' => __pcHelp('Attachment'),
],
'agenda_attachment_meta' => [
'#type' => 'hidden',
],
'agenda_attachment_preview' => [
'#type' => 'checkbox',
'#title' => 'Show preview',
'#replace_title' => 'Show the embedded document preview',
'#default_value' => '1',
'#return_value' => '1',
],
];
}
/**
* Saves form values
*/
public function save_meta($post_id, $post, $update)
{
// Grab form values from Request
$values = $this->validate_values($post);
if (!empty($values)) {
// Build file meta info for elastic
// @TODO add processing for non-stateless
if (!empty($values['agenda_attachment'])) {
$stateless_meta = \Proud\Core\getStatelessFileMeta($values['agenda_attachment']);
try {
$values['agenda_attachment_meta'] = json_encode($stateless_meta);
} catch (\Exception $e) {
error_log($e);
}
}
$this->save_all($values, $post_id);
}
}
}
if (is_admin()) {
new MeetingAgenda();
}
}
// MeetingAddress meta box
if (class_exists('ProudMetaBox')) {
class MeetingAgendaPacket extends \ProudMetaBox
{
public $options = [ // Meta options, key => default
'agenda_packet' => '',
'agenda_packet_attachment' => '',
'agenda_packet_attachment_meta' => '',
'agenda_packet_attachment_preview' => '1',
];
public function __construct()
{
parent::__construct(
'meeting_agenda_packet', // key
'Agenda Packet', // title
'meeting', // screen
'normal', // position
'high' // priority
);
}
/**
* Called on form creation
* @param $displaying : false if just building form, true if about to display
* Use displaying:true to do any difficult loading that should only occur when
* the form actually will display
*/
public function set_fields($displaying)
{
// Already set, no loading necessary
if ($displaying) {
return;
}
$this->fields = [
'agenda_packet' => [
'#type' => 'editor',
'#title' => __pcHelp('Agenda Packet Text'),
],
'agenda_packet_attachment' => [
'#type' => 'select_file',
'#title' => __pcHelp('Attachment'),
],
'agenda_packet_attachment_meta' => [
'#type' => 'hidden',
],
'agenda_packet_updated' => [
'#type' => 'hidden',
'#class' => 'updated',
],
'agenda_packet_attachment_preview' => [
'#type' => 'checkbox',
'#title' => 'Show preview',
'#replace_title' => 'Show the embedded document preview',
'#default_value' => '1',
'#return_value' => '1',
],
];
}
/**
* Saves form values
*/
public function save_meta($post_id, $post, $update)
{
// Grab form values from Request
$values = $this->validate_values($post);
if (!empty($values)) {
// Build file meta info for elastic
// @TODO add processing for non-stateless
if (!empty($values['agenda_packet_attachment'])) {
$stateless_meta = \Proud\Core\getStatelessFileMeta($values['agenda_packet_attachment']);
try {
$values['agenda_packet_attachment_meta'] = json_encode($stateless_meta);
} catch (\Exception $e) {
error_log($e);
}
}
$this->save_all($values, $post_id);
}
}
}
if (is_admin()) {
new MeetingAgendaPacket();
}
}
// MeetingAddress meta box
if (class_exists('ProudMetaBox')) {
class MeetingMinutes extends \ProudMetaBox
{
public $options = [ // Meta options, key => default
'minutes' => '',
'minutes_attachment' => '',
'minutes_attachment_meta' => '',
'minutes_attachment_preview' => '1',
];
public function __construct()
{
parent::__construct(
'meeting_minutes', // key
'Minutes', // title
'meeting', // screen
'normal', // position
'high' // priority
);
}
/**
* Called on form creation
* @param $displaying : false if just building form, true if about to display
* Use displaying:true to do any difficult loading that should only occur when
* the form actually will display
*/
public function set_fields($displaying)
{
// Already set, no loading necessary
if ($displaying) {
return;
}
$this->fields = [
'minutes' => [
'#type' => 'editor',
'#title' => __pcHelp('Minutes Text'),
],
'minutes_attachment' => [
'#type' => 'select_file',
'#title' => __pcHelp('Attachment'),
],
'minutes_attachment_meta' => [
'#type' => 'hidden',
],
'minutes_updated' => [
'#type' => 'hidden',
'#class' => 'updated',
],
'minutes_attachment_preview' => [
'#type' => 'checkbox',
'#title' => 'Show preview',
'#replace_title' => 'Show the embedded document preview',
'#default_value' => '1',
'#return_value' => '1',
],
];
}
/**
* Saves form values
*/
public function save_meta($post_id, $post, $update)
{
// Grab form values from Request
$values = $this->validate_values($post);
if (!empty($values)) {
// Build file meta info for elastic
// @TODO add processing for non-stateless
if (!empty($values['minutes_attachment'])) {
$stateless_meta = \Proud\Core\getStatelessFileMeta($values['minutes_attachment']);
try {
$values['minutes_attachment_meta'] = json_encode($stateless_meta);
} catch (\Exception $e) {
error_log($e);
}
}
$this->save_all($values, $post_id);
}
}
}
if (is_admin()) {
new MeetingMinutes();
}
}
// MeetingVideo meta box
if (class_exists('ProudMetaBox')) {
class MeetingVideo extends \ProudMetaBox
{
public $options = [ // Meta options, key => default
'video_style' => '',
'video' => '',
'youtube_bookmarks' => '',
'external_video' => '',
];
public function __construct()
{
parent::__construct(
'meeting_video', // key
'Video', // title
'meeting', // screen
'normal', // position
'high' // priority
);
}
/**
* Called on form creation
* @param $displaying : false if just building form, true if about to display
* Use displaying:true to do any difficult loading that should only occur when
* the form actually will display
*/
public function set_fields($displaying)
{
// Already set, no loading necessary
if ($displaying) {
return;
}
$path = plugins_url('assets/', __FILE__);
$this->fields = [
'video_style' => [
'#title' => __('Video Type', 'wp-proud-core'),
'#type' => 'radios',
'#default_value' => '',
'#options' => [
'' => __('Embedded Youtube Player', 'wp-proud-core'),
'external' => __('Link out to external webpage', 'wp-proud-core'),
],
],
'video' => [
'#type' => 'text',
'#title' => __pcHelp('YouTube Video'),
'#description' => __pcHelp('Enter the URL or ID of the YouTube video'),
'#states' => [
'visible' => [
'video_style' => [
'operator' => '!=',
'value' => ['external'],
'glue' => '&&'
],
],
],
],
'external_video' => [
'#type' => 'text',
'#title' => __pcHelp('External Video'),
'#description' => __pcHelp('Enter the URL to open in a new tab'),
'#states' => [
'visible' => [
'video_style' => [
'operator' => '==',
'value' => ['external'],
'glue' => '&&'
],
],
],
],
'youtube_bookmarks' => [
'#title' => __pcHelp('bookmarks'),
'#type' => 'text',
],
'youtube_bookmarks_html' => [
'#type' => 'html',
'#html' => file_get_contents(__DIR__ . '/assets/html/youtube-bookmarks.php'),
],
];
}
/**
* Prints form
*/
public function settings_content($post)
{
// version plugin
$plugin_data = get_plugin_data(__FILE__);
parent::settings_content($post);
// Enqueue JS
$path = plugins_url('assets/', __FILE__);
wp_enqueue_script('moment-js', $path . 'vendor/bootstrap-datetimepicker/moment.min.js', '', esc_attr($plugin_data['Version']), 'all');
wp_enqueue_style('glyphicons-css', '//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css', '', esc_attr($plugin_data['Version']), 'all');
wp_enqueue_script('bootstrap-datetimepicker-js', $path . 'vendor/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js', '', esc_attr($plugin_data['Version']), 'all');
wp_enqueue_style('bootstrap-datetimepicker-css', $path . 'vendor/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css', '', esc_attr($plugin_data['Version']), 'all');
wp_enqueue_script('youtube-api', '//www.youtube.com/iframe_api', '', esc_attr($plugin_data['Version']), 'all');
wp_enqueue_script('handlebars', $path . 'vendor/handlebars.min.js', '', esc_attr($plugin_data['Version']), 'all');
wp_enqueue_style('proud-meeting-css', $path . 'css/proud-meeting.css', '', esc_attr($plugin_data['Version']), 'all');
wp_enqueue_script('proud-meeting-youtube-bookmarks-js', $path . 'js/youtube-bookmarks.js', '', esc_attr($plugin_data['Version']), 'all');
wp_enqueue_script('proud-meeting-js', $path . 'js/proud-meeting.js', 'jquery', esc_attr($plugin_data['Version']), 'all');
wp_localize_script('proud-meeting-js', 'ProudMeeting', [
'proudMeetingNonce' => wp_create_nonce('proud_track_metabox_change')
]);
}
/**
* Saves form values
*/
public function save_meta($post_id, $post, $update)
{
// Grab form values from Request
$values = $this->validate_values($post);
if (!empty($values)) {
$this->save_all($values, $post_id);
}
}
}
if (is_admin()) {
new MeetingVideo();
}
}
// MeetingAudio meta box
if (class_exists('ProudMetaBox')) {
class MeetingAudio extends \ProudMetaBox
{
public $options = [ // Meta options, key => default
'audio' => '',
];
public function __construct()
{
parent::__construct(
'meeting_audio', // key
'Audio', // title
'meeting', // screen
'normal', // position
'high' // priority
);
}
/**
* Called on form creation
* @param $displaying : false if just building form, true if about to display
* Use displaying:true to do any difficult loading that should only occur when
* the form actually will display
*/
public function set_fields($displaying)
{
// Already set, no loading necessary
if ($displaying) {
return;
}
$path = plugins_url('assets/', __FILE__);
$this->fields = [
'audio' => [
'#type' => 'text',
'#title' => __pcHelp('SoundCloud Embed Code'),
'#placeholder' => '<iframe ...',
'#description' => __pcHelp('Enter the Embed Code by clicking on Share > Embed within SoundCloud. <a href="https://help.soundcloud.com/hc/en-us/articles/115003565128-Embedding-a-track-or-playlist-on-WordPress" target="_blank">Learn more</a>.'),
]
];
}
/**
* Saves form values
*/
public function save_meta($post_id, $post, $update)
{
// Grab form values from Request
$values = $this->validate_values($post);
if (!empty($values)) {
$this->save_all($values, $post_id);
}
}
}
if (is_admin()) {
new MeetingAudio();
}
}
// Meeting desc meta box (empty for body)
if (class_exists('ProudMetaBox')) {
class MeetingCategory extends \ProudTermMetaBox
{
public $options = [ // Meta options, key => default
'icon' => '',
'color' => '',
];
public function __construct()
{
parent::__construct(
'meeting-taxonomy', // key
'Settings' // title
);
}
private function colors()
{
return [
'' => ' - Select - ',
'#ED9356' => 'Orange',
'#456D9C' => 'Blue',
'#E76C6D' => 'Red',
'#5A97C4' => 'Dark blue',
'#4DC3FF' => 'Baby blue',
'#9BBF6A' => 'Green',
];
}
/**
* Called on form creation
* @param $displaying : false if just building form, true if about to display
* Use displaying:true to do any difficult loading that should only occur when
* the form actually will display
*/
public function set_fields($displaying)
{
// Already set, no loading necessary
if ($displaying) {
return;
}
global $proudcore;
$this->fields = [
'icon' => [
'#title' => 'Icon',
'#type' => 'fa-icon',
'#default_value' => '',
'#to_js_settings' => false
],
'color' => [
'#title' => 'Color',
'#type' => 'select',
'#options' => $this->colors(),
'#default_value' => '',
'#to_js_settings' => false
],
'markup' => [
'#type' => 'html',
'#html' => '<style type="text/css">.term-description-wrap { display: none; }</style>',
],