@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | */ |
146 | 146 | function can_use_espresso_conditionals($conditional_tag) |
147 | 147 | { |
148 | - if (! did_action('AHEE__EE_System__initialize')) { |
|
148 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
149 | 149 | EE_Error::doing_it_wrong( |
150 | 150 | __FUNCTION__, |
151 | 151 | sprintf( |
@@ -165,7 +165,7 @@ discard block |
||
165 | 165 | |
166 | 166 | /*************************** Event Queries ***************************/ |
167 | 167 | |
168 | -if (! function_exists('espresso_get_events')) { |
|
168 | +if ( ! function_exists('espresso_get_events')) { |
|
169 | 169 | /** |
170 | 170 | * espresso_get_events |
171 | 171 | * |
@@ -215,10 +215,10 @@ discard block |
||
215 | 215 | */ |
216 | 216 | function espresso_load_ticket_selector() |
217 | 217 | { |
218 | - EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
218 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
219 | 219 | } |
220 | 220 | |
221 | -if (! function_exists('espresso_ticket_selector')) { |
|
221 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
222 | 222 | /** |
223 | 223 | * espresso_ticket_selector |
224 | 224 | * |
@@ -228,7 +228,7 @@ discard block |
||
228 | 228 | */ |
229 | 229 | function espresso_ticket_selector($event = null) |
230 | 230 | { |
231 | - if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
231 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
232 | 232 | espresso_load_ticket_selector(); |
233 | 233 | EED_Ticket_Selector::set_definitions(); |
234 | 234 | echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
@@ -237,7 +237,7 @@ discard block |
||
237 | 237 | } |
238 | 238 | |
239 | 239 | |
240 | -if (! function_exists('espresso_view_details_btn')) { |
|
240 | +if ( ! function_exists('espresso_view_details_btn')) { |
|
241 | 241 | /** |
242 | 242 | * espresso_view_details_btn |
243 | 243 | * |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | function espresso_view_details_btn($event = null) |
249 | 249 | { |
250 | - if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
250 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
251 | 251 | espresso_load_ticket_selector(); |
252 | 252 | echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
253 | 253 | } |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | |
258 | 258 | /*************************** EEH_Event_View ***************************/ |
259 | 259 | |
260 | -if (! function_exists('espresso_load_event_list_assets')) { |
|
260 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
261 | 261 | /** |
262 | 262 | * espresso_load_event_list_assets |
263 | 263 | * ensures that event list styles and scripts are loaded |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | } |
274 | 274 | |
275 | 275 | |
276 | -if (! function_exists('espresso_event_reg_button')) { |
|
276 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
277 | 277 | /** |
278 | 278 | * espresso_event_reg_button |
279 | 279 | * returns the "Register Now" button if event is active, |
@@ -290,7 +290,7 @@ discard block |
||
290 | 290 | function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
291 | 291 | { |
292 | 292 | $event = EEH_Event_View::get_event($EVT_ID); |
293 | - if (! $event instanceof EE_Event) { |
|
293 | + if ( ! $event instanceof EE_Event) { |
|
294 | 294 | return; |
295 | 295 | } |
296 | 296 | $event_status = $event->get_active_status(); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | } |
337 | 337 | |
338 | 338 | |
339 | -if (! function_exists('espresso_display_ticket_selector')) { |
|
339 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
340 | 340 | /** |
341 | 341 | * espresso_display_ticket_selector |
342 | 342 | * whether or not to display the Ticket Selector for an event |
@@ -353,7 +353,7 @@ discard block |
||
353 | 353 | } |
354 | 354 | |
355 | 355 | |
356 | -if (! function_exists('espresso_event_status_banner')) { |
|
356 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
357 | 357 | /** |
358 | 358 | * espresso_event_status |
359 | 359 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | } |
371 | 371 | |
372 | 372 | |
373 | -if (! function_exists('espresso_event_status')) { |
|
373 | +if ( ! function_exists('espresso_event_status')) { |
|
374 | 374 | /** |
375 | 375 | * espresso_event_status |
376 | 376 | * returns the event status if it is sold out, expired, or inactive |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | } |
389 | 389 | |
390 | 390 | |
391 | -if (! function_exists('espresso_event_categories')) { |
|
391 | +if ( ! function_exists('espresso_event_categories')) { |
|
392 | 392 | /** |
393 | 393 | * espresso_event_categories |
394 | 394 | * returns the terms associated with an event |
@@ -411,7 +411,7 @@ discard block |
||
411 | 411 | } |
412 | 412 | |
413 | 413 | |
414 | -if (! function_exists('espresso_event_tickets_available')) { |
|
414 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
415 | 415 | /** |
416 | 416 | * espresso_event_tickets_available |
417 | 417 | * returns the ticket types available for purchase for an event |
@@ -429,14 +429,14 @@ discard block |
||
429 | 429 | if (is_array($tickets) && ! empty($tickets)) { |
430 | 430 | // if formatting then $html will be a string, else it will be an array of ticket objects |
431 | 431 | $html = |
432 | - $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
432 | + $format ? '<ul id="ee-event-tickets-ul-'.esc_attr($EVT_ID).'" class="ee-event-tickets-ul">' : []; |
|
433 | 433 | foreach ($tickets as $ticket) { |
434 | 434 | if ($ticket instanceof EE_Ticket) { |
435 | 435 | if ($format) { |
436 | 436 | $html .= '<li id="ee-event-tickets-li-' |
437 | 437 | . esc_attr($ticket->ID()) |
438 | 438 | . '" class="ee-event-tickets-li">'; |
439 | - $html .= esc_html($ticket->name()) . ' '; |
|
439 | + $html .= esc_html($ticket->name()).' '; |
|
440 | 440 | $html .= EEH_Template::format_currency( |
441 | 441 | $ticket->get_ticket_total_with_taxes() |
442 | 442 | ); // already escaped |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | } |
460 | 460 | } |
461 | 461 | |
462 | -if (! function_exists('espresso_event_date_obj')) { |
|
462 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
463 | 463 | /** |
464 | 464 | * espresso_event_date_obj |
465 | 465 | * returns the primary date object for an event |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | } |
477 | 477 | |
478 | 478 | |
479 | -if (! function_exists('espresso_event_date')) { |
|
479 | +if ( ! function_exists('espresso_event_date')) { |
|
480 | 480 | /** |
481 | 481 | * espresso_event_date |
482 | 482 | * returns the primary date for an event |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | } |
506 | 506 | |
507 | 507 | |
508 | -if (! function_exists('espresso_list_of_event_dates')) { |
|
508 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
509 | 509 | /** |
510 | 510 | * espresso_list_of_event_dates |
511 | 511 | * returns a unordered list of dates for an event |
@@ -538,14 +538,14 @@ discard block |
||
538 | 538 | $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
539 | 539 | $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
540 | 540 | $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, $limit); |
541 | - if (! $format) { |
|
541 | + if ( ! $format) { |
|
542 | 542 | return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
543 | 543 | } |
544 | 544 | $newline = $add_breaks ? '<br />' : ''; |
545 | 545 | if (is_array($datetimes) && ! empty($datetimes)) { |
546 | 546 | global $post; |
547 | 547 | $html = |
548 | - '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
548 | + '<ul id="ee-event-datetimes-ul-'.esc_attr($post->ID).'" class="ee-event-datetimes-ul ee-clearfix">'; |
|
549 | 549 | foreach ($datetimes as $datetime) { |
550 | 550 | if ($datetime instanceof EE_Datetime) { |
551 | 551 | |
@@ -553,7 +553,7 @@ discard block |
||
553 | 553 | $datetime_html = ! empty($datetime_name) |
554 | 554 | ? ' |
555 | 555 | <strong class="ee-event-datetimes-li-date-name"> |
556 | - ' . esc_html($datetime_name) . ' |
|
556 | + ' . esc_html($datetime_name).' |
|
557 | 557 | </strong>' . $newline |
558 | 558 | : ''; |
559 | 559 | |
@@ -561,16 +561,16 @@ discard block |
||
561 | 561 | $datetime_html .= ! empty($datetime_description) |
562 | 562 | ? ' |
563 | 563 | <span class="ee-event-datetimes-li-date-desc"> |
564 | - ' . wp_kses($datetime_description, $allowedtags) . ' |
|
564 | + ' . wp_kses($datetime_description, $allowedtags).' |
|
565 | 565 | </span>' . $newline |
566 | 566 | : ''; |
567 | 567 | |
568 | 568 | $datetime_html .= ' |
569 | 569 | <span class="dashicons dashicons-calendar"></span> |
570 | - <span class="ee-event-datetimes-li-daterange">' . $datetime->date_range($date_format) . '</span> |
|
570 | + <span class="ee-event-datetimes-li-daterange">' . $datetime->date_range($date_format).'</span> |
|
571 | 571 | <br/> |
572 | 572 | <span class="dashicons dashicons-clock"></span> |
573 | - <span class="ee-event-datetimes-li-timerange">' . $datetime->time_range($time_format) . '</span> |
|
573 | + <span class="ee-event-datetimes-li-timerange">' . $datetime->time_range($time_format).'</span> |
|
574 | 574 | '; |
575 | 575 | |
576 | 576 | $datetime_html = apply_filters( |
@@ -580,11 +580,11 @@ discard block |
||
580 | 580 | ); |
581 | 581 | |
582 | 582 | $DTD_ID = esc_attr($datetime->ID()); |
583 | - $active_status = esc_attr(' ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
583 | + $active_status = esc_attr(' ee-event-datetimes-li-'.$datetime->get_active_status()); |
|
584 | 584 | |
585 | 585 | $html .= ' |
586 | - <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li' . $active_status . '"> |
|
587 | - ' . $datetime_html . ' |
|
586 | + <li id="ee-event-datetimes-li-' . $DTD_ID.'" class="ee-event-datetimes-li'.$active_status.'"> |
|
587 | + ' . $datetime_html.' |
|
588 | 588 | </li>'; |
589 | 589 | } |
590 | 590 | } |
@@ -597,7 +597,7 @@ discard block |
||
597 | 597 | ' . esc_html__( |
598 | 598 | 'There are no upcoming dates for this event.', |
599 | 599 | 'event_espresso' |
600 | - ) . ' |
|
600 | + ).' |
|
601 | 601 | </p> |
602 | 602 | <br/>'; |
603 | 603 | } |
@@ -610,7 +610,7 @@ discard block |
||
610 | 610 | } |
611 | 611 | |
612 | 612 | |
613 | -if (! function_exists('espresso_event_end_date')) { |
|
613 | +if ( ! function_exists('espresso_event_end_date')) { |
|
614 | 614 | /** |
615 | 615 | * espresso_event_end_date |
616 | 616 | * returns the last date for an event |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | } |
638 | 638 | } |
639 | 639 | |
640 | -if (! function_exists('espresso_event_date_range')) { |
|
640 | +if ( ! function_exists('espresso_event_date_range')) { |
|
641 | 641 | /** |
642 | 642 | * espresso_event_date_range |
643 | 643 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | } |
696 | 696 | } |
697 | 697 | |
698 | -if (! function_exists('espresso_next_upcoming_datetime_obj')) { |
|
698 | +if ( ! function_exists('espresso_next_upcoming_datetime_obj')) { |
|
699 | 699 | /** |
700 | 700 | * espresso_next_upcoming_datetime_obj |
701 | 701 | * returns the next upcoming datetime object for an event |
@@ -710,7 +710,7 @@ discard block |
||
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
713 | -if (! function_exists('espresso_next_upcoming_datetime')) { |
|
713 | +if ( ! function_exists('espresso_next_upcoming_datetime')) { |
|
714 | 714 | /** |
715 | 715 | * espresso_next_upcoming_datetime |
716 | 716 | * returns the start date and time for the next upcoming event. |
@@ -732,11 +732,11 @@ discard block |
||
732 | 732 | $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
733 | 733 | $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
734 | 734 | |
735 | - $datetime_format = trim($date_format . ' ' . $time_format); |
|
735 | + $datetime_format = trim($date_format.' '.$time_format); |
|
736 | 736 | |
737 | 737 | $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
738 | 738 | |
739 | - if (! $datetime instanceof EE_Datetime) { |
|
739 | + if ( ! $datetime instanceof EE_Datetime) { |
|
740 | 740 | return ''; |
741 | 741 | } |
742 | 742 | if ($echo) { |
@@ -747,7 +747,7 @@ discard block |
||
747 | 747 | } |
748 | 748 | } |
749 | 749 | |
750 | -if (! function_exists('espresso_event_date_as_calendar_page')) { |
|
750 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
751 | 751 | /** |
752 | 752 | * espresso_event_date_as_calendar_page |
753 | 753 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -764,7 +764,7 @@ discard block |
||
764 | 764 | } |
765 | 765 | |
766 | 766 | |
767 | -if (! function_exists('espresso_event_link_url')) { |
|
767 | +if ( ! function_exists('espresso_event_link_url')) { |
|
768 | 768 | /** |
769 | 769 | * espresso_event_link_url |
770 | 770 | * |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | } |
786 | 786 | |
787 | 787 | |
788 | -if (! function_exists('espresso_event_has_content_or_excerpt')) { |
|
788 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
789 | 789 | /** |
790 | 790 | * espresso_event_has_content_or_excerpt |
791 | 791 | * |
@@ -802,7 +802,7 @@ discard block |
||
802 | 802 | } |
803 | 803 | |
804 | 804 | |
805 | -if (! function_exists('espresso_event_content_or_excerpt')) { |
|
805 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
806 | 806 | /** |
807 | 807 | * espresso_event_content_or_excerpt |
808 | 808 | * |
@@ -822,7 +822,7 @@ discard block |
||
822 | 822 | } |
823 | 823 | |
824 | 824 | |
825 | -if (! function_exists('espresso_event_phone')) { |
|
825 | +if ( ! function_exists('espresso_event_phone')) { |
|
826 | 826 | /** |
827 | 827 | * espresso_event_phone |
828 | 828 | * |
@@ -843,7 +843,7 @@ discard block |
||
843 | 843 | } |
844 | 844 | |
845 | 845 | |
846 | -if (! function_exists('espresso_edit_event_link')) { |
|
846 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
847 | 847 | /** |
848 | 848 | * espresso_edit_event_link |
849 | 849 | * returns a link to edit an event |
@@ -865,7 +865,7 @@ discard block |
||
865 | 865 | } |
866 | 866 | |
867 | 867 | |
868 | -if (! function_exists('espresso_organization_name')) { |
|
868 | +if ( ! function_exists('espresso_organization_name')) { |
|
869 | 869 | /** |
870 | 870 | * espresso_organization_name |
871 | 871 | * |
@@ -883,7 +883,7 @@ discard block |
||
883 | 883 | } |
884 | 884 | } |
885 | 885 | |
886 | -if (! function_exists('espresso_organization_address')) { |
|
886 | +if ( ! function_exists('espresso_organization_address')) { |
|
887 | 887 | /** |
888 | 888 | * espresso_organization_address |
889 | 889 | * |
@@ -907,7 +907,7 @@ discard block |
||
907 | 907 | } |
908 | 908 | } |
909 | 909 | |
910 | -if (! function_exists('espresso_organization_email')) { |
|
910 | +if ( ! function_exists('espresso_organization_email')) { |
|
911 | 911 | /** |
912 | 912 | * espresso_organization_email |
913 | 913 | * |
@@ -925,7 +925,7 @@ discard block |
||
925 | 925 | } |
926 | 926 | } |
927 | 927 | |
928 | -if (! function_exists('espresso_organization_logo_url')) { |
|
928 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
929 | 929 | /** |
930 | 930 | * espresso_organization_logo_url |
931 | 931 | * |
@@ -943,7 +943,7 @@ discard block |
||
943 | 943 | } |
944 | 944 | } |
945 | 945 | |
946 | -if (! function_exists('espresso_organization_facebook')) { |
|
946 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
947 | 947 | /** |
948 | 948 | * espresso_organization_facebook |
949 | 949 | * |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | } |
962 | 962 | } |
963 | 963 | |
964 | -if (! function_exists('espresso_organization_twitter')) { |
|
964 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
965 | 965 | /** |
966 | 966 | * espresso_organization_twitter |
967 | 967 | * |
@@ -979,7 +979,7 @@ discard block |
||
979 | 979 | } |
980 | 980 | } |
981 | 981 | |
982 | -if (! function_exists('espresso_organization_linkedin')) { |
|
982 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
983 | 983 | /** |
984 | 984 | * espresso_organization_linkedin |
985 | 985 | * |
@@ -997,7 +997,7 @@ discard block |
||
997 | 997 | } |
998 | 998 | } |
999 | 999 | |
1000 | -if (! function_exists('espresso_organization_pinterest')) { |
|
1000 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
1001 | 1001 | /** |
1002 | 1002 | * espresso_organization_pinterest |
1003 | 1003 | * |
@@ -1015,7 +1015,7 @@ discard block |
||
1015 | 1015 | } |
1016 | 1016 | } |
1017 | 1017 | |
1018 | -if (! function_exists('espresso_organization_google')) { |
|
1018 | +if ( ! function_exists('espresso_organization_google')) { |
|
1019 | 1019 | /** |
1020 | 1020 | * espresso_organization_google |
1021 | 1021 | * |
@@ -1033,7 +1033,7 @@ discard block |
||
1033 | 1033 | } |
1034 | 1034 | } |
1035 | 1035 | |
1036 | -if (! function_exists('espresso_organization_instagram')) { |
|
1036 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
1037 | 1037 | /** |
1038 | 1038 | * espresso_organization_instagram |
1039 | 1039 | * |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | /*************************** EEH_Venue_View ***************************/ |
1056 | 1056 | |
1057 | 1057 | |
1058 | -if (! function_exists('espresso_event_venues')) { |
|
1058 | +if ( ! function_exists('espresso_event_venues')) { |
|
1059 | 1059 | /** |
1060 | 1060 | * espresso_event_venues |
1061 | 1061 | * |
@@ -1070,7 +1070,7 @@ discard block |
||
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | |
1073 | -if (! function_exists('espresso_venue_id')) { |
|
1073 | +if ( ! function_exists('espresso_venue_id')) { |
|
1074 | 1074 | /** |
1075 | 1075 | * espresso_venue_name |
1076 | 1076 | * |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | } |
1089 | 1089 | |
1090 | 1090 | |
1091 | -if (! function_exists('espresso_is_venue_private')) { |
|
1091 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
1092 | 1092 | /** |
1093 | 1093 | * Return whether a venue is private or not. |
1094 | 1094 | * |
@@ -1106,7 +1106,7 @@ discard block |
||
1106 | 1106 | } |
1107 | 1107 | |
1108 | 1108 | |
1109 | -if (! function_exists('espresso_venue_is_password_protected')) { |
|
1109 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
1110 | 1110 | /** |
1111 | 1111 | * returns true or false if a venue is password protected or not |
1112 | 1112 | * |
@@ -1123,7 +1123,7 @@ discard block |
||
1123 | 1123 | } |
1124 | 1124 | |
1125 | 1125 | |
1126 | -if (! function_exists('espresso_password_protected_venue_form')) { |
|
1126 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
1127 | 1127 | /** |
1128 | 1128 | * Returns a password form if venue is password protected. |
1129 | 1129 | * |
@@ -1140,7 +1140,7 @@ discard block |
||
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | |
1143 | -if (! function_exists('espresso_venue_name')) { |
|
1143 | +if ( ! function_exists('espresso_venue_name')) { |
|
1144 | 1144 | /** |
1145 | 1145 | * espresso_venue_name |
1146 | 1146 | * |
@@ -1163,7 +1163,7 @@ discard block |
||
1163 | 1163 | } |
1164 | 1164 | |
1165 | 1165 | |
1166 | -if (! function_exists('espresso_venue_link')) { |
|
1166 | +if ( ! function_exists('espresso_venue_link')) { |
|
1167 | 1167 | /** |
1168 | 1168 | * espresso_venue_link |
1169 | 1169 | * |
@@ -1181,7 +1181,7 @@ discard block |
||
1181 | 1181 | } |
1182 | 1182 | |
1183 | 1183 | |
1184 | -if (! function_exists('espresso_venue_description')) { |
|
1184 | +if ( ! function_exists('espresso_venue_description')) { |
|
1185 | 1185 | /** |
1186 | 1186 | * espresso_venue_description |
1187 | 1187 | * |
@@ -1203,7 +1203,7 @@ discard block |
||
1203 | 1203 | } |
1204 | 1204 | |
1205 | 1205 | |
1206 | -if (! function_exists('espresso_venue_excerpt')) { |
|
1206 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
1207 | 1207 | /** |
1208 | 1208 | * espresso_venue_excerpt |
1209 | 1209 | * |
@@ -1225,7 +1225,7 @@ discard block |
||
1225 | 1225 | } |
1226 | 1226 | |
1227 | 1227 | |
1228 | -if (! function_exists('espresso_venue_categories')) { |
|
1228 | +if ( ! function_exists('espresso_venue_categories')) { |
|
1229 | 1229 | /** |
1230 | 1230 | * espresso_venue_categories |
1231 | 1231 | * returns the terms associated with a venue |
@@ -1248,7 +1248,7 @@ discard block |
||
1248 | 1248 | } |
1249 | 1249 | |
1250 | 1250 | |
1251 | -if (! function_exists('espresso_venue_address')) { |
|
1251 | +if ( ! function_exists('espresso_venue_address')) { |
|
1252 | 1252 | /** |
1253 | 1253 | * espresso_venue_address |
1254 | 1254 | * returns a formatted block of html for displaying a venue's address |
@@ -1271,7 +1271,7 @@ discard block |
||
1271 | 1271 | } |
1272 | 1272 | |
1273 | 1273 | |
1274 | -if (! function_exists('espresso_venue_raw_address')) { |
|
1274 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1275 | 1275 | /** |
1276 | 1276 | * espresso_venue_address |
1277 | 1277 | * returns an UN-formatted string containing a venue's address |
@@ -1294,7 +1294,7 @@ discard block |
||
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | |
1297 | -if (! function_exists('espresso_venue_has_address')) { |
|
1297 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1298 | 1298 | /** |
1299 | 1299 | * espresso_venue_has_address |
1300 | 1300 | * returns TRUE or FALSE if a Venue has address information |
@@ -1311,7 +1311,7 @@ discard block |
||
1311 | 1311 | } |
1312 | 1312 | |
1313 | 1313 | |
1314 | -if (! function_exists('espresso_venue_gmap')) { |
|
1314 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1315 | 1315 | /** |
1316 | 1316 | * espresso_venue_gmap |
1317 | 1317 | * returns a google map for the venue address |
@@ -1335,7 +1335,7 @@ discard block |
||
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | |
1338 | -if (! function_exists('espresso_venue_phone')) { |
|
1338 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1339 | 1339 | /** |
1340 | 1340 | * espresso_venue_phone |
1341 | 1341 | * |
@@ -1356,7 +1356,7 @@ discard block |
||
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | |
1359 | -if (! function_exists('espresso_venue_website')) { |
|
1359 | +if ( ! function_exists('espresso_venue_website')) { |
|
1360 | 1360 | /** |
1361 | 1361 | * espresso_venue_website |
1362 | 1362 | * |
@@ -1377,7 +1377,7 @@ discard block |
||
1377 | 1377 | } |
1378 | 1378 | |
1379 | 1379 | |
1380 | -if (! function_exists('espresso_edit_venue_link')) { |
|
1380 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1381 | 1381 | /** |
1382 | 1382 | * espresso_edit_venue_link |
1383 | 1383 | * |
@@ -19,13 +19,13 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function is_espresso_event($event = null) |
21 | 21 | { |
22 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
23 | - // extract EE_Event object from passed param regardless of what it is (within reason of course) |
|
24 | - $event = EEH_Event_View::get_event($event); |
|
25 | - // do we have a valid event ? |
|
26 | - return $event instanceof EE_Event; |
|
27 | - } |
|
28 | - return false; |
|
22 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
23 | + // extract EE_Event object from passed param regardless of what it is (within reason of course) |
|
24 | + $event = EEH_Event_View::get_event($event); |
|
25 | + // do we have a valid event ? |
|
26 | + return $event instanceof EE_Event; |
|
27 | + } |
|
28 | + return false; |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | /** |
@@ -36,12 +36,12 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function is_espresso_event_single() |
38 | 38 | { |
39 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
40 | - global $wp_query; |
|
41 | - // return conditionals set by CPTs |
|
42 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : false; |
|
43 | - } |
|
44 | - return false; |
|
39 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
40 | + global $wp_query; |
|
41 | + // return conditionals set by CPTs |
|
42 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : false; |
|
43 | + } |
|
44 | + return false; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
@@ -52,11 +52,11 @@ discard block |
||
52 | 52 | */ |
53 | 53 | function is_espresso_event_archive() |
54 | 54 | { |
55 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
56 | - global $wp_query; |
|
57 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : false; |
|
58 | - } |
|
59 | - return false; |
|
55 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
56 | + global $wp_query; |
|
57 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : false; |
|
58 | + } |
|
59 | + return false; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -67,11 +67,11 @@ discard block |
||
67 | 67 | */ |
68 | 68 | function is_espresso_event_taxonomy() |
69 | 69 | { |
70 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
71 | - global $wp_query; |
|
72 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : false; |
|
73 | - } |
|
74 | - return false; |
|
70 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
71 | + global $wp_query; |
|
72 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : false; |
|
73 | + } |
|
74 | + return false; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -85,13 +85,13 @@ discard block |
||
85 | 85 | */ |
86 | 86 | function is_espresso_venue($venue = null) |
87 | 87 | { |
88 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
89 | - // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
|
90 | - $venue = EEH_Venue_View::get_venue($venue, false); |
|
91 | - // do we have a valid event ? |
|
92 | - return $venue instanceof EE_Venue; |
|
93 | - } |
|
94 | - return false; |
|
88 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
89 | + // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
|
90 | + $venue = EEH_Venue_View::get_venue($venue, false); |
|
91 | + // do we have a valid event ? |
|
92 | + return $venue instanceof EE_Venue; |
|
93 | + } |
|
94 | + return false; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | */ |
103 | 103 | function is_espresso_venue_single() |
104 | 104 | { |
105 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
106 | - global $wp_query; |
|
107 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : false; |
|
108 | - } |
|
109 | - return false; |
|
105 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
106 | + global $wp_query; |
|
107 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : false; |
|
108 | + } |
|
109 | + return false; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | */ |
118 | 118 | function is_espresso_venue_archive() |
119 | 119 | { |
120 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
121 | - global $wp_query; |
|
122 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : false; |
|
123 | - } |
|
124 | - return false; |
|
120 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
121 | + global $wp_query; |
|
122 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : false; |
|
123 | + } |
|
124 | + return false; |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | */ |
133 | 133 | function is_espresso_venue_taxonomy() |
134 | 134 | { |
135 | - if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
136 | - global $wp_query; |
|
137 | - return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : false; |
|
138 | - } |
|
139 | - return false; |
|
135 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
136 | + global $wp_query; |
|
137 | + return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : false; |
|
138 | + } |
|
139 | + return false; |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | /** |
@@ -148,62 +148,62 @@ discard block |
||
148 | 148 | */ |
149 | 149 | function can_use_espresso_conditionals($conditional_tag) |
150 | 150 | { |
151 | - if (! did_action('AHEE__EE_System__initialize')) { |
|
152 | - EE_Error::doing_it_wrong( |
|
153 | - __FUNCTION__, |
|
154 | - sprintf( |
|
155 | - esc_html__( |
|
156 | - 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', |
|
157 | - 'event_espresso' |
|
158 | - ), |
|
159 | - $conditional_tag |
|
160 | - ), |
|
161 | - '4.4.0' |
|
162 | - ); |
|
163 | - return false; |
|
164 | - } |
|
165 | - return true; |
|
151 | + if (! did_action('AHEE__EE_System__initialize')) { |
|
152 | + EE_Error::doing_it_wrong( |
|
153 | + __FUNCTION__, |
|
154 | + sprintf( |
|
155 | + esc_html__( |
|
156 | + 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', |
|
157 | + 'event_espresso' |
|
158 | + ), |
|
159 | + $conditional_tag |
|
160 | + ), |
|
161 | + '4.4.0' |
|
162 | + ); |
|
163 | + return false; |
|
164 | + } |
|
165 | + return true; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | |
169 | 169 | /*************************** Event Queries ***************************/ |
170 | 170 | |
171 | 171 | if (! function_exists('espresso_get_events')) { |
172 | - /** |
|
173 | - * espresso_get_events |
|
174 | - * |
|
175 | - * @param array $params |
|
176 | - * @return array |
|
177 | - */ |
|
178 | - function espresso_get_events($params = []) |
|
179 | - { |
|
180 | - //set default params |
|
181 | - $default_espresso_events_params = [ |
|
182 | - 'limit' => 10, |
|
183 | - 'show_expired' => false, |
|
184 | - 'month' => null, |
|
185 | - 'category_slug' => null, |
|
186 | - 'order_by' => 'start_date', |
|
187 | - 'sort' => 'ASC', |
|
188 | - ]; |
|
189 | - // allow the defaults to be filtered |
|
190 | - $default_espresso_events_params = apply_filters( |
|
191 | - 'espresso_get_events__default_espresso_events_params', |
|
192 | - $default_espresso_events_params |
|
193 | - ); |
|
194 | - // grab params and merge with defaults, then extract |
|
195 | - $params = array_merge($default_espresso_events_params, $params); |
|
196 | - // run the query |
|
197 | - $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
198 | - // assign results to a variable so we can return it |
|
199 | - $events = $events_query->have_posts() ? $events_query->posts : []; |
|
200 | - // but first reset the query and postdata |
|
201 | - wp_reset_query(); |
|
202 | - wp_reset_postdata(); |
|
203 | - EED_Events_Archive::remove_all_events_archive_filters(); |
|
204 | - unset($events_query); |
|
205 | - return $events; |
|
206 | - } |
|
172 | + /** |
|
173 | + * espresso_get_events |
|
174 | + * |
|
175 | + * @param array $params |
|
176 | + * @return array |
|
177 | + */ |
|
178 | + function espresso_get_events($params = []) |
|
179 | + { |
|
180 | + //set default params |
|
181 | + $default_espresso_events_params = [ |
|
182 | + 'limit' => 10, |
|
183 | + 'show_expired' => false, |
|
184 | + 'month' => null, |
|
185 | + 'category_slug' => null, |
|
186 | + 'order_by' => 'start_date', |
|
187 | + 'sort' => 'ASC', |
|
188 | + ]; |
|
189 | + // allow the defaults to be filtered |
|
190 | + $default_espresso_events_params = apply_filters( |
|
191 | + 'espresso_get_events__default_espresso_events_params', |
|
192 | + $default_espresso_events_params |
|
193 | + ); |
|
194 | + // grab params and merge with defaults, then extract |
|
195 | + $params = array_merge($default_espresso_events_params, $params); |
|
196 | + // run the query |
|
197 | + $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
198 | + // assign results to a variable so we can return it |
|
199 | + $events = $events_query->have_posts() ? $events_query->posts : []; |
|
200 | + // but first reset the query and postdata |
|
201 | + wp_reset_query(); |
|
202 | + wp_reset_postdata(); |
|
203 | + EED_Events_Archive::remove_all_events_archive_filters(); |
|
204 | + unset($events_query); |
|
205 | + return $events; |
|
206 | + } |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | |
@@ -218,357 +218,357 @@ discard block |
||
218 | 218 | */ |
219 | 219 | function espresso_load_ticket_selector() |
220 | 220 | { |
221 | - EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
221 | + EE_Registry::instance()->load_file(EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if (! function_exists('espresso_ticket_selector')) { |
225 | - /** |
|
226 | - * espresso_ticket_selector |
|
227 | - * |
|
228 | - * @param null $event |
|
229 | - * @throws EE_Error |
|
230 | - * @throws ReflectionException |
|
231 | - */ |
|
232 | - function espresso_ticket_selector($event = null) |
|
233 | - { |
|
234 | - if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
235 | - espresso_load_ticket_selector(); |
|
236 | - EED_Ticket_Selector::set_definitions(); |
|
237 | - echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
|
238 | - } |
|
239 | - } |
|
225 | + /** |
|
226 | + * espresso_ticket_selector |
|
227 | + * |
|
228 | + * @param null $event |
|
229 | + * @throws EE_Error |
|
230 | + * @throws ReflectionException |
|
231 | + */ |
|
232 | + function espresso_ticket_selector($event = null) |
|
233 | + { |
|
234 | + if (! apply_filters('FHEE_disable_espresso_ticket_selector', false)) { |
|
235 | + espresso_load_ticket_selector(); |
|
236 | + EED_Ticket_Selector::set_definitions(); |
|
237 | + echo EED_Ticket_Selector::display_ticket_selector($event); // already escaped |
|
238 | + } |
|
239 | + } |
|
240 | 240 | } |
241 | 241 | |
242 | 242 | |
243 | 243 | if (! function_exists('espresso_view_details_btn')) { |
244 | - /** |
|
245 | - * espresso_view_details_btn |
|
246 | - * |
|
247 | - * @param null $event |
|
248 | - * @throws EE_Error |
|
249 | - * @throws ReflectionException |
|
250 | - */ |
|
251 | - function espresso_view_details_btn($event = null) |
|
252 | - { |
|
253 | - if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
254 | - espresso_load_ticket_selector(); |
|
255 | - echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
|
256 | - } |
|
257 | - } |
|
244 | + /** |
|
245 | + * espresso_view_details_btn |
|
246 | + * |
|
247 | + * @param null $event |
|
248 | + * @throws EE_Error |
|
249 | + * @throws ReflectionException |
|
250 | + */ |
|
251 | + function espresso_view_details_btn($event = null) |
|
252 | + { |
|
253 | + if (! apply_filters('FHEE_disable_espresso_view_details_btn', false)) { |
|
254 | + espresso_load_ticket_selector(); |
|
255 | + echo EED_Ticket_Selector::display_ticket_selector($event, true); // already escaped |
|
256 | + } |
|
257 | + } |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
261 | 261 | /*************************** EEH_Event_View ***************************/ |
262 | 262 | |
263 | 263 | if (! function_exists('espresso_load_event_list_assets')) { |
264 | - /** |
|
265 | - * espresso_load_event_list_assets |
|
266 | - * ensures that event list styles and scripts are loaded |
|
267 | - * |
|
268 | - * @return void |
|
269 | - */ |
|
270 | - function espresso_load_event_list_assets() |
|
271 | - { |
|
272 | - $event_list = EED_Events_Archive::instance(); |
|
273 | - add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10); |
|
274 | - add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
275 | - } |
|
264 | + /** |
|
265 | + * espresso_load_event_list_assets |
|
266 | + * ensures that event list styles and scripts are loaded |
|
267 | + * |
|
268 | + * @return void |
|
269 | + */ |
|
270 | + function espresso_load_event_list_assets() |
|
271 | + { |
|
272 | + $event_list = EED_Events_Archive::instance(); |
|
273 | + add_action('AHEE__EE_System__initialize_last', [$event_list, 'load_event_list_assets'], 10); |
|
274 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
275 | + } |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | |
279 | 279 | if (! function_exists('espresso_event_reg_button')) { |
280 | - /** |
|
281 | - * espresso_event_reg_button |
|
282 | - * returns the "Register Now" button if event is active, |
|
283 | - * an inactive button like status banner if the event is not active |
|
284 | - * or a "Read More" button if so desired |
|
285 | - * |
|
286 | - * @param null $btn_text_if_active |
|
287 | - * @param bool $btn_text_if_inactive |
|
288 | - * @param bool $EVT_ID |
|
289 | - * @return void |
|
290 | - * @throws EE_Error |
|
291 | - * @throws ReflectionException |
|
292 | - */ |
|
293 | - function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
|
294 | - { |
|
295 | - $event = EEH_Event_View::get_event($EVT_ID); |
|
296 | - if (! $event instanceof EE_Event) { |
|
297 | - return; |
|
298 | - } |
|
299 | - $event_status = $event->get_active_status(); |
|
300 | - switch ($event_status) { |
|
301 | - case EE_Datetime::sold_out : |
|
302 | - $btn_text = __('Sold Out', 'event_espresso'); |
|
303 | - $class = 'ee-pink'; |
|
304 | - break; |
|
305 | - case EE_Datetime::expired : |
|
306 | - $btn_text = __('Event is Over', 'event_espresso'); |
|
307 | - $class = 'ee-grey'; |
|
308 | - break; |
|
309 | - case EE_Datetime::inactive : |
|
310 | - $btn_text = __('Event Not Active', 'event_espresso'); |
|
311 | - $class = 'ee-grey'; |
|
312 | - break; |
|
313 | - case EE_Datetime::cancelled : |
|
314 | - $btn_text = __('Event was Cancelled', 'event_espresso'); |
|
315 | - $class = 'ee-red'; |
|
316 | - break; |
|
317 | - case EE_Datetime::upcoming : |
|
318 | - case EE_Datetime::active : |
|
319 | - default : |
|
320 | - $btn_text = ! empty($btn_text_if_active) |
|
321 | - ? $btn_text_if_active |
|
322 | - : __('Register Now', 'event_espresso'); |
|
323 | - $class = 'ee-green'; |
|
324 | - } |
|
325 | - if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
326 | - $btn_text = $btn_text_if_inactive; |
|
327 | - $class = 'ee-grey'; |
|
328 | - } |
|
329 | - ?> |
|
280 | + /** |
|
281 | + * espresso_event_reg_button |
|
282 | + * returns the "Register Now" button if event is active, |
|
283 | + * an inactive button like status banner if the event is not active |
|
284 | + * or a "Read More" button if so desired |
|
285 | + * |
|
286 | + * @param null $btn_text_if_active |
|
287 | + * @param bool $btn_text_if_inactive |
|
288 | + * @param bool $EVT_ID |
|
289 | + * @return void |
|
290 | + * @throws EE_Error |
|
291 | + * @throws ReflectionException |
|
292 | + */ |
|
293 | + function espresso_event_reg_button($btn_text_if_active = null, $btn_text_if_inactive = false, $EVT_ID = false) |
|
294 | + { |
|
295 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
296 | + if (! $event instanceof EE_Event) { |
|
297 | + return; |
|
298 | + } |
|
299 | + $event_status = $event->get_active_status(); |
|
300 | + switch ($event_status) { |
|
301 | + case EE_Datetime::sold_out : |
|
302 | + $btn_text = __('Sold Out', 'event_espresso'); |
|
303 | + $class = 'ee-pink'; |
|
304 | + break; |
|
305 | + case EE_Datetime::expired : |
|
306 | + $btn_text = __('Event is Over', 'event_espresso'); |
|
307 | + $class = 'ee-grey'; |
|
308 | + break; |
|
309 | + case EE_Datetime::inactive : |
|
310 | + $btn_text = __('Event Not Active', 'event_espresso'); |
|
311 | + $class = 'ee-grey'; |
|
312 | + break; |
|
313 | + case EE_Datetime::cancelled : |
|
314 | + $btn_text = __('Event was Cancelled', 'event_espresso'); |
|
315 | + $class = 'ee-red'; |
|
316 | + break; |
|
317 | + case EE_Datetime::upcoming : |
|
318 | + case EE_Datetime::active : |
|
319 | + default : |
|
320 | + $btn_text = ! empty($btn_text_if_active) |
|
321 | + ? $btn_text_if_active |
|
322 | + : __('Register Now', 'event_espresso'); |
|
323 | + $class = 'ee-green'; |
|
324 | + } |
|
325 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
326 | + $btn_text = $btn_text_if_inactive; |
|
327 | + $class = 'ee-grey'; |
|
328 | + } |
|
329 | + ?> |
|
330 | 330 | <a class="ee-button ee-register-button <?php echo esc_attr($class); ?>" |
331 | 331 | href="<?php espresso_event_link_url($EVT_ID); ?>" |
332 | 332 | <?php echo EED_Events_Archive::link_target(); // already escaped |
333 | - ?> |
|
333 | + ?> |
|
334 | 334 | > |
335 | 335 | <?php echo esc_html($btn_text); ?> |
336 | 336 | </a> |
337 | 337 | <?php |
338 | - } |
|
338 | + } |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | |
342 | 342 | if (! function_exists('espresso_display_ticket_selector')) { |
343 | - /** |
|
344 | - * espresso_display_ticket_selector |
|
345 | - * whether or not to display the Ticket Selector for an event |
|
346 | - * |
|
347 | - * @param bool $EVT_ID |
|
348 | - * @return boolean |
|
349 | - * @throws EE_Error |
|
350 | - * @throws ReflectionException |
|
351 | - */ |
|
352 | - function espresso_display_ticket_selector($EVT_ID = false) |
|
353 | - { |
|
354 | - return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
355 | - } |
|
343 | + /** |
|
344 | + * espresso_display_ticket_selector |
|
345 | + * whether or not to display the Ticket Selector for an event |
|
346 | + * |
|
347 | + * @param bool $EVT_ID |
|
348 | + * @return boolean |
|
349 | + * @throws EE_Error |
|
350 | + * @throws ReflectionException |
|
351 | + */ |
|
352 | + function espresso_display_ticket_selector($EVT_ID = false) |
|
353 | + { |
|
354 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
355 | + } |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
359 | 359 | if (! function_exists('espresso_event_status_banner')) { |
360 | - /** |
|
361 | - * espresso_event_status |
|
362 | - * returns a banner showing the event status if it is sold out, expired, or inactive |
|
363 | - * |
|
364 | - * @param bool $EVT_ID |
|
365 | - * @return string |
|
366 | - * @throws EE_Error |
|
367 | - * @throws ReflectionException |
|
368 | - */ |
|
369 | - function espresso_event_status_banner($EVT_ID = false) |
|
370 | - { |
|
371 | - return EEH_Event_View::event_status($EVT_ID); |
|
372 | - } |
|
360 | + /** |
|
361 | + * espresso_event_status |
|
362 | + * returns a banner showing the event status if it is sold out, expired, or inactive |
|
363 | + * |
|
364 | + * @param bool $EVT_ID |
|
365 | + * @return string |
|
366 | + * @throws EE_Error |
|
367 | + * @throws ReflectionException |
|
368 | + */ |
|
369 | + function espresso_event_status_banner($EVT_ID = false) |
|
370 | + { |
|
371 | + return EEH_Event_View::event_status($EVT_ID); |
|
372 | + } |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | |
376 | 376 | if (! function_exists('espresso_event_status')) { |
377 | - /** |
|
378 | - * espresso_event_status |
|
379 | - * returns the event status if it is sold out, expired, or inactive |
|
380 | - * |
|
381 | - * @param int $EVT_ID |
|
382 | - * @param bool $echo |
|
383 | - * @return string |
|
384 | - * @throws EE_Error |
|
385 | - * @throws ReflectionException |
|
386 | - */ |
|
387 | - function espresso_event_status($EVT_ID = 0, $echo = true) |
|
388 | - { |
|
389 | - return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
390 | - } |
|
377 | + /** |
|
378 | + * espresso_event_status |
|
379 | + * returns the event status if it is sold out, expired, or inactive |
|
380 | + * |
|
381 | + * @param int $EVT_ID |
|
382 | + * @param bool $echo |
|
383 | + * @return string |
|
384 | + * @throws EE_Error |
|
385 | + * @throws ReflectionException |
|
386 | + */ |
|
387 | + function espresso_event_status($EVT_ID = 0, $echo = true) |
|
388 | + { |
|
389 | + return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
390 | + } |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | |
394 | 394 | if (! function_exists('espresso_event_categories')) { |
395 | - /** |
|
396 | - * espresso_event_categories |
|
397 | - * returns the terms associated with an event |
|
398 | - * |
|
399 | - * @param int $EVT_ID |
|
400 | - * @param bool $hide_uncategorized |
|
401 | - * @param bool $echo |
|
402 | - * @return string |
|
403 | - * @throws EE_Error |
|
404 | - * @throws ReflectionException |
|
405 | - */ |
|
406 | - function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true) |
|
407 | - { |
|
408 | - if ($echo) { |
|
409 | - echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); // already escaped |
|
410 | - return ''; |
|
411 | - } |
|
412 | - return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
413 | - } |
|
395 | + /** |
|
396 | + * espresso_event_categories |
|
397 | + * returns the terms associated with an event |
|
398 | + * |
|
399 | + * @param int $EVT_ID |
|
400 | + * @param bool $hide_uncategorized |
|
401 | + * @param bool $echo |
|
402 | + * @return string |
|
403 | + * @throws EE_Error |
|
404 | + * @throws ReflectionException |
|
405 | + */ |
|
406 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = true, $echo = true) |
|
407 | + { |
|
408 | + if ($echo) { |
|
409 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); // already escaped |
|
410 | + return ''; |
|
411 | + } |
|
412 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
413 | + } |
|
414 | 414 | } |
415 | 415 | |
416 | 416 | |
417 | 417 | if (! function_exists('espresso_event_tickets_available')) { |
418 | - /** |
|
419 | - * espresso_event_tickets_available |
|
420 | - * returns the ticket types available for purchase for an event |
|
421 | - * |
|
422 | - * @param int $EVT_ID |
|
423 | - * @param bool $echo |
|
424 | - * @param bool $format |
|
425 | - * @return string |
|
426 | - * @throws EE_Error |
|
427 | - * @throws ReflectionException |
|
428 | - */ |
|
429 | - function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true) |
|
430 | - { |
|
431 | - $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
432 | - if (is_array($tickets) && ! empty($tickets)) { |
|
433 | - // if formatting then $html will be a string, else it will be an array of ticket objects |
|
434 | - $html = |
|
435 | - $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
436 | - foreach ($tickets as $ticket) { |
|
437 | - if ($ticket instanceof EE_Ticket) { |
|
438 | - if ($format) { |
|
439 | - $html .= '<li id="ee-event-tickets-li-' |
|
440 | - . esc_attr($ticket->ID()) |
|
441 | - . '" class="ee-event-tickets-li">'; |
|
442 | - $html .= esc_html($ticket->name()) . ' '; |
|
443 | - $html .= EEH_Template::format_currency( |
|
444 | - $ticket->get_ticket_total_with_taxes() |
|
445 | - ); // already escaped |
|
446 | - $html .= '</li>'; |
|
447 | - } else { |
|
448 | - $html[] = $ticket; |
|
449 | - } |
|
450 | - } |
|
451 | - } |
|
452 | - if ($format) { |
|
453 | - $html .= '</ul>'; |
|
454 | - } |
|
455 | - if ($echo && $format) { |
|
456 | - echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
457 | - return ''; |
|
458 | - } |
|
459 | - return $html; |
|
460 | - } |
|
461 | - return ''; |
|
462 | - } |
|
418 | + /** |
|
419 | + * espresso_event_tickets_available |
|
420 | + * returns the ticket types available for purchase for an event |
|
421 | + * |
|
422 | + * @param int $EVT_ID |
|
423 | + * @param bool $echo |
|
424 | + * @param bool $format |
|
425 | + * @return string |
|
426 | + * @throws EE_Error |
|
427 | + * @throws ReflectionException |
|
428 | + */ |
|
429 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = true, $format = true) |
|
430 | + { |
|
431 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
432 | + if (is_array($tickets) && ! empty($tickets)) { |
|
433 | + // if formatting then $html will be a string, else it will be an array of ticket objects |
|
434 | + $html = |
|
435 | + $format ? '<ul id="ee-event-tickets-ul-' . esc_attr($EVT_ID) . '" class="ee-event-tickets-ul">' : []; |
|
436 | + foreach ($tickets as $ticket) { |
|
437 | + if ($ticket instanceof EE_Ticket) { |
|
438 | + if ($format) { |
|
439 | + $html .= '<li id="ee-event-tickets-li-' |
|
440 | + . esc_attr($ticket->ID()) |
|
441 | + . '" class="ee-event-tickets-li">'; |
|
442 | + $html .= esc_html($ticket->name()) . ' '; |
|
443 | + $html .= EEH_Template::format_currency( |
|
444 | + $ticket->get_ticket_total_with_taxes() |
|
445 | + ); // already escaped |
|
446 | + $html .= '</li>'; |
|
447 | + } else { |
|
448 | + $html[] = $ticket; |
|
449 | + } |
|
450 | + } |
|
451 | + } |
|
452 | + if ($format) { |
|
453 | + $html .= '</ul>'; |
|
454 | + } |
|
455 | + if ($echo && $format) { |
|
456 | + echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
457 | + return ''; |
|
458 | + } |
|
459 | + return $html; |
|
460 | + } |
|
461 | + return ''; |
|
462 | + } |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | if (! function_exists('espresso_event_date_obj')) { |
466 | - /** |
|
467 | - * espresso_event_date_obj |
|
468 | - * returns the primary date object for an event |
|
469 | - * |
|
470 | - * @param bool $EVT_ID |
|
471 | - * @return EE_Datetime|null |
|
472 | - * @throws EE_Error |
|
473 | - * @throws ReflectionException |
|
474 | - */ |
|
475 | - function espresso_event_date_obj($EVT_ID = false) |
|
476 | - { |
|
477 | - return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
478 | - } |
|
466 | + /** |
|
467 | + * espresso_event_date_obj |
|
468 | + * returns the primary date object for an event |
|
469 | + * |
|
470 | + * @param bool $EVT_ID |
|
471 | + * @return EE_Datetime|null |
|
472 | + * @throws EE_Error |
|
473 | + * @throws ReflectionException |
|
474 | + */ |
|
475 | + function espresso_event_date_obj($EVT_ID = false) |
|
476 | + { |
|
477 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
478 | + } |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
482 | 482 | if (! function_exists('espresso_event_date')) { |
483 | - /** |
|
484 | - * espresso_event_date |
|
485 | - * returns the primary date for an event |
|
486 | - * |
|
487 | - * @param string $date_format |
|
488 | - * @param string $time_format |
|
489 | - * @param bool $EVT_ID |
|
490 | - * @param bool $echo |
|
491 | - * @return string |
|
492 | - * @throws EE_Error |
|
493 | - * @throws ReflectionException |
|
494 | - */ |
|
495 | - function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
496 | - { |
|
497 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
498 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
499 | - $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
500 | - $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
501 | - if ($echo) { |
|
502 | - echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); // already escaped |
|
503 | - return ''; |
|
504 | - } |
|
505 | - return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
506 | - |
|
507 | - } |
|
483 | + /** |
|
484 | + * espresso_event_date |
|
485 | + * returns the primary date for an event |
|
486 | + * |
|
487 | + * @param string $date_format |
|
488 | + * @param string $time_format |
|
489 | + * @param bool $EVT_ID |
|
490 | + * @param bool $echo |
|
491 | + * @return string |
|
492 | + * @throws EE_Error |
|
493 | + * @throws ReflectionException |
|
494 | + */ |
|
495 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
496 | + { |
|
497 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
498 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
499 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
500 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
501 | + if ($echo) { |
|
502 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); // already escaped |
|
503 | + return ''; |
|
504 | + } |
|
505 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
506 | + |
|
507 | + } |
|
508 | 508 | } |
509 | 509 | |
510 | 510 | |
511 | 511 | if (! function_exists('espresso_list_of_event_dates')) { |
512 | - /** |
|
513 | - * espresso_list_of_event_dates |
|
514 | - * returns a unordered list of dates for an event |
|
515 | - * |
|
516 | - * @param int $EVT_ID |
|
517 | - * @param string $date_format |
|
518 | - * @param string $time_format |
|
519 | - * @param bool $echo |
|
520 | - * @param null $show_expired |
|
521 | - * @param bool $format |
|
522 | - * @param bool $add_breaks |
|
523 | - * @param null $limit |
|
524 | - * @return string |
|
525 | - * @throws EE_Error |
|
526 | - * @throws ReflectionException |
|
527 | - */ |
|
528 | - function espresso_list_of_event_dates( |
|
529 | - $EVT_ID = 0, |
|
530 | - $date_format = '', |
|
531 | - $time_format = '', |
|
532 | - $echo = true, |
|
533 | - $show_expired = null, |
|
534 | - $format = true, |
|
535 | - $add_breaks = true, |
|
536 | - $limit = null |
|
537 | - ) { |
|
538 | - $allowedtags = AllowedTags::getAllowedTags(); |
|
539 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
540 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
541 | - $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
542 | - $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
543 | - $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, $limit); |
|
544 | - if (! $format) { |
|
545 | - return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
546 | - } |
|
547 | - $newline = $add_breaks ? '<br />' : ''; |
|
548 | - if (is_array($datetimes) && ! empty($datetimes)) { |
|
549 | - global $post; |
|
550 | - $html = |
|
551 | - '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
552 | - foreach ($datetimes as $datetime) { |
|
553 | - if ($datetime instanceof EE_Datetime) { |
|
554 | - |
|
555 | - $datetime_name = $datetime->name(); |
|
556 | - $datetime_html = ! empty($datetime_name) |
|
557 | - ? ' |
|
512 | + /** |
|
513 | + * espresso_list_of_event_dates |
|
514 | + * returns a unordered list of dates for an event |
|
515 | + * |
|
516 | + * @param int $EVT_ID |
|
517 | + * @param string $date_format |
|
518 | + * @param string $time_format |
|
519 | + * @param bool $echo |
|
520 | + * @param null $show_expired |
|
521 | + * @param bool $format |
|
522 | + * @param bool $add_breaks |
|
523 | + * @param null $limit |
|
524 | + * @return string |
|
525 | + * @throws EE_Error |
|
526 | + * @throws ReflectionException |
|
527 | + */ |
|
528 | + function espresso_list_of_event_dates( |
|
529 | + $EVT_ID = 0, |
|
530 | + $date_format = '', |
|
531 | + $time_format = '', |
|
532 | + $echo = true, |
|
533 | + $show_expired = null, |
|
534 | + $format = true, |
|
535 | + $add_breaks = true, |
|
536 | + $limit = null |
|
537 | + ) { |
|
538 | + $allowedtags = AllowedTags::getAllowedTags(); |
|
539 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
540 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
541 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
542 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
543 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, false, $limit); |
|
544 | + if (! $format) { |
|
545 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
546 | + } |
|
547 | + $newline = $add_breaks ? '<br />' : ''; |
|
548 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
549 | + global $post; |
|
550 | + $html = |
|
551 | + '<ul id="ee-event-datetimes-ul-' . esc_attr($post->ID) . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
552 | + foreach ($datetimes as $datetime) { |
|
553 | + if ($datetime instanceof EE_Datetime) { |
|
554 | + |
|
555 | + $datetime_name = $datetime->name(); |
|
556 | + $datetime_html = ! empty($datetime_name) |
|
557 | + ? ' |
|
558 | 558 | <strong class="ee-event-datetimes-li-date-name"> |
559 | 559 | ' . esc_html($datetime_name) . ' |
560 | 560 | </strong>' . $newline |
561 | - : ''; |
|
561 | + : ''; |
|
562 | 562 | |
563 | - $datetime_description = $datetime->description(); |
|
564 | - $datetime_html .= ! empty($datetime_description) |
|
565 | - ? ' |
|
563 | + $datetime_description = $datetime->description(); |
|
564 | + $datetime_html .= ! empty($datetime_description) |
|
565 | + ? ' |
|
566 | 566 | <span class="ee-event-datetimes-li-date-desc"> |
567 | 567 | ' . wp_kses($datetime_description, $allowedtags) . ' |
568 | 568 | </span>' . $newline |
569 | - : ''; |
|
569 | + : ''; |
|
570 | 570 | |
571 | - $datetime_html .= ' |
|
571 | + $datetime_html .= ' |
|
572 | 572 | <span class="dashicons dashicons-calendar"></span> |
573 | 573 | <span class="ee-event-datetimes-li-daterange">' . $datetime->date_range($date_format) . '</span> |
574 | 574 | <br/> |
@@ -576,482 +576,482 @@ discard block |
||
576 | 576 | <span class="ee-event-datetimes-li-timerange">' . $datetime->time_range($time_format) . '</span> |
577 | 577 | '; |
578 | 578 | |
579 | - $datetime_html = apply_filters( |
|
580 | - 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
581 | - $datetime_html, |
|
582 | - $datetime |
|
583 | - ); |
|
579 | + $datetime_html = apply_filters( |
|
580 | + 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
581 | + $datetime_html, |
|
582 | + $datetime |
|
583 | + ); |
|
584 | 584 | |
585 | - $DTD_ID = esc_attr($datetime->ID()); |
|
586 | - $active_status = esc_attr(' ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
585 | + $DTD_ID = esc_attr($datetime->ID()); |
|
586 | + $active_status = esc_attr(' ee-event-datetimes-li-' . $datetime->get_active_status()); |
|
587 | 587 | |
588 | - $html .= ' |
|
588 | + $html .= ' |
|
589 | 589 | <li id="ee-event-datetimes-li-' . $DTD_ID . '" class="ee-event-datetimes-li' . $active_status . '"> |
590 | 590 | ' . $datetime_html . ' |
591 | 591 | </li>'; |
592 | - } |
|
593 | - } |
|
594 | - $html .= '</ul>'; |
|
595 | - } else { |
|
596 | - $html = |
|
597 | - ' |
|
592 | + } |
|
593 | + } |
|
594 | + $html .= '</ul>'; |
|
595 | + } else { |
|
596 | + $html = |
|
597 | + ' |
|
598 | 598 | <p> |
599 | 599 | <span class="dashicons dashicons-marker pink-text"></span> |
600 | 600 | ' . esc_html__( |
601 | - 'There are no upcoming dates for this event.', |
|
602 | - 'event_espresso' |
|
603 | - ) . ' |
|
601 | + 'There are no upcoming dates for this event.', |
|
602 | + 'event_espresso' |
|
603 | + ) . ' |
|
604 | 604 | </p> |
605 | 605 | <br/>'; |
606 | - } |
|
607 | - if ($echo) { |
|
608 | - echo wp_kses($html, AllowedTags::getWithFormTags()); |
|
609 | - return ''; |
|
610 | - } |
|
611 | - return $html; |
|
612 | - } |
|
606 | + } |
|
607 | + if ($echo) { |
|
608 | + echo wp_kses($html, AllowedTags::getWithFormTags()); |
|
609 | + return ''; |
|
610 | + } |
|
611 | + return $html; |
|
612 | + } |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | |
616 | 616 | if (! function_exists('espresso_event_end_date')) { |
617 | - /** |
|
618 | - * espresso_event_end_date |
|
619 | - * returns the last date for an event |
|
620 | - * |
|
621 | - * @param string $date_format |
|
622 | - * @param string $time_format |
|
623 | - * @param bool $EVT_ID |
|
624 | - * @param bool $echo |
|
625 | - * @return string |
|
626 | - * @throws EE_Error |
|
627 | - * @throws ReflectionException |
|
628 | - */ |
|
629 | - function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
630 | - { |
|
631 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
632 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
633 | - $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
634 | - $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
635 | - if ($echo) { |
|
636 | - echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); // already escaped |
|
637 | - return ''; |
|
638 | - } |
|
639 | - return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
640 | - } |
|
617 | + /** |
|
618 | + * espresso_event_end_date |
|
619 | + * returns the last date for an event |
|
620 | + * |
|
621 | + * @param string $date_format |
|
622 | + * @param string $time_format |
|
623 | + * @param bool $EVT_ID |
|
624 | + * @param bool $echo |
|
625 | + * @return string |
|
626 | + * @throws EE_Error |
|
627 | + * @throws ReflectionException |
|
628 | + */ |
|
629 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = false, $echo = true) |
|
630 | + { |
|
631 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
632 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
633 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
634 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
635 | + if ($echo) { |
|
636 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); // already escaped |
|
637 | + return ''; |
|
638 | + } |
|
639 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
640 | + } |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | if (! function_exists('espresso_event_date_range')) { |
644 | - /** |
|
645 | - * espresso_event_date_range |
|
646 | - * returns the first and last chronologically ordered dates for an event (if different) |
|
647 | - * |
|
648 | - * @param string $date_format |
|
649 | - * @param string $time_format |
|
650 | - * @param string $single_date_format |
|
651 | - * @param string $single_time_format |
|
652 | - * @param bool $EVT_ID |
|
653 | - * @param bool $echo |
|
654 | - * @return string |
|
655 | - * @throws EE_Error |
|
656 | - * @throws ReflectionException |
|
657 | - */ |
|
658 | - function espresso_event_date_range( |
|
659 | - $date_format = '', |
|
660 | - $time_format = '', |
|
661 | - $single_date_format = '', |
|
662 | - $single_time_format = '', |
|
663 | - $EVT_ID = false, |
|
664 | - $echo = true |
|
665 | - ) { |
|
666 | - // set and filter date and time formats when a range is returned |
|
667 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
668 | - $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
669 | - // get the start and end date with NO time portion |
|
670 | - $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
671 | - $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
672 | - // now we can determine if date range spans more than one day |
|
673 | - if ($the_event_date != $the_event_end_date) { |
|
674 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
675 | - $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
676 | - $html = sprintf( |
|
677 | - /* translators: 1: first event date, 2: last event date */ |
|
678 | - esc_html__('%1$s - %2$s', 'event_espresso'), |
|
679 | - EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
680 | - EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
681 | - ); |
|
682 | - } else { |
|
683 | - // set and filter date and time formats when only a single datetime is returned |
|
684 | - $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
685 | - $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
686 | - $single_date_format = |
|
687 | - apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
688 | - $single_time_format = |
|
689 | - apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
690 | - $html = |
|
691 | - EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
692 | - } |
|
693 | - if ($echo) { |
|
694 | - echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
695 | - return ''; |
|
696 | - } |
|
697 | - return $html; |
|
698 | - } |
|
644 | + /** |
|
645 | + * espresso_event_date_range |
|
646 | + * returns the first and last chronologically ordered dates for an event (if different) |
|
647 | + * |
|
648 | + * @param string $date_format |
|
649 | + * @param string $time_format |
|
650 | + * @param string $single_date_format |
|
651 | + * @param string $single_time_format |
|
652 | + * @param bool $EVT_ID |
|
653 | + * @param bool $echo |
|
654 | + * @return string |
|
655 | + * @throws EE_Error |
|
656 | + * @throws ReflectionException |
|
657 | + */ |
|
658 | + function espresso_event_date_range( |
|
659 | + $date_format = '', |
|
660 | + $time_format = '', |
|
661 | + $single_date_format = '', |
|
662 | + $single_time_format = '', |
|
663 | + $EVT_ID = false, |
|
664 | + $echo = true |
|
665 | + ) { |
|
666 | + // set and filter date and time formats when a range is returned |
|
667 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
668 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
669 | + // get the start and end date with NO time portion |
|
670 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
671 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
672 | + // now we can determine if date range spans more than one day |
|
673 | + if ($the_event_date != $the_event_end_date) { |
|
674 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
675 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
676 | + $html = sprintf( |
|
677 | + /* translators: 1: first event date, 2: last event date */ |
|
678 | + esc_html__('%1$s - %2$s', 'event_espresso'), |
|
679 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
680 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
681 | + ); |
|
682 | + } else { |
|
683 | + // set and filter date and time formats when only a single datetime is returned |
|
684 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
685 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
686 | + $single_date_format = |
|
687 | + apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
688 | + $single_time_format = |
|
689 | + apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
690 | + $html = |
|
691 | + EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
692 | + } |
|
693 | + if ($echo) { |
|
694 | + echo wp_kses($html, AllowedTags::getAllowedTags()); |
|
695 | + return ''; |
|
696 | + } |
|
697 | + return $html; |
|
698 | + } |
|
699 | 699 | } |
700 | 700 | |
701 | 701 | if (! function_exists('espresso_next_upcoming_datetime_obj')) { |
702 | - /** |
|
703 | - * espresso_next_upcoming_datetime_obj |
|
704 | - * returns the next upcoming datetime object for an event |
|
705 | - * |
|
706 | - * @param int $EVT_ID |
|
707 | - * @return EE_Datetime|null |
|
708 | - * @throws EE_Error |
|
709 | - */ |
|
710 | - function espresso_next_upcoming_datetime_obj($EVT_ID = 0) |
|
711 | - { |
|
712 | - return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
713 | - } |
|
702 | + /** |
|
703 | + * espresso_next_upcoming_datetime_obj |
|
704 | + * returns the next upcoming datetime object for an event |
|
705 | + * |
|
706 | + * @param int $EVT_ID |
|
707 | + * @return EE_Datetime|null |
|
708 | + * @throws EE_Error |
|
709 | + */ |
|
710 | + function espresso_next_upcoming_datetime_obj($EVT_ID = 0) |
|
711 | + { |
|
712 | + return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
713 | + } |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | if (! function_exists('espresso_next_upcoming_datetime')) { |
717 | - /** |
|
718 | - * espresso_next_upcoming_datetime |
|
719 | - * returns the start date and time for the next upcoming event. |
|
720 | - * |
|
721 | - * @param string $date_format |
|
722 | - * @param string $time_format |
|
723 | - * @param int $EVT_ID |
|
724 | - * @param bool $echo |
|
725 | - * @return string |
|
726 | - * @throws EE_Error |
|
727 | - * @throws ReflectionException |
|
728 | - */ |
|
729 | - function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) |
|
730 | - { |
|
731 | - |
|
732 | - $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
733 | - $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
734 | - |
|
735 | - $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
736 | - $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
737 | - |
|
738 | - $datetime_format = trim($date_format . ' ' . $time_format); |
|
739 | - |
|
740 | - $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
741 | - |
|
742 | - if (! $datetime instanceof EE_Datetime) { |
|
743 | - return ''; |
|
744 | - } |
|
745 | - if ($echo) { |
|
746 | - echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format)); |
|
747 | - return ''; |
|
748 | - } |
|
749 | - return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
750 | - } |
|
717 | + /** |
|
718 | + * espresso_next_upcoming_datetime |
|
719 | + * returns the start date and time for the next upcoming event. |
|
720 | + * |
|
721 | + * @param string $date_format |
|
722 | + * @param string $time_format |
|
723 | + * @param int $EVT_ID |
|
724 | + * @param bool $echo |
|
725 | + * @return string |
|
726 | + * @throws EE_Error |
|
727 | + * @throws ReflectionException |
|
728 | + */ |
|
729 | + function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) |
|
730 | + { |
|
731 | + |
|
732 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
733 | + $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
734 | + |
|
735 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
736 | + $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
737 | + |
|
738 | + $datetime_format = trim($date_format . ' ' . $time_format); |
|
739 | + |
|
740 | + $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
741 | + |
|
742 | + if (! $datetime instanceof EE_Datetime) { |
|
743 | + return ''; |
|
744 | + } |
|
745 | + if ($echo) { |
|
746 | + echo esc_html($datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format)); |
|
747 | + return ''; |
|
748 | + } |
|
749 | + return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
750 | + } |
|
751 | 751 | } |
752 | 752 | |
753 | 753 | if (! function_exists('espresso_event_date_as_calendar_page')) { |
754 | - /** |
|
755 | - * espresso_event_date_as_calendar_page |
|
756 | - * returns the primary date for an event, stylized to appear as the page of a calendar |
|
757 | - * |
|
758 | - * @param bool $EVT_ID |
|
759 | - * @return void |
|
760 | - * @throws EE_Error |
|
761 | - * @throws ReflectionException |
|
762 | - */ |
|
763 | - function espresso_event_date_as_calendar_page($EVT_ID = false) |
|
764 | - { |
|
765 | - EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
766 | - } |
|
754 | + /** |
|
755 | + * espresso_event_date_as_calendar_page |
|
756 | + * returns the primary date for an event, stylized to appear as the page of a calendar |
|
757 | + * |
|
758 | + * @param bool $EVT_ID |
|
759 | + * @return void |
|
760 | + * @throws EE_Error |
|
761 | + * @throws ReflectionException |
|
762 | + */ |
|
763 | + function espresso_event_date_as_calendar_page($EVT_ID = false) |
|
764 | + { |
|
765 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
766 | + } |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | |
770 | 770 | if (! function_exists('espresso_event_link_url')) { |
771 | - /** |
|
772 | - * espresso_event_link_url |
|
773 | - * |
|
774 | - * @param int $EVT_ID |
|
775 | - * @param bool $echo |
|
776 | - * @return string |
|
777 | - * @throws EE_Error |
|
778 | - * @throws ReflectionException |
|
779 | - */ |
|
780 | - function espresso_event_link_url($EVT_ID = 0, $echo = true) |
|
781 | - { |
|
782 | - if ($echo) { |
|
783 | - echo EEH_Event_View::event_link_url($EVT_ID); // already escaped |
|
784 | - return ''; |
|
785 | - } |
|
786 | - return EEH_Event_View::event_link_url($EVT_ID); |
|
787 | - } |
|
771 | + /** |
|
772 | + * espresso_event_link_url |
|
773 | + * |
|
774 | + * @param int $EVT_ID |
|
775 | + * @param bool $echo |
|
776 | + * @return string |
|
777 | + * @throws EE_Error |
|
778 | + * @throws ReflectionException |
|
779 | + */ |
|
780 | + function espresso_event_link_url($EVT_ID = 0, $echo = true) |
|
781 | + { |
|
782 | + if ($echo) { |
|
783 | + echo EEH_Event_View::event_link_url($EVT_ID); // already escaped |
|
784 | + return ''; |
|
785 | + } |
|
786 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
787 | + } |
|
788 | 788 | } |
789 | 789 | |
790 | 790 | |
791 | 791 | if (! function_exists('espresso_event_has_content_or_excerpt')) { |
792 | - /** |
|
793 | - * espresso_event_has_content_or_excerpt |
|
794 | - * |
|
795 | - * @access public |
|
796 | - * @param bool $EVT_ID |
|
797 | - * @return boolean |
|
798 | - * @throws EE_Error |
|
799 | - * @throws ReflectionException |
|
800 | - */ |
|
801 | - function espresso_event_has_content_or_excerpt($EVT_ID = false) |
|
802 | - { |
|
803 | - return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
804 | - } |
|
792 | + /** |
|
793 | + * espresso_event_has_content_or_excerpt |
|
794 | + * |
|
795 | + * @access public |
|
796 | + * @param bool $EVT_ID |
|
797 | + * @return boolean |
|
798 | + * @throws EE_Error |
|
799 | + * @throws ReflectionException |
|
800 | + */ |
|
801 | + function espresso_event_has_content_or_excerpt($EVT_ID = false) |
|
802 | + { |
|
803 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
804 | + } |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | |
808 | 808 | if (! function_exists('espresso_event_content_or_excerpt')) { |
809 | - /** |
|
810 | - * espresso_event_content_or_excerpt |
|
811 | - * |
|
812 | - * @param int $num_words |
|
813 | - * @param null $more |
|
814 | - * @param bool $echo |
|
815 | - * @return string |
|
816 | - */ |
|
817 | - function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true) |
|
818 | - { |
|
819 | - if ($echo) { |
|
820 | - echo EEH_Event_View::event_content_or_excerpt($num_words, $more); // already escaped |
|
821 | - return ''; |
|
822 | - } |
|
823 | - return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
824 | - } |
|
809 | + /** |
|
810 | + * espresso_event_content_or_excerpt |
|
811 | + * |
|
812 | + * @param int $num_words |
|
813 | + * @param null $more |
|
814 | + * @param bool $echo |
|
815 | + * @return string |
|
816 | + */ |
|
817 | + function espresso_event_content_or_excerpt($num_words = 55, $more = null, $echo = true) |
|
818 | + { |
|
819 | + if ($echo) { |
|
820 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); // already escaped |
|
821 | + return ''; |
|
822 | + } |
|
823 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
824 | + } |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
828 | 828 | if (! function_exists('espresso_event_phone')) { |
829 | - /** |
|
830 | - * espresso_event_phone |
|
831 | - * |
|
832 | - * @param int $EVT_ID |
|
833 | - * @param bool $echo |
|
834 | - * @return string |
|
835 | - * @throws EE_Error |
|
836 | - * @throws ReflectionException |
|
837 | - */ |
|
838 | - function espresso_event_phone($EVT_ID = 0, $echo = true) |
|
839 | - { |
|
840 | - if ($echo) { |
|
841 | - echo EEH_Event_View::event_phone($EVT_ID); // already escaped |
|
842 | - return ''; |
|
843 | - } |
|
844 | - return EEH_Event_View::event_phone($EVT_ID); |
|
845 | - } |
|
829 | + /** |
|
830 | + * espresso_event_phone |
|
831 | + * |
|
832 | + * @param int $EVT_ID |
|
833 | + * @param bool $echo |
|
834 | + * @return string |
|
835 | + * @throws EE_Error |
|
836 | + * @throws ReflectionException |
|
837 | + */ |
|
838 | + function espresso_event_phone($EVT_ID = 0, $echo = true) |
|
839 | + { |
|
840 | + if ($echo) { |
|
841 | + echo EEH_Event_View::event_phone($EVT_ID); // already escaped |
|
842 | + return ''; |
|
843 | + } |
|
844 | + return EEH_Event_View::event_phone($EVT_ID); |
|
845 | + } |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | |
849 | 849 | if (! function_exists('espresso_edit_event_link')) { |
850 | - /** |
|
851 | - * espresso_edit_event_link |
|
852 | - * returns a link to edit an event |
|
853 | - * |
|
854 | - * @param int $EVT_ID |
|
855 | - * @param bool $echo |
|
856 | - * @return string |
|
857 | - * @throws EE_Error |
|
858 | - * @throws ReflectionException |
|
859 | - */ |
|
860 | - function espresso_edit_event_link($EVT_ID = 0, $echo = true) |
|
861 | - { |
|
862 | - if ($echo) { |
|
863 | - echo EEH_Event_View::edit_event_link($EVT_ID); // already escaped |
|
864 | - return ''; |
|
865 | - } |
|
866 | - return EEH_Event_View::edit_event_link($EVT_ID); |
|
867 | - } |
|
850 | + /** |
|
851 | + * espresso_edit_event_link |
|
852 | + * returns a link to edit an event |
|
853 | + * |
|
854 | + * @param int $EVT_ID |
|
855 | + * @param bool $echo |
|
856 | + * @return string |
|
857 | + * @throws EE_Error |
|
858 | + * @throws ReflectionException |
|
859 | + */ |
|
860 | + function espresso_edit_event_link($EVT_ID = 0, $echo = true) |
|
861 | + { |
|
862 | + if ($echo) { |
|
863 | + echo EEH_Event_View::edit_event_link($EVT_ID); // already escaped |
|
864 | + return ''; |
|
865 | + } |
|
866 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
867 | + } |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | |
871 | 871 | if (! function_exists('espresso_organization_name')) { |
872 | - /** |
|
873 | - * espresso_organization_name |
|
874 | - * |
|
875 | - * @param bool $echo |
|
876 | - * @return string |
|
877 | - * @throws EE_Error |
|
878 | - */ |
|
879 | - function espresso_organization_name($echo = true) |
|
880 | - { |
|
881 | - if ($echo) { |
|
882 | - echo EE_Registry::instance()->CFG->organization->get_pretty('name'); // already escaped |
|
883 | - return ''; |
|
884 | - } |
|
885 | - return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
886 | - } |
|
872 | + /** |
|
873 | + * espresso_organization_name |
|
874 | + * |
|
875 | + * @param bool $echo |
|
876 | + * @return string |
|
877 | + * @throws EE_Error |
|
878 | + */ |
|
879 | + function espresso_organization_name($echo = true) |
|
880 | + { |
|
881 | + if ($echo) { |
|
882 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); // already escaped |
|
883 | + return ''; |
|
884 | + } |
|
885 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
886 | + } |
|
887 | 887 | } |
888 | 888 | |
889 | 889 | if (! function_exists('espresso_organization_address')) { |
890 | - /** |
|
891 | - * espresso_organization_address |
|
892 | - * |
|
893 | - * @param string $type |
|
894 | - * @return string |
|
895 | - */ |
|
896 | - function espresso_organization_address($type = 'inline') |
|
897 | - { |
|
898 | - if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
899 | - $address = new EventEspresso\core\domain\entities\GenericAddress( |
|
900 | - EE_Registry::instance()->CFG->organization->address_1, |
|
901 | - EE_Registry::instance()->CFG->organization->address_2, |
|
902 | - EE_Registry::instance()->CFG->organization->city, |
|
903 | - EE_Registry::instance()->CFG->organization->STA_ID, |
|
904 | - EE_Registry::instance()->CFG->organization->zip, |
|
905 | - EE_Registry::instance()->CFG->organization->CNT_ISO |
|
906 | - ); |
|
907 | - return EEH_Address::format($address, $type); |
|
908 | - } |
|
909 | - return ''; |
|
910 | - } |
|
890 | + /** |
|
891 | + * espresso_organization_address |
|
892 | + * |
|
893 | + * @param string $type |
|
894 | + * @return string |
|
895 | + */ |
|
896 | + function espresso_organization_address($type = 'inline') |
|
897 | + { |
|
898 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
899 | + $address = new EventEspresso\core\domain\entities\GenericAddress( |
|
900 | + EE_Registry::instance()->CFG->organization->address_1, |
|
901 | + EE_Registry::instance()->CFG->organization->address_2, |
|
902 | + EE_Registry::instance()->CFG->organization->city, |
|
903 | + EE_Registry::instance()->CFG->organization->STA_ID, |
|
904 | + EE_Registry::instance()->CFG->organization->zip, |
|
905 | + EE_Registry::instance()->CFG->organization->CNT_ISO |
|
906 | + ); |
|
907 | + return EEH_Address::format($address, $type); |
|
908 | + } |
|
909 | + return ''; |
|
910 | + } |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | if (! function_exists('espresso_organization_email')) { |
914 | - /** |
|
915 | - * espresso_organization_email |
|
916 | - * |
|
917 | - * @param bool $echo |
|
918 | - * @return string |
|
919 | - * @throws EE_Error |
|
920 | - */ |
|
921 | - function espresso_organization_email($echo = true) |
|
922 | - { |
|
923 | - if ($echo) { |
|
924 | - echo EE_Registry::instance()->CFG->organization->get_pretty('email'); // already escaped |
|
925 | - return ''; |
|
926 | - } |
|
927 | - return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
928 | - } |
|
914 | + /** |
|
915 | + * espresso_organization_email |
|
916 | + * |
|
917 | + * @param bool $echo |
|
918 | + * @return string |
|
919 | + * @throws EE_Error |
|
920 | + */ |
|
921 | + function espresso_organization_email($echo = true) |
|
922 | + { |
|
923 | + if ($echo) { |
|
924 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); // already escaped |
|
925 | + return ''; |
|
926 | + } |
|
927 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
928 | + } |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | if (! function_exists('espresso_organization_logo_url')) { |
932 | - /** |
|
933 | - * espresso_organization_logo_url |
|
934 | - * |
|
935 | - * @param bool $echo |
|
936 | - * @return string |
|
937 | - * @throws EE_Error |
|
938 | - */ |
|
939 | - function espresso_organization_logo_url($echo = true) |
|
940 | - { |
|
941 | - if ($echo) { |
|
942 | - echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); // already escaped |
|
943 | - return ''; |
|
944 | - } |
|
945 | - return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
946 | - } |
|
932 | + /** |
|
933 | + * espresso_organization_logo_url |
|
934 | + * |
|
935 | + * @param bool $echo |
|
936 | + * @return string |
|
937 | + * @throws EE_Error |
|
938 | + */ |
|
939 | + function espresso_organization_logo_url($echo = true) |
|
940 | + { |
|
941 | + if ($echo) { |
|
942 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); // already escaped |
|
943 | + return ''; |
|
944 | + } |
|
945 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
946 | + } |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | if (! function_exists('espresso_organization_facebook')) { |
950 | - /** |
|
951 | - * espresso_organization_facebook |
|
952 | - * |
|
953 | - * @param bool $echo |
|
954 | - * @return string |
|
955 | - * @throws EE_Error |
|
956 | - */ |
|
957 | - function espresso_organization_facebook($echo = true) |
|
958 | - { |
|
959 | - if ($echo) { |
|
960 | - echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); // already escaped |
|
961 | - return ''; |
|
962 | - } |
|
963 | - return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
964 | - } |
|
950 | + /** |
|
951 | + * espresso_organization_facebook |
|
952 | + * |
|
953 | + * @param bool $echo |
|
954 | + * @return string |
|
955 | + * @throws EE_Error |
|
956 | + */ |
|
957 | + function espresso_organization_facebook($echo = true) |
|
958 | + { |
|
959 | + if ($echo) { |
|
960 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); // already escaped |
|
961 | + return ''; |
|
962 | + } |
|
963 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
964 | + } |
|
965 | 965 | } |
966 | 966 | |
967 | 967 | if (! function_exists('espresso_organization_twitter')) { |
968 | - /** |
|
969 | - * espresso_organization_twitter |
|
970 | - * |
|
971 | - * @param bool $echo |
|
972 | - * @return string |
|
973 | - * @throws EE_Error |
|
974 | - */ |
|
975 | - function espresso_organization_twitter($echo = true) |
|
976 | - { |
|
977 | - if ($echo) { |
|
978 | - echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); // already escaped |
|
979 | - return ''; |
|
980 | - } |
|
981 | - return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
982 | - } |
|
968 | + /** |
|
969 | + * espresso_organization_twitter |
|
970 | + * |
|
971 | + * @param bool $echo |
|
972 | + * @return string |
|
973 | + * @throws EE_Error |
|
974 | + */ |
|
975 | + function espresso_organization_twitter($echo = true) |
|
976 | + { |
|
977 | + if ($echo) { |
|
978 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); // already escaped |
|
979 | + return ''; |
|
980 | + } |
|
981 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
982 | + } |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | if (! function_exists('espresso_organization_linkedin')) { |
986 | - /** |
|
987 | - * espresso_organization_linkedin |
|
988 | - * |
|
989 | - * @param bool $echo |
|
990 | - * @return string |
|
991 | - * @throws EE_Error |
|
992 | - */ |
|
993 | - function espresso_organization_linkedin($echo = true) |
|
994 | - { |
|
995 | - if ($echo) { |
|
996 | - echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); // already escaped |
|
997 | - return ''; |
|
998 | - } |
|
999 | - return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
1000 | - } |
|
986 | + /** |
|
987 | + * espresso_organization_linkedin |
|
988 | + * |
|
989 | + * @param bool $echo |
|
990 | + * @return string |
|
991 | + * @throws EE_Error |
|
992 | + */ |
|
993 | + function espresso_organization_linkedin($echo = true) |
|
994 | + { |
|
995 | + if ($echo) { |
|
996 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); // already escaped |
|
997 | + return ''; |
|
998 | + } |
|
999 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
1000 | + } |
|
1001 | 1001 | } |
1002 | 1002 | |
1003 | 1003 | if (! function_exists('espresso_organization_pinterest')) { |
1004 | - /** |
|
1005 | - * espresso_organization_pinterest |
|
1006 | - * |
|
1007 | - * @param bool $echo |
|
1008 | - * @return string |
|
1009 | - * @throws EE_Error |
|
1010 | - */ |
|
1011 | - function espresso_organization_pinterest($echo = true) |
|
1012 | - { |
|
1013 | - if ($echo) { |
|
1014 | - echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); // already escaped |
|
1015 | - return ''; |
|
1016 | - } |
|
1017 | - return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
1018 | - } |
|
1004 | + /** |
|
1005 | + * espresso_organization_pinterest |
|
1006 | + * |
|
1007 | + * @param bool $echo |
|
1008 | + * @return string |
|
1009 | + * @throws EE_Error |
|
1010 | + */ |
|
1011 | + function espresso_organization_pinterest($echo = true) |
|
1012 | + { |
|
1013 | + if ($echo) { |
|
1014 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); // already escaped |
|
1015 | + return ''; |
|
1016 | + } |
|
1017 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
1018 | + } |
|
1019 | 1019 | } |
1020 | 1020 | |
1021 | 1021 | if (! function_exists('espresso_organization_google')) { |
1022 | - /** |
|
1023 | - * espresso_organization_google |
|
1024 | - * |
|
1025 | - * @param bool $echo |
|
1026 | - * @return string |
|
1027 | - * @throws EE_Error |
|
1028 | - */ |
|
1029 | - function espresso_organization_google($echo = true) |
|
1030 | - { |
|
1031 | - if ($echo) { |
|
1032 | - echo EE_Registry::instance()->CFG->organization->get_pretty('google'); // already escaped |
|
1033 | - return ''; |
|
1034 | - } |
|
1035 | - return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
1036 | - } |
|
1022 | + /** |
|
1023 | + * espresso_organization_google |
|
1024 | + * |
|
1025 | + * @param bool $echo |
|
1026 | + * @return string |
|
1027 | + * @throws EE_Error |
|
1028 | + */ |
|
1029 | + function espresso_organization_google($echo = true) |
|
1030 | + { |
|
1031 | + if ($echo) { |
|
1032 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); // already escaped |
|
1033 | + return ''; |
|
1034 | + } |
|
1035 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
1036 | + } |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | if (! function_exists('espresso_organization_instagram')) { |
1040 | - /** |
|
1041 | - * espresso_organization_instagram |
|
1042 | - * |
|
1043 | - * @param bool $echo |
|
1044 | - * @return string |
|
1045 | - * @throws EE_Error |
|
1046 | - */ |
|
1047 | - function espresso_organization_instagram($echo = true) |
|
1048 | - { |
|
1049 | - if ($echo) { |
|
1050 | - echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); // already escaped |
|
1051 | - return ''; |
|
1052 | - } |
|
1053 | - return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
1054 | - } |
|
1040 | + /** |
|
1041 | + * espresso_organization_instagram |
|
1042 | + * |
|
1043 | + * @param bool $echo |
|
1044 | + * @return string |
|
1045 | + * @throws EE_Error |
|
1046 | + */ |
|
1047 | + function espresso_organization_instagram($echo = true) |
|
1048 | + { |
|
1049 | + if ($echo) { |
|
1050 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); // already escaped |
|
1051 | + return ''; |
|
1052 | + } |
|
1053 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
1054 | + } |
|
1055 | 1055 | } |
1056 | 1056 | |
1057 | 1057 | |
@@ -1059,345 +1059,345 @@ discard block |
||
1059 | 1059 | |
1060 | 1060 | |
1061 | 1061 | if (! function_exists('espresso_event_venues')) { |
1062 | - /** |
|
1063 | - * espresso_event_venues |
|
1064 | - * |
|
1065 | - * @return array all venues related to an event |
|
1066 | - * @throws EE_Error |
|
1067 | - * @throws ReflectionException |
|
1068 | - */ |
|
1069 | - function espresso_event_venues() |
|
1070 | - { |
|
1071 | - return EEH_Venue_View::get_event_venues(); |
|
1072 | - } |
|
1062 | + /** |
|
1063 | + * espresso_event_venues |
|
1064 | + * |
|
1065 | + * @return array all venues related to an event |
|
1066 | + * @throws EE_Error |
|
1067 | + * @throws ReflectionException |
|
1068 | + */ |
|
1069 | + function espresso_event_venues() |
|
1070 | + { |
|
1071 | + return EEH_Venue_View::get_event_venues(); |
|
1072 | + } |
|
1073 | 1073 | } |
1074 | 1074 | |
1075 | 1075 | |
1076 | 1076 | if (! function_exists('espresso_venue_id')) { |
1077 | - /** |
|
1078 | - * espresso_venue_name |
|
1079 | - * |
|
1080 | - * @access public |
|
1081 | - * @param int $EVT_ID |
|
1082 | - * @return string |
|
1083 | - * @throws EE_Error |
|
1084 | - * @throws ReflectionException |
|
1085 | - */ |
|
1086 | - function espresso_venue_id($EVT_ID = 0) |
|
1087 | - { |
|
1088 | - $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
1089 | - return $venue instanceof EE_Venue ? $venue->ID() : 0; |
|
1090 | - } |
|
1077 | + /** |
|
1078 | + * espresso_venue_name |
|
1079 | + * |
|
1080 | + * @access public |
|
1081 | + * @param int $EVT_ID |
|
1082 | + * @return string |
|
1083 | + * @throws EE_Error |
|
1084 | + * @throws ReflectionException |
|
1085 | + */ |
|
1086 | + function espresso_venue_id($EVT_ID = 0) |
|
1087 | + { |
|
1088 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
1089 | + return $venue instanceof EE_Venue ? $venue->ID() : 0; |
|
1090 | + } |
|
1091 | 1091 | } |
1092 | 1092 | |
1093 | 1093 | |
1094 | 1094 | if (! function_exists('espresso_is_venue_private')) { |
1095 | - /** |
|
1096 | - * Return whether a venue is private or not. |
|
1097 | - * |
|
1098 | - * @param int $VNU_ID optional, the venue id to check. |
|
1099 | - * |
|
1100 | - * @return bool | null |
|
1101 | - * @throws EE_Error |
|
1102 | - * @throws ReflectionException |
|
1103 | - * @see EEH_Venue_View::get_venue() for more info on expected return results. |
|
1104 | - */ |
|
1105 | - function espresso_is_venue_private($VNU_ID = 0) |
|
1106 | - { |
|
1107 | - return EEH_Venue_View::is_venue_private($VNU_ID); |
|
1108 | - } |
|
1095 | + /** |
|
1096 | + * Return whether a venue is private or not. |
|
1097 | + * |
|
1098 | + * @param int $VNU_ID optional, the venue id to check. |
|
1099 | + * |
|
1100 | + * @return bool | null |
|
1101 | + * @throws EE_Error |
|
1102 | + * @throws ReflectionException |
|
1103 | + * @see EEH_Venue_View::get_venue() for more info on expected return results. |
|
1104 | + */ |
|
1105 | + function espresso_is_venue_private($VNU_ID = 0) |
|
1106 | + { |
|
1107 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
1108 | + } |
|
1109 | 1109 | } |
1110 | 1110 | |
1111 | 1111 | |
1112 | 1112 | if (! function_exists('espresso_venue_is_password_protected')) { |
1113 | - /** |
|
1114 | - * returns true or false if a venue is password protected or not |
|
1115 | - * |
|
1116 | - * @param int $VNU_ID optional, the venue id to check. |
|
1117 | - * @return bool |
|
1118 | - * @throws EE_Error |
|
1119 | - * @throws ReflectionException |
|
1120 | - */ |
|
1121 | - function espresso_venue_is_password_protected($VNU_ID = 0) |
|
1122 | - { |
|
1123 | - EE_Registry::instance()->load_helper('Venue_View'); |
|
1124 | - return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
1125 | - } |
|
1113 | + /** |
|
1114 | + * returns true or false if a venue is password protected or not |
|
1115 | + * |
|
1116 | + * @param int $VNU_ID optional, the venue id to check. |
|
1117 | + * @return bool |
|
1118 | + * @throws EE_Error |
|
1119 | + * @throws ReflectionException |
|
1120 | + */ |
|
1121 | + function espresso_venue_is_password_protected($VNU_ID = 0) |
|
1122 | + { |
|
1123 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
1124 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
1125 | + } |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | |
1129 | 1129 | if (! function_exists('espresso_password_protected_venue_form')) { |
1130 | - /** |
|
1131 | - * Returns a password form if venue is password protected. |
|
1132 | - * |
|
1133 | - * @param int $VNU_ID optional, the venue id to check. |
|
1134 | - * @return string |
|
1135 | - * @throws EE_Error |
|
1136 | - * @throws ReflectionException |
|
1137 | - */ |
|
1138 | - function espresso_password_protected_venue_form($VNU_ID = 0) |
|
1139 | - { |
|
1140 | - EE_Registry::instance()->load_helper('Venue_View'); |
|
1141 | - return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
1142 | - } |
|
1130 | + /** |
|
1131 | + * Returns a password form if venue is password protected. |
|
1132 | + * |
|
1133 | + * @param int $VNU_ID optional, the venue id to check. |
|
1134 | + * @return string |
|
1135 | + * @throws EE_Error |
|
1136 | + * @throws ReflectionException |
|
1137 | + */ |
|
1138 | + function espresso_password_protected_venue_form($VNU_ID = 0) |
|
1139 | + { |
|
1140 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
1141 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
1142 | + } |
|
1143 | 1143 | } |
1144 | 1144 | |
1145 | 1145 | |
1146 | 1146 | if (! function_exists('espresso_venue_name')) { |
1147 | - /** |
|
1148 | - * espresso_venue_name |
|
1149 | - * |
|
1150 | - * @access public |
|
1151 | - * @param int $VNU_ID |
|
1152 | - * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
1153 | - * @param bool $echo |
|
1154 | - * @return string |
|
1155 | - * @throws EE_Error |
|
1156 | - * @throws ReflectionException |
|
1157 | - */ |
|
1158 | - function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true) |
|
1159 | - { |
|
1160 | - if ($echo) { |
|
1161 | - echo EEH_Venue_View::venue_name($link_to, $VNU_ID); // already escaped |
|
1162 | - return ''; |
|
1163 | - } |
|
1164 | - return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1165 | - } |
|
1147 | + /** |
|
1148 | + * espresso_venue_name |
|
1149 | + * |
|
1150 | + * @access public |
|
1151 | + * @param int $VNU_ID |
|
1152 | + * @param string $link_to - options( details, website, none ) whether to turn Venue name into a clickable link to the Venue's details page or website |
|
1153 | + * @param bool $echo |
|
1154 | + * @return string |
|
1155 | + * @throws EE_Error |
|
1156 | + * @throws ReflectionException |
|
1157 | + */ |
|
1158 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = true) |
|
1159 | + { |
|
1160 | + if ($echo) { |
|
1161 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); // already escaped |
|
1162 | + return ''; |
|
1163 | + } |
|
1164 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1165 | + } |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | |
1169 | 1169 | if (! function_exists('espresso_venue_link')) { |
1170 | - /** |
|
1171 | - * espresso_venue_link |
|
1172 | - * |
|
1173 | - * @access public |
|
1174 | - * @param int $VNU_ID |
|
1175 | - * @param string $text |
|
1176 | - * @return string |
|
1177 | - * @throws EE_Error |
|
1178 | - * @throws ReflectionException |
|
1179 | - */ |
|
1180 | - function espresso_venue_link($VNU_ID = 0, $text = '') |
|
1181 | - { |
|
1182 | - return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
1183 | - } |
|
1170 | + /** |
|
1171 | + * espresso_venue_link |
|
1172 | + * |
|
1173 | + * @access public |
|
1174 | + * @param int $VNU_ID |
|
1175 | + * @param string $text |
|
1176 | + * @return string |
|
1177 | + * @throws EE_Error |
|
1178 | + * @throws ReflectionException |
|
1179 | + */ |
|
1180 | + function espresso_venue_link($VNU_ID = 0, $text = '') |
|
1181 | + { |
|
1182 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
1183 | + } |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | |
1187 | 1187 | if (! function_exists('espresso_venue_description')) { |
1188 | - /** |
|
1189 | - * espresso_venue_description |
|
1190 | - * |
|
1191 | - * @access public |
|
1192 | - * @param bool $VNU_ID |
|
1193 | - * @param bool $echo |
|
1194 | - * @return string |
|
1195 | - * @throws EE_Error |
|
1196 | - * @throws ReflectionException |
|
1197 | - */ |
|
1198 | - function espresso_venue_description($VNU_ID = false, $echo = true) |
|
1199 | - { |
|
1200 | - if ($echo) { |
|
1201 | - echo EEH_Venue_View::venue_description($VNU_ID); // already escaped |
|
1202 | - return ''; |
|
1203 | - } |
|
1204 | - return EEH_Venue_View::venue_description($VNU_ID); |
|
1205 | - } |
|
1188 | + /** |
|
1189 | + * espresso_venue_description |
|
1190 | + * |
|
1191 | + * @access public |
|
1192 | + * @param bool $VNU_ID |
|
1193 | + * @param bool $echo |
|
1194 | + * @return string |
|
1195 | + * @throws EE_Error |
|
1196 | + * @throws ReflectionException |
|
1197 | + */ |
|
1198 | + function espresso_venue_description($VNU_ID = false, $echo = true) |
|
1199 | + { |
|
1200 | + if ($echo) { |
|
1201 | + echo EEH_Venue_View::venue_description($VNU_ID); // already escaped |
|
1202 | + return ''; |
|
1203 | + } |
|
1204 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
1205 | + } |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | |
1209 | 1209 | if (! function_exists('espresso_venue_excerpt')) { |
1210 | - /** |
|
1211 | - * espresso_venue_excerpt |
|
1212 | - * |
|
1213 | - * @access public |
|
1214 | - * @param int $VNU_ID |
|
1215 | - * @param bool $echo |
|
1216 | - * @return string |
|
1217 | - * @throws EE_Error |
|
1218 | - * @throws ReflectionException |
|
1219 | - */ |
|
1220 | - function espresso_venue_excerpt($VNU_ID = 0, $echo = true) |
|
1221 | - { |
|
1222 | - if ($echo) { |
|
1223 | - echo EEH_Venue_View::venue_excerpt($VNU_ID); // already escaped |
|
1224 | - return ''; |
|
1225 | - } |
|
1226 | - return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1227 | - } |
|
1210 | + /** |
|
1211 | + * espresso_venue_excerpt |
|
1212 | + * |
|
1213 | + * @access public |
|
1214 | + * @param int $VNU_ID |
|
1215 | + * @param bool $echo |
|
1216 | + * @return string |
|
1217 | + * @throws EE_Error |
|
1218 | + * @throws ReflectionException |
|
1219 | + */ |
|
1220 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = true) |
|
1221 | + { |
|
1222 | + if ($echo) { |
|
1223 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); // already escaped |
|
1224 | + return ''; |
|
1225 | + } |
|
1226 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1227 | + } |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | |
1231 | 1231 | if (! function_exists('espresso_venue_categories')) { |
1232 | - /** |
|
1233 | - * espresso_venue_categories |
|
1234 | - * returns the terms associated with a venue |
|
1235 | - * |
|
1236 | - * @param int $VNU_ID |
|
1237 | - * @param bool $hide_uncategorized |
|
1238 | - * @param bool $echo |
|
1239 | - * @return string |
|
1240 | - * @throws EE_Error |
|
1241 | - * @throws ReflectionException |
|
1242 | - */ |
|
1243 | - function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true) |
|
1244 | - { |
|
1245 | - if ($echo) { |
|
1246 | - echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); // already escaped |
|
1247 | - return ''; |
|
1248 | - } |
|
1249 | - return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1250 | - } |
|
1232 | + /** |
|
1233 | + * espresso_venue_categories |
|
1234 | + * returns the terms associated with a venue |
|
1235 | + * |
|
1236 | + * @param int $VNU_ID |
|
1237 | + * @param bool $hide_uncategorized |
|
1238 | + * @param bool $echo |
|
1239 | + * @return string |
|
1240 | + * @throws EE_Error |
|
1241 | + * @throws ReflectionException |
|
1242 | + */ |
|
1243 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = true, $echo = true) |
|
1244 | + { |
|
1245 | + if ($echo) { |
|
1246 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); // already escaped |
|
1247 | + return ''; |
|
1248 | + } |
|
1249 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1250 | + } |
|
1251 | 1251 | } |
1252 | 1252 | |
1253 | 1253 | |
1254 | 1254 | if (! function_exists('espresso_venue_address')) { |
1255 | - /** |
|
1256 | - * espresso_venue_address |
|
1257 | - * returns a formatted block of html for displaying a venue's address |
|
1258 | - * |
|
1259 | - * @param string $type 'inline' or 'multiline' |
|
1260 | - * @param int $VNU_ID |
|
1261 | - * @param bool $echo |
|
1262 | - * @return string |
|
1263 | - * @throws EE_Error |
|
1264 | - * @throws ReflectionException |
|
1265 | - */ |
|
1266 | - function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1267 | - { |
|
1268 | - if ($echo) { |
|
1269 | - echo EEH_Venue_View::venue_address($type, $VNU_ID); // already escaped |
|
1270 | - return ''; |
|
1271 | - } |
|
1272 | - return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1273 | - } |
|
1255 | + /** |
|
1256 | + * espresso_venue_address |
|
1257 | + * returns a formatted block of html for displaying a venue's address |
|
1258 | + * |
|
1259 | + * @param string $type 'inline' or 'multiline' |
|
1260 | + * @param int $VNU_ID |
|
1261 | + * @param bool $echo |
|
1262 | + * @return string |
|
1263 | + * @throws EE_Error |
|
1264 | + * @throws ReflectionException |
|
1265 | + */ |
|
1266 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1267 | + { |
|
1268 | + if ($echo) { |
|
1269 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); // already escaped |
|
1270 | + return ''; |
|
1271 | + } |
|
1272 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1273 | + } |
|
1274 | 1274 | } |
1275 | 1275 | |
1276 | 1276 | |
1277 | 1277 | if (! function_exists('espresso_venue_raw_address')) { |
1278 | - /** |
|
1279 | - * espresso_venue_address |
|
1280 | - * returns an UN-formatted string containing a venue's address |
|
1281 | - * |
|
1282 | - * @param string $type 'inline' or 'multiline' |
|
1283 | - * @param int $VNU_ID |
|
1284 | - * @param bool $echo |
|
1285 | - * @return string |
|
1286 | - * @throws EE_Error |
|
1287 | - * @throws ReflectionException |
|
1288 | - */ |
|
1289 | - function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1290 | - { |
|
1291 | - if ($echo) { |
|
1292 | - echo EEH_Venue_View::venue_address($type, $VNU_ID, false, false); // already escaped |
|
1293 | - return ''; |
|
1294 | - } |
|
1295 | - return EEH_Venue_View::venue_address($type, $VNU_ID, false, false); |
|
1296 | - } |
|
1278 | + /** |
|
1279 | + * espresso_venue_address |
|
1280 | + * returns an UN-formatted string containing a venue's address |
|
1281 | + * |
|
1282 | + * @param string $type 'inline' or 'multiline' |
|
1283 | + * @param int $VNU_ID |
|
1284 | + * @param bool $echo |
|
1285 | + * @return string |
|
1286 | + * @throws EE_Error |
|
1287 | + * @throws ReflectionException |
|
1288 | + */ |
|
1289 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = true) |
|
1290 | + { |
|
1291 | + if ($echo) { |
|
1292 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, false, false); // already escaped |
|
1293 | + return ''; |
|
1294 | + } |
|
1295 | + return EEH_Venue_View::venue_address($type, $VNU_ID, false, false); |
|
1296 | + } |
|
1297 | 1297 | } |
1298 | 1298 | |
1299 | 1299 | |
1300 | 1300 | if (! function_exists('espresso_venue_has_address')) { |
1301 | - /** |
|
1302 | - * espresso_venue_has_address |
|
1303 | - * returns TRUE or FALSE if a Venue has address information |
|
1304 | - * |
|
1305 | - * @param int $VNU_ID |
|
1306 | - * @return bool |
|
1307 | - * @throws EE_Error |
|
1308 | - * @throws ReflectionException |
|
1309 | - */ |
|
1310 | - function espresso_venue_has_address($VNU_ID = 0) |
|
1311 | - { |
|
1312 | - return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1313 | - } |
|
1301 | + /** |
|
1302 | + * espresso_venue_has_address |
|
1303 | + * returns TRUE or FALSE if a Venue has address information |
|
1304 | + * |
|
1305 | + * @param int $VNU_ID |
|
1306 | + * @return bool |
|
1307 | + * @throws EE_Error |
|
1308 | + * @throws ReflectionException |
|
1309 | + */ |
|
1310 | + function espresso_venue_has_address($VNU_ID = 0) |
|
1311 | + { |
|
1312 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1313 | + } |
|
1314 | 1314 | } |
1315 | 1315 | |
1316 | 1316 | |
1317 | 1317 | if (! function_exists('espresso_venue_gmap')) { |
1318 | - /** |
|
1319 | - * espresso_venue_gmap |
|
1320 | - * returns a google map for the venue address |
|
1321 | - * |
|
1322 | - * @param int $VNU_ID |
|
1323 | - * @param bool $map_ID |
|
1324 | - * @param array $gmap |
|
1325 | - * @param bool $echo |
|
1326 | - * @return string |
|
1327 | - * @throws EE_Error |
|
1328 | - * @throws ReflectionException |
|
1329 | - */ |
|
1330 | - function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true) |
|
1331 | - { |
|
1332 | - if ($echo) { |
|
1333 | - echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped |
|
1334 | - return ''; |
|
1335 | - } |
|
1336 | - return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1337 | - } |
|
1318 | + /** |
|
1319 | + * espresso_venue_gmap |
|
1320 | + * returns a google map for the venue address |
|
1321 | + * |
|
1322 | + * @param int $VNU_ID |
|
1323 | + * @param bool $map_ID |
|
1324 | + * @param array $gmap |
|
1325 | + * @param bool $echo |
|
1326 | + * @return string |
|
1327 | + * @throws EE_Error |
|
1328 | + * @throws ReflectionException |
|
1329 | + */ |
|
1330 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = false, $gmap = [], $echo = true) |
|
1331 | + { |
|
1332 | + if ($echo) { |
|
1333 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); // already escaped |
|
1334 | + return ''; |
|
1335 | + } |
|
1336 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1337 | + } |
|
1338 | 1338 | } |
1339 | 1339 | |
1340 | 1340 | |
1341 | 1341 | if (! function_exists('espresso_venue_phone')) { |
1342 | - /** |
|
1343 | - * espresso_venue_phone |
|
1344 | - * |
|
1345 | - * @param int $VNU_ID |
|
1346 | - * @param bool $echo |
|
1347 | - * @return string |
|
1348 | - * @throws EE_Error |
|
1349 | - * @throws ReflectionException |
|
1350 | - */ |
|
1351 | - function espresso_venue_phone($VNU_ID = 0, $echo = true) |
|
1352 | - { |
|
1353 | - if ($echo) { |
|
1354 | - echo EEH_Venue_View::venue_phone($VNU_ID); // already escaped |
|
1355 | - return ''; |
|
1356 | - } |
|
1357 | - return EEH_Venue_View::venue_phone($VNU_ID); |
|
1358 | - } |
|
1342 | + /** |
|
1343 | + * espresso_venue_phone |
|
1344 | + * |
|
1345 | + * @param int $VNU_ID |
|
1346 | + * @param bool $echo |
|
1347 | + * @return string |
|
1348 | + * @throws EE_Error |
|
1349 | + * @throws ReflectionException |
|
1350 | + */ |
|
1351 | + function espresso_venue_phone($VNU_ID = 0, $echo = true) |
|
1352 | + { |
|
1353 | + if ($echo) { |
|
1354 | + echo EEH_Venue_View::venue_phone($VNU_ID); // already escaped |
|
1355 | + return ''; |
|
1356 | + } |
|
1357 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1358 | + } |
|
1359 | 1359 | } |
1360 | 1360 | |
1361 | 1361 | |
1362 | 1362 | if (! function_exists('espresso_venue_website')) { |
1363 | - /** |
|
1364 | - * espresso_venue_website |
|
1365 | - * |
|
1366 | - * @param int $VNU_ID |
|
1367 | - * @param bool $echo |
|
1368 | - * @return string |
|
1369 | - * @throws EE_Error |
|
1370 | - * @throws ReflectionException |
|
1371 | - */ |
|
1372 | - function espresso_venue_website($VNU_ID = 0, $echo = true) |
|
1373 | - { |
|
1374 | - if ($echo) { |
|
1375 | - echo EEH_Venue_View::venue_website_link($VNU_ID); // already escaped |
|
1376 | - return ''; |
|
1377 | - } |
|
1378 | - return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1379 | - } |
|
1363 | + /** |
|
1364 | + * espresso_venue_website |
|
1365 | + * |
|
1366 | + * @param int $VNU_ID |
|
1367 | + * @param bool $echo |
|
1368 | + * @return string |
|
1369 | + * @throws EE_Error |
|
1370 | + * @throws ReflectionException |
|
1371 | + */ |
|
1372 | + function espresso_venue_website($VNU_ID = 0, $echo = true) |
|
1373 | + { |
|
1374 | + if ($echo) { |
|
1375 | + echo EEH_Venue_View::venue_website_link($VNU_ID); // already escaped |
|
1376 | + return ''; |
|
1377 | + } |
|
1378 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1379 | + } |
|
1380 | 1380 | } |
1381 | 1381 | |
1382 | 1382 | |
1383 | 1383 | if (! function_exists('espresso_edit_venue_link')) { |
1384 | - /** |
|
1385 | - * espresso_edit_venue_link |
|
1386 | - * |
|
1387 | - * @param int $VNU_ID |
|
1388 | - * @param bool $echo |
|
1389 | - * @return string |
|
1390 | - * @throws EE_Error |
|
1391 | - * @throws ReflectionException |
|
1392 | - */ |
|
1393 | - function espresso_edit_venue_link($VNU_ID = 0, $echo = true) |
|
1394 | - { |
|
1395 | - if ($echo) { |
|
1396 | - echo EEH_Venue_View::edit_venue_link($VNU_ID); // already escaped |
|
1397 | - return ''; |
|
1398 | - } |
|
1399 | - return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1400 | - } |
|
1384 | + /** |
|
1385 | + * espresso_edit_venue_link |
|
1386 | + * |
|
1387 | + * @param int $VNU_ID |
|
1388 | + * @param bool $echo |
|
1389 | + * @return string |
|
1390 | + * @throws EE_Error |
|
1391 | + * @throws ReflectionException |
|
1392 | + */ |
|
1393 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = true) |
|
1394 | + { |
|
1395 | + if ($echo) { |
|
1396 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); // already escaped |
|
1397 | + return ''; |
|
1398 | + } |
|
1399 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1400 | + } |
|
1401 | 1401 | } |
1402 | 1402 | |
1403 | 1403 |
@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | <div class="padding"> |
4 | 4 | <p> |
5 | 5 | <?php printf( |
6 | - esc_html__( |
|
7 | - '%1$sNote:%2$s The %3$s[ESPRESSO_EVENT_ATTENDEES]%4$s shortcode is not used to represent the attendees post type directly, but is instead used to represent the intersection of attendees with events. So it\'s always returning a list of attendees %5$sin relation to%6$s an event.', |
|
8 | - 'event_espresso' |
|
9 | - ), |
|
10 | - '<strong>', |
|
11 | - '</strong>', |
|
12 | - '<code>', |
|
13 | - '</code>', |
|
14 | - '<em>', |
|
15 | - '</em>' |
|
16 | - ); ?> |
|
6 | + esc_html__( |
|
7 | + '%1$sNote:%2$s The %3$s[ESPRESSO_EVENT_ATTENDEES]%4$s shortcode is not used to represent the attendees post type directly, but is instead used to represent the intersection of attendees with events. So it\'s always returning a list of attendees %5$sin relation to%6$s an event.', |
|
8 | + 'event_espresso' |
|
9 | + ), |
|
10 | + '<strong>', |
|
11 | + '</strong>', |
|
12 | + '<code>', |
|
13 | + '</code>', |
|
14 | + '<em>', |
|
15 | + '</em>' |
|
16 | + ); ?> |
|
17 | 17 | </p> |
18 | 18 | |
19 | 19 | <ul> |
@@ -21,9 +21,9 @@ discard block |
||
21 | 21 | <strong>[ESPRESSO_EVENT_ATTENDEES]</strong><br> |
22 | 22 | <p class="description"> |
23 | 23 | <?php esc_html_e( |
24 | - 'With no parameters, this shows the attendees for the earliest active event, or if no active event, the earliest upcoming event. If it is used in Event Description, then it will show the attendees for that event.', |
|
25 | - 'event_espresso' |
|
26 | - ); ?> |
|
24 | + 'With no parameters, this shows the attendees for the earliest active event, or if no active event, the earliest upcoming event. If it is used in Event Description, then it will show the attendees for that event.', |
|
25 | + 'event_espresso' |
|
26 | + ); ?> |
|
27 | 27 | </p> |
28 | 28 | <br> |
29 | 29 | </li> |
@@ -52,20 +52,20 @@ discard block |
||
52 | 52 | <strong>[ESPRESSO_EVENT_ATTENDEES status=RAP]</strong><br> |
53 | 53 | <p class="description"> |
54 | 54 | <?php esc_html_e( |
55 | - 'You can list attendees that have a specific registration status (use status code) or use "all" to return all attendees regardless of status. Default when you don\'t have this parameter set is to only return attendees attached to approved contacts.', |
|
56 | - 'event_espresso' |
|
57 | - ); ?> |
|
55 | + 'You can list attendees that have a specific registration status (use status code) or use "all" to return all attendees regardless of status. Default when you don\'t have this parameter set is to only return attendees attached to approved contacts.', |
|
56 | + 'event_espresso' |
|
57 | + ); ?> |
|
58 | 58 | </p> |
59 | 59 | <p> |
60 | 60 | <?php esc_html_e('The statuses you can use are:', 'event_espresso'); ?> |
61 | 61 | <br> |
62 | 62 | <?php |
63 | - foreach ($reg_status_array as $status_code => $status_label) { |
|
64 | - $status_code = esc_html($status_code); |
|
65 | - $status_label = esc_html($status_label); |
|
66 | - echo "<strong>$status_code</strong>: $status_label<br>"; |
|
67 | - } |
|
68 | - ?> |
|
63 | + foreach ($reg_status_array as $status_code => $status_label) { |
|
64 | + $status_code = esc_html($status_code); |
|
65 | + $status_label = esc_html($status_label); |
|
66 | + echo "<strong>$status_code</strong>: $status_label<br>"; |
|
67 | + } |
|
68 | + ?> |
|
69 | 69 | |
70 | 70 | </p> |
71 | 71 | <br> |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | <strong>[ESPRESSO_EVENT_ATTENDEES display_on_archives=true]</strong><br> |
75 | 75 | <p class="description"> |
76 | 76 | <?php esc_html_e( |
77 | - 'Will display the attendees list when events are viewed on archive pages.', |
|
78 | - 'event_espresso' |
|
79 | - ); ?> |
|
77 | + 'Will display the attendees list when events are viewed on archive pages.', |
|
78 | + 'event_espresso' |
|
79 | + ); ?> |
|
80 | 80 | </p> |
81 | 81 | <br> |
82 | 82 | </li> |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | |
118 | 118 | protected function _installation() |
119 | 119 | { |
120 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php'; |
|
120 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php'; |
|
121 | 121 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
122 | 122 | $template_path, |
123 | 123 | '', |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | add_meta_box( |
139 | 139 | "espresso_{$box}_settings", |
140 | 140 | $label, |
141 | - function ($post, $metabox) { |
|
141 | + function($post, $metabox) { |
|
142 | 142 | EEH_Template::display_template( |
143 | 143 | $metabox['args']['template_path'], |
144 | 144 | $metabox['args']['template_args'] |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $box, |
174 | 174 | $label, |
175 | 175 | array( |
176 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
176 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php", |
|
177 | 177 | 'template_args' => $this->_template_args, |
178 | 178 | ) |
179 | 179 | ); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | $box, |
206 | 206 | $label, |
207 | 207 | array( |
208 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
208 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php", |
|
209 | 209 | 'template_args' => $this->_template_args, |
210 | 210 | ) |
211 | 211 | ); |
@@ -233,7 +233,7 @@ discard block |
||
233 | 233 | $box, |
234 | 234 | $label, |
235 | 235 | array( |
236 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
236 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH."support_admin_details_{$box}.template.php", |
|
237 | 237 | 'template_args' => $this->_template_args, |
238 | 238 | ) |
239 | 239 | ); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | protected function _developers() |
245 | 245 | { |
246 | 246 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
247 | - EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php', |
|
247 | + EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php', |
|
248 | 248 | array(), |
249 | 249 | true |
250 | 250 | ); |
@@ -11,241 +11,241 @@ |
||
11 | 11 | */ |
12 | 12 | class Support_Admin_Page extends EE_Admin_Page |
13 | 13 | { |
14 | - protected function _init_page_props() |
|
15 | - { |
|
16 | - $this->page_slug = EE_SUPPORT_PG_SLUG; |
|
17 | - $this->page_label = esc_html__('Help & Support', 'event_espresso'); |
|
18 | - $this->_admin_base_url = EE_SUPPORT_ADMIN_URL; |
|
19 | - $this->_admin_base_path = EE_SUPPORT_ADMIN; |
|
20 | - } |
|
21 | - |
|
22 | - |
|
23 | - protected function _ajax_hooks() |
|
24 | - { |
|
25 | - } |
|
26 | - |
|
27 | - |
|
28 | - protected function _define_page_props() |
|
29 | - { |
|
30 | - $this->_labels = array(); |
|
31 | - $this->_admin_page_title = $this->page_label; |
|
32 | - } |
|
33 | - |
|
34 | - |
|
35 | - protected function _set_page_routes() |
|
36 | - { |
|
37 | - $this->_page_routes = array( |
|
38 | - 'default' => array( |
|
39 | - 'func' => '_contact_support', |
|
40 | - 'capability' => 'ee_read_ee', |
|
41 | - ), |
|
42 | - 'developers' => array( |
|
43 | - 'func' => '_developers', |
|
44 | - 'capability' => 'ee_read_ee', |
|
45 | - ), |
|
46 | - 'shortcodes' => array( |
|
47 | - 'func' => '_shortcodes', |
|
48 | - 'capability' => 'ee_read_ee', |
|
49 | - ), |
|
50 | - ); |
|
51 | - } |
|
52 | - |
|
53 | - |
|
54 | - protected function _set_page_config() |
|
55 | - { |
|
56 | - $this->_page_config = array( |
|
57 | - 'default' => array( |
|
58 | - 'nav' => array( |
|
59 | - 'label' => esc_html__('Support', 'event_espresso'), |
|
60 | - 'order' => 30, |
|
61 | - ), |
|
62 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')), |
|
63 | - 'require_nonce' => false, |
|
64 | - ), |
|
65 | - 'developers' => array( |
|
66 | - 'nav' => array( |
|
67 | - 'label' => esc_html__('Developers', 'event_espresso'), |
|
68 | - 'order' => 50, |
|
69 | - ), |
|
70 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
71 | - 'require_nonce' => false, |
|
72 | - ), |
|
73 | - 'shortcodes' => array( |
|
74 | - 'nav' => array( |
|
75 | - 'label' => esc_html__('Shortcodes', 'event_espresso'), |
|
76 | - 'order' => 60, |
|
77 | - ), |
|
78 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')), |
|
79 | - 'require_nonce' => false, |
|
80 | - ), |
|
81 | - ); |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - // none of the below group are currently used for Support pages |
|
86 | - protected function _add_screen_options() |
|
87 | - { |
|
88 | - } |
|
89 | - |
|
90 | - |
|
91 | - protected function _add_feature_pointers() |
|
92 | - { |
|
93 | - } |
|
94 | - |
|
95 | - |
|
96 | - public function admin_init() |
|
97 | - { |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - public function admin_notices() |
|
102 | - { |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - public function admin_footer_scripts() |
|
107 | - { |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - public function load_scripts_styles() |
|
112 | - { |
|
113 | - } |
|
114 | - |
|
115 | - |
|
116 | - protected function _installation() |
|
117 | - { |
|
118 | - $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php'; |
|
119 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
120 | - $template_path, |
|
121 | - '', |
|
122 | - true |
|
123 | - ); |
|
124 | - $this->display_admin_page_with_sidebar(); |
|
125 | - } |
|
126 | - |
|
127 | - |
|
128 | - protected function _resources() |
|
129 | - { |
|
130 | - $this->display_admin_page_with_sidebar(); |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - protected function _add_settings_metabox($box, $label, array $args) |
|
135 | - { |
|
136 | - add_meta_box( |
|
137 | - "espresso_{$box}_settings", |
|
138 | - $label, |
|
139 | - function ($post, $metabox) { |
|
140 | - EEH_Template::display_template( |
|
141 | - $metabox['args']['template_path'], |
|
142 | - $metabox['args']['template_args'] |
|
143 | - ); |
|
144 | - }, |
|
145 | - $this->_current_screen->id, |
|
146 | - 'normal', |
|
147 | - 'high', |
|
148 | - apply_filters( |
|
149 | - "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array", |
|
150 | - $args |
|
151 | - ) |
|
152 | - ); |
|
153 | - } |
|
154 | - |
|
155 | - |
|
156 | - protected function _resources_boxes() |
|
157 | - { |
|
158 | - $boxes = apply_filters( |
|
159 | - 'FHEE__Support_Admin_Page___resources_boxes__boxes_array', |
|
160 | - array( |
|
161 | - 'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'), |
|
162 | - 'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'), |
|
163 | - 'hire_developer' => esc_html__('Hire a Developer', 'event_espresso'), |
|
164 | - 'partners' => esc_html__('Partners', 'event_espresso'), |
|
165 | - 'recommended_plugins' => esc_html__('Recommended Plugins', 'event_espresso'), |
|
166 | - 'other_resources' => esc_html__('Other Resources', 'event_espresso'), |
|
167 | - ) |
|
168 | - ); |
|
169 | - foreach ($boxes as $box => $label) { |
|
170 | - $this->_add_settings_metabox( |
|
171 | - $box, |
|
172 | - $label, |
|
173 | - array( |
|
174 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
175 | - 'template_args' => $this->_template_args, |
|
176 | - ) |
|
177 | - ); |
|
178 | - } |
|
179 | - } |
|
180 | - |
|
181 | - |
|
182 | - protected function _shortcodes() |
|
183 | - { |
|
184 | - $this->display_admin_page_with_sidebar(); |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - protected function _shortcodes_boxes() |
|
189 | - { |
|
190 | - $boxes = apply_filters( |
|
191 | - 'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array', |
|
192 | - array( |
|
193 | - 'shortcodes_event_listings' => esc_html__('Event Listings', 'event_espresso'), |
|
194 | - 'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'), |
|
195 | - 'shortcodes_category' => esc_html__('Event Categories', 'event_espresso'), |
|
196 | - 'shortcodes_attendee' => esc_html__('Event Attendees', 'event_espresso') |
|
197 | - /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/ |
|
198 | - /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/ |
|
199 | - ) |
|
200 | - ); |
|
201 | - foreach ($boxes as $box => $label) { |
|
202 | - $this->_add_settings_metabox( |
|
203 | - $box, |
|
204 | - $label, |
|
205 | - array( |
|
206 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
207 | - 'template_args' => $this->_template_args, |
|
208 | - ) |
|
209 | - ); |
|
210 | - } |
|
211 | - } |
|
212 | - |
|
213 | - |
|
214 | - protected function _contact_support() |
|
215 | - { |
|
216 | - $this->display_admin_page_with_sidebar(); |
|
217 | - } |
|
218 | - |
|
219 | - |
|
220 | - protected function _support_boxes() |
|
221 | - { |
|
222 | - $boxes = apply_filters( |
|
223 | - 'FHEE__Support_Admin_Page___support_boxes__boxes_array', |
|
224 | - array( |
|
225 | - 'contact_support' => esc_html__('Contact Support', 'event_espresso'), |
|
226 | - 'important_information' => esc_html__('Important Information', 'event_espresso'), |
|
227 | - ) |
|
228 | - ); |
|
229 | - foreach ($boxes as $box => $label) { |
|
230 | - $this->_add_settings_metabox( |
|
231 | - $box, |
|
232 | - $label, |
|
233 | - array( |
|
234 | - 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
235 | - 'template_args' => $this->_template_args, |
|
236 | - ) |
|
237 | - ); |
|
238 | - } |
|
239 | - } |
|
240 | - |
|
241 | - |
|
242 | - protected function _developers() |
|
243 | - { |
|
244 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
245 | - EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php', |
|
246 | - array(), |
|
247 | - true |
|
248 | - ); |
|
249 | - $this->display_admin_page_with_sidebar(); |
|
250 | - } |
|
14 | + protected function _init_page_props() |
|
15 | + { |
|
16 | + $this->page_slug = EE_SUPPORT_PG_SLUG; |
|
17 | + $this->page_label = esc_html__('Help & Support', 'event_espresso'); |
|
18 | + $this->_admin_base_url = EE_SUPPORT_ADMIN_URL; |
|
19 | + $this->_admin_base_path = EE_SUPPORT_ADMIN; |
|
20 | + } |
|
21 | + |
|
22 | + |
|
23 | + protected function _ajax_hooks() |
|
24 | + { |
|
25 | + } |
|
26 | + |
|
27 | + |
|
28 | + protected function _define_page_props() |
|
29 | + { |
|
30 | + $this->_labels = array(); |
|
31 | + $this->_admin_page_title = $this->page_label; |
|
32 | + } |
|
33 | + |
|
34 | + |
|
35 | + protected function _set_page_routes() |
|
36 | + { |
|
37 | + $this->_page_routes = array( |
|
38 | + 'default' => array( |
|
39 | + 'func' => '_contact_support', |
|
40 | + 'capability' => 'ee_read_ee', |
|
41 | + ), |
|
42 | + 'developers' => array( |
|
43 | + 'func' => '_developers', |
|
44 | + 'capability' => 'ee_read_ee', |
|
45 | + ), |
|
46 | + 'shortcodes' => array( |
|
47 | + 'func' => '_shortcodes', |
|
48 | + 'capability' => 'ee_read_ee', |
|
49 | + ), |
|
50 | + ); |
|
51 | + } |
|
52 | + |
|
53 | + |
|
54 | + protected function _set_page_config() |
|
55 | + { |
|
56 | + $this->_page_config = array( |
|
57 | + 'default' => array( |
|
58 | + 'nav' => array( |
|
59 | + 'label' => esc_html__('Support', 'event_espresso'), |
|
60 | + 'order' => 30, |
|
61 | + ), |
|
62 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')), |
|
63 | + 'require_nonce' => false, |
|
64 | + ), |
|
65 | + 'developers' => array( |
|
66 | + 'nav' => array( |
|
67 | + 'label' => esc_html__('Developers', 'event_espresso'), |
|
68 | + 'order' => 50, |
|
69 | + ), |
|
70 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
71 | + 'require_nonce' => false, |
|
72 | + ), |
|
73 | + 'shortcodes' => array( |
|
74 | + 'nav' => array( |
|
75 | + 'label' => esc_html__('Shortcodes', 'event_espresso'), |
|
76 | + 'order' => 60, |
|
77 | + ), |
|
78 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')), |
|
79 | + 'require_nonce' => false, |
|
80 | + ), |
|
81 | + ); |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + // none of the below group are currently used for Support pages |
|
86 | + protected function _add_screen_options() |
|
87 | + { |
|
88 | + } |
|
89 | + |
|
90 | + |
|
91 | + protected function _add_feature_pointers() |
|
92 | + { |
|
93 | + } |
|
94 | + |
|
95 | + |
|
96 | + public function admin_init() |
|
97 | + { |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + public function admin_notices() |
|
102 | + { |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + public function admin_footer_scripts() |
|
107 | + { |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + public function load_scripts_styles() |
|
112 | + { |
|
113 | + } |
|
114 | + |
|
115 | + |
|
116 | + protected function _installation() |
|
117 | + { |
|
118 | + $template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php'; |
|
119 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
120 | + $template_path, |
|
121 | + '', |
|
122 | + true |
|
123 | + ); |
|
124 | + $this->display_admin_page_with_sidebar(); |
|
125 | + } |
|
126 | + |
|
127 | + |
|
128 | + protected function _resources() |
|
129 | + { |
|
130 | + $this->display_admin_page_with_sidebar(); |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + protected function _add_settings_metabox($box, $label, array $args) |
|
135 | + { |
|
136 | + add_meta_box( |
|
137 | + "espresso_{$box}_settings", |
|
138 | + $label, |
|
139 | + function ($post, $metabox) { |
|
140 | + EEH_Template::display_template( |
|
141 | + $metabox['args']['template_path'], |
|
142 | + $metabox['args']['template_args'] |
|
143 | + ); |
|
144 | + }, |
|
145 | + $this->_current_screen->id, |
|
146 | + 'normal', |
|
147 | + 'high', |
|
148 | + apply_filters( |
|
149 | + "FHEE__Support_Admin_Page___add_settings_metabox__{$box}_args_array", |
|
150 | + $args |
|
151 | + ) |
|
152 | + ); |
|
153 | + } |
|
154 | + |
|
155 | + |
|
156 | + protected function _resources_boxes() |
|
157 | + { |
|
158 | + $boxes = apply_filters( |
|
159 | + 'FHEE__Support_Admin_Page___resources_boxes__boxes_array', |
|
160 | + array( |
|
161 | + 'favorite_theme_developers' => esc_html__('Favorite Theme Developers', 'event_espresso'), |
|
162 | + 'highly_recommended_themes' => esc_html__('Highly Recommended Themes', 'event_espresso'), |
|
163 | + 'hire_developer' => esc_html__('Hire a Developer', 'event_espresso'), |
|
164 | + 'partners' => esc_html__('Partners', 'event_espresso'), |
|
165 | + 'recommended_plugins' => esc_html__('Recommended Plugins', 'event_espresso'), |
|
166 | + 'other_resources' => esc_html__('Other Resources', 'event_espresso'), |
|
167 | + ) |
|
168 | + ); |
|
169 | + foreach ($boxes as $box => $label) { |
|
170 | + $this->_add_settings_metabox( |
|
171 | + $box, |
|
172 | + $label, |
|
173 | + array( |
|
174 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
175 | + 'template_args' => $this->_template_args, |
|
176 | + ) |
|
177 | + ); |
|
178 | + } |
|
179 | + } |
|
180 | + |
|
181 | + |
|
182 | + protected function _shortcodes() |
|
183 | + { |
|
184 | + $this->display_admin_page_with_sidebar(); |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + protected function _shortcodes_boxes() |
|
189 | + { |
|
190 | + $boxes = apply_filters( |
|
191 | + 'FHEE__Support_Admin_Page___shortcodes_boxes__boxes_array', |
|
192 | + array( |
|
193 | + 'shortcodes_event_listings' => esc_html__('Event Listings', 'event_espresso'), |
|
194 | + 'shortcodes_ticket_selector' => esc_html__('Event Ticket Selector', 'event_espresso'), |
|
195 | + 'shortcodes_category' => esc_html__('Event Categories', 'event_espresso'), |
|
196 | + 'shortcodes_attendee' => esc_html__('Event Attendees', 'event_espresso') |
|
197 | + /*'shortcodes_single_events' => esc_html__('Single Events', 'event_espresso'),*/ |
|
198 | + /*'shortcodes_attendee_listings' => esc_html__('Attendee Listings', 'event_espresso'),*/ |
|
199 | + ) |
|
200 | + ); |
|
201 | + foreach ($boxes as $box => $label) { |
|
202 | + $this->_add_settings_metabox( |
|
203 | + $box, |
|
204 | + $label, |
|
205 | + array( |
|
206 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
207 | + 'template_args' => $this->_template_args, |
|
208 | + ) |
|
209 | + ); |
|
210 | + } |
|
211 | + } |
|
212 | + |
|
213 | + |
|
214 | + protected function _contact_support() |
|
215 | + { |
|
216 | + $this->display_admin_page_with_sidebar(); |
|
217 | + } |
|
218 | + |
|
219 | + |
|
220 | + protected function _support_boxes() |
|
221 | + { |
|
222 | + $boxes = apply_filters( |
|
223 | + 'FHEE__Support_Admin_Page___support_boxes__boxes_array', |
|
224 | + array( |
|
225 | + 'contact_support' => esc_html__('Contact Support', 'event_espresso'), |
|
226 | + 'important_information' => esc_html__('Important Information', 'event_espresso'), |
|
227 | + ) |
|
228 | + ); |
|
229 | + foreach ($boxes as $box => $label) { |
|
230 | + $this->_add_settings_metabox( |
|
231 | + $box, |
|
232 | + $label, |
|
233 | + array( |
|
234 | + 'template_path' => EE_SUPPORT_ADMIN_TEMPLATE_PATH . "support_admin_details_{$box}.template.php", |
|
235 | + 'template_args' => $this->_template_args, |
|
236 | + ) |
|
237 | + ); |
|
238 | + } |
|
239 | + } |
|
240 | + |
|
241 | + |
|
242 | + protected function _developers() |
|
243 | + { |
|
244 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
245 | + EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php', |
|
246 | + array(), |
|
247 | + true |
|
248 | + ); |
|
249 | + $this->display_admin_page_with_sidebar(); |
|
250 | + } |
|
251 | 251 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | */ |
126 | 126 | protected function getLoader() |
127 | 127 | { |
128 | - if (! $this->loader instanceof LoaderInterface) { |
|
128 | + if ( ! $this->loader instanceof LoaderInterface) { |
|
129 | 129 | $this->loader = LoaderFactory::getLoader(); |
130 | 130 | } |
131 | 131 | return $this->loader; |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
174 | 174 | wp_enqueue_script( |
175 | 175 | 'batch_runner_init', |
176 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
176 | + BATCH_URL.'assets/batch_runner_init.js', |
|
177 | 177 | ['batch_runner'], |
178 | 178 | EVENT_ESPRESSO_VERSION, |
179 | 179 | true |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
200 | 200 | wp_enqueue_script( |
201 | 201 | 'batch_file_runner_init', |
202 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
202 | + BATCH_URL.'assets/batch_file_runner_init.js', |
|
203 | 203 | ['batch_runner'], |
204 | 204 | EVENT_ESPRESSO_VERSION, |
205 | 205 | true |
@@ -213,7 +213,7 @@ discard block |
||
213 | 213 | wp_strip_all_tags( |
214 | 214 | __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso') |
215 | 215 | ), |
216 | - '<a href="' . $return_url . '">', |
|
216 | + '<a href="'.$return_url.'">', |
|
217 | 217 | '</a>' |
218 | 218 | ), |
219 | 219 | 'return_url' => $return_url, |
@@ -239,20 +239,20 @@ discard block |
||
239 | 239 | ); |
240 | 240 | wp_register_script( |
241 | 241 | 'progress_bar', |
242 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
242 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', |
|
243 | 243 | ['jquery'], |
244 | 244 | EVENT_ESPRESSO_VERSION, |
245 | 245 | true |
246 | 246 | ); |
247 | 247 | wp_enqueue_style( |
248 | 248 | 'progress_bar', |
249 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
249 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', |
|
250 | 250 | [], |
251 | 251 | EVENT_ESPRESSO_VERSION |
252 | 252 | ); |
253 | 253 | wp_enqueue_script( |
254 | 254 | 'batch_runner', |
255 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
255 | + EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', |
|
256 | 256 | ['progress_bar', CoreAssetManager::JS_HANDLE_CORE], |
257 | 257 | EVENT_ESPRESSO_VERSION, |
258 | 258 | true |
@@ -283,7 +283,7 @@ discard block |
||
283 | 283 | { |
284 | 284 | $request = EED_Batch::getRequest(); |
285 | 285 | if ($request->requestParamIsSet('batch') && $request->requestParamIsSet('espresso_batch')) { |
286 | - return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
286 | + return EE_MODULES.'batch/templates/batch_frontend_wrapper.template.html'; |
|
287 | 287 | } |
288 | 288 | return $template; |
289 | 289 | } |
@@ -298,11 +298,11 @@ discard block |
||
298 | 298 | public function register_admin_pages() |
299 | 299 | { |
300 | 300 | add_submenu_page( |
301 | - '', // parent slug. we don't want this to actually appear in the menu |
|
301 | + '', // parent slug. we don't want this to actually appear in the menu |
|
302 | 302 | esc_html__('Batch Job', 'event_espresso'), // page title |
303 | - 'n/a', // menu title |
|
304 | - 'read', // we want this page to actually be accessible to anyone, |
|
305 | - 'espresso_batch', // menu slug |
|
303 | + 'n/a', // menu title |
|
304 | + 'read', // we want this page to actually be accessible to anyone, |
|
305 | + 'espresso_batch', // menu slug |
|
306 | 306 | [self::instance(), 'show_admin_page'] |
307 | 307 | ); |
308 | 308 | } |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | public function show_admin_page() |
316 | 316 | { |
317 | 317 | echo EEH_Template::locate_template( |
318 | - EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
318 | + EE_MODULES.'batch/templates/batch_wrapper.template.html', |
|
319 | 319 | ['batch_request_type' => $this->batch_request_type()] |
320 | 320 | ); |
321 | 321 | } |
@@ -26,402 +26,402 @@ |
||
26 | 26 | */ |
27 | 27 | class EED_Batch extends EED_Module |
28 | 28 | { |
29 | - /** |
|
30 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
31 | - * processes data only |
|
32 | - */ |
|
33 | - const batch_job = 'job'; |
|
34 | - |
|
35 | - /** |
|
36 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
37 | - * produces a file for download |
|
38 | - */ |
|
39 | - const batch_file_job = 'file'; |
|
40 | - |
|
41 | - /** |
|
42 | - * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
43 | - * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
44 | - * at all |
|
45 | - */ |
|
46 | - const batch_not_job = 'none'; |
|
47 | - |
|
48 | - /** |
|
49 | - * |
|
50 | - * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
51 | - */ |
|
52 | - protected $_batch_request_type = null; |
|
53 | - |
|
54 | - /** |
|
55 | - * Because we want to use the response in both the localized JS and in the body |
|
56 | - * we need to make this response available between method calls |
|
57 | - * |
|
58 | - * @var JobStepResponse |
|
59 | - */ |
|
60 | - protected $_job_step_response = null; |
|
61 | - |
|
62 | - /** |
|
63 | - * @var LoaderInterface |
|
64 | - */ |
|
65 | - protected $loader; |
|
66 | - |
|
67 | - |
|
68 | - /** |
|
69 | - * Gets the batch instance |
|
70 | - * |
|
71 | - * @return EED_Module|EED_Batch |
|
72 | - * @throws EE_Error |
|
73 | - * @throws ReflectionException |
|
74 | - */ |
|
75 | - public static function instance() |
|
76 | - { |
|
77 | - return parent::get_instance(__CLASS__); |
|
78 | - } |
|
79 | - |
|
80 | - |
|
81 | - /** |
|
82 | - * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
83 | - * because it's an attack vector and there are currently no implementations |
|
84 | - * |
|
85 | - * @throws EE_Error |
|
86 | - * @throws ReflectionException |
|
87 | - */ |
|
88 | - public static function set_hooks() |
|
89 | - { |
|
90 | - // because this is a possible attack vector, let's have this disabled until |
|
91 | - // we at least have a real use for it on the frontend |
|
92 | - if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
93 | - add_action('wp_enqueue_scripts', [self::instance(), 'enqueue_scripts']); |
|
94 | - add_filter('template_include', [self::instance(), 'override_template'], 99); |
|
95 | - } |
|
96 | - } |
|
97 | - |
|
98 | - |
|
99 | - /** |
|
100 | - * Initializes some hooks for the admin in order to run batch jobs |
|
101 | - * |
|
102 | - * @throws EE_Error |
|
103 | - * @throws ReflectionException |
|
104 | - */ |
|
105 | - public static function set_hooks_admin() |
|
106 | - { |
|
107 | - add_action('admin_menu', [self::instance(), 'register_admin_pages']); |
|
108 | - add_action('admin_enqueue_scripts', [self::instance(), 'enqueue_scripts']); |
|
109 | - |
|
110 | - // ajax |
|
111 | - add_action('wp_ajax_espresso_batch_continue', [self::instance(), 'batch_continue']); |
|
112 | - add_action('wp_ajax_espresso_batch_cleanup', [self::instance(), 'batch_cleanup']); |
|
113 | - add_action('wp_ajax_nopriv_espresso_batch_continue', [self::instance(), 'batch_continue']); |
|
114 | - add_action('wp_ajax_nopriv_espresso_batch_cleanup', [self::instance(), 'batch_cleanup']); |
|
115 | - } |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return LoaderInterface |
|
120 | - * @throws InvalidArgumentException |
|
121 | - * @throws InvalidDataTypeException |
|
122 | - * @throws InvalidInterfaceException |
|
123 | - * @since 4.9.80.p |
|
124 | - */ |
|
125 | - protected function getLoader() |
|
126 | - { |
|
127 | - if (! $this->loader instanceof LoaderInterface) { |
|
128 | - $this->loader = LoaderFactory::getLoader(); |
|
129 | - } |
|
130 | - return $this->loader; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * Enqueues batch scripts on the frontend or admin, and creates a job |
|
136 | - */ |
|
137 | - public function enqueue_scripts() |
|
138 | - { |
|
139 | - $request = EED_Batch::getRequest(); |
|
140 | - if ( |
|
141 | - $request->getRequestParam('espresso_batch') |
|
142 | - || $request->getRequestParam('page') === 'espresso_batch' |
|
143 | - ) { |
|
144 | - if ( |
|
145 | - ! $request->requestParamIsSet('default_nonce') |
|
146 | - || ! wp_verify_nonce($request->getRequestParam('default_nonce'), 'default_nonce') |
|
147 | - ) { |
|
148 | - wp_die( |
|
149 | - esc_html__( |
|
150 | - 'The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', |
|
151 | - 'event_espresso' |
|
152 | - ) |
|
153 | - ); |
|
154 | - } |
|
155 | - switch ($this->batch_request_type()) { |
|
156 | - case self::batch_job: |
|
157 | - $this->enqueue_scripts_styles_batch_create(); |
|
158 | - break; |
|
159 | - case self::batch_file_job: |
|
160 | - $this->enqueue_scripts_styles_batch_file_create(); |
|
161 | - break; |
|
162 | - } |
|
163 | - } |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - /** |
|
168 | - * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
169 | - */ |
|
170 | - public function enqueue_scripts_styles_batch_create() |
|
171 | - { |
|
172 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
173 | - wp_enqueue_script( |
|
174 | - 'batch_runner_init', |
|
175 | - BATCH_URL . 'assets/batch_runner_init.js', |
|
176 | - ['batch_runner'], |
|
177 | - EVENT_ESPRESSO_VERSION, |
|
178 | - true |
|
179 | - ); |
|
180 | - wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
181 | - wp_localize_script( |
|
182 | - 'batch_runner_init', |
|
183 | - 'ee_job_i18n', |
|
184 | - [ |
|
185 | - 'return_url' => EED_Batch::getRequest()->getRequestParam('return_url', '', 'url'), |
|
186 | - ] |
|
187 | - ); |
|
188 | - } |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
193 | - */ |
|
194 | - public function enqueue_scripts_styles_batch_file_create() |
|
195 | - { |
|
196 | - $return_url = EED_Batch::getRequest()->getRequestParam('return_url', '', 'url'); |
|
197 | - // creates a job based on the request variable |
|
198 | - $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
199 | - wp_enqueue_script( |
|
200 | - 'batch_file_runner_init', |
|
201 | - BATCH_URL . 'assets/batch_file_runner_init.js', |
|
202 | - ['batch_runner'], |
|
203 | - EVENT_ESPRESSO_VERSION, |
|
204 | - true |
|
205 | - ); |
|
206 | - wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
207 | - wp_localize_script( |
|
208 | - 'batch_file_runner_init', |
|
209 | - 'ee_job_i18n', |
|
210 | - [ |
|
211 | - 'download_and_redirecting' => sprintf( |
|
212 | - wp_strip_all_tags( |
|
213 | - __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso') |
|
214 | - ), |
|
215 | - '<a href="' . $return_url . '">', |
|
216 | - '</a>' |
|
217 | - ), |
|
218 | - 'return_url' => $return_url, |
|
219 | - ] |
|
220 | - ); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * Enqueues scripts and styles common to any batch job, and creates |
|
226 | - * a job from the request data, and stores the response in the |
|
227 | - * $this->_job_step_response property |
|
228 | - * |
|
229 | - * @return JobStepResponse |
|
230 | - */ |
|
231 | - protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
232 | - { |
|
233 | - $request = EED_Batch::getRequest(); |
|
234 | - // just copy the bits of EE admin's eei18n that we need in the JS |
|
235 | - EE_Registry::$i18n_js_strings['batchJobError'] = __( |
|
236 | - 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
237 | - 'event_espresso' |
|
238 | - ); |
|
239 | - wp_register_script( |
|
240 | - 'progress_bar', |
|
241 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
242 | - ['jquery'], |
|
243 | - EVENT_ESPRESSO_VERSION, |
|
244 | - true |
|
245 | - ); |
|
246 | - wp_enqueue_style( |
|
247 | - 'progress_bar', |
|
248 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
249 | - [], |
|
250 | - EVENT_ESPRESSO_VERSION |
|
251 | - ); |
|
252 | - wp_enqueue_script( |
|
253 | - 'batch_runner', |
|
254 | - EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
255 | - ['progress_bar', CoreAssetManager::JS_HANDLE_CORE], |
|
256 | - EVENT_ESPRESSO_VERSION, |
|
257 | - true |
|
258 | - ); |
|
259 | - $job_handler_classname = $request->getRequestParam('job_handler', '', 'fqcn'); |
|
260 | - $request_data = $request->requestParams(); |
|
261 | - $request_data = array_diff_key( |
|
262 | - $request_data, |
|
263 | - array_flip(['action', 'page', 'ee', 'batch']) |
|
264 | - ); |
|
265 | - /** @var EventEspressoBatchRequest\BatchRequestProcessor $batch_runner */ |
|
266 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
267 | - // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
268 | - $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
269 | - // remember the response for later. We need it to display the page body |
|
270 | - $this->_job_step_response = $job_response; |
|
271 | - return $job_response; |
|
272 | - } |
|
273 | - |
|
274 | - |
|
275 | - /** |
|
276 | - * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
277 | - * |
|
278 | - * @param string $template |
|
279 | - * @return string |
|
280 | - */ |
|
281 | - public function override_template($template) |
|
282 | - { |
|
283 | - $request = EED_Batch::getRequest(); |
|
284 | - if ($request->requestParamIsSet('batch') && $request->requestParamIsSet('espresso_batch')) { |
|
285 | - return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
286 | - } |
|
287 | - return $template; |
|
288 | - } |
|
289 | - |
|
290 | - |
|
291 | - /** |
|
292 | - * Adds an admin page which doesn't appear in the admin menu |
|
293 | - * |
|
294 | - * @throws EE_Error |
|
295 | - * @throws ReflectionException |
|
296 | - */ |
|
297 | - public function register_admin_pages() |
|
298 | - { |
|
299 | - add_submenu_page( |
|
300 | - '', // parent slug. we don't want this to actually appear in the menu |
|
301 | - esc_html__('Batch Job', 'event_espresso'), // page title |
|
302 | - 'n/a', // menu title |
|
303 | - 'read', // we want this page to actually be accessible to anyone, |
|
304 | - 'espresso_batch', // menu slug |
|
305 | - [self::instance(), 'show_admin_page'] |
|
306 | - ); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - /** |
|
311 | - * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
312 | - * of creating the job and localizing some data |
|
313 | - */ |
|
314 | - public function show_admin_page() |
|
315 | - { |
|
316 | - echo EEH_Template::locate_template( |
|
317 | - EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
318 | - ['batch_request_type' => $this->batch_request_type()] |
|
319 | - ); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * Receives ajax calls for continuing a job |
|
325 | - */ |
|
326 | - public function batch_continue() |
|
327 | - { |
|
328 | - $job_id = EED_Batch::getRequest()->getRequestParam('job_id'); |
|
329 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
330 | - $response_obj = $batch_runner->continue_job($job_id); |
|
331 | - $this->_return_json($response_obj->to_array()); |
|
332 | - } |
|
333 | - |
|
334 | - |
|
335 | - /** |
|
336 | - * Receives the ajax call to cleanup a job |
|
337 | - * |
|
338 | - * @return void |
|
339 | - */ |
|
340 | - public function batch_cleanup() |
|
341 | - { |
|
342 | - $job_id = EED_Batch::getRequest()->getRequestParam('job_id'); |
|
343 | - $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
344 | - $response_obj = $batch_runner->cleanup_job($job_id); |
|
345 | - $this->_return_json($response_obj->to_array()); |
|
346 | - } |
|
347 | - |
|
348 | - |
|
349 | - /** |
|
350 | - * Returns a json response |
|
351 | - * |
|
352 | - * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
353 | - * |
|
354 | - * The returned json object is created from an array in the following format: |
|
355 | - * array( |
|
356 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
357 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
358 | - * We're also going to include the template args with every package (so js can pick out any specific template |
|
359 | - * args that might be included in here) |
|
360 | - * 'isEEajax' => true,//indicates this is a response from EE |
|
361 | - * ) |
|
362 | - */ |
|
363 | - protected function _return_json($data) |
|
364 | - { |
|
365 | - $json = [ |
|
366 | - 'notices' => EE_Error::get_notices(), |
|
367 | - 'data' => $data, |
|
368 | - 'isEEajax' => true |
|
369 | - // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
370 | - ]; |
|
371 | - |
|
372 | - |
|
373 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
374 | - if (null === error_get_last() || ! headers_sent()) { |
|
375 | - header('Content-Type: application/json; charset=UTF-8'); |
|
376 | - } |
|
377 | - echo wp_json_encode($json); |
|
378 | - exit(); |
|
379 | - } |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * Gets the job step response which was done during the enqueuing of scripts |
|
384 | - * |
|
385 | - * @return JobStepResponse |
|
386 | - */ |
|
387 | - public function job_step_response() |
|
388 | - { |
|
389 | - return $this->_job_step_response; |
|
390 | - } |
|
391 | - |
|
392 | - |
|
393 | - /** |
|
394 | - * Gets the batch request type indicated in the current request |
|
395 | - * |
|
396 | - * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
397 | - */ |
|
398 | - public function batch_request_type() |
|
399 | - { |
|
400 | - $request = EED_Batch::getRequest(); |
|
401 | - if ($this->_batch_request_type === null) { |
|
402 | - $batch = $request->getRequestParam('batch'); |
|
403 | - switch ($batch) { |
|
404 | - case self::batch_job: |
|
405 | - $this->_batch_request_type = self::batch_job; |
|
406 | - break; |
|
407 | - case self::batch_file_job: |
|
408 | - $this->_batch_request_type = self::batch_file_job; |
|
409 | - break; |
|
410 | - default: |
|
411 | - // if we didn't find that it was a batch request, indicate it wasn't |
|
412 | - $this->_batch_request_type = self::batch_not_job; |
|
413 | - } |
|
414 | - } |
|
415 | - return $this->_batch_request_type; |
|
416 | - } |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * Unnecessary |
|
421 | - * |
|
422 | - * @param WP $WP |
|
423 | - */ |
|
424 | - public function run($WP) |
|
425 | - { |
|
426 | - } |
|
29 | + /** |
|
30 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
31 | + * processes data only |
|
32 | + */ |
|
33 | + const batch_job = 'job'; |
|
34 | + |
|
35 | + /** |
|
36 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that |
|
37 | + * produces a file for download |
|
38 | + */ |
|
39 | + const batch_file_job = 'file'; |
|
40 | + |
|
41 | + /** |
|
42 | + * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT |
|
43 | + * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ] |
|
44 | + * at all |
|
45 | + */ |
|
46 | + const batch_not_job = 'none'; |
|
47 | + |
|
48 | + /** |
|
49 | + * |
|
50 | + * @var string 'file', or 'job', or false to indicate its not a batch request at all |
|
51 | + */ |
|
52 | + protected $_batch_request_type = null; |
|
53 | + |
|
54 | + /** |
|
55 | + * Because we want to use the response in both the localized JS and in the body |
|
56 | + * we need to make this response available between method calls |
|
57 | + * |
|
58 | + * @var JobStepResponse |
|
59 | + */ |
|
60 | + protected $_job_step_response = null; |
|
61 | + |
|
62 | + /** |
|
63 | + * @var LoaderInterface |
|
64 | + */ |
|
65 | + protected $loader; |
|
66 | + |
|
67 | + |
|
68 | + /** |
|
69 | + * Gets the batch instance |
|
70 | + * |
|
71 | + * @return EED_Module|EED_Batch |
|
72 | + * @throws EE_Error |
|
73 | + * @throws ReflectionException |
|
74 | + */ |
|
75 | + public static function instance() |
|
76 | + { |
|
77 | + return parent::get_instance(__CLASS__); |
|
78 | + } |
|
79 | + |
|
80 | + |
|
81 | + /** |
|
82 | + * Sets hooks to enable batch jobs on the frontend. Disabled by default |
|
83 | + * because it's an attack vector and there are currently no implementations |
|
84 | + * |
|
85 | + * @throws EE_Error |
|
86 | + * @throws ReflectionException |
|
87 | + */ |
|
88 | + public static function set_hooks() |
|
89 | + { |
|
90 | + // because this is a possible attack vector, let's have this disabled until |
|
91 | + // we at least have a real use for it on the frontend |
|
92 | + if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) { |
|
93 | + add_action('wp_enqueue_scripts', [self::instance(), 'enqueue_scripts']); |
|
94 | + add_filter('template_include', [self::instance(), 'override_template'], 99); |
|
95 | + } |
|
96 | + } |
|
97 | + |
|
98 | + |
|
99 | + /** |
|
100 | + * Initializes some hooks for the admin in order to run batch jobs |
|
101 | + * |
|
102 | + * @throws EE_Error |
|
103 | + * @throws ReflectionException |
|
104 | + */ |
|
105 | + public static function set_hooks_admin() |
|
106 | + { |
|
107 | + add_action('admin_menu', [self::instance(), 'register_admin_pages']); |
|
108 | + add_action('admin_enqueue_scripts', [self::instance(), 'enqueue_scripts']); |
|
109 | + |
|
110 | + // ajax |
|
111 | + add_action('wp_ajax_espresso_batch_continue', [self::instance(), 'batch_continue']); |
|
112 | + add_action('wp_ajax_espresso_batch_cleanup', [self::instance(), 'batch_cleanup']); |
|
113 | + add_action('wp_ajax_nopriv_espresso_batch_continue', [self::instance(), 'batch_continue']); |
|
114 | + add_action('wp_ajax_nopriv_espresso_batch_cleanup', [self::instance(), 'batch_cleanup']); |
|
115 | + } |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return LoaderInterface |
|
120 | + * @throws InvalidArgumentException |
|
121 | + * @throws InvalidDataTypeException |
|
122 | + * @throws InvalidInterfaceException |
|
123 | + * @since 4.9.80.p |
|
124 | + */ |
|
125 | + protected function getLoader() |
|
126 | + { |
|
127 | + if (! $this->loader instanceof LoaderInterface) { |
|
128 | + $this->loader = LoaderFactory::getLoader(); |
|
129 | + } |
|
130 | + return $this->loader; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * Enqueues batch scripts on the frontend or admin, and creates a job |
|
136 | + */ |
|
137 | + public function enqueue_scripts() |
|
138 | + { |
|
139 | + $request = EED_Batch::getRequest(); |
|
140 | + if ( |
|
141 | + $request->getRequestParam('espresso_batch') |
|
142 | + || $request->getRequestParam('page') === 'espresso_batch' |
|
143 | + ) { |
|
144 | + if ( |
|
145 | + ! $request->requestParamIsSet('default_nonce') |
|
146 | + || ! wp_verify_nonce($request->getRequestParam('default_nonce'), 'default_nonce') |
|
147 | + ) { |
|
148 | + wp_die( |
|
149 | + esc_html__( |
|
150 | + 'The link you clicked to start the batch job has expired. Please go back and refresh the previous page.', |
|
151 | + 'event_espresso' |
|
152 | + ) |
|
153 | + ); |
|
154 | + } |
|
155 | + switch ($this->batch_request_type()) { |
|
156 | + case self::batch_job: |
|
157 | + $this->enqueue_scripts_styles_batch_create(); |
|
158 | + break; |
|
159 | + case self::batch_file_job: |
|
160 | + $this->enqueue_scripts_styles_batch_file_create(); |
|
161 | + break; |
|
162 | + } |
|
163 | + } |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + /** |
|
168 | + * Create a batch job, enqueues a script to run it, and localizes some data for it |
|
169 | + */ |
|
170 | + public function enqueue_scripts_styles_batch_create() |
|
171 | + { |
|
172 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
173 | + wp_enqueue_script( |
|
174 | + 'batch_runner_init', |
|
175 | + BATCH_URL . 'assets/batch_runner_init.js', |
|
176 | + ['batch_runner'], |
|
177 | + EVENT_ESPRESSO_VERSION, |
|
178 | + true |
|
179 | + ); |
|
180 | + wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array()); |
|
181 | + wp_localize_script( |
|
182 | + 'batch_runner_init', |
|
183 | + 'ee_job_i18n', |
|
184 | + [ |
|
185 | + 'return_url' => EED_Batch::getRequest()->getRequestParam('return_url', '', 'url'), |
|
186 | + ] |
|
187 | + ); |
|
188 | + } |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it |
|
193 | + */ |
|
194 | + public function enqueue_scripts_styles_batch_file_create() |
|
195 | + { |
|
196 | + $return_url = EED_Batch::getRequest()->getRequestParam('return_url', '', 'url'); |
|
197 | + // creates a job based on the request variable |
|
198 | + $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job(); |
|
199 | + wp_enqueue_script( |
|
200 | + 'batch_file_runner_init', |
|
201 | + BATCH_URL . 'assets/batch_file_runner_init.js', |
|
202 | + ['batch_runner'], |
|
203 | + EVENT_ESPRESSO_VERSION, |
|
204 | + true |
|
205 | + ); |
|
206 | + wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array()); |
|
207 | + wp_localize_script( |
|
208 | + 'batch_file_runner_init', |
|
209 | + 'ee_job_i18n', |
|
210 | + [ |
|
211 | + 'download_and_redirecting' => sprintf( |
|
212 | + wp_strip_all_tags( |
|
213 | + __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso') |
|
214 | + ), |
|
215 | + '<a href="' . $return_url . '">', |
|
216 | + '</a>' |
|
217 | + ), |
|
218 | + 'return_url' => $return_url, |
|
219 | + ] |
|
220 | + ); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * Enqueues scripts and styles common to any batch job, and creates |
|
226 | + * a job from the request data, and stores the response in the |
|
227 | + * $this->_job_step_response property |
|
228 | + * |
|
229 | + * @return JobStepResponse |
|
230 | + */ |
|
231 | + protected function _enqueue_batch_job_scripts_and_styles_and_start_job() |
|
232 | + { |
|
233 | + $request = EED_Batch::getRequest(); |
|
234 | + // just copy the bits of EE admin's eei18n that we need in the JS |
|
235 | + EE_Registry::$i18n_js_strings['batchJobError'] = __( |
|
236 | + 'An error occurred and the job has been stopped. Please refresh the page to try again.', |
|
237 | + 'event_espresso' |
|
238 | + ); |
|
239 | + wp_register_script( |
|
240 | + 'progress_bar', |
|
241 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', |
|
242 | + ['jquery'], |
|
243 | + EVENT_ESPRESSO_VERSION, |
|
244 | + true |
|
245 | + ); |
|
246 | + wp_enqueue_style( |
|
247 | + 'progress_bar', |
|
248 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', |
|
249 | + [], |
|
250 | + EVENT_ESPRESSO_VERSION |
|
251 | + ); |
|
252 | + wp_enqueue_script( |
|
253 | + 'batch_runner', |
|
254 | + EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', |
|
255 | + ['progress_bar', CoreAssetManager::JS_HANDLE_CORE], |
|
256 | + EVENT_ESPRESSO_VERSION, |
|
257 | + true |
|
258 | + ); |
|
259 | + $job_handler_classname = $request->getRequestParam('job_handler', '', 'fqcn'); |
|
260 | + $request_data = $request->requestParams(); |
|
261 | + $request_data = array_diff_key( |
|
262 | + $request_data, |
|
263 | + array_flip(['action', 'page', 'ee', 'batch']) |
|
264 | + ); |
|
265 | + /** @var EventEspressoBatchRequest\BatchRequestProcessor $batch_runner */ |
|
266 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
267 | + // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' |
|
268 | + $job_response = $batch_runner->create_job($job_handler_classname, $request_data); |
|
269 | + // remember the response for later. We need it to display the page body |
|
270 | + $this->_job_step_response = $job_response; |
|
271 | + return $job_response; |
|
272 | + } |
|
273 | + |
|
274 | + |
|
275 | + /** |
|
276 | + * If we are doing a frontend batch job, this makes it so WP shows our template's HTML |
|
277 | + * |
|
278 | + * @param string $template |
|
279 | + * @return string |
|
280 | + */ |
|
281 | + public function override_template($template) |
|
282 | + { |
|
283 | + $request = EED_Batch::getRequest(); |
|
284 | + if ($request->requestParamIsSet('batch') && $request->requestParamIsSet('espresso_batch')) { |
|
285 | + return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html'; |
|
286 | + } |
|
287 | + return $template; |
|
288 | + } |
|
289 | + |
|
290 | + |
|
291 | + /** |
|
292 | + * Adds an admin page which doesn't appear in the admin menu |
|
293 | + * |
|
294 | + * @throws EE_Error |
|
295 | + * @throws ReflectionException |
|
296 | + */ |
|
297 | + public function register_admin_pages() |
|
298 | + { |
|
299 | + add_submenu_page( |
|
300 | + '', // parent slug. we don't want this to actually appear in the menu |
|
301 | + esc_html__('Batch Job', 'event_espresso'), // page title |
|
302 | + 'n/a', // menu title |
|
303 | + 'read', // we want this page to actually be accessible to anyone, |
|
304 | + 'espresso_batch', // menu slug |
|
305 | + [self::instance(), 'show_admin_page'] |
|
306 | + ); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + /** |
|
311 | + * Renders the admin page, after most of the work was already done during enqueuing scripts |
|
312 | + * of creating the job and localizing some data |
|
313 | + */ |
|
314 | + public function show_admin_page() |
|
315 | + { |
|
316 | + echo EEH_Template::locate_template( |
|
317 | + EE_MODULES . 'batch/templates/batch_wrapper.template.html', |
|
318 | + ['batch_request_type' => $this->batch_request_type()] |
|
319 | + ); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * Receives ajax calls for continuing a job |
|
325 | + */ |
|
326 | + public function batch_continue() |
|
327 | + { |
|
328 | + $job_id = EED_Batch::getRequest()->getRequestParam('job_id'); |
|
329 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
330 | + $response_obj = $batch_runner->continue_job($job_id); |
|
331 | + $this->_return_json($response_obj->to_array()); |
|
332 | + } |
|
333 | + |
|
334 | + |
|
335 | + /** |
|
336 | + * Receives the ajax call to cleanup a job |
|
337 | + * |
|
338 | + * @return void |
|
339 | + */ |
|
340 | + public function batch_cleanup() |
|
341 | + { |
|
342 | + $job_id = EED_Batch::getRequest()->getRequestParam('job_id'); |
|
343 | + $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor'); |
|
344 | + $response_obj = $batch_runner->cleanup_job($job_id); |
|
345 | + $this->_return_json($response_obj->to_array()); |
|
346 | + } |
|
347 | + |
|
348 | + |
|
349 | + /** |
|
350 | + * Returns a json response |
|
351 | + * |
|
352 | + * @param array $data The data we want to send echo via in the JSON response's "data" element |
|
353 | + * |
|
354 | + * The returned json object is created from an array in the following format: |
|
355 | + * array( |
|
356 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
357 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. |
|
358 | + * We're also going to include the template args with every package (so js can pick out any specific template |
|
359 | + * args that might be included in here) |
|
360 | + * 'isEEajax' => true,//indicates this is a response from EE |
|
361 | + * ) |
|
362 | + */ |
|
363 | + protected function _return_json($data) |
|
364 | + { |
|
365 | + $json = [ |
|
366 | + 'notices' => EE_Error::get_notices(), |
|
367 | + 'data' => $data, |
|
368 | + 'isEEajax' => true |
|
369 | + // special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
370 | + ]; |
|
371 | + |
|
372 | + |
|
373 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
374 | + if (null === error_get_last() || ! headers_sent()) { |
|
375 | + header('Content-Type: application/json; charset=UTF-8'); |
|
376 | + } |
|
377 | + echo wp_json_encode($json); |
|
378 | + exit(); |
|
379 | + } |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * Gets the job step response which was done during the enqueuing of scripts |
|
384 | + * |
|
385 | + * @return JobStepResponse |
|
386 | + */ |
|
387 | + public function job_step_response() |
|
388 | + { |
|
389 | + return $this->_job_step_response; |
|
390 | + } |
|
391 | + |
|
392 | + |
|
393 | + /** |
|
394 | + * Gets the batch request type indicated in the current request |
|
395 | + * |
|
396 | + * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job |
|
397 | + */ |
|
398 | + public function batch_request_type() |
|
399 | + { |
|
400 | + $request = EED_Batch::getRequest(); |
|
401 | + if ($this->_batch_request_type === null) { |
|
402 | + $batch = $request->getRequestParam('batch'); |
|
403 | + switch ($batch) { |
|
404 | + case self::batch_job: |
|
405 | + $this->_batch_request_type = self::batch_job; |
|
406 | + break; |
|
407 | + case self::batch_file_job: |
|
408 | + $this->_batch_request_type = self::batch_file_job; |
|
409 | + break; |
|
410 | + default: |
|
411 | + // if we didn't find that it was a batch request, indicate it wasn't |
|
412 | + $this->_batch_request_type = self::batch_not_job; |
|
413 | + } |
|
414 | + } |
|
415 | + return $this->_batch_request_type; |
|
416 | + } |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * Unnecessary |
|
421 | + * |
|
422 | + * @param WP $WP |
|
423 | + */ |
|
424 | + public function run($WP) |
|
425 | + { |
|
426 | + } |
|
427 | 427 | } |
@@ -15,7 +15,7 @@ |
||
15 | 15 | ), |
16 | 16 | '<a href="https://eventespresso.com/wp-login.php">', |
17 | 17 | '</a>' |
18 | - );?> |
|
18 | + ); ?> |
|
19 | 19 | </p> |
20 | 20 | <p class="ee-attention"> |
21 | 21 | <?php printf( |
@@ -9,77 +9,77 @@ |
||
9 | 9 | </p> |
10 | 10 | <p> |
11 | 11 | <?php printf( |
12 | - esc_html__( |
|
13 | - 'Enter your support license key in this field to benefit from one-click updates. To manage your support license key, please %1$slogin to your Event Espresso account%2$s. Then click on Edit Account Details which appears in the left sidebar menu.', |
|
14 | - 'event_espresso' |
|
15 | - ), |
|
16 | - '<a href="https://eventespresso.com/wp-login.php">', |
|
17 | - '</a>' |
|
18 | - );?> |
|
12 | + esc_html__( |
|
13 | + 'Enter your support license key in this field to benefit from one-click updates. To manage your support license key, please %1$slogin to your Event Espresso account%2$s. Then click on Edit Account Details which appears in the left sidebar menu.', |
|
14 | + 'event_espresso' |
|
15 | + ), |
|
16 | + '<a href="https://eventespresso.com/wp-login.php">', |
|
17 | + '</a>' |
|
18 | + );?> |
|
19 | 19 | </p> |
20 | 20 | <p class="ee-attention"> |
21 | 21 | <?php printf( |
22 | - esc_html__( |
|
23 | - 'Site license keys are now called support license keys. Your support license key should only be entered on live/production sites. If this is a development or test site, %sdo not%s enter your support license key.', |
|
24 | - 'event_espresso' |
|
25 | - ), |
|
26 | - '<strong>', |
|
27 | - '</strong>' |
|
28 | - ); ?> |
|
22 | + esc_html__( |
|
23 | + 'Site license keys are now called support license keys. Your support license key should only be entered on live/production sites. If this is a development or test site, %sdo not%s enter your support license key.', |
|
24 | + 'event_espresso' |
|
25 | + ), |
|
26 | + '<strong>', |
|
27 | + '</strong>' |
|
28 | + ); ?> |
|
29 | 29 | </p> |
30 | 30 | <p> |
31 | 31 | <strong><?php esc_html_e('Contact Information', 'event_espresso'); ?></strong> |
32 | 32 | </p> |
33 | 33 | <p> |
34 | 34 | <?php esc_html_e( |
35 | - 'Enter information about your organization here. Be sure to keep your information up-to-date.', |
|
36 | - 'event_espresso' |
|
37 | - ); ?><br /> |
|
35 | + 'Enter information about your organization here. Be sure to keep your information up-to-date.', |
|
36 | + 'event_espresso' |
|
37 | + ); ?><br /> |
|
38 | 38 | <?php esc_html_e( |
39 | - 'Changing your country on this page will also change your country on the Countries page. This will affect your currency options which are used through Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP.', |
|
40 | - 'event_espresso' |
|
41 | - ); ?> |
|
39 | + 'Changing your country on this page will also change your country on the Countries page. This will affect your currency options which are used through Event Espresso. For example, if your country is currently set to United States, then your currency is USD. If you were to switch your country to United Kingdom, then your currency would change to GBP.', |
|
40 | + 'event_espresso' |
|
41 | + ); ?> |
|
42 | 42 | </p> |
43 | 43 | <p> |
44 | 44 | <strong><?php esc_html_e('Company Logo', 'event_espresso'); ?></strong> |
45 | 45 | </p> |
46 | 46 | <p> |
47 | 47 | <?php esc_html_e( |
48 | - 'You can upload a new logo here. We recommend an image that is 400 pixels wide or smaller. Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
49 | - 'event_espresso' |
|
50 | - ); ?> |
|
48 | + 'You can upload a new logo here. We recommend an image that is 400 pixels wide or smaller. Your logo will be used on custom invoices, tickets, certificates, and payment templates.', |
|
49 | + 'event_espresso' |
|
50 | + ); ?> |
|
51 | 51 | </p> |
52 | 52 | <p> |
53 | 53 | <strong><?php esc_html_e('Social Links', 'event_espresso'); ?></strong> |
54 | 54 | </p> |
55 | 55 | <p> |
56 | 56 | <?php esc_html_e( |
57 | - 'These URLs can be displayed automatically within your emails (using shortcodes) and front-end templates (using template tags).', |
|
58 | - 'event_espresso' |
|
59 | - ); ?> |
|
57 | + 'These URLs can be displayed automatically within your emails (using shortcodes) and front-end templates (using template tags).', |
|
58 | + 'event_espresso' |
|
59 | + ); ?> |
|
60 | 60 | </p> |
61 | 61 | <p> |
62 | 62 | <strong><?php esc_html_e('User eXperience Improvement Program (UXIP)', 'event_espresso'); ?></strong> |
63 | 63 | </p> |
64 | 64 | <p> |
65 | 65 | <?php esc_html_e( |
66 | - 'You can take part in making Event Espresso better! Your information will never be sold, traded, or misused in any way. This programs is voluntary and you can opt out at any time.', |
|
67 | - 'event_espresso' |
|
68 | - ); ?> |
|
66 | + 'You can take part in making Event Espresso better! Your information will never be sold, traded, or misused in any way. This programs is voluntary and you can opt out at any time.', |
|
67 | + 'event_espresso' |
|
68 | + ); ?> |
|
69 | 69 | </p> |
70 | 70 | <p> |
71 | 71 | <strong><?php esc_html_e('Recommendations', 'event_espresso'); ?></strong> |
72 | 72 | <br /> |
73 | 73 | <?php esc_html_e( |
74 | - 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
75 | - 'event_espresso' |
|
76 | - ); ?> |
|
74 | + 'To learn more about the options on this page, take a look at the different tabs that appear on the left side of the page.', |
|
75 | + 'event_espresso' |
|
76 | + ); ?> |
|
77 | 77 | </p> |
78 | 78 | <p> |
79 | 79 | <strong><?php esc_html_e('Screen Options', 'event_espresso'); ?></strong> |
80 | 80 | <br /> |
81 | 81 | <?php esc_html_e( |
82 | - 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
83 | - 'event_espresso' |
|
84 | - ); ?> |
|
82 | + 'You can customize the information that is shown on this page by toggling the Screen Options tab. Then you can add or remove checkmarks to hide or show certain content.', |
|
83 | + 'event_espresso' |
|
84 | + ); ?> |
|
85 | 85 | </p> |
86 | 86 | \ No newline at end of file |
@@ -69,7 +69,7 @@ |
||
69 | 69 | $keys_only = empty( |
70 | 70 | array_filter( |
71 | 71 | array_values($data_value), |
72 | - function ($v) { |
|
72 | + function($v) { |
|
73 | 73 | return $v !== null && (is_array($v) || trim($v) !== ''); |
74 | 74 | } |
75 | 75 | ) |
@@ -19,38 +19,38 @@ discard block |
||
19 | 19 | */ |
20 | 20 | function ee_recurse_into_array_for_display($data, $depth = 0, $td = true) |
21 | 21 | { |
22 | - if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
23 | - // is_object($incomplete_class) actually returns false, hence why we check for it |
|
24 | - $data = json_decode(json_encode($data), true); |
|
25 | - } |
|
26 | - if (empty($data)) { |
|
27 | - return; |
|
28 | - } |
|
29 | - if (is_array($data)) { |
|
30 | - $depth++; |
|
31 | - ksort($data, SORT_NATURAL | SORT_FLAG_CASE); |
|
32 | - if (EEH_Array::is_associative_array($data)) { ?> |
|
22 | + if (is_object($data) || $data instanceof __PHP_Incomplete_Class) { |
|
23 | + // is_object($incomplete_class) actually returns false, hence why we check for it |
|
24 | + $data = json_decode(json_encode($data), true); |
|
25 | + } |
|
26 | + if (empty($data)) { |
|
27 | + return; |
|
28 | + } |
|
29 | + if (is_array($data)) { |
|
30 | + $depth++; |
|
31 | + ksort($data, SORT_NATURAL | SORT_FLAG_CASE); |
|
32 | + if (EEH_Array::is_associative_array($data)) { ?> |
|
33 | 33 | <table class='ee-system-stati ee-system-stati-<?php echo absint($depth); ?>'> |
34 | 34 | <tbody> |
35 | 35 | <?php foreach ($data as $data_key => $data_value) { |
36 | - // if the value is a single element array with no key, |
|
37 | - // and the value is a primitive (not an array, object, etc.) |
|
38 | - if ( |
|
39 | - is_array($data_value) |
|
40 | - && count($data_value) === 1 |
|
41 | - && empty(key($data_value)) |
|
42 | - && is_scalar(reset($data_value)) |
|
43 | - ) { |
|
44 | - ?> |
|
36 | + // if the value is a single element array with no key, |
|
37 | + // and the value is a primitive (not an array, object, etc.) |
|
38 | + if ( |
|
39 | + is_array($data_value) |
|
40 | + && count($data_value) === 1 |
|
41 | + && empty(key($data_value)) |
|
42 | + && is_scalar(reset($data_value)) |
|
43 | + ) { |
|
44 | + ?> |
|
45 | 45 | <tr> |
46 | 46 | <td class="ee-system-stati-value" colspan="2"> |
47 | 47 | <?php echo esc_html(reset($data_value)); ?> |
48 | 48 | </td> |
49 | 49 | </tr> |
50 | 50 | <?php |
51 | - continue; |
|
52 | - } |
|
53 | - ?> |
|
51 | + continue; |
|
52 | + } |
|
53 | + ?> |
|
54 | 54 | <tr> |
55 | 55 | <td class='ee-system-stati-key'> |
56 | 56 | <span class="ee-system-stati-label"> |
@@ -65,31 +65,31 @@ discard block |
||
65 | 65 | <?php if (is_scalar($data_value)) { ?> |
66 | 66 | <?php ee_recurse_into_array_for_display($data_value, $depth); ?> |
67 | 67 | <?php } else { |
68 | - if (is_array($data_value) && count($data_value) === 1) { |
|
69 | - // verify that values have been set |
|
70 | - $keys_only = empty( |
|
71 | - array_filter( |
|
72 | - array_values($data_value), |
|
73 | - function ($v) { |
|
74 | - return $v !== null && (is_array($v) || trim($v) !== ''); |
|
75 | - } |
|
76 | - ) |
|
77 | - ); |
|
78 | - // if the array only consists of keys (no values) |
|
79 | - if ($keys_only) { |
|
80 | - // then use keys for values |
|
81 | - $data_value = array_keys($data_value); |
|
82 | - // but if there is only one value now |
|
83 | - if (count($data_value) === 1) { |
|
84 | - // then pass that single value back into this function |
|
85 | - // this prevents extra empty layers of nothing being added to the output |
|
86 | - ee_recurse_into_array_for_display(reset($data_value), $depth); |
|
87 | - // need to finish the row off though |
|
88 | - echo '</tr>'; |
|
89 | - continue; |
|
90 | - } |
|
91 | - } |
|
92 | - } ?> |
|
68 | + if (is_array($data_value) && count($data_value) === 1) { |
|
69 | + // verify that values have been set |
|
70 | + $keys_only = empty( |
|
71 | + array_filter( |
|
72 | + array_values($data_value), |
|
73 | + function ($v) { |
|
74 | + return $v !== null && (is_array($v) || trim($v) !== ''); |
|
75 | + } |
|
76 | + ) |
|
77 | + ); |
|
78 | + // if the array only consists of keys (no values) |
|
79 | + if ($keys_only) { |
|
80 | + // then use keys for values |
|
81 | + $data_value = array_keys($data_value); |
|
82 | + // but if there is only one value now |
|
83 | + if (count($data_value) === 1) { |
|
84 | + // then pass that single value back into this function |
|
85 | + // this prevents extra empty layers of nothing being added to the output |
|
86 | + ee_recurse_into_array_for_display(reset($data_value), $depth); |
|
87 | + // need to finish the row off though |
|
88 | + echo '</tr>'; |
|
89 | + continue; |
|
90 | + } |
|
91 | + } |
|
92 | + } ?> |
|
93 | 93 | <td class="ee-system-stati-sub-values"> |
94 | 94 | <?php ee_recurse_into_array_for_display($data_value, $depth); ?> |
95 | 95 | </td> |
@@ -107,19 +107,19 @@ discard block |
||
107 | 107 | <?php } ?> |
108 | 108 | </ul> |
109 | 109 | <?php } else { |
110 | - // there's no key (label) and there's only one value, |
|
111 | - // so let's just pass that value back into this function, |
|
112 | - // but reset the depth back to where it was. |
|
113 | - // this prevents extra empty layers of nothing being added to the output |
|
114 | - $depth--; |
|
115 | - ee_recurse_into_array_for_display(reset($data), $depth, false); |
|
116 | - } |
|
117 | - } else { |
|
118 | - echo ($td ? '<td class="ee-system-stati-value">' : ''); |
|
119 | - // simple value |
|
120 | - echo wp_kses($data, AllowedTags::getAllowedTags()); |
|
121 | - echo ($td ? '</td>' : ''); |
|
122 | - } |
|
110 | + // there's no key (label) and there's only one value, |
|
111 | + // so let's just pass that value back into this function, |
|
112 | + // but reset the depth back to where it was. |
|
113 | + // this prevents extra empty layers of nothing being added to the output |
|
114 | + $depth--; |
|
115 | + ee_recurse_into_array_for_display(reset($data), $depth, false); |
|
116 | + } |
|
117 | + } else { |
|
118 | + echo ($td ? '<td class="ee-system-stati-value">' : ''); |
|
119 | + // simple value |
|
120 | + echo wp_kses($data, AllowedTags::getAllowedTags()); |
|
121 | + echo ($td ? '</td>' : ''); |
|
122 | + } |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | ?> |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | // load initial stuff. |
101 | 101 | $this->_set_file_and_folder_name(); |
102 | 102 | $this->_set_menu_map(); |
103 | - if (! $this->verifyMenuMapSet()) { |
|
103 | + if ( ! $this->verifyMenuMapSet()) { |
|
104 | 104 | return; |
105 | 105 | } |
106 | 106 | // set default capability |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | { |
141 | 141 | if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
142 | 142 | EE_Error::doing_it_wrong( |
143 | - get_class($this) . '::$_menu_map', |
|
143 | + get_class($this).'::$_menu_map', |
|
144 | 144 | sprintf( |
145 | 145 | esc_html__( |
146 | 146 | 'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | { |
179 | 179 | wp_register_style( |
180 | 180 | 'espresso_menu', |
181 | - EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
181 | + EE_ADMIN_URL.'assets/admin-menu-styles.css', |
|
182 | 182 | ['dashicons'], |
183 | 183 | EVENT_ESPRESSO_VERSION |
184 | 184 | ); |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | protected function _set_capability() |
206 | 206 | { |
207 | 207 | $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
208 | - $this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability); |
|
208 | + $this->capability = apply_filters('FHEE_'.$this->_menu_map->menu_slug.'_capability', $capability); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -221,7 +221,7 @@ discard block |
||
221 | 221 | { |
222 | 222 | // let's check user access first |
223 | 223 | $this->_check_user_access(); |
224 | - if (! is_object($this->_loaded_page_object)) { |
|
224 | + if ( ! is_object($this->_loaded_page_object)) { |
|
225 | 225 | return; |
226 | 226 | } |
227 | 227 | $this->_loaded_page_object->route_admin_request(); |
@@ -234,15 +234,15 @@ discard block |
||
234 | 234 | */ |
235 | 235 | public function set_page_dependencies($wp_page_slug) |
236 | 236 | { |
237 | - if (! $this->_load_page) { |
|
237 | + if ( ! $this->_load_page) { |
|
238 | 238 | return; |
239 | 239 | } |
240 | - if (! is_object($this->_loaded_page_object)) { |
|
240 | + if ( ! is_object($this->_loaded_page_object)) { |
|
241 | 241 | $msg[] = esc_html__( |
242 | 242 | 'We can\'t load the page because we\'re missing a valid page object that tells us what to load', |
243 | 243 | 'event_espresso' |
244 | 244 | ); |
245 | - $msg[] = $msg[0] . "\r\n" |
|
245 | + $msg[] = $msg[0]."\r\n" |
|
246 | 246 | . sprintf( |
247 | 247 | esc_html__( |
248 | 248 | 'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', |
@@ -250,15 +250,15 @@ discard block |
||
250 | 250 | ), |
251 | 251 | $this->_file_name, |
252 | 252 | $this->_file_name, |
253 | - $this->_folder_path . $this->_file_name, |
|
253 | + $this->_folder_path.$this->_file_name, |
|
254 | 254 | $this->_menu_map->menu_slug |
255 | 255 | ); |
256 | 256 | throw new EE_Error(implode('||', $msg)); |
257 | 257 | } |
258 | 258 | $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
259 | - $page_hook = 'load-' . $wp_page_slug; |
|
259 | + $page_hook = 'load-'.$wp_page_slug; |
|
260 | 260 | // hook into page load hook so all page specific stuff gets loaded. |
261 | - if (! empty($wp_page_slug)) { |
|
261 | + if ( ! empty($wp_page_slug)) { |
|
262 | 262 | add_action($page_hook, [$this->_loaded_page_object, 'load_page_dependencies']); |
263 | 263 | } |
264 | 264 | } |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | foreach ($bt as $index => $values) { |
295 | 295 | if (isset($values['class']) && $values['class'] == $class) { |
296 | 296 | $file_index = $index - 1; |
297 | - $this->_folder_name = basename(dirname($bt[ $file_index ]['file'])); |
|
298 | - if (! empty($this->_folder_name)) { |
|
297 | + $this->_folder_name = basename(dirname($bt[$file_index]['file'])); |
|
298 | + if ( ! empty($this->_folder_name)) { |
|
299 | 299 | break; |
300 | 300 | } |
301 | 301 | } |
302 | 302 | } |
303 | - $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/'; |
|
303 | + $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.'/'; |
|
304 | 304 | $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name); |
305 | 305 | $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name)); |
306 | 306 | $this->_file_name = str_replace(' ', '_', $this->_file_name); |
@@ -331,17 +331,17 @@ discard block |
||
331 | 331 | . $this->_file_name |
332 | 332 | . '_Hooks_Extend.class.php' |
333 | 333 | ); |
334 | - $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend); |
|
334 | + $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend); |
|
335 | 335 | } |
336 | 336 | // loop through decaf folders |
337 | 337 | $hook_files_glob_path = apply_filters( |
338 | 338 | 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', |
339 | - $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' |
|
339 | + $this->_folder_path.'*'.$this->_file_name.'_Hooks.class.php' |
|
340 | 340 | ); |
341 | - $this->_hook_paths = array_merge( |
|
341 | + $this->_hook_paths = array_merge( |
|
342 | 342 | $this->_register_hook_files($hook_files_glob_path), |
343 | 343 | $this->_hook_paths |
344 | - ); // making sure any extended hook paths are later in the array than the core hook paths! |
|
344 | + ); // making sure any extended hook paths are later in the array than the core hook paths! |
|
345 | 345 | return $this->_hook_paths; |
346 | 346 | } |
347 | 347 | |
@@ -355,11 +355,11 @@ discard block |
||
355 | 355 | foreach ($hook_paths as $file) { |
356 | 356 | // lets get the linked admin. |
357 | 357 | $hook_file = $extend |
358 | - ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file) |
|
358 | + ? str_replace(EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.'/', '', $file) |
|
359 | 359 | : str_replace($this->_folder_path, '', $file); |
360 | 360 | $replace = $extend |
361 | - ? '_' . $this->_file_name . '_Hooks_Extend.class.php' |
|
362 | - : '_' . $this->_file_name . '_Hooks.class.php'; |
|
361 | + ? '_'.$this->_file_name.'_Hooks_Extend.class.php' |
|
362 | + : '_'.$this->_file_name.'_Hooks.class.php'; |
|
363 | 363 | $rel_admin = str_replace($replace, '', $hook_file); |
364 | 364 | $rel_admin = strtolower($rel_admin); |
365 | 365 | // make sure we haven't already got a hook setup for this page path |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | continue; |
368 | 368 | } |
369 | 369 | $this->hook_file = $hook_file; |
370 | - $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
|
370 | + $rel_admin_hook = 'FHEE_do_other_page_hooks_'.$rel_admin; |
|
371 | 371 | add_filter($rel_admin_hook, [$this, 'load_admin_hook']); |
372 | 372 | $this->_files_hooked[] = $rel_admin; |
373 | 373 | } |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $this->_load_page = true; |
402 | 402 | |
403 | 403 | // we don't need to do a page_request check here because it's only called via WP menu system. |
404 | - $admin_page = $this->_file_name . '_Admin_Page'; |
|
404 | + $admin_page = $this->_file_name.'_Admin_Page'; |
|
405 | 405 | $hook_suffix = "{$menu_slug}_{$admin_page}"; |
406 | 406 | $admin_page = apply_filters( |
407 | 407 | "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", |
@@ -411,14 +411,14 @@ discard block |
||
411 | 411 | return; |
412 | 412 | } |
413 | 413 | // define requested admin page class name then load the file and instantiate |
414 | - $path_to_file = str_replace(['\\', '/'], '/', $this->_folder_path . $admin_page . '.core.php'); |
|
414 | + $path_to_file = str_replace(['\\', '/'], '/', $this->_folder_path.$admin_page.'.core.php'); |
|
415 | 415 | // so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be: |
416 | 416 | // FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
417 | 417 | $path_to_file = apply_filters( |
418 | 418 | "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", |
419 | 419 | $path_to_file |
420 | 420 | ); |
421 | - if (! is_readable($path_to_file)) { |
|
421 | + if ( ! is_readable($path_to_file)) { |
|
422 | 422 | return; |
423 | 423 | } |
424 | 424 | // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | |
435 | 435 | public function get_admin_page_name() |
436 | 436 | { |
437 | - return $this->_file_name . '_Admin_Page'; |
|
437 | + return $this->_file_name.'_Admin_Page'; |
|
438 | 438 | } |
439 | 439 | |
440 | 440 |
@@ -16,451 +16,451 @@ |
||
16 | 16 | */ |
17 | 17 | abstract class EE_Admin_Page_Init extends EE_Base |
18 | 18 | { |
19 | - // identity properties (set in _set_defaults and _set_init_properties) |
|
20 | - public $label; |
|
19 | + // identity properties (set in _set_defaults and _set_init_properties) |
|
20 | + public $label; |
|
21 | 21 | |
22 | - /** |
|
23 | - * Menu map has a capability. However, this allows admin pages to have separate capability requirements for menus |
|
24 | - * and accessing pages. If capability is NOT set, then it defaults to the menu_map capability. |
|
25 | - * |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - public $capability; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * This holds the menu map object for this admin page. |
|
33 | - * |
|
34 | - * @var EE_Admin_Page_Menu_Map |
|
35 | - */ |
|
36 | - protected $_menu_map; |
|
37 | - |
|
38 | - /** |
|
39 | - * deprecated |
|
40 | - */ |
|
41 | - public $menu_label; |
|
42 | - |
|
43 | - public $menu_slug; |
|
44 | - |
|
45 | - |
|
46 | - // set in _set_defaults |
|
47 | - protected $_folder_name; |
|
48 | - |
|
49 | - protected $_folder_path; |
|
50 | - |
|
51 | - protected $_file_name; |
|
52 | - |
|
53 | - public $hook_file; |
|
54 | - |
|
55 | - protected $_wp_page_slug; |
|
56 | - |
|
57 | - protected $_routing; |
|
58 | - |
|
59 | - |
|
60 | - // will hold page object. |
|
61 | - protected $_loaded_page_object; |
|
62 | - |
|
63 | - |
|
64 | - // for caf |
|
65 | - protected $_files_hooked; |
|
66 | - |
|
67 | - protected $_hook_paths; |
|
68 | - |
|
69 | - // load_page? |
|
70 | - private $_load_page; |
|
71 | - |
|
72 | - /** |
|
73 | - * @var LoaderInterface |
|
74 | - */ |
|
75 | - protected $loader; |
|
76 | - |
|
77 | - /** |
|
78 | - * @var RequestInterface |
|
79 | - */ |
|
80 | - protected $request; |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * @Constructor |
|
85 | - * @return void |
|
86 | - */ |
|
87 | - public function __construct(RequestInterface $request = null) |
|
88 | - { |
|
89 | - $this->loader = LoaderFactory::getLoader(); |
|
90 | - $this->request = $request instanceof RequestInterface |
|
91 | - ? $request |
|
92 | - : $this->loader->getShared(RequestInterface::class); |
|
93 | - // set global defaults |
|
94 | - $this->_set_defaults(); |
|
95 | - // set properties that are always available with objects. |
|
96 | - $this->_set_init_properties(); |
|
97 | - // global styles/scripts across all wp admin pages |
|
98 | - add_action('admin_enqueue_scripts', [$this, 'load_wp_global_scripts_styles'], 5); |
|
99 | - // load initial stuff. |
|
100 | - $this->_set_file_and_folder_name(); |
|
101 | - $this->_set_menu_map(); |
|
102 | - if (! $this->verifyMenuMapSet()) { |
|
103 | - return; |
|
104 | - } |
|
105 | - // set default capability |
|
106 | - $this->_set_capability(); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * _set_init_properties |
|
112 | - * Child classes use to set the following properties: |
|
113 | - * $label |
|
114 | - * |
|
115 | - * @abstract |
|
116 | - * @return void |
|
117 | - */ |
|
118 | - abstract protected function _set_init_properties(); |
|
119 | - |
|
120 | - |
|
121 | - /** |
|
122 | - * _set_menu_map is a function that child classes use to set the menu_map property (which should be an instance of |
|
123 | - * EE_Admin_Page_Menu_Map. Their menu can either be EE_Admin_Page_Main_Menu or EE_Admin_Page_Sub_Menu. |
|
124 | - * |
|
125 | - * @since 4.4.0 |
|
126 | - * @ return void. |
|
127 | - */ |
|
128 | - protected function _set_menu_map() |
|
129 | - { |
|
130 | - return []; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - /** |
|
135 | - * @return bool |
|
136 | - * @since 4.10.14.p |
|
137 | - */ |
|
138 | - private function verifyMenuMapSet() |
|
139 | - { |
|
140 | - if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
141 | - EE_Error::doing_it_wrong( |
|
142 | - get_class($this) . '::$_menu_map', |
|
143 | - sprintf( |
|
144 | - esc_html__( |
|
145 | - 'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', |
|
146 | - 'event_espresso' |
|
147 | - ), |
|
148 | - get_class($this) |
|
149 | - ), |
|
150 | - '4.4.0' |
|
151 | - ); |
|
152 | - return true; |
|
153 | - } |
|
154 | - return false; |
|
155 | - } |
|
156 | - |
|
157 | - |
|
158 | - /** |
|
159 | - * returns the menu map for this admin page |
|
160 | - * |
|
161 | - * @return EE_Admin_Page_Menu_Map |
|
162 | - * @since 4.4.0 |
|
163 | - */ |
|
164 | - public function get_menu_map() |
|
165 | - { |
|
166 | - return $this->_menu_map; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * This loads scripts and styles for the EE_Admin system |
|
172 | - * that must be available on ALL WP admin pages (i.e. EE_menu items) |
|
173 | - * |
|
174 | - * @return void |
|
175 | - */ |
|
176 | - public function load_wp_global_scripts_styles() |
|
177 | - { |
|
178 | - wp_register_style( |
|
179 | - 'espresso_menu', |
|
180 | - EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
181 | - ['dashicons'], |
|
182 | - EVENT_ESPRESSO_VERSION |
|
183 | - ); |
|
184 | - wp_enqueue_style('espresso_menu'); |
|
185 | - } |
|
186 | - |
|
187 | - |
|
188 | - /** |
|
189 | - * this sets default properties (might be overridden in _set_init_properties); |
|
190 | - * |
|
191 | - * @return void |
|
192 | - */ |
|
193 | - private function _set_defaults() |
|
194 | - { |
|
195 | - $this->_file_name = $this->_folder_name = $this->_wp_page_slug = $this->capability = null; |
|
196 | - $this->_routing = true; |
|
197 | - $this->_load_page = false; |
|
198 | - $this->_files_hooked = $this->_hook_paths = []; |
|
199 | - // menu_map |
|
200 | - $this->_menu_map = $this->get_menu_map(); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - protected function _set_capability() |
|
205 | - { |
|
206 | - $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
|
207 | - $this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability); |
|
208 | - } |
|
209 | - |
|
210 | - |
|
211 | - /** |
|
212 | - * initialize_admin_page |
|
213 | - * This method is what executes the loading of the specific page class for the given dir_name as called by the |
|
214 | - * EE_Admin_Init class. |
|
215 | - * |
|
216 | - * @return void |
|
217 | - * @uses _initialize_admin_page() |
|
218 | - */ |
|
219 | - public function initialize_admin_page() |
|
220 | - { |
|
221 | - // let's check user access first |
|
222 | - $this->_check_user_access(); |
|
223 | - if (! is_object($this->_loaded_page_object)) { |
|
224 | - return; |
|
225 | - } |
|
226 | - $this->_loaded_page_object->route_admin_request(); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * @param string $wp_page_slug |
|
232 | - * @throws EE_Error |
|
233 | - */ |
|
234 | - public function set_page_dependencies($wp_page_slug) |
|
235 | - { |
|
236 | - if (! $this->_load_page) { |
|
237 | - return; |
|
238 | - } |
|
239 | - if (! is_object($this->_loaded_page_object)) { |
|
240 | - $msg[] = esc_html__( |
|
241 | - 'We can\'t load the page because we\'re missing a valid page object that tells us what to load', |
|
242 | - 'event_espresso' |
|
243 | - ); |
|
244 | - $msg[] = $msg[0] . "\r\n" |
|
245 | - . sprintf( |
|
246 | - esc_html__( |
|
247 | - 'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', |
|
248 | - 'event_espresso' |
|
249 | - ), |
|
250 | - $this->_file_name, |
|
251 | - $this->_file_name, |
|
252 | - $this->_folder_path . $this->_file_name, |
|
253 | - $this->_menu_map->menu_slug |
|
254 | - ); |
|
255 | - throw new EE_Error(implode('||', $msg)); |
|
256 | - } |
|
257 | - $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
|
258 | - $page_hook = 'load-' . $wp_page_slug; |
|
259 | - // hook into page load hook so all page specific stuff gets loaded. |
|
260 | - if (! empty($wp_page_slug)) { |
|
261 | - add_action($page_hook, [$this->_loaded_page_object, 'load_page_dependencies']); |
|
262 | - } |
|
263 | - } |
|
264 | - |
|
265 | - |
|
266 | - /** |
|
267 | - * This executes the initial page loads for EE_Admin pages to take care of any ajax or other code needing to run |
|
268 | - * before the load-page... hook. Note, the page loads are happening around the wp_init hook. |
|
269 | - * |
|
270 | - * @return void |
|
271 | - */ |
|
272 | - public function do_initial_loads() |
|
273 | - { |
|
274 | - // no loading or initializing if menu map is setup incorrectly. |
|
275 | - if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
276 | - return; |
|
277 | - } |
|
278 | - $this->_initialize_admin_page(); |
|
279 | - } |
|
280 | - |
|
281 | - |
|
282 | - /** |
|
283 | - * all we're doing here is setting the $_file_name property for later use. |
|
284 | - * |
|
285 | - * @return void |
|
286 | - */ |
|
287 | - private function _set_file_and_folder_name() |
|
288 | - { |
|
289 | - $bt = debug_backtrace(); |
|
290 | - // for more reliable determination of folder name |
|
291 | - // we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this). Why? Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins) |
|
292 | - $class = get_class($this); |
|
293 | - foreach ($bt as $index => $values) { |
|
294 | - if (isset($values['class']) && $values['class'] == $class) { |
|
295 | - $file_index = $index - 1; |
|
296 | - $this->_folder_name = basename(dirname($bt[ $file_index ]['file'])); |
|
297 | - if (! empty($this->_folder_name)) { |
|
298 | - break; |
|
299 | - } |
|
300 | - } |
|
301 | - } |
|
302 | - $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/'; |
|
303 | - $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name); |
|
304 | - $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name)); |
|
305 | - $this->_file_name = str_replace(' ', '_', $this->_file_name); |
|
306 | - } |
|
307 | - |
|
308 | - |
|
309 | - /** |
|
310 | - * This automatically checks if we have a hook class in the loaded child directory. If we DO then we will register |
|
311 | - * it with the appropriate pages. That way all we have to do is make sure the file is named correctly and |
|
312 | - * "dropped" in. Example: if we wanted to set this up for Messages hooking into Events then we would do: |
|
313 | - * events_Messages_Hooks.class.php |
|
314 | - * |
|
315 | - * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks |
|
316 | - * files/classes |
|
317 | - * @return array |
|
318 | - */ |
|
319 | - public function register_hooks($extend = false) |
|
320 | - { |
|
321 | - |
|
322 | - // get a list of files in the directory that have the "Hook" in their name an |
|
323 | - // if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property. Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf. |
|
324 | - if ($extend) { |
|
325 | - $hook_files_glob_path = apply_filters( |
|
326 | - 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', |
|
327 | - EE_CORE_CAF_ADMIN_EXTEND |
|
328 | - . $this->_folder_name |
|
329 | - . '/*' |
|
330 | - . $this->_file_name |
|
331 | - . '_Hooks_Extend.class.php' |
|
332 | - ); |
|
333 | - $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend); |
|
334 | - } |
|
335 | - // loop through decaf folders |
|
336 | - $hook_files_glob_path = apply_filters( |
|
337 | - 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', |
|
338 | - $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' |
|
339 | - ); |
|
340 | - $this->_hook_paths = array_merge( |
|
341 | - $this->_register_hook_files($hook_files_glob_path), |
|
342 | - $this->_hook_paths |
|
343 | - ); // making sure any extended hook paths are later in the array than the core hook paths! |
|
344 | - return $this->_hook_paths; |
|
345 | - } |
|
346 | - |
|
347 | - |
|
348 | - protected function _register_hook_files($hook_files_glob_path, $extend = false) |
|
349 | - { |
|
350 | - $hook_paths = glob($hook_files_glob_path); |
|
351 | - if (empty($hook_paths)) { |
|
352 | - return []; |
|
353 | - } |
|
354 | - foreach ($hook_paths as $file) { |
|
355 | - // lets get the linked admin. |
|
356 | - $hook_file = $extend |
|
357 | - ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file) |
|
358 | - : str_replace($this->_folder_path, '', $file); |
|
359 | - $replace = $extend |
|
360 | - ? '_' . $this->_file_name . '_Hooks_Extend.class.php' |
|
361 | - : '_' . $this->_file_name . '_Hooks.class.php'; |
|
362 | - $rel_admin = str_replace($replace, '', $hook_file); |
|
363 | - $rel_admin = strtolower($rel_admin); |
|
364 | - // make sure we haven't already got a hook setup for this page path |
|
365 | - if (in_array($rel_admin, $this->_files_hooked)) { |
|
366 | - continue; |
|
367 | - } |
|
368 | - $this->hook_file = $hook_file; |
|
369 | - $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
|
370 | - add_filter($rel_admin_hook, [$this, 'load_admin_hook']); |
|
371 | - $this->_files_hooked[] = $rel_admin; |
|
372 | - } |
|
373 | - return $hook_paths; |
|
374 | - } |
|
375 | - |
|
376 | - |
|
377 | - public function load_admin_hook($registered_pages) |
|
378 | - { |
|
379 | - return array_merge((array) $this->hook_file, $registered_pages); |
|
380 | - } |
|
381 | - |
|
382 | - |
|
383 | - /** |
|
384 | - * _initialize_admin_page |
|
385 | - * |
|
386 | - * @see initialize_admin_page() for info |
|
387 | - */ |
|
388 | - protected function _initialize_admin_page() |
|
389 | - { |
|
390 | - // JUST CHECK WE'RE ON RIGHT PAGE. |
|
391 | - $page = $this->request->getRequestParam('page'); |
|
392 | - $page = $this->request->getRequestParam('current_page', $page); |
|
393 | - $menu_slug = $this->_menu_map->menu_slug; |
|
394 | - |
|
395 | - |
|
396 | - if ($this->_routing && ($page === '' || $page !== $menu_slug)) { |
|
397 | - // not on the right page so let's get out. |
|
398 | - return; |
|
399 | - } |
|
400 | - $this->_load_page = true; |
|
401 | - |
|
402 | - // we don't need to do a page_request check here because it's only called via WP menu system. |
|
403 | - $admin_page = $this->_file_name . '_Admin_Page'; |
|
404 | - $hook_suffix = "{$menu_slug}_{$admin_page}"; |
|
405 | - $admin_page = apply_filters( |
|
406 | - "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", |
|
407 | - $admin_page |
|
408 | - ); |
|
409 | - if (empty($admin_page)) { |
|
410 | - return; |
|
411 | - } |
|
412 | - // define requested admin page class name then load the file and instantiate |
|
413 | - $path_to_file = str_replace(['\\', '/'], '/', $this->_folder_path . $admin_page . '.core.php'); |
|
414 | - // so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be: |
|
415 | - // FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
416 | - $path_to_file = apply_filters( |
|
417 | - "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", |
|
418 | - $path_to_file |
|
419 | - ); |
|
420 | - if (! is_readable($path_to_file)) { |
|
421 | - return; |
|
422 | - } |
|
423 | - // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place |
|
424 | - do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization'); |
|
425 | - do_action("AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_{$menu_slug}"); |
|
426 | - require_once($path_to_file); |
|
427 | - $this->_loaded_page_object = $this->loader->getShared($admin_page, [$this->_routing]); |
|
428 | - |
|
429 | - do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization'); |
|
430 | - do_action("AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_{$menu_slug}"); |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - public function get_admin_page_name() |
|
435 | - { |
|
436 | - return $this->_file_name . '_Admin_Page'; |
|
437 | - } |
|
438 | - |
|
439 | - |
|
440 | - /** |
|
441 | - * @return mixed |
|
442 | - */ |
|
443 | - public function loaded_page_object() |
|
444 | - { |
|
445 | - return $this->_loaded_page_object; |
|
446 | - } |
|
447 | - |
|
448 | - /** |
|
449 | - * _check_user_access |
|
450 | - * verifies user access for this admin page. If no user access is available then let's gracefully exit with a |
|
451 | - * WordPress die message. |
|
452 | - * |
|
453 | - * @return void wp_die if fail |
|
454 | - */ |
|
455 | - private function _check_user_access() |
|
456 | - { |
|
457 | - if ( |
|
458 | - ! EE_Registry::instance()->CAP->current_user_can( |
|
459 | - $this->_menu_map->capability, |
|
460 | - $this->_menu_map->menu_slug |
|
461 | - ) |
|
462 | - ) { |
|
463 | - wp_die(esc_html__('You don\'t have access to this page.', 'event_espresso'), '', ['back_link' => true]); |
|
464 | - } |
|
465 | - } |
|
22 | + /** |
|
23 | + * Menu map has a capability. However, this allows admin pages to have separate capability requirements for menus |
|
24 | + * and accessing pages. If capability is NOT set, then it defaults to the menu_map capability. |
|
25 | + * |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + public $capability; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * This holds the menu map object for this admin page. |
|
33 | + * |
|
34 | + * @var EE_Admin_Page_Menu_Map |
|
35 | + */ |
|
36 | + protected $_menu_map; |
|
37 | + |
|
38 | + /** |
|
39 | + * deprecated |
|
40 | + */ |
|
41 | + public $menu_label; |
|
42 | + |
|
43 | + public $menu_slug; |
|
44 | + |
|
45 | + |
|
46 | + // set in _set_defaults |
|
47 | + protected $_folder_name; |
|
48 | + |
|
49 | + protected $_folder_path; |
|
50 | + |
|
51 | + protected $_file_name; |
|
52 | + |
|
53 | + public $hook_file; |
|
54 | + |
|
55 | + protected $_wp_page_slug; |
|
56 | + |
|
57 | + protected $_routing; |
|
58 | + |
|
59 | + |
|
60 | + // will hold page object. |
|
61 | + protected $_loaded_page_object; |
|
62 | + |
|
63 | + |
|
64 | + // for caf |
|
65 | + protected $_files_hooked; |
|
66 | + |
|
67 | + protected $_hook_paths; |
|
68 | + |
|
69 | + // load_page? |
|
70 | + private $_load_page; |
|
71 | + |
|
72 | + /** |
|
73 | + * @var LoaderInterface |
|
74 | + */ |
|
75 | + protected $loader; |
|
76 | + |
|
77 | + /** |
|
78 | + * @var RequestInterface |
|
79 | + */ |
|
80 | + protected $request; |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * @Constructor |
|
85 | + * @return void |
|
86 | + */ |
|
87 | + public function __construct(RequestInterface $request = null) |
|
88 | + { |
|
89 | + $this->loader = LoaderFactory::getLoader(); |
|
90 | + $this->request = $request instanceof RequestInterface |
|
91 | + ? $request |
|
92 | + : $this->loader->getShared(RequestInterface::class); |
|
93 | + // set global defaults |
|
94 | + $this->_set_defaults(); |
|
95 | + // set properties that are always available with objects. |
|
96 | + $this->_set_init_properties(); |
|
97 | + // global styles/scripts across all wp admin pages |
|
98 | + add_action('admin_enqueue_scripts', [$this, 'load_wp_global_scripts_styles'], 5); |
|
99 | + // load initial stuff. |
|
100 | + $this->_set_file_and_folder_name(); |
|
101 | + $this->_set_menu_map(); |
|
102 | + if (! $this->verifyMenuMapSet()) { |
|
103 | + return; |
|
104 | + } |
|
105 | + // set default capability |
|
106 | + $this->_set_capability(); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * _set_init_properties |
|
112 | + * Child classes use to set the following properties: |
|
113 | + * $label |
|
114 | + * |
|
115 | + * @abstract |
|
116 | + * @return void |
|
117 | + */ |
|
118 | + abstract protected function _set_init_properties(); |
|
119 | + |
|
120 | + |
|
121 | + /** |
|
122 | + * _set_menu_map is a function that child classes use to set the menu_map property (which should be an instance of |
|
123 | + * EE_Admin_Page_Menu_Map. Their menu can either be EE_Admin_Page_Main_Menu or EE_Admin_Page_Sub_Menu. |
|
124 | + * |
|
125 | + * @since 4.4.0 |
|
126 | + * @ return void. |
|
127 | + */ |
|
128 | + protected function _set_menu_map() |
|
129 | + { |
|
130 | + return []; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + /** |
|
135 | + * @return bool |
|
136 | + * @since 4.10.14.p |
|
137 | + */ |
|
138 | + private function verifyMenuMapSet() |
|
139 | + { |
|
140 | + if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
141 | + EE_Error::doing_it_wrong( |
|
142 | + get_class($this) . '::$_menu_map', |
|
143 | + sprintf( |
|
144 | + esc_html__( |
|
145 | + 'The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', |
|
146 | + 'event_espresso' |
|
147 | + ), |
|
148 | + get_class($this) |
|
149 | + ), |
|
150 | + '4.4.0' |
|
151 | + ); |
|
152 | + return true; |
|
153 | + } |
|
154 | + return false; |
|
155 | + } |
|
156 | + |
|
157 | + |
|
158 | + /** |
|
159 | + * returns the menu map for this admin page |
|
160 | + * |
|
161 | + * @return EE_Admin_Page_Menu_Map |
|
162 | + * @since 4.4.0 |
|
163 | + */ |
|
164 | + public function get_menu_map() |
|
165 | + { |
|
166 | + return $this->_menu_map; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * This loads scripts and styles for the EE_Admin system |
|
172 | + * that must be available on ALL WP admin pages (i.e. EE_menu items) |
|
173 | + * |
|
174 | + * @return void |
|
175 | + */ |
|
176 | + public function load_wp_global_scripts_styles() |
|
177 | + { |
|
178 | + wp_register_style( |
|
179 | + 'espresso_menu', |
|
180 | + EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
181 | + ['dashicons'], |
|
182 | + EVENT_ESPRESSO_VERSION |
|
183 | + ); |
|
184 | + wp_enqueue_style('espresso_menu'); |
|
185 | + } |
|
186 | + |
|
187 | + |
|
188 | + /** |
|
189 | + * this sets default properties (might be overridden in _set_init_properties); |
|
190 | + * |
|
191 | + * @return void |
|
192 | + */ |
|
193 | + private function _set_defaults() |
|
194 | + { |
|
195 | + $this->_file_name = $this->_folder_name = $this->_wp_page_slug = $this->capability = null; |
|
196 | + $this->_routing = true; |
|
197 | + $this->_load_page = false; |
|
198 | + $this->_files_hooked = $this->_hook_paths = []; |
|
199 | + // menu_map |
|
200 | + $this->_menu_map = $this->get_menu_map(); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + protected function _set_capability() |
|
205 | + { |
|
206 | + $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
|
207 | + $this->capability = apply_filters('FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability); |
|
208 | + } |
|
209 | + |
|
210 | + |
|
211 | + /** |
|
212 | + * initialize_admin_page |
|
213 | + * This method is what executes the loading of the specific page class for the given dir_name as called by the |
|
214 | + * EE_Admin_Init class. |
|
215 | + * |
|
216 | + * @return void |
|
217 | + * @uses _initialize_admin_page() |
|
218 | + */ |
|
219 | + public function initialize_admin_page() |
|
220 | + { |
|
221 | + // let's check user access first |
|
222 | + $this->_check_user_access(); |
|
223 | + if (! is_object($this->_loaded_page_object)) { |
|
224 | + return; |
|
225 | + } |
|
226 | + $this->_loaded_page_object->route_admin_request(); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * @param string $wp_page_slug |
|
232 | + * @throws EE_Error |
|
233 | + */ |
|
234 | + public function set_page_dependencies($wp_page_slug) |
|
235 | + { |
|
236 | + if (! $this->_load_page) { |
|
237 | + return; |
|
238 | + } |
|
239 | + if (! is_object($this->_loaded_page_object)) { |
|
240 | + $msg[] = esc_html__( |
|
241 | + 'We can\'t load the page because we\'re missing a valid page object that tells us what to load', |
|
242 | + 'event_espresso' |
|
243 | + ); |
|
244 | + $msg[] = $msg[0] . "\r\n" |
|
245 | + . sprintf( |
|
246 | + esc_html__( |
|
247 | + 'The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', |
|
248 | + 'event_espresso' |
|
249 | + ), |
|
250 | + $this->_file_name, |
|
251 | + $this->_file_name, |
|
252 | + $this->_folder_path . $this->_file_name, |
|
253 | + $this->_menu_map->menu_slug |
|
254 | + ); |
|
255 | + throw new EE_Error(implode('||', $msg)); |
|
256 | + } |
|
257 | + $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
|
258 | + $page_hook = 'load-' . $wp_page_slug; |
|
259 | + // hook into page load hook so all page specific stuff gets loaded. |
|
260 | + if (! empty($wp_page_slug)) { |
|
261 | + add_action($page_hook, [$this->_loaded_page_object, 'load_page_dependencies']); |
|
262 | + } |
|
263 | + } |
|
264 | + |
|
265 | + |
|
266 | + /** |
|
267 | + * This executes the initial page loads for EE_Admin pages to take care of any ajax or other code needing to run |
|
268 | + * before the load-page... hook. Note, the page loads are happening around the wp_init hook. |
|
269 | + * |
|
270 | + * @return void |
|
271 | + */ |
|
272 | + public function do_initial_loads() |
|
273 | + { |
|
274 | + // no loading or initializing if menu map is setup incorrectly. |
|
275 | + if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
276 | + return; |
|
277 | + } |
|
278 | + $this->_initialize_admin_page(); |
|
279 | + } |
|
280 | + |
|
281 | + |
|
282 | + /** |
|
283 | + * all we're doing here is setting the $_file_name property for later use. |
|
284 | + * |
|
285 | + * @return void |
|
286 | + */ |
|
287 | + private function _set_file_and_folder_name() |
|
288 | + { |
|
289 | + $bt = debug_backtrace(); |
|
290 | + // for more reliable determination of folder name |
|
291 | + // we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this). Why? Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins) |
|
292 | + $class = get_class($this); |
|
293 | + foreach ($bt as $index => $values) { |
|
294 | + if (isset($values['class']) && $values['class'] == $class) { |
|
295 | + $file_index = $index - 1; |
|
296 | + $this->_folder_name = basename(dirname($bt[ $file_index ]['file'])); |
|
297 | + if (! empty($this->_folder_name)) { |
|
298 | + break; |
|
299 | + } |
|
300 | + } |
|
301 | + } |
|
302 | + $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . '/'; |
|
303 | + $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name); |
|
304 | + $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name)); |
|
305 | + $this->_file_name = str_replace(' ', '_', $this->_file_name); |
|
306 | + } |
|
307 | + |
|
308 | + |
|
309 | + /** |
|
310 | + * This automatically checks if we have a hook class in the loaded child directory. If we DO then we will register |
|
311 | + * it with the appropriate pages. That way all we have to do is make sure the file is named correctly and |
|
312 | + * "dropped" in. Example: if we wanted to set this up for Messages hooking into Events then we would do: |
|
313 | + * events_Messages_Hooks.class.php |
|
314 | + * |
|
315 | + * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks |
|
316 | + * files/classes |
|
317 | + * @return array |
|
318 | + */ |
|
319 | + public function register_hooks($extend = false) |
|
320 | + { |
|
321 | + |
|
322 | + // get a list of files in the directory that have the "Hook" in their name an |
|
323 | + // if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property. Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf. |
|
324 | + if ($extend) { |
|
325 | + $hook_files_glob_path = apply_filters( |
|
326 | + 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', |
|
327 | + EE_CORE_CAF_ADMIN_EXTEND |
|
328 | + . $this->_folder_name |
|
329 | + . '/*' |
|
330 | + . $this->_file_name |
|
331 | + . '_Hooks_Extend.class.php' |
|
332 | + ); |
|
333 | + $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend); |
|
334 | + } |
|
335 | + // loop through decaf folders |
|
336 | + $hook_files_glob_path = apply_filters( |
|
337 | + 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', |
|
338 | + $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' |
|
339 | + ); |
|
340 | + $this->_hook_paths = array_merge( |
|
341 | + $this->_register_hook_files($hook_files_glob_path), |
|
342 | + $this->_hook_paths |
|
343 | + ); // making sure any extended hook paths are later in the array than the core hook paths! |
|
344 | + return $this->_hook_paths; |
|
345 | + } |
|
346 | + |
|
347 | + |
|
348 | + protected function _register_hook_files($hook_files_glob_path, $extend = false) |
|
349 | + { |
|
350 | + $hook_paths = glob($hook_files_glob_path); |
|
351 | + if (empty($hook_paths)) { |
|
352 | + return []; |
|
353 | + } |
|
354 | + foreach ($hook_paths as $file) { |
|
355 | + // lets get the linked admin. |
|
356 | + $hook_file = $extend |
|
357 | + ? str_replace(EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . '/', '', $file) |
|
358 | + : str_replace($this->_folder_path, '', $file); |
|
359 | + $replace = $extend |
|
360 | + ? '_' . $this->_file_name . '_Hooks_Extend.class.php' |
|
361 | + : '_' . $this->_file_name . '_Hooks.class.php'; |
|
362 | + $rel_admin = str_replace($replace, '', $hook_file); |
|
363 | + $rel_admin = strtolower($rel_admin); |
|
364 | + // make sure we haven't already got a hook setup for this page path |
|
365 | + if (in_array($rel_admin, $this->_files_hooked)) { |
|
366 | + continue; |
|
367 | + } |
|
368 | + $this->hook_file = $hook_file; |
|
369 | + $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
|
370 | + add_filter($rel_admin_hook, [$this, 'load_admin_hook']); |
|
371 | + $this->_files_hooked[] = $rel_admin; |
|
372 | + } |
|
373 | + return $hook_paths; |
|
374 | + } |
|
375 | + |
|
376 | + |
|
377 | + public function load_admin_hook($registered_pages) |
|
378 | + { |
|
379 | + return array_merge((array) $this->hook_file, $registered_pages); |
|
380 | + } |
|
381 | + |
|
382 | + |
|
383 | + /** |
|
384 | + * _initialize_admin_page |
|
385 | + * |
|
386 | + * @see initialize_admin_page() for info |
|
387 | + */ |
|
388 | + protected function _initialize_admin_page() |
|
389 | + { |
|
390 | + // JUST CHECK WE'RE ON RIGHT PAGE. |
|
391 | + $page = $this->request->getRequestParam('page'); |
|
392 | + $page = $this->request->getRequestParam('current_page', $page); |
|
393 | + $menu_slug = $this->_menu_map->menu_slug; |
|
394 | + |
|
395 | + |
|
396 | + if ($this->_routing && ($page === '' || $page !== $menu_slug)) { |
|
397 | + // not on the right page so let's get out. |
|
398 | + return; |
|
399 | + } |
|
400 | + $this->_load_page = true; |
|
401 | + |
|
402 | + // we don't need to do a page_request check here because it's only called via WP menu system. |
|
403 | + $admin_page = $this->_file_name . '_Admin_Page'; |
|
404 | + $hook_suffix = "{$menu_slug}_{$admin_page}"; |
|
405 | + $admin_page = apply_filters( |
|
406 | + "FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", |
|
407 | + $admin_page |
|
408 | + ); |
|
409 | + if (empty($admin_page)) { |
|
410 | + return; |
|
411 | + } |
|
412 | + // define requested admin page class name then load the file and instantiate |
|
413 | + $path_to_file = str_replace(['\\', '/'], '/', $this->_folder_path . $admin_page . '.core.php'); |
|
414 | + // so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be: |
|
415 | + // FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
416 | + $path_to_file = apply_filters( |
|
417 | + "FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", |
|
418 | + $path_to_file |
|
419 | + ); |
|
420 | + if (! is_readable($path_to_file)) { |
|
421 | + return; |
|
422 | + } |
|
423 | + // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place |
|
424 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization'); |
|
425 | + do_action("AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_{$menu_slug}"); |
|
426 | + require_once($path_to_file); |
|
427 | + $this->_loaded_page_object = $this->loader->getShared($admin_page, [$this->_routing]); |
|
428 | + |
|
429 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization'); |
|
430 | + do_action("AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_{$menu_slug}"); |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + public function get_admin_page_name() |
|
435 | + { |
|
436 | + return $this->_file_name . '_Admin_Page'; |
|
437 | + } |
|
438 | + |
|
439 | + |
|
440 | + /** |
|
441 | + * @return mixed |
|
442 | + */ |
|
443 | + public function loaded_page_object() |
|
444 | + { |
|
445 | + return $this->_loaded_page_object; |
|
446 | + } |
|
447 | + |
|
448 | + /** |
|
449 | + * _check_user_access |
|
450 | + * verifies user access for this admin page. If no user access is available then let's gracefully exit with a |
|
451 | + * WordPress die message. |
|
452 | + * |
|
453 | + * @return void wp_die if fail |
|
454 | + */ |
|
455 | + private function _check_user_access() |
|
456 | + { |
|
457 | + if ( |
|
458 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
459 | + $this->_menu_map->capability, |
|
460 | + $this->_menu_map->menu_slug |
|
461 | + ) |
|
462 | + ) { |
|
463 | + wp_die(esc_html__('You don\'t have access to this page.', 'event_espresso'), '', ['back_link' => true]); |
|
464 | + } |
|
465 | + } |
|
466 | 466 | } |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | "endDate": "<?php echo esc_html($event_end); ?>", |
26 | 26 | "description": <?php echo wp_json_encode($event_description); ?>, |
27 | 27 | "url": "<?php echo esc_url_raw($event_permalink); ?>", |
28 | - "eventAttendanceMode": "<?php echo esc_url_raw('https://schema.org/' . $event_attendance_mode); ?>", |
|
28 | + "eventAttendanceMode": "<?php echo esc_url_raw('https://schema.org/'.$event_attendance_mode); ?>", |
|
29 | 29 | "eventStatus": [ "<?php echo esc_url_raw($event_status); ?>" ], |
30 | 30 | "offers": [ |
31 | 31 | <?php |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | "price": "<?php echo esc_html($ticket['price']); ?>", |
40 | 40 | "priceCurrency": "<?php echo esc_html($currency); ?>" |
41 | 41 | <?php if (isset($ticket['availability'])) { |
42 | - ?>,"availability": "<?php echo esc_url_raw('https://schema.org/' . $ticket['availability']); ?>" |
|
42 | + ?>,"availability": "<?php echo esc_url_raw('https://schema.org/'.$ticket['availability']); ?>" |
|
43 | 43 | <?php } ?> |
44 | 44 | }<?php |
45 | 45 | $i++; |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | "eventStatus": [ "<?php echo esc_url_raw($event_status); ?>" ], |
30 | 30 | "offers": [ |
31 | 31 | <?php |
32 | - $i = 0; |
|
33 | - foreach ($event_tickets as $ticket) {?> |
|
32 | + $i = 0; |
|
33 | + foreach ($event_tickets as $ticket) {?> |
|
34 | 34 | { |
35 | 35 | "@type": "Offer", |
36 | 36 | "url": "<?php echo esc_url_raw($event_permalink); ?>", |
@@ -39,18 +39,18 @@ discard block |
||
39 | 39 | "price": "<?php echo esc_html($ticket['price']); ?>", |
40 | 40 | "priceCurrency": "<?php echo esc_html($currency); ?>" |
41 | 41 | <?php if (isset($ticket['availability'])) { |
42 | - ?>,"availability": "<?php echo esc_url_raw('https://schema.org/' . $ticket['availability']); ?>" |
|
42 | + ?>,"availability": "<?php echo esc_url_raw('https://schema.org/' . $ticket['availability']); ?>" |
|
43 | 43 | <?php } ?> |
44 | 44 | }<?php |
45 | - $i++; |
|
46 | - if ($i < count($event_tickets)) { |
|
47 | - echo ','; |
|
48 | - } |
|
49 | - } |
|
50 | - ?> |
|
45 | + $i++; |
|
46 | + if ($i < count($event_tickets)) { |
|
47 | + echo ','; |
|
48 | + } |
|
49 | + } |
|
50 | + ?> |
|
51 | 51 | ]<?php |
52 | - if ($venue_name) { |
|
53 | - ?>, |
|
52 | + if ($venue_name) { |
|
53 | + ?>, |
|
54 | 54 | "location": { |
55 | 55 | "@type": "Place", |
56 | 56 | "name": <?php echo wp_json_encode($venue_name); ?>, |
@@ -63,13 +63,13 @@ discard block |
||
63 | 63 | } |
64 | 64 | } |
65 | 65 | <?php |
66 | - } ?> |
|
66 | + } ?> |
|
67 | 67 | <?php |
68 | - if ($event_image) { |
|
69 | - ?>, |
|
68 | + if ($event_image) { |
|
69 | + ?>, |
|
70 | 70 | "image": "<?php echo esc_url_raw($event_image); ?>" |
71 | 71 | <?php |
72 | - } ?> |
|
72 | + } ?> |
|
73 | 73 | <?php do_action('AHEE__json_linked_data_for_event__template'); ?> |
74 | 74 | } |
75 | 75 |
@@ -25,7 +25,7 @@ |
||
25 | 25 | if ($is_array) { |
26 | 26 | $values = []; |
27 | 27 | foreach ((array) $param as $key => $value) { |
28 | - $values[ $key ] = $this->clean($value, $type, is_array($value), $delimiter); |
|
28 | + $values[$key] = $this->clean($value, $type, is_array($value), $delimiter); |
|
29 | 29 | } |
30 | 30 | return $values; |
31 | 31 | } |
@@ -6,67 +6,67 @@ |
||
6 | 6 | |
7 | 7 | class RequestSanitizer |
8 | 8 | { |
9 | - /** |
|
10 | - * Will sanitize the supplied request parameter based on the specified data type |
|
11 | - * |
|
12 | - * @param mixed $param the supplied request parameter |
|
13 | - * @param string $type the specified data type (default: "string") |
|
14 | - * valid values: "bool", "float", "int", "key", "url", or "string" |
|
15 | - * @param bool $is_array if true, then $param will be treated as an array of $type |
|
16 | - * @param string $delimiter if $param is a CSV like value (ex: 1,2,3,4,5...) then this is the value separator |
|
17 | - * @return array|bool|float|int|string |
|
18 | - * @since 4.10.14.p |
|
19 | - */ |
|
20 | - public function clean($param, $type = DataType::STRING, $is_array = false, $delimiter = '') |
|
21 | - { |
|
22 | - if ($delimiter !== '' && is_string($param)) { |
|
23 | - $param = explode($delimiter, $param); |
|
24 | - $is_array = is_array($param); |
|
25 | - // unset the delimiter else this function will recurse forever when we loop over the array of results |
|
26 | - $delimiter = ''; |
|
27 | - } |
|
28 | - // check if we are getting an improperly typed array and correct |
|
29 | - $is_array = $is_array && is_array($param); |
|
30 | - if ($is_array) { |
|
31 | - $values = []; |
|
32 | - foreach ((array) $param as $key => $value) { |
|
33 | - $values[ $key ] = $this->clean($value, $type, is_array($value), $delimiter); |
|
34 | - } |
|
35 | - return $values; |
|
36 | - } |
|
37 | - return $this->sanitizeParam($param, $type); |
|
38 | - } |
|
9 | + /** |
|
10 | + * Will sanitize the supplied request parameter based on the specified data type |
|
11 | + * |
|
12 | + * @param mixed $param the supplied request parameter |
|
13 | + * @param string $type the specified data type (default: "string") |
|
14 | + * valid values: "bool", "float", "int", "key", "url", or "string" |
|
15 | + * @param bool $is_array if true, then $param will be treated as an array of $type |
|
16 | + * @param string $delimiter if $param is a CSV like value (ex: 1,2,3,4,5...) then this is the value separator |
|
17 | + * @return array|bool|float|int|string |
|
18 | + * @since 4.10.14.p |
|
19 | + */ |
|
20 | + public function clean($param, $type = DataType::STRING, $is_array = false, $delimiter = '') |
|
21 | + { |
|
22 | + if ($delimiter !== '' && is_string($param)) { |
|
23 | + $param = explode($delimiter, $param); |
|
24 | + $is_array = is_array($param); |
|
25 | + // unset the delimiter else this function will recurse forever when we loop over the array of results |
|
26 | + $delimiter = ''; |
|
27 | + } |
|
28 | + // check if we are getting an improperly typed array and correct |
|
29 | + $is_array = $is_array && is_array($param); |
|
30 | + if ($is_array) { |
|
31 | + $values = []; |
|
32 | + foreach ((array) $param as $key => $value) { |
|
33 | + $values[ $key ] = $this->clean($value, $type, is_array($value), $delimiter); |
|
34 | + } |
|
35 | + return $values; |
|
36 | + } |
|
37 | + return $this->sanitizeParam($param, $type); |
|
38 | + } |
|
39 | 39 | |
40 | 40 | |
41 | - /** |
|
42 | - * @param mixed $param |
|
43 | - * @param string $type |
|
44 | - * @return array|float|int|mixed|string|string[]|null |
|
45 | - * @since 4.10.20.p |
|
46 | - */ |
|
47 | - public function sanitizeParam($param, $type = DataType::STRING) |
|
48 | - { |
|
49 | - switch ($type) { |
|
50 | - case DataType::BOOL: |
|
51 | - return filter_var($param, FILTER_VALIDATE_BOOLEAN); |
|
52 | - case DataType::FLOAT: |
|
53 | - return (float) $param; |
|
54 | - case DataType::FQCN: |
|
55 | - return preg_replace('[^\\\w\d]', '', $param); |
|
56 | - case DataType::HTML: |
|
57 | - $allowed_tags = AllowedTags::getAllowedTags(); |
|
58 | - return wp_kses($param, $allowed_tags); |
|
59 | - case DataType::INT: |
|
60 | - return (int) $param; |
|
61 | - case DataType::KEY: |
|
62 | - return sanitize_key($param); |
|
63 | - case DataType::TITLE: |
|
64 | - return sanitize_title($param); |
|
65 | - case DataType::URL: |
|
66 | - return esc_url_raw($param); |
|
67 | - case DataType::STRING: |
|
68 | - default: |
|
69 | - return sanitize_text_field($param); |
|
70 | - } |
|
71 | - } |
|
41 | + /** |
|
42 | + * @param mixed $param |
|
43 | + * @param string $type |
|
44 | + * @return array|float|int|mixed|string|string[]|null |
|
45 | + * @since 4.10.20.p |
|
46 | + */ |
|
47 | + public function sanitizeParam($param, $type = DataType::STRING) |
|
48 | + { |
|
49 | + switch ($type) { |
|
50 | + case DataType::BOOL: |
|
51 | + return filter_var($param, FILTER_VALIDATE_BOOLEAN); |
|
52 | + case DataType::FLOAT: |
|
53 | + return (float) $param; |
|
54 | + case DataType::FQCN: |
|
55 | + return preg_replace('[^\\\w\d]', '', $param); |
|
56 | + case DataType::HTML: |
|
57 | + $allowed_tags = AllowedTags::getAllowedTags(); |
|
58 | + return wp_kses($param, $allowed_tags); |
|
59 | + case DataType::INT: |
|
60 | + return (int) $param; |
|
61 | + case DataType::KEY: |
|
62 | + return sanitize_key($param); |
|
63 | + case DataType::TITLE: |
|
64 | + return sanitize_title($param); |
|
65 | + case DataType::URL: |
|
66 | + return esc_url_raw($param); |
|
67 | + case DataType::STRING: |
|
68 | + default: |
|
69 | + return sanitize_text_field($param); |
|
70 | + } |
|
71 | + } |
|
72 | 72 | } |