-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathadmin_meeting.php
More file actions
537 lines (513 loc) · 26.4 KB
/
Copy pathadmin_meeting.php
File metadata and controls
537 lines (513 loc) · 26.4 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
<?php
// customizations for the add/edit meeting administration screens
// custom title
add_filter('enter_title_here', function ($title) {
$screen = get_current_screen();
if ($screen->post_type == 'tsml_meeting') {
$title = __('Enter meeting name', '12-step-meeting-list');
}
return $title;
});
// move author meta box to right side
add_action('do_meta_boxes', function () {
remove_meta_box('authordiv', 'tsml_meeting', 'normal');
add_meta_box('authordiv', __('Editor', '12-step-meeting-list'), 'post_author_meta_box', 'tsml_meeting', 'side', 'default');
});
// add admin assets to tsml screens only
add_action('admin_enqueue_scripts', function () {
$screen = get_current_screen();
if (is_object($screen) && $screen->post_type === 'tsml_meeting') {
tsml_assets();
}
});
// edit page
add_action('admin_init', function () {
// compares versions and updates databases as needed for upgrades
$tsml_version = get_option('tsml_version');
if (version_compare($tsml_version, TSML_VERSION, '<')) {
// do this every time
update_option('tsml_version', TSML_VERSION);
flush_rewrite_rules();
};
add_meta_box('info', __('Meeting Information', '12-step-meeting-list'), function () {
global $tsml_days, $tsml_programs, $tsml_program, $tsml_nonce, $tsml_types_in_use, $tsml_data_sources;
$meeting = tsml_get_meeting();
$languages = tsml_languages();
$types = array_diff_key($tsml_programs[$tsml_program]['types'], array_merge($languages, array_fill_keys(['ONL', 'TC'], true)));
$user_language = strtoupper(substr(get_user_locale(), 0, 2));
// time is before the end of april and not currently using temporary closure
if (!in_array('TC', $tsml_types_in_use) && time() < strtotime('2020-04-30')) {
tsml_alert('Please note: a new “Temporary Closure” meeting type has recently been added. Use this to indicate meetings that are temporarily not meeting. Find it under “View all” below.', 'warning');
}
if (!empty($meeting->data_source)) {
$data_source_name = property_exists($meeting, 'data_source_name') ? $meeting->data_source_name : $meeting->data_source;
$message = sprintf(
// translators: %s is the data source name
__('This meeting was imported from an external feed %s. Any changes you make here will be overwritten when you refresh the data.', '12-step-meeting-list'),
"<strong>$data_source_name</strong>"
);
tsml_alert($message, 'warning');
}
// nonce field
wp_nonce_field($tsml_nonce, 'tsml_nonce', false);
?>
<div class="notice notice-error tsml-form-errors" style="display:none">
<p><?php esc_html_e('Your meeting has errors that need attention', '12-step-meeting-list'); ?></p>
<ul></ul>
</div>
<div class="meta_form_row">
<label for="day">
<?php esc_html_e('Day', '12-step-meeting-list') ?>
</label>
<select name="day" id="day">
<?php foreach ($tsml_days as $key => $day) { ?>
<option value="<?php echo esc_attr($key) ?>" <?php selected(strcmp(@$meeting->day, $key) == 0) ?>>
<?php echo esc_html($day) ?>
</option>
<?php } ?>
<option disabled>──────</option>
<option value="" <?php selected(!strlen(@$meeting->day)) ?>>
<?php esc_html_e('Appointment', '12-step-meeting-list') ?>
</option>
</select>
</div>
<div class="meta_form_row">
<label for="time">
<?php esc_html_e('Time', '12-step-meeting-list') ?>
</label>
<?php
tsml_input_text('time', @$meeting->time, ['class' => 'time', 'data-time-format' => get_option('time_format'), 'disabled' => !strlen(@$meeting->day)]);
tsml_input_text('end_time', @$meeting->end_time, ['class' => 'time', 'data-time-format' => get_option('time_format'), 'disabled' => !strlen(@$meeting->day)]);
?>
</div>
<?php if (count($types)) { ?>
<div class="meta_form_row">
<label for="types">
<?php esc_html_e('Types', '12-step-meeting-list') ?>
</label>
<div
class="checkboxes<?php if (!empty($tsml_types_in_use) && count($tsml_types_in_use) !== count($tsml_programs[$tsml_program]['types'])) { ?> has_more<?php } ?>">
<?php
foreach ($types as $key => $type) { ?>
<label <?php if (!empty($tsml_types_in_use) && !in_array($key, $tsml_types_in_use)) {
echo ' class="not_in_use"';
} ?>>
<input type="checkbox" name="types[]" value="<?php echo esc_attr($key) ?>" <?php checked(in_array($key, @$meeting->types)) ?>>
<?php echo esc_html($type) ?>
</label>
<?php } ?>
<div class="toggle_more">
<div class="more">
<span class="dashicons dashicons-arrow-down-alt2"></span> <a href="#more-types">
<?php esc_html_e('View all', '12-step-meeting-list') ?>
</a>
</div>
<div class="less">
<span class="dashicons dashicons-arrow-up-alt2"></span> <a href="#more-types">
<?php esc_html_e('Hide types not in use', '12-step-meeting-list') ?>
</a>
</div>
</div>
</div>
</div>
<?php } ?>
<div class="meta_form_row">
<label for="languages">
<?php esc_html_e('Languages', '12-step-meeting-list') ?>
</label>
<div
class="checkboxes<?php if (!empty($tsml_types_in_use) && count($tsml_types_in_use) !== count($tsml_programs[$tsml_program]['types'])) { ?> has_more<?php } ?>">
<?php foreach ($languages as $key => $type) { ?>
<label <?php if (!empty($tsml_types_in_use) && !in_array($key, $tsml_types_in_use) && $key !== $user_language) {
echo ' class="not_in_use"';
} ?>>
<input type="checkbox" name="types[]" value="<?php echo esc_attr($key) ?>" <?php checked(in_array($key, @$meeting->types)) ?>>
<?php echo esc_html($type) ?>
</label>
<?php } ?>
<div class="toggle_more">
<div class="more">
<span class="dashicons dashicons-arrow-down-alt2"></span> <a href="#more-types">
<?php esc_html_e('View all', '12-step-meeting-list') ?>
</a>
</div>
<div class="less">
<span class="dashicons dashicons-arrow-up-alt2"></span> <a href="#more-types">
<?php esc_html_e('Hide languages not in use', '12-step-meeting-list') ?>
</a>
</div>
</div>
</div>
</div>
<div class="meta_form_row">
<label for="content">
<?php esc_html_e('Notes', '12-step-meeting-list') ?>
</label>
<textarea name="content" id="content"
placeholder="<?php esc_attr_e('eg. Birthday speaker meeting last Saturday of the month', '12-step-meeting-list') ?>"><?php echo esc_textarea($meeting->post_content) ?></textarea>
</div>
<div class="meta_form_separator">
<h4>
<?php esc_html_e('Online Meeting Details', '12-step-meeting-list') ?>
</h4>
<p>
<?php echo wp_kses(
sprintf(
// translators: %s is the list of supported conference providers
__('If this meeting has videoconference information, please enter the full valid URL here. Currently supported providers: %s. If other details are required, such as a password, they can be included in the Notes field above, but a ‘one tap’ experience is ideal. Passwords can be appended to phone numbers using this format <code>+12125551212,,123456789#,,#,,444444#</code>', '12-step-meeting-list'),
implode(', ', tsml_conference_providers())
),
TSML_ALLOWED_HTML
) ?>
</p>
</div>
<div class="meta_form_row">
<label for="conference_url">
<?php esc_html_e('URL', '12-step-meeting-list') ?>
</label>
<?php tsml_input_url('conference_url', @$meeting->conference_url) ?>
<small class="error_message" data-message="1">
<?php esc_html_e('Zoom conference urls must be valid to join or register for a meeting. Example: https://zoom.us/j/1234567890', '12-step-meeting-list') ?>
</small>
<small class="warning_message" data-message="2">
<?php esc_html_e('Your conference url has been updated to follow the Zoom url standard.', '12-step-meeting-list') ?>
</small>
</div>
<div class="meta_form_row">
<label for="conference_url_notes">
<?php esc_html_e('URL Notes', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('conference_url_notes', @$meeting->conference_url_notes) ?>
</div>
<div class="meta_form_row">
<label for="conference_phone">
<?php esc_html_e('Phone', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('conference_phone', @$meeting->conference_phone, ['placeholder' => "+12125551212,,123456789#,,#,,444444#"]) ?>
</div>
<div class="meta_form_row">
<label for="conference_phone_notes">
<?php esc_html_e('Phone Notes', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('conference_phone_notes', @$meeting->conference_phone_notes) ?>
</div>
<?php
}, 'tsml_meeting', 'normal', 'low');
add_meta_box(
'location',
__('Location Information', '12-step-meeting-list'),
function () {
global $tsml_timezone, $tsml_user_interface, $post;
$meeting = tsml_get_meeting();
$location = $meetings = [];
if ($meeting->post_parent) {
$location = tsml_get_location($meeting->post_parent);
$meetings = tsml_get_meetings(['location_id' => $location->ID]);
}
?>
<div class="meta_form_row radio">
<div class="in_person">
<div>
<?php esc_html_e('Can I currently attend this meeting in person?', '12-step-meeting-list') ?>
</div>
<label>
<input type="radio" name="in_person" value="yes" <?php checked(empty($meeting->attendance_option) || $meeting->attendance_option == 'in_person' || $meeting->attendance_option == 'hybrid') ?> />
<?php esc_html_e('Yes', '12-step-meeting-list') ?>
</label>
<label>
<input type="radio" name="in_person" value="no" <?php checked($meeting->attendance_option == 'online' || $meeting->attendance_option == 'inactive') ?> />
<?php esc_html_e('No', '12-step-meeting-list') ?>
</label>
</div>
<div class="location_note">
<?php esc_html_e('Select Yes for in-person or hybrid meetings.', '12-step-meeting-list') ?><br />
<?php esc_html_e('Select No for online-only meetings, or meetings that are temporarily inactive.', '12-step-meeting-list') ?><br /><br />
<?php esc_html_e('For meetings I can attend in person:', '12-step-meeting-list') ?>
<ul>
<li>
<?php esc_html_e('A specific address is required', '12-step-meeting-list') ?>
</li>
</ul>
<?php esc_html_e('For online or hybrid meetings:', '12-step-meeting-list') ?>
<ul>
<li>
<?php esc_html_e('Fill in the "Online Meeting Details" above', '12-step-meeting-list') ?>
</li>
</ul>
<?php esc_html_e('For online-only meetings:', '12-step-meeting-list') ?>
<ul>
<li>
<?php esc_html_e('Use an approximate address, example: Philadelphia, PA, USA. It may help to think of it as the meeting\'s origin. The Meeting Guide app uses this information to infer the meeting\'s time zone.', '12-step-meeting-list') ?>
</li>
</ul>
</div>
</div>
<div class="meta_form_row">
<label for="location">
<?php esc_html_e('Location', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('location', @$location->post_title) ?>
</div>
<div class="meta_form_row">
<label for="formatted_address">
<?php esc_html_e('Address', '12-step-meeting-list') ?>
</label>
<?php
tsml_input_text('formatted_address', @$location->formatted_address, ['data-original-value' => @$location->formatted_address]);
tsml_input_hidden('approximate', @$location->approximate);
tsml_input_hidden('latitude', @$location->latitude);
tsml_input_hidden('longitude', @$location->longitude);
?>
<small class="error_message" data-message="1">
<?php esc_html_e('Error: In person meetings must have a specific address.', '12-step-meeting-list') ?>
</small>
<small class="error_message" data-message="2">
<?php esc_html_e('Error: Unable to process this address for exact location.', '12-step-meeting-list') ?>
</small>
<small class="error_message" data-message="3">
<?php esc_html_e('Online meetings must have a approximate address, like the nearest city or town.', '12-step-meeting-list') ?>
</small>
<small class="warning_message" data-message="4">
<?php esc_html_e('Warning: Online meetings with a specific address will appear that the location temporarily closed. Meetings that are Online only should use appoximate addresses.', '12-step-meeting-list') ?><br /><br />
<?php esc_html_e('Example:', '12-step-meeting-list') ?><br />
<?php esc_html_e('Location: Online-Philadelphia', '12-step-meeting-list') ?><br />
<?php esc_html_e('Address: Philadelphia, PA, USA', '12-step-meeting-list') ?>
</small>
</div>
<?php if (count($meetings) > 1) { ?>
<div class="meta_form_row checkbox apply_address_to_location hidden">
<label>
<input type="checkbox" name="apply_address_to_location">
<?php esc_html_e('Apply this updated address to all meetings at this location', '12-step-meeting-list') ?>
</label>
</div>
<?php }
// phpcs:ignore
if (wp_count_terms('tsml_region')) { ?>
<div class="meta_form_row">
<label for="region">
<?php esc_html_e('Region', '12-step-meeting-list') ?>
</label>
<?php wp_dropdown_categories([
'name' => 'region',
'taxonomy' => 'tsml_region',
'hierarchical' => true,
'hide_empty' => false,
'orderby' => 'name',
'selected' => empty($location->region_id) ? null : $location->region_id,
'show_option_none' => __('Region', '12-step-meeting-list'),
]) ?>
</div>
<?php } ?>
<div class="meta_form_row">
<label>
<?php esc_html_e('Map', '12-step-meeting-list') ?>
</label>
<div id="map"></div>
</div>
<div class="meta_form_row">
<label for="timezone">
<?php esc_html_e('Timezone', '12-step-meeting-list') ?>
</label>
<?php
$timezone = null;
if ($location && $location->timezone) {
$timezone = $location->timezone;
} elseif ($post && 'auto-draft' === $post->post_status) {
$timezone = $tsml_timezone;
}
tsml_timezone_select($timezone)
?>
</div>
<?php if (empty($location->timezone) && empty($tsml_timezone) && $tsml_user_interface === 'tsml_ui') { ?>
<div class="meta_form_separator">
<p>
<?php esc_html_e('Because your site does not have a default timezone set, a timezone must be selected here for the meeting to appear on the meeting finder page.', '12-step-meeting-list') ?>
</p>
</div>
<?php } ?>
<?php if (count($meetings) > 1) { ?>
<div class="meta_form_row">
<label>
<?php esc_html_e('Meetings', '12-step-meeting-list') ?>
</label>
<?php tsml_admin_meeting_list($meetings, $meeting->ID) ?>
</div>
<?php } ?>
<div class="meta_form_row">
<label>
<?php esc_html_e('Location Notes', '12-step-meeting-list') ?>
</label>
<textarea name="location_notes"
placeholder="<?php esc_html_e('eg. Around back, basement, ring buzzer', '12-step-meeting-list') ?>"><?php echo esc_attr(@$location->post_content) ?></textarea>
</div>
<?php
},
'tsml_meeting',
'normal',
'low'
);
add_meta_box('group', __('Contact Information <small>Optional</small>', '12-step-meeting-list'), function () {
global $tsml_contact_display;
$meeting = tsml_get_meeting();
$meetings = [];
$district = 0;
if (!empty($meeting->group_id)) {
$meetings = tsml_get_meetings(['group_id' => $meeting->group_id]);
$district = wp_get_post_terms($meeting->group_id, 'tsml_district', ['fields' => 'ids']);
if (is_array($district)) {
$district = empty($district) ? 0 : $district[0];
}
}
?>
<div id="contact-type" data-type="<?php echo empty($meeting->group) ? 'meeting' : 'group' ?>">
<div class="meta_form_row radio">
<label>
<input type="radio" name="group_status" value="meeting" <?php checked(empty($meeting->group)) ?>>
<?php esc_html_e('Individual meeting', '12-step-meeting-list') ?>
</label>
<label>
<input type="radio" name="group_status" value="group" <?php checked(!empty($meeting->group)) ?>>
<?php esc_html_e('Part of a group', '12-step-meeting-list') ?>
</label>
</div>
<div class="meta_form_row group-visible">
<label for="group">
<?php esc_html_e('Group', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('group', @$meeting->group) ?>
</div>
<div class="meta_form_row checkbox apply_group_to_location hidden">
<label>
<input type="checkbox" name="apply_group_to_location">
<?php esc_html_e('Apply this group to all meetings at this location', '12-step-meeting-list') ?>
</label>
</div>
<?php if (count($meetings) > 1) { ?>
<div class="meta_form_row">
<label><?php esc_html_e('Meetings', '12-step-meeting-list') ?></label>
<?php tsml_admin_meeting_list($meetings, $meeting->ID) ?>
</div>
<?php }
// phpcs:ignore
if (wp_count_terms('tsml_district')) { ?>
<div class="meta_form_row group-visible">
<label for="district">
<?php esc_html_e('District', '12-step-meeting-list') ?>
</label>
<?php wp_dropdown_categories([
'name' => 'district',
'taxonomy' => 'tsml_district',
'hierarchical' => true,
'hide_empty' => false,
'orderby' => 'name',
'selected' => $district,
'show_option_none' => __('None', '12-step-meeting-list'),
]) ?>
</div>
<?php } ?>
<div class="meta_form_row group-visible">
<label for="group_notes">
<?php esc_html_e('Group Notes', '12-step-meeting-list') ?>
</label>
<textarea name="group_notes" id="group_notes"
placeholder="<?php esc_html_e('eg. Group history, when the business meeting is, etc.', '12-step-meeting-list') ?>"><?php echo esc_textarea(@$meeting->group_notes) ?></textarea>
</div>
<div class="meta_form_row">
<label for="website">
<?php esc_html_e('Website', '12-step-meeting-list') ?>
</label>
<?php tsml_input_url('website', @$meeting->website) ?>
</div>
<div class="meta_form_row">
<label for="website_2">
<?php esc_html_e('Website 2', '12-step-meeting-list') ?>
</label>
<?php tsml_input_url('website_2', @$meeting->website_2) ?>
</div>
<div class="meta_form_row">
<label for="email">
<?php esc_html_e('Email', '12-step-meeting-list') ?>
</label>
<?php tsml_input_email('email', @$meeting->email, ['placeholder' => 'group@website.org']) ?>
</div>
<div class="meta_form_row">
<label for="phone">
<?php esc_html_e('Phone', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('phone', @$meeting->phone, ['placeholder' => '+18005551212']) ?>
</div>
<div class="meta_form_row">
<label for="mailing_address">
<?php esc_html_e('Mailing Address', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('mailing_address', @$meeting->mailing_address, ['placeholder' => '123 Main St, Anytown OK']) ?>
</div>
<div class="meta_form_row">
<label>
<?php esc_html_e('Venmo', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('venmo', @$meeting->venmo, ['placeholder' => '@VenmoHandle']) ?>
</div>
<div class="meta_form_row">
<label>
<?php esc_html_e('Cash App', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('square', @$meeting->square, ['placeholder' => '$Cashtag']) ?>
</div>
<div class="meta_form_row">
<label>
<?php esc_html_e('PayPal', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('paypal', @$meeting->paypal, ['placeholder' => 'PayPalUsername']) ?>
<small class="error_message" data-message="1">
<?php esc_html_e('A valid PayPal username can only contain letters and numbers, and be less than 20 characters.', '12-step-meeting-list') ?>
</small>
</div>
<div class="meta_form_row">
<label>
<?php esc_html_e('Homegroup Online', '12-step-meeting-list') ?>
</label>
<?php tsml_input_text('homegroup_online', @$meeting->homegroup_online, ['placeholder' => 'Homegroup Online group code']) ?>
<small class="error_message" data-message="1">
<?php esc_html_e('A valid Homegroup Online group code can only contain letters and numbers.', '12-step-meeting-list') ?>
</small>
</div>
<div class="meta_form_row">
<label>
<?php esc_html_e('Contacts', '12-step-meeting-list') ?>
<span style="display: block;font-size:90%;color:#999;">
(
<?php if ($tsml_contact_display == 'public') {
esc_html_e('Public', '12-step-meeting-list');
} else {
esc_html_e('Private', '12-step-meeting-list');
} ?>)
</span>
</label>
<div class="container">
<?php
for ($i = 1; $i <= TSML_GROUP_CONTACT_COUNT; $i++) { ?>
<div class="row">
<?php
foreach (['name' => __('Name', '12-step-meeting-list'), 'email' => __('Email', '12-step-meeting-list'), 'phone' => __('Phone', '12-step-meeting-list')] as $key => $label) {
$field = implode('_', ['contact', $i, $key]);
?>
<div>
<?php tsml_input_text($field, @$meeting->{$field}, ['placeholder' => $label]) ?>
</div>
<?php } ?>
</div>
<?php } ?>
</div>
</div>
<div class="meta_form_row">
<label for="last_contact">
<?php esc_html_e('Last Contact', '12-step-meeting-list') ?>
</label>
<?php tsml_input_date('last_contact', @$meeting->last_contact) ?>
</div>
</div>
<?php
}, 'tsml_meeting', 'normal', 'low');
});