-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathclass-mjm-clinic.php
2271 lines (1970 loc) · 86.4 KB
/
class-mjm-clinic.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
/**
* Plugin Name.
*
* @package MJM_Clinic
* @author Matt Manning
* @license GPLv3
* @link http://mjman.net
* @copyright 2014 - 2024 Matt Manning
*/
/**
* Plugin class.
*
* @package MJM_Clinic
* @author Matt Manning
*/
class MJM_Clinic
{
/**
* Plugin version, used for triggering updates, cache-busting of style and script file references.
*
* @since 1.0.0
*
* @var string
*/
protected $version = '1.1.23';
/**
* Unique identifier for your plugin.
*
* Use this value (not the variable name) as the text domain when internationalizing strings of text. It should
* match the Text Domain file header in the main plugin file.
*
* @since 1.0.0
*
* @var string
*/
protected $plugin_slug = 'mjm-clinic';
/**
* Instance of this class.
*
* @since 1.0.0
*
* @var object
*/
protected static $instance = null;
/**
* Slug of the plugin screen.
*
* @since 1.0.0
*
* @var string
*/
protected $plugin_screen_hook_suffix = null;
/**
* Post Types Registered by this plugin
*
* @since 1.0.1
*
* @var array
*/
protected $available_post_types = array('mjm-clinic-service', 'mjm-clinic-condition', 'mjm-clinic-feedback', 'mjm-clinic-casestudy', 'mjm-clinic-staff');
/**
* Initialize the plugin.
*
* @since 1.0.0
*/
private function __construct()
{
include_once('views/actions.php');
}
/**
* Return an instance of this class.
*
* @since 1.0.0
*
* @return object A single instance of this class.
*/
public static function get_instance()
{
// If the single instance hasn't been set, set it now.
if (null == self::$instance) {
self::$instance = new self;
}
return self::$instance;
}
/**
* Do i18n stuff
*
* @since 1.0
*
*/
public function setup_i18n()
{
//@TODO languages
//load_plugin_textdomain( 'mjm-clinic', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
}
/**
* Set up rewrite rules
*
* @since 1.0.
*
*/
public function add_rewrite_rules()
{
}
/**
* Fired when the plugin is activated.
*
* @since 1.0.0
*
* @param boolean $network_wide True if WPMU superadmin uses "Network Activate" action, false if WPMU is disabled or plugin is activated on an individual blog.
*/
public static function activate($network_wide)
{
file_put_contents(__DIR__.'/my_loggg.txt', ob_get_contents());
// add mjm-clinic caps to editors
if (get_role('editor')) {
$role = get_role('editor');
$role->add_cap('add_mjm-clinic');
$role->add_cap('publish_mjm-clinic');
$role->add_cap('edit_mjm-clinic');
$role->add_cap('edit_others_mjm-clinic');
$role->add_cap('read_mjm-clinic');
$role->add_cap('edit_published_mjm-clinic');
$role->add_cap('delete_published_mjm-clinic');
$role->add_cap('delete_mjm-clinic');
}
// add mjm-clinic caps to admins
if (get_role('administrator')) {
$role = get_role('administrator');
$role->add_cap('add_mjm-clinic');
$role->add_cap('publish_mjm-clinic');
$role->add_cap('edit_mjm-clinic');
$role->add_cap('edit_others_mjm-clinic');
$role->add_cap('read_mjm-clinic');
$role->add_cap('edit_published_mjm-clinic');
$role->add_cap('delete_published_mjm-clinic');
$role->add_cap('delete_mjm-clinic');
$role->add_cap('add_mjm_clinic_location');
$role->add_cap('manage_clinic_service_options');
}
add_option('MJM_Clinic_Activated_Plugin', 'mjm-clinic');
}
/**
* Fired when the plugin is deactivated.
*
* @since 1.0.0
*
* @param boolean $network_wide True if WPMU superadmin uses "Network Deactivate" action, false if WPMU is disabled or plugin is deactivated on an individual blog.
*/
public static function deactivate($network_wide)
{
if (get_role('editor')) {
$role = get_role('editor');
$role->remove_cap('add_mjm-clinic');
$role->remove_cap('publish_mjm-clinic');
$role->remove_cap('edit_mjm-clinic');
$role->remove_cap('edit_others_mjm-clinic');
$role->remove_cap('read_mjm-clinic');
$role->remove_cap('edit_published_mjm-clinic');
$role->remove_cap('delete_published_mjm-clinic');
$role->remove_cap('delete_mjm-clinic');
}
if (get_role('administrator')) {
$role = get_role('administrator');
$role->remove_cap('add_mjm-clinic');
$role->remove_cap('publish_mjm-clinic');
$role->remove_cap('edit_mjm-clinic');
$role->remove_cap('edit_others_mjm-clinic');
$role->remove_cap('read_mjm-clinic');
$role->remove_cap('edit_published_mjm-clinic');
$role->remove_cap('delete_published_mjm-clinic');
$role->remove_cap('delete_mjm-clinic');
$role->remove_cap('add_mjm_clinic_location');
$role->remove_cap('manage_clinic_service_options');
}
flush_rewrite_rules();
}
/**
* Register and enqueue admin-specific style sheets
*
* @since 1.0.0
*
* @return null
*/
public function enqueue_admin_styles()
{
wp_enqueue_style($this->plugin_slug . '-admin-styles', plugins_url('css/admin.css', __FILE__), array(), $this->version);
}
/**
* Register and enqueue admin-specific JavaScript.
*
* @since 1.0.0
*
* @return null Return early if no settings page is registered.
*/
public function enqueue_admin_scripts()
{
if (is_admin() && current_user_can('publish_mjm-clinic')) {
wp_enqueue_script($this->plugin_slug . '-admin-script', plugins_url('js/admin.js', __FILE__), array('jquery'), $this->version);
}
}
/**
* Register and enqueue fontend style sheet.
*
* @since 1.0.0
* @TODO allow for front end CSS overides!
*/
public function enqueue_scripts()
{
global $post;
if (!is_admin() && (in_array(get_post_type(), $this->available_post_types) || (is_page() && (has_shortcode($post->post_content, 'mjm-clinic-booking-form') || has_shortcode($post->post_content, 'mjm-clinic-service-box-links') || has_shortcode($post->post_content, 'mjm-clinic-condition-list') || has_shortcode($post->post_content, 'mjm-clinic-staff'))))) {
if (locate_template('/mjm-clinic/public.css') == '') {
wp_enqueue_style($this->plugin_slug . '-public', plugins_url('css/public.css', __FILE__), array(), $this->version);
wp_enqueue_style($this->plugin_slug . '-fontawesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css');
} else {
wp_enqueue_style($this->plugin_slug . '-public', get_stylesheet_directory_uri() . '/mjm-clinic/public.css', array(), $this->version);
}
}
//register scripts used in shortcodes
$booking_js = (locate_template('/mjm-clinic/booking_form.js') == '') ? plugins_url('js/booking_form.js', __FILE__) : get_stylesheet_directory_uri() . '/mjm-clinic/booking_form.js';
$datepicker_css = (locate_template('/mjm-clinic/jquery-ui.min.css') == '') ? plugins_url('css/jquery-ui.min.css', __FILE__) : get_stylesheet_directory_uri() . '/mjm-clinic/jquery-ui.min.css';
$map_js = (locate_template('/mjm-clinic/map.js') == '') ? plugins_url('js/map.js', __FILE__) : get_stylesheet_directory_uri() . '/mjm-clinic/map.js';
$options = get_mjm_clinic_options();
$safe_api_key = esc_attr($options['mjm_clinic_googleapi_key']);
$map_url = add_query_arg( array('key' => $safe_api_key), 'https://maps.googleapis.com/maps/api/js');
wp_register_script('mjm-clinic-map-script', $map_url, array(), $this->version, true);
wp_register_script('mjm-clinic-map-init-script', $map_js, array('mjm-clinic-map-script', 'jquery'), $this->version, true);
wp_register_script('mjm-clinic-script-validate_form', plugins_url('js/jquery.validate.min.js', __FILE__), array('jquery'), $this->version, true);
wp_register_script('mjm-clinic-script-booking_form', $booking_js, array('jquery'), $this->version, true);
wp_register_script('mjm-clinic-script-list', plugins_url('js/list.min.js', __FILE__), array('jquery'), $this->version, true);
wp_register_style('mjm-clinic-script-datepicker-css', $datepicker_css, array(), $this->version);
}
/**
* Register the administration menu for this plugin into the WordPress Dashboard menu.
*
* @since 1.0.0
*/
public function add_plugin_admin_menu()
{
$this->plugin_screen_hook_suffix = add_submenu_page(
'edit.php?post_type=mjm-clinic-service',
__('Clinic Settings', 'mjm-clinic'),
__('Settings', 'mjm-clinic'),
'manage_clinic_service_options',
$this->plugin_slug . '-options',
array($this, 'display_plugin_admin_page')
);
global $submenu;
unset($submenu['edit.php?post_type=mjm-clinic-service'][10]);
}
/**
* Render the settings page for this plugin.
*
* @since 1.0.0
*/
public function display_plugin_admin_page()
{
include_once('views/admin.php');
}
/**
* Register the service listing post type
*
* @since 1.0.0
*/
public function register_post_type_mjm_clinic_service()
{
include_once(CLINIC_SERVICES_FUNC);
$options = get_mjm_clinic_options();
if (isset($options['comments']) && $options['comments']) {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'comments','custom-fields');
} else {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions','custom-fields');
}
$capabilities = array(
'publish_posts' => 'publish_mjm-clinic',
'edit_posts' => 'edit_mjm-clinic',
'edit_others_posts' => 'edit_others_mjm-clinic',
'delete_posts' => 'delete_mjm-clinic',
'edit_post' => 'edit_mjm-clinic',
'delete_post' => 'delete_mjm-clinic',
'read_post' => 'read_mjm-clinic'
);
$labels = array(
'name' => __('Services', 'mjm-clinic'),
'all_items' => 'Services',
'singular_name' => __('Clinic Service', 'mjm-clinic'),
'add_new' => __('Add New Service', 'mjm-clinic'),
'add_new_item' => __('Add New Clinic Service', 'mjm-clinic'),
'edit_item' => __('Edit Listing', 'mjm-clinic'),
'new_item' => __('New Clinic Service', 'mjm-clinic'),
'view_item' => __('View Clinic Service', 'mjm-clinic'),
'search_items' => __('Search Clinic Services', 'mjm-clinic'),
'not_found' => __('No service listings found', 'mjm-clinic'),
'not_found_in_trash' => __('No service listings found in Trash', 'mjm-clinic'),
'menu_name' => __('Clinic', 'mjm-clinic'),);
$args = array('labels' => $labels,
'menu_icon' => 'dashicons-clipboard',
'hierarchical' => false,
'description' => 'Clinic Service',
'supports' => $supports,
'taxonomies' => array('mjm_clinic_service_category', 'mjm_clinic_related_product', 'mjm_clinic_indication', 'mjm_clinic_location'),
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'mjm-clinic',
'capabilities' => $capabilities,
'map_meta_cap' => false,
'rewrite' => array(
'slug' => 'therapy',
'with_front' => false
)
);
register_post_type('mjm-clinic-service', $args);
}
/**
* Register the conditions listing post type
*
* @since 1.0.0
*/
public function register_post_type_mjm_clinic_condition()
{
include_once(CLINIC_SERVICES_FUNC);
$options = get_mjm_clinic_options();
if (isset($options['comments']) && $options['comments']) {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'comments', 'custom-fields');
} else {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom-fields');
}
$capabilities = array(
'publish_posts' => 'publish_mjm-clinic',
'edit_posts' => 'edit_mjm-clinic',
'edit_others_posts' => 'edit_others_mjm-clinic',
'delete_posts' => 'delete_mjm-clinic',
'edit_post' => 'edit_mjm-clinic',
'delete_post' => 'delete_mjm-clinic',
'read_post' => 'read_mjm-clinic'
);
$labels = array(
'name' => __('Health Conditions', 'mjm-clinic'),
'singular_name' => __('Health Condition', 'mjm-clinic'),
'add_new' => __('Add New', 'mjm-clinic'),
'add_new_item' => __('Add New Health Condition', 'mjm-clinic'),
'edit_item' => __('Edit Listing', 'mjm-clinic'),
'new_item' => __('New Health Condition', 'mjm-clinic'),
'view_item' => __('View Health Condition', 'mjm-clinic'),
'search_items' => __('Search Health Conditions', 'mjm-clinic'),
'not_found' => __('No listings found', 'mjm-clinic'),
'not_found_in_trash' => __('No listings found in Trash', 'mjm-clinic'),
'menu_name' => __('Health Conditions', 'mjm-clinic'),);
$args = array('labels' => $labels,
'hierarchical' => false,
'description' => 'Health Condition',
'supports' => $supports,
'taxonomies' => array('mjm_clinic_indication', 'mjm_clinic_contraindication'),
'public' => true,
'show_ui' => true,
'show_in_menu' => 'edit.php?post_type=mjm-clinic-service',
'menu_position' => 1,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'mjm-clinic',
'capabilities' => $capabilities,
'map_meta_cap' => false,
'rewrite' => array(
'slug' => 'can-we-help/condition',
'with_front' => false
)
);
register_post_type('mjm-clinic-condition', $args);
}
/**
* Register the patient feedback listing post type
*
* @since 1.0.1
*/
public function register_post_type_mjm_clinic_patient_feedback()
{
include_once(CLINIC_SERVICES_FUNC);
$options = get_mjm_clinic_options();
if (isset($options['comments']) && $options['comments']) {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'comments', 'custom-fields');
} else {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom-fields');
}
$capabilities = array(
'publish_posts' => 'publish_mjm-clinic',
'edit_posts' => 'edit_mjm-clinic',
'edit_others_posts' => 'edit_others_mjm-clinic',
'delete_posts' => 'delete_mjm-clinic',
'edit_post' => 'edit_mjm-clinic',
'delete_post' => 'delete_mjm-clinic',
'read_post' => 'read_mjm-clinic'
);
$labels = array(
'name' => __('Patient Feedback', 'mjm-clinic'),
'singular_name' => __('Patient Feedback', 'mjm-clinic'),
'add_new' => __('Add New', 'mjm-clinic'),
'add_new_item' => __('Add New Patient Feedback', 'mjm-clinic'),
'edit_item' => __('Edit Listing', 'mjm-clinic'),
'new_item' => __('New Patient Feedback', 'mjm-clinic'),
'view_item' => __('View Patient Feedback', 'mjm-clinic'),
'search_items' => __('Search Patient Feedback', 'mjm-clinic'),
'not_found' => __('No listings found', 'mjm-clinic'),
'not_found_in_trash' => __('No listings found in Trash', 'mjm-clinic'),
'menu_name' => __('Patient Feedback', 'mjm-clinic'),);
$args = array('labels' => $labels,
'hierarchical' => false,
'description' => 'Patient Feedback',
'supports' => $supports,
'taxonomies' => array('mjm_clinic_indication'),
'public' => true,
'show_ui' => true,
'show_in_menu' => 'edit.php?post_type=mjm-clinic-service',
'menu_position' => 2,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'mjm-clinic',
'capabilities' => $capabilities,
'map_meta_cap' => false,
'rewrite' => array(
'slug' => 'patient-feedback',
'with_front' => false
)
);
register_post_type('mjm-clinic-feedback', $args);
}
/**
* Register the case study listing post type
*
* @since 1.0.1
*/
public function register_post_type_mjm_clinic_case_study()
{
include_once(CLINIC_SERVICES_FUNC);
$options = get_mjm_clinic_options();
if (isset($options['comments']) && $options['comments']) {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'comments', 'custom-fields');
} else {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom-fields');
}
$capabilities = array(
'publish_posts' => 'publish_mjm-clinic',
'edit_posts' => 'edit_mjm-clinic',
'edit_others_posts' => 'edit_others_mjm-clinic',
'delete_posts' => 'delete_mjm-clinic',
'edit_post' => 'edit_mjm-clinic',
'delete_post' => 'delete_mjm-clinic',
'read_post' => 'read_mjm-clinic'
);
$labels = array(
'name' => __('Case Studies', 'mjm-clinic'),
'singular_name' => __('Case Study', 'mjm-clinic'),
'add_new' => __('Add New', 'mjm-clinic'),
'add_new_item' => __('Add New Case Study', 'mjm-clinic'),
'edit_item' => __('Edit Listing', 'mjm-clinic'),
'new_item' => __('New Case Study', 'mjm-clinic'),
'view_item' => __('View Case Study', 'mjm-clinic'),
'search_items' => __('Search Case Studies', 'mjm-clinic'),
'not_found' => __('No listings found', 'mjm-clinic'),
'not_found_in_trash' => __('No listings found in Trash', 'mjm-clinic'),
'menu_name' => __('Case Studies', 'mjm-clinic'),);
$args = array('labels' => $labels,
'hierarchical' => false,
'description' => 'Case Study',
'supports' => $supports,
'taxonomies' => array('mjm_clinic_indication'),
'public' => true,
'show_ui' => true,
'show_in_menu' => 'edit.php?post_type=mjm-clinic-service',
'menu_position' => 3,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'mjm-clinic',
'capabilities' => $capabilities,
'map_meta_cap' => false,
'rewrite' => array(
'slug' => 'case-study',
'with_front' => false
)
);
register_post_type('mjm-clinic-casestudy', $args);
}
/**
* Register the case study listing post type
*
* @since 1.1
*/
public function register_post_type_mjm_clinic_staff()
{
include_once(CLINIC_SERVICES_FUNC);
$options = get_mjm_clinic_options();
if (isset($options['comments']) && $options['comments']) {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'comments', 'custom-fields');
} else {
$supports = array('title', 'editor', 'excerpt', 'thumbnail', 'revisions', 'custom-fields');
}
$capabilities = array(
'publish_posts' => 'publish_mjm-clinic',
'edit_posts' => 'edit_mjm-clinic',
'edit_others_posts' => 'edit_others_mjm-clinic',
'delete_posts' => 'delete_mjm-clinic',
'edit_post' => 'edit_mjm-clinic',
'delete_post' => 'delete_mjm-clinic',
'read_post' => 'read_mjm-clinic'
);
$labels = array(
'name' => __('Staff', 'mjm-clinic'),
'singular_name' => __('Staff Member', 'mjm-clinic'),
'add_new' => __('Add New', 'mjm-clinic'),
'add_new_item' => __('Add New Staff Member', 'mjm-clinic'),
'edit_item' => __('Edit Staff Member', 'mjm-clinic'),
'new_item' => __('New Staff Member', 'mjm-clinic'),
'view_item' => __('View Staff Member', 'mjm-clinic'),
'search_items' => __('Search Staff Members', 'mjm-clinic'),
'not_found' => __('No listings found', 'mjm-clinic'),
'not_found_in_trash' => __('No listings found in Trash', 'mjm-clinic'),
'menu_name' => __('Staff', 'mjm-clinic-staff'));
$args = array('labels' => $labels,
'hierarchical' => false,
'description' => 'Staff, doctors, therapists',
'supports' => $supports,
'taxonomies' => array('mjm_clinic_staff_type', 'mjm_clinic_location'),
'public' => true,
'show_ui' => true,
'show_in_menu' => 'edit.php?post_type=mjm-clinic-service',
//'menu_position' => 1,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => false,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'mjm-clinic',
'capabilities' => $capabilities,
'map_meta_cap' => false,
'rewrite' => array(
'slug' => 'staff',
'with_front' => false
)
);
register_post_type('mjm-clinic-staff', $args);
}
/**
* Register the mjm_clinic_service_category taxonomy
*
* @since 1.0.0
*/
public function register_taxonomy_mjm_clinic_service_category()
{
register_taxonomy('mjm_clinic_service_category', array('mjm-clinic-service'), array(
'label' => __('Service Categories', 'mjm-clinic'),
'labels' => array(
'name' => __('Service Categories', 'mjm-clinic'),
'singular_name' => __('Category', 'mjm-clinic'),
'search_items' => __('Search Categories', 'mjm-clinic'),
'popular_items' => __('Popular Categories', 'mjm-clinic'),
'all_items' => __('All Categories', 'mjm-clinic'),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __('Edit Category', 'mjm-clinic'),
'update_item' => __('Update Category', 'mjm-clinic'),
'add_new_item' => __('Add New Category', 'mjm-clinic'),
'new_item_name' => __('New Category Name', 'mjm-clinic'),
'separate_items_with_commas' => __('Separate categories with commas', 'mjm-clinic'),
'add_or_remove_items' => __('Add or remove categories', 'mjm-clinic'),
'choose_from_most_used' => __('Choose from the most used categories', 'mjm-clinic'),
'not_found' => __('No categories found', 'mjm-clinic'),
'menu_name' => __('Service Categories', 'mjm-clinic'),
),
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'hierarchical' => true,
'update_count_callback' => '',
'query_var' => 'mjm_clinic_service_category',
'rewrite' => array(
'slug' => 'our-services',
'with_front' => false,
'hierarchical' => false,
),
'capabilities' => array(
'manage_terms' => 'edit_mjm-clinic',
'edit_terms' => 'edit_mjm-clinic',
'delete_terms' => 'edit_others_mjm-clinic',
'manage_categories' => 'edit_mjm-clinic',
'assign_terms' => 'edit_mjm-clinic'
),
));
}
/**
* Add custom fields to the service category taxonomy
*
* @since 1.0.0
*/
public function add_taxonomy_form_fields_mjm_clinic_service_category()
{
//case name field
include(plugin_dir_path(__FILE__) . 'views/templates/admin/taxonomy-form-fields-service-category.php');
}
/**
* Add custom fields to the service category taxonomy edit view
*
* @since 1.0.0
*/
public function add_taxonomy_edit_form_fields_mjm_clinic_service_category($term)
{
// put the term ID into a variable
$t_id = $term->term_id;
// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_option("taxonomy_$t_id");
include(plugin_dir_path(__FILE__) . 'views/templates/admin/taxonomy-form-fields-edit-service-category.php');
}
public function edit_service_category_columns($columns)
{
unset($columns['description']);
return $columns;
}
/**
* Register the related product taxonomy
*
* @since 1.0.0
*/
public function register_taxonomy_mjm_clinic_related_product()
{
register_taxonomy('mjm_clinic_related_product', array('mjm-clinic-service', 'mjm-clinic-condition'), array(
'label' => __('Related Products', 'mjm-clinic'),
'labels' => array(
'name' => __('Related Products', 'mjm-clinic'),
'singular_name' => __('Related Product', 'mjm-clinic'),
'search_items' => __('Search Related Products', 'mjm-clinic'),
'popular_items' => __('Popular Related Products', 'mjm-clinic'),
'all_items' => __('All Related Products', 'mjm-clinic'),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __('Edit Related Product', 'mjm-clinic'),
'update_item' => __('Update Related Product', 'mjm-clinic'),
'add_new_item' => __('Add New Related Product', 'mjm-clinic'),
'new_item_name' => __('New Related Product Name', 'mjm-clinic'),
'separate_items_with_commas' => __('Separate Related Products with commas', 'mjm-clinic'),
'add_or_remove_items' => __('Add or remove Related Products', 'mjm-clinic'),
'choose_from_most_used' => __('Choose from the most used Related Products', 'mjm-clinic'),
'menu_name' => __('Related Products', 'mjm-clinic'),
),
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'hierarchical' => false,
'update_count_callback' => '',
'query_var' => 'mjm_clinic_related_product',
'rewrite' => array(
'slug' => 'mjm_clinic_related_product',
'with_front' => true,
'hierarchical' => false,
),
'capabilities' => array(
'manage_terms' => 'edit_mjm-clinic',
'edit_terms' => 'edit_mjm-clinic',
'delete_terms' => 'edit_others_mjm-clinic',
'manage_categories' => 'edit_mjm-clinic',
'assign_terms' => 'edit_mjm-clinic'
),
));
}
/**
* Add custom fields to the related product taxonomy
*
* @since 1.0.0
*/
public function add_taxonomy_form_fields_mjm_clinic_related_product() {}
/**
* Add custom fields to the related product taxonomy edit view
*
* @since 1.0.0
*/
public function add_taxonomy_edit_form_fields_mjm_clinic_related_product($term)
{
// put the term ID into a variable
$t_id = $term->term_id;
// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_option("taxonomy_$t_id");
}
/**
* Register the indication taxonomy
*
* @since 1.0.0
*/
public function register_taxonomy_mjm_clinic_indication()
{
register_taxonomy('mjm_clinic_indication', array('mjm-clinic-service', 'mjm-clinic-condition', 'mjm-clinic-casestudy', 'mjm-clinic-feedback'), array(
'label' => __('Indication Tags', 'mjm-clinic'),
'labels' => array(
'name' => __('Indication Tags', 'mjm-clinic'),
'singular_name' => __('Indication', 'mjm-clinic'),
'search_items' => __('Search Indications', 'mjm-clinic'),
'popular_items' => __('Popular Indications', 'mjm-clinic'),
'all_items' => __('All Indications', 'mjm-clinic'),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __('Edit Indication', 'mjm-clinic'),
'update_item' => __('Update Indication', 'mjm-clinic'),
'add_new_item' => __('Add New Indication', 'mjm-clinic'),
'new_item_name' => __('New Indication Name', 'mjm-clinic'),
'separate_items_with_commas' => __('Separate Indications with commas', 'mjm-clinic'),
'add_or_remove_items' => __('Add or remove Indications', 'mjm-clinic'),
'choose_from_most_used' => __('Choose from the most used Indications', 'mjm-clinic'),
'menu_name' => __('Indication Tags', 'mjm-clinic'),
),
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'hierarchical' => false,
'update_count_callback' => '',
'query_var' => 'mjm_clinic_indication',
'rewrite' => array(
'slug' => 'symptom-indication',
'with_front' => true,
'hierarchical' => false,
),
'capabilities' => array(
'manage_terms' => 'edit_mjm-clinic',
'edit_terms' => 'edit_mjm-clinic',
'delete_terms' => 'edit_others_mjm-clinic',
'manage_categories' => 'edit_mjm-clinic',
'assign_terms' => 'edit_mjm-clinic'
),
));
}
/**
* Register the clinic-location taxonomy
*
* @since 1.0.0
*/
public function register_taxonomy_mjm_clinic_location()
{
register_taxonomy('mjm_clinic_location', array('mjm-clinic-service','mjm-clinic-staff'), array(
'label' => __('Clinic Locations', 'mjm-clinic'),
'labels' => array(
'name' => __('Clinic Locations', 'mjm-clinic'),
'singular_name' => __('Location', 'mjm-clinic'),
'search_items' => __('Search Location', 'mjm-clinic'),
'popular_items' => __('Popular Location', 'mjm-clinic'),
'all_items' => __('All Location', 'mjm-clinic'),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __('Edit Location', 'mjm-clinic'),
'update_item' => __('Update Location', 'mjm-clinic'),
'add_new_item' => __('Add New Clinic Location', 'mjm-clinic'),
'new_item_name' => __('New Location Name', 'mjm-clinic'),
'separate_items_with_commas' => __('Separate Location with commas', 'mjm-clinic'),
'add_or_remove_items' => __('Add or remove Location', 'mjm-clinic'),
'choose_from_most_used' => __('Choose from the most used Location', 'mjm-clinic'),
'menu_name' => __('Locations', 'mjm-clinic'),
),
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'hierarchical' => false,
'update_count_callback' => '',
'query_var' => 'mjm_clinic_location',
'rewrite' => array(
'slug' => 'mjm_clinic_location',
'with_front' => false,
'hierarchical' => false,
),
'capabilities' => array(
'manage_terms' => 'edit_mjm-clinic',
'edit_terms' => 'edit_mjm-clinic',
'delete_terms' => 'edit_mjm-clinic',
'assign_terms' => 'edit_mjm-clinic'
)
));
}
/**
* Add custom fields to the clinic location taxonomy
*
* @since 1.0.0
*/
public function add_taxonomy_form_fields_mjm_clinic_location()
{
include(plugin_dir_path(__FILE__) . 'views/templates/admin/taxonomy-form-fields-location.php');
}
/**
* Add custom fields to the clinic_location taxonomy edit view
*
* @since 1.0.0
*/
public function add_taxonomy_edit_form_fields_mjm_clinic_location($term)
{
// put the term ID into a variable
$t_id = $term->term_id;
// retrieve the existing value(s) for this meta field. This returns an array
$term_meta = get_option("taxonomy_$t_id");
include(plugin_dir_path(__FILE__) . 'views/templates/admin/taxonomy-form-fields-edit-location.php');
}
/**
* Register the contraindications taxonomy
*
* @since 1.0.0
*/
public function register_taxonomy_mjm_clinic_contraindication()
{
register_taxonomy('mjm_clinic_contraindication', array('mjm-clinic-service', 'mjm-clinic-condition'), array(
'label' => __('Contraindication Tags', 'mjm-clinic'),
'labels' => array(
'name' => __('Contraindication Tags', 'mjm-clinic'),
'singular_name' => __('Contraindication', 'mjm-clinic'),
'search_items' => __('Search Contraindications', 'mjm-clinic'),
'popular_items' => __('Popular Contraindications', 'mjm-clinic'),
'all_items' => __('All Contraindications', 'mjm-clinic'),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __('Edit Contraindication', 'mjm-clinic'),
'update_item' => __('Update Contraindication', 'mjm-clinic'),
'add_new_item' => __('Add New Contraindication', 'mjm-clinic'),
'new_item_name' => __('New Contraindication Name', 'mjm-clinic'),
'separate_items_with_commas' => __('Separate Contraindications with commas', 'mjm-clinic'),
'add_or_remove_items' => __('Add or remove Contraindications', 'mjm-clinic'),
'choose_from_most_used' => __('Choose from the most used Contraindications', 'mjm-clinic'),
'menu_name' => __('Contraindication Tags', 'mjm-clinic'),
),
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'hierarchical' => false,
'update_count_callback' => '',
'query_var' => 'mjm_clinic_contraindication',
'rewrite' => array(
'slug' => 'mjm_clinic_contraindication',
'with_front' => true,
'hierarchical' => false,
),
'capabilities' => array(
'manage_terms' => 'edit_mjm-clinic',
'edit_terms' => 'edit_mjm-clinic',
'delete_terms' => 'edit_others_mjm-clinic',
'manage_categories' => 'edit_mjm-clinic',
'assign_terms' => 'edit_mjm-clinic'
),
));
}
/**
* Register the clinic-stafftype taxonomy
*
* @since 1.1
*/
public function register_taxonomy_mjm_clinic_staff_type()
{
register_taxonomy('mjm_clinic_staff_type', array('mjm-clinic-staff'), array(
'label' => __('Staff Type', 'mjm-clinic'),
'labels' => array(
'name' => __('Staff Role', 'mjm-clinic'),
'singular_name' => __('Staff Role', 'mjm-clinic'),
'search_items' => __('Search Staff Roles', 'mjm-clinic'),
'popular_items' => __('Popular Staff Roles', 'mjm-clinic'),
'all_items' => __('All Staff Roles', 'mjm-clinic'),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __('Edit Staff Role', 'mjm-clinic'),
'update_item' => __('Update Staff Role', 'mjm-clinic'),
'add_new_item' => __('Add New Staff Role', 'mjm-clinic'),
'new_item_name' => __('New Staff Role', 'mjm-clinic'),
'separate_items_with_commas' => __('Eg. Doctor, Therapist', 'mjm-clinic'),
'add_or_remove_items' => __('Add or remove Staff Roles', 'mjm-clinic'),
'choose_from_most_used' => __('Choose from the most used Staff Roles', 'mjm-clinic'),
'menu_name' => __('Staff Roles', 'mjm-clinic'),
),
'public' => true,
'show_in_nav_menus' => true,
'show_ui' => true,
'show_tagcloud' => true,
'hierarchical' => false,
'update_count_callback' => '',
'query_var' => 'mjm_clinic_staff_type',
'rewrite' => array(
'slug' => 'mjm_clinic_staff_type',
'with_front' => false,
'hierarchical' => false,
),
'capabilities' => array(
'manage_terms' => 'edit_mjm-clinic',
'edit_terms' => 'edit_mjm-clinic',
'delete_terms' => 'edit_mjm-clinic',
'assign_terms' => 'edit_mjm-clinic'
)
));
}
/**
* Save custom taxonomy fields