|
3 | 3 | global $wp_query;
|
4 | 4 | $api_key = EDU()->get_option( 'eduadmin-api-key' );
|
5 | 5 |
|
6 |
| -if ( ! $api_key || empty( $api_key ) ) { |
7 |
| - echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>'; |
| 6 | +if ( ! EDU()->api_connection ) { |
| 7 | + echo esc_html_x( 'EduAdmin Booking could not connect to the API', 'frontend', 'eduadmin-booking' ); |
8 | 8 | } else {
|
9 |
| - include 'course-info.php'; |
10 |
| - if ( ! $selected_course ) { |
11 |
| - ?> |
12 |
| - <script type="text/javascript">location.href = '<?php echo esc_url( $base_url ); ?>';</script> |
13 |
| - <?php |
14 |
| - exit( 200 ); |
15 |
| - } |
16 |
| - ?> |
17 |
| - <div class="eduadmin detail-view" data-courseid="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>" |
18 |
| - data-eventid="<?php echo( isset( $_REQUEST['eid'] ) ? esc_attr( sanitize_text_field( $_REQUEST['eid'] ) ) : '' ); ?>"> |
19 |
| - <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);" |
20 |
| - class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a> |
21 |
| - <div class="title"> |
22 |
| - <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?> |
23 |
| - <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" /> |
24 |
| - <?php endif; ?> |
25 |
| - <h1 class="courseTitle"><?php echo esc_html( $name ); ?> |
26 |
| - <small |
27 |
| - class="courseLevel"><?php echo esc_html( false !== $course_level ? $course_level['Name'] : '' ); ?></small> |
28 |
| - </h1> |
29 |
| - </div> |
30 |
| - <hr /> |
31 |
| - <div class="textblock"> |
| 9 | + if ( ! $api_key || empty( $api_key ) ) { |
| 10 | + echo 'Please complete the configuration: <a href="' . esc_url( admin_url() . 'admin.php?page=eduadmin-settings' ) . '">EduAdmin - Api Authentication</a>'; |
| 11 | + } else { |
| 12 | + include 'course-info.php'; |
| 13 | + if ( ! $selected_course ) { |
| 14 | + ?> |
| 15 | + <script type="text/javascript">location.href = '<?php echo esc_url( $base_url ); ?>';</script> |
32 | 16 | <?php
|
33 |
| - if ( ! in_array( 'description', $hide_sections, true ) && ! empty( $selected_course['CourseDescription'] ) ) { |
34 |
| - if ( $show_headers ) { |
35 |
| - ?> |
36 |
| - <h3><?php echo esc_html_x( 'Course description', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 17 | + exit( 200 ); |
| 18 | + } |
| 19 | + ?> |
| 20 | + <div class="eduadmin detail-view" |
| 21 | + data-courseid="<?php echo esc_attr( $selected_course['CourseTemplateId'] ); ?>" |
| 22 | + data-eventid="<?php echo( isset( $_REQUEST['eid'] ) ? esc_attr( sanitize_text_field( $_REQUEST['eid'] ) ) : '' ); ?>"> |
| 23 | + <a href="javascript://" onclick="eduGlobalMethods.GoBack('../', event);" |
| 24 | + class="backLink"><?php echo esc_html_x( '« Go back', 'frontend', 'eduadmin-booking' ); ?></a> |
| 25 | + <div class="title"> |
| 26 | + <?php if ( ! empty( $selected_course['ImageUrl'] ) ) : ?> |
| 27 | + <img src="<?php echo esc_url( $selected_course['ImageUrl'] ); ?>" class="courseImage" /> |
| 28 | + <?php endif; ?> |
| 29 | + <h1 class="courseTitle"><?php echo esc_html( $name ); ?> |
| 30 | + <small |
| 31 | + class="courseLevel"><?php echo esc_html( false !== $course_level ? $course_level['Name'] : '' ); ?></small> |
| 32 | + </h1> |
| 33 | + </div> |
| 34 | + <hr /> |
| 35 | + <div class="textblock"> |
| 36 | + <?php |
| 37 | + if ( ! in_array( 'description', $hide_sections, true ) && ! empty( $selected_course['CourseDescription'] ) ) { |
| 38 | + if ( $show_headers ) { |
| 39 | + ?> |
| 40 | + <h3><?php echo esc_html_x( 'Course description', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 41 | + <?php } ?> |
| 42 | + <div> |
| 43 | + <?php |
| 44 | + echo wp_kses_post( $selected_course['CourseDescription'] ); |
| 45 | + ?> |
| 46 | + </div> |
37 | 47 | <?php } ?>
|
38 |
| - <div> |
39 |
| - <?php |
40 |
| - echo wp_kses_post( $selected_course['CourseDescription'] ); |
41 |
| - ?> |
42 |
| - </div> |
43 |
| - <?php } ?> |
44 |
| - <?php |
45 |
| - if ( ! in_array( 'goal', $hide_sections, true ) && ! empty( $selected_course['CourseGoal'] ) ) { |
46 |
| - if ( $show_headers ) { |
47 |
| - ?> |
48 |
| - <h3><?php echo esc_html_x( 'Course goal', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 48 | + <?php |
| 49 | + if ( ! in_array( 'goal', $hide_sections, true ) && ! empty( $selected_course['CourseGoal'] ) ) { |
| 50 | + if ( $show_headers ) { |
| 51 | + ?> |
| 52 | + <h3><?php echo esc_html_x( 'Course goal', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 53 | + <?php } ?> |
| 54 | + <div> |
| 55 | + <?php |
| 56 | + echo wp_kses_post( $selected_course['CourseGoal'] ); |
| 57 | + ?> |
| 58 | + </div> |
49 | 59 | <?php } ?>
|
50 |
| - <div> |
51 |
| - <?php |
52 |
| - echo wp_kses_post( $selected_course['CourseGoal'] ); |
53 |
| - ?> |
54 |
| - </div> |
55 |
| - <?php } ?> |
56 |
| - <?php |
57 |
| - if ( ! in_array( 'target', $hide_sections, true ) && ! empty( $selected_course['TargetGroup'] ) ) { |
58 |
| - if ( $show_headers ) { |
59 |
| - ?> |
60 |
| - <h3><?php echo esc_html_x( 'Target group', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 60 | + <?php |
| 61 | + if ( ! in_array( 'target', $hide_sections, true ) && ! empty( $selected_course['TargetGroup'] ) ) { |
| 62 | + if ( $show_headers ) { |
| 63 | + ?> |
| 64 | + <h3><?php echo esc_html_x( 'Target group', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 65 | + <?php } ?> |
| 66 | + <div> |
| 67 | + <?php |
| 68 | + echo wp_kses_post( $selected_course['TargetGroup'] ); |
| 69 | + ?> |
| 70 | + </div> |
61 | 71 | <?php } ?>
|
62 |
| - <div> |
63 |
| - <?php |
64 |
| - echo wp_kses_post( $selected_course['TargetGroup'] ); |
65 |
| - ?> |
66 |
| - </div> |
67 |
| - <?php } ?> |
68 |
| - <?php |
69 |
| - if ( ! in_array( 'prerequisites', $hide_sections, true ) && ! empty( $selected_course['Prerequisites'] ) ) { |
70 |
| - if ( $show_headers ) { |
71 |
| - ?> |
72 |
| - <h3><?php echo esc_html_x( 'Prerequisites', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 72 | + <?php |
| 73 | + if ( ! in_array( 'prerequisites', $hide_sections, true ) && ! empty( $selected_course['Prerequisites'] ) ) { |
| 74 | + if ( $show_headers ) { |
| 75 | + ?> |
| 76 | + <h3><?php echo esc_html_x( 'Prerequisites', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 77 | + <?php } ?> |
| 78 | + <div> |
| 79 | + <?php |
| 80 | + echo wp_kses_post( $selected_course['Prerequisites'] ); |
| 81 | + ?> |
| 82 | + </div> |
73 | 83 | <?php } ?>
|
74 |
| - <div> |
75 |
| - <?php |
76 |
| - echo wp_kses_post( $selected_course['Prerequisites'] ); |
77 |
| - ?> |
78 |
| - </div> |
79 |
| - <?php } ?> |
80 |
| - <?php |
81 |
| - if ( ! in_array( 'after', $hide_sections, true ) && ! empty( $selected_course['CourseAfter'] ) ) { |
82 |
| - if ( $show_headers ) { |
83 |
| - ?> |
84 |
| - <h3><?php echo esc_html_x( 'After the course', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 84 | + <?php |
| 85 | + if ( ! in_array( 'after', $hide_sections, true ) && ! empty( $selected_course['CourseAfter'] ) ) { |
| 86 | + if ( $show_headers ) { |
| 87 | + ?> |
| 88 | + <h3><?php echo esc_html_x( 'After the course', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 89 | + <?php } ?> |
| 90 | + <div> |
| 91 | + <?php |
| 92 | + echo wp_kses_post( $selected_course['CourseAfter'] ); |
| 93 | + ?> |
| 94 | + </div> |
85 | 95 | <?php } ?>
|
86 |
| - <div> |
87 |
| - <?php |
88 |
| - echo wp_kses_post( $selected_course['CourseAfter'] ); |
89 |
| - ?> |
90 |
| - </div> |
91 |
| - <?php } ?> |
92 |
| - <?php |
93 |
| - if ( ! in_array( 'quote', $hide_sections, true ) && ! empty( $selected_course['Quote'] ) ) { |
94 |
| - if ( $show_headers ) { |
95 |
| - ?> |
96 |
| - <h3><?php echo esc_html_x( 'Quotes', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 96 | + <?php |
| 97 | + if ( ! in_array( 'quote', $hide_sections, true ) && ! empty( $selected_course['Quote'] ) ) { |
| 98 | + if ( $show_headers ) { |
| 99 | + ?> |
| 100 | + <h3><?php echo esc_html_x( 'Quotes', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 101 | + <?php } ?> |
| 102 | + <div> |
| 103 | + <?php |
| 104 | + echo wp_kses_post( $selected_course['Quote'] ); |
| 105 | + ?> |
| 106 | + </div> |
97 | 107 | <?php } ?>
|
98 |
| - <div> |
| 108 | + </div> |
| 109 | + <div class="eventInformation"> |
| 110 | + <?php |
| 111 | + if ( ! in_array( 'time', $hide_sections, true ) && ! empty( $selected_course['StartTime'] ) && ! empty( $selected_course['EndTime'] ) ) { |
| 112 | + ?> |
| 113 | + <h3><?php echo esc_html_x( 'Time', 'frontend', 'eduadmin-booking' ); ?></h3> |
99 | 114 | <?php
|
100 |
| - echo wp_kses_post( $selected_course['Quote'] ); |
| 115 | + /* translators: 1: Number of days */ |
| 116 | + echo esc_html( ( $selected_course['Days'] > 0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) . $selected_course['StartTime'] . ' - ' . $selected_course['EndTime'] ); |
| 117 | + } |
| 118 | + |
| 119 | + if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) { |
101 | 120 | ?>
|
102 |
| - </div> |
103 |
| - <?php } ?> |
104 |
| - </div> |
105 |
| - <div class="eventInformation"> |
106 |
| - <?php |
107 |
| - if ( ! in_array( 'time', $hide_sections, true ) && ! empty( $selected_course['StartTime'] ) && ! empty( $selected_course['EndTime'] ) ) { |
| 121 | + <h3><?php echo esc_html_x( 'Price', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 122 | + <?php |
| 123 | + $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' ); |
| 124 | + |
| 125 | + if ( 1 === count( $prices ) ) { |
| 126 | + echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) ); |
| 127 | + } else { |
| 128 | + foreach ( $prices as $up ) { |
| 129 | + echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) ); |
| 130 | + } |
| 131 | + } |
| 132 | + } |
108 | 133 | ?>
|
109 |
| - <h3><?php echo esc_html_x( 'Time', 'frontend', 'eduadmin-booking' ); ?></h3> |
110 |
| - <?php |
111 |
| - /* translators: 1: Number of days */ |
112 |
| - echo esc_html( ( $selected_course['Days'] > 0 ? sprintf( _n( '%1$d day', '%1$d days', $selected_course['Days'], 'eduadmin-booking' ), $selected_course['Days'] ) . ', ' : '' ) . $selected_course['StartTime'] . ' - ' . $selected_course['EndTime'] ); |
113 |
| - } |
| 134 | + </div> |
114 | 135 |
|
115 |
| - if ( ! in_array( 'price', $hide_sections, true ) && ! empty( $prices ) ) { |
| 136 | + <?php |
| 137 | + include 'blocks/event-list.php'; |
| 138 | + if ( $allow_interest_reg_object && false !== $object_interest_page ) { |
116 | 139 | ?>
|
117 |
| - <h3><?php echo esc_html_x( 'Price', 'frontend', 'eduadmin-booking' ); ?></h3> |
| 140 | + <br /> |
| 141 | + <div class="inquiry"> |
| 142 | + <a class="inquiry-link" |
| 143 | + href="<?php echo esc_url( $base_url . '/' . make_slugs( $name ) . '__' . $selected_course['CourseTemplateId'] . '/interest/' . edu_get_query_string( '?' ) . '&_=' . time() ); ?>"><?php echo esc_html_x( 'Send inquiry about this course', 'frontend', 'eduadmin-booking' ); ?></a> |
| 144 | + </div> |
118 | 145 | <?php
|
119 |
| - $currency = EDU()->get_option( 'eduadmin-currency', 'SEK' ); |
120 |
| - |
121 |
| - if ( 1 === count( $prices ) ) { |
122 |
| - echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', current( $prices )['PriceNameDescription'], edu_get_price( current( $prices )['Price'], $selected_course['ParticipantVat'] ) ) ); |
123 |
| - } else { |
124 |
| - foreach ( $prices as $up ) { |
125 |
| - echo wp_kses_post( sprintf( '<div class="pricename"><span class="pricename-description">%1$s</span> <span class="pricename-price">%2$s</span></div>', $up['PriceNameDescription'], edu_get_price( $up['Price'], $selected_course['ParticipantVat'] ) ) ); |
126 |
| - } |
127 |
| - } |
128 | 146 | }
|
129 | 147 | ?>
|
130 | 148 | </div>
|
131 |
| - |
132 | 149 | <?php
|
133 |
| - include 'blocks/event-list.php'; |
134 |
| - if ( $allow_interest_reg_object && false !== $object_interest_page ) { |
135 |
| - ?> |
136 |
| - <br /> |
137 |
| - <div class="inquiry"> |
138 |
| - <a class="inquiry-link" |
139 |
| - href="<?php echo esc_url( $base_url . '/' . make_slugs( $name ) . '__' . $selected_course['CourseTemplateId'] . '/interest/' . edu_get_query_string( '?' ) . '&_=' . time() ); ?>"><?php echo esc_html_x( 'Send inquiry about this course', 'frontend', 'eduadmin-booking' ); ?></a> |
140 |
| - </div> |
141 |
| - <?php |
142 |
| - } |
143 |
| - ?> |
144 |
| - </div> |
145 |
| - <?php |
| 150 | + } |
146 | 151 | }
|
147 |
| - |
148 | 152 | $out = ob_get_clean();
|
149 | 153 |
|
150 | 154 | return $out;
|
0 commit comments