@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | * |
20 | 20 | */ |
21 | 21 | if (! defined('EVENT_ESPRESSO_VERSION')) { |
22 | - exit('No direct script access allowed'); |
|
22 | + exit('No direct script access allowed'); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | |
@@ -27,404 +27,404 @@ discard block |
||
27 | 27 | class Event extends Calculations_Base |
28 | 28 | { |
29 | 29 | |
30 | - /** |
|
31 | - * Calculates the total spaces on the event (not subtracting sales, but taking |
|
32 | - * sales into account; so this is the optimum sales that CAN still be achieved) |
|
33 | - * See EE_Event::total_available_spaces( true ); |
|
34 | - * |
|
35 | - * @param array $wpdb_row |
|
36 | - * @param \WP_REST_Request $request |
|
37 | - * @param Base $controller |
|
38 | - * @return int |
|
39 | - * @throws EE_Error |
|
40 | - */ |
|
41 | - public static function optimumSalesAtStart($wpdb_row, $request, $controller) |
|
42 | - { |
|
43 | - $event_obj = null; |
|
44 | - if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
45 | - $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
46 | - } |
|
47 | - if ($event_obj instanceof EE_Event) { |
|
48 | - return $event_obj->total_available_spaces(); |
|
49 | - } |
|
50 | - throw new EE_Error( |
|
51 | - sprintf( |
|
52 | - __( |
|
53 | - // @codingStandardsIgnoreStart |
|
54 | - 'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', |
|
55 | - // @codingStandardsIgnoreEnd |
|
56 | - 'event_espresso' |
|
57 | - ), |
|
58 | - $wpdb_row['Event_CPT.ID'], |
|
59 | - print_r($wpdb_row, true) |
|
60 | - ) |
|
61 | - ); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * Calculates the total spaces on the event (ignoring all sales; so this is the optimum |
|
68 | - * sales that COULD have been achieved) |
|
69 | - * See EE_Event::total_available_spaces( true ); |
|
70 | - * |
|
71 | - * @param array $wpdb_row |
|
72 | - * @param \WP_REST_Request $request |
|
73 | - * @param Base $controller |
|
74 | - * @return int |
|
75 | - * @throws EE_Error |
|
76 | - */ |
|
77 | - public static function optimumSalesNow($wpdb_row, $request, $controller) |
|
78 | - { |
|
79 | - $event_obj = null; |
|
80 | - if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
81 | - $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
82 | - } |
|
83 | - if ($event_obj instanceof EE_Event) { |
|
84 | - return $event_obj->total_available_spaces(true); |
|
85 | - } |
|
86 | - throw new EE_Error( |
|
87 | - sprintf( |
|
88 | - __( |
|
89 | - // @codingStandardsIgnoreStart |
|
90 | - 'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', |
|
91 | - // @codingStandardsIgnoreEnd |
|
92 | - 'event_espresso' |
|
93 | - ), |
|
94 | - $wpdb_row['Event_CPT.ID'], |
|
95 | - print_r($wpdb_row, true) |
|
96 | - ) |
|
97 | - ); |
|
98 | - } |
|
99 | - |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * Like optimum_sales_now, but minus total sales so far. |
|
104 | - * See EE_Event::spaces_remaining_for_sale( true ); |
|
105 | - * |
|
106 | - * @param array $wpdb_row |
|
107 | - * @param \WP_REST_Request $request |
|
108 | - * @param Base $controller |
|
109 | - * @return int |
|
110 | - * @throws EE_Error |
|
111 | - */ |
|
112 | - public static function spacesRemaining($wpdb_row, $request, $controller) |
|
113 | - { |
|
114 | - $event_obj = null; |
|
115 | - if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
116 | - $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
117 | - } |
|
118 | - if ($event_obj instanceof EE_Event) { |
|
119 | - return $event_obj->spaces_remaining_for_sale(); |
|
120 | - } |
|
121 | - throw new EE_Error( |
|
122 | - sprintf( |
|
123 | - __( |
|
124 | - // @codingStandardsIgnoreStart |
|
125 | - 'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', |
|
126 | - // @codingStandardsIgnoreEnd |
|
127 | - 'event_espresso' |
|
128 | - ), |
|
129 | - $wpdb_row['Event_CPT.ID'], |
|
130 | - print_r($wpdb_row, true) |
|
131 | - ) |
|
132 | - ); |
|
133 | - } |
|
134 | - |
|
135 | - |
|
136 | - |
|
137 | - /** |
|
138 | - * Counts the number of approved registrations for this event (regardless |
|
139 | - * of how many datetimes each registrations' ticket purchase is for) |
|
140 | - * |
|
141 | - * @param array $wpdb_row |
|
142 | - * @param \WP_REST_Request $request |
|
143 | - * @param Base $controller |
|
144 | - * @return int |
|
145 | - * @throws EE_Error |
|
146 | - */ |
|
147 | - public static function spotsTaken($wpdb_row, $request, $controller) |
|
148 | - { |
|
149 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
150 | - throw new EE_Error( |
|
151 | - sprintf( |
|
152 | - __( |
|
153 | - // @codingStandardsIgnoreStart |
|
154 | - 'Cannot calculate spots_taken because the database row %1$s does not have a valid entry for "Event_CPT.ID"', |
|
155 | - // @codingStandardsIgnoreEnd |
|
156 | - 'event_espresso' |
|
157 | - ), |
|
158 | - print_r($wpdb_row, true) |
|
159 | - ) |
|
160 | - ); |
|
161 | - } |
|
162 | - return EEM_Registration::instance()->count( |
|
163 | - array( |
|
164 | - array( |
|
165 | - 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
166 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
167 | - ), |
|
168 | - ), |
|
169 | - 'REG_ID', |
|
170 | - true |
|
171 | - ); |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - |
|
176 | - /** |
|
177 | - * Counts the number of pending-payment registrations for this event (regardless |
|
178 | - * of how many datetimes each registrations' ticket purchase is for) |
|
179 | - * |
|
180 | - * @param array $wpdb_row |
|
181 | - * @param \WP_REST_Request $request |
|
182 | - * @param Base $controller |
|
183 | - * @return int |
|
184 | - * @throws EE_Error |
|
185 | - * @throws RestException |
|
186 | - */ |
|
187 | - public static function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
|
188 | - { |
|
189 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
190 | - throw new EE_Error( |
|
191 | - sprintf( |
|
192 | - __( |
|
193 | - // @codingStandardsIgnoreStart |
|
194 | - 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
195 | - // @codingStandardsIgnoreEnd |
|
196 | - 'event_espresso' |
|
197 | - ), |
|
198 | - print_r($wpdb_row, true) |
|
199 | - ) |
|
200 | - ); |
|
201 | - } |
|
202 | - self::verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment'); |
|
203 | - return EEM_Registration::instance()->count( |
|
204 | - array( |
|
205 | - array( |
|
206 | - 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
207 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
208 | - ), |
|
209 | - ), |
|
210 | - 'REG_ID', |
|
211 | - true |
|
212 | - ); |
|
213 | - } |
|
214 | - |
|
215 | - |
|
216 | - |
|
217 | - /** |
|
218 | - * Counts all the registrations who have checked into one of this events' datetimes |
|
219 | - * See EE_Event::total_available_spaces( false ); |
|
220 | - * |
|
221 | - * @param array $wpdb_row |
|
222 | - * @param \WP_REST_Request $request |
|
223 | - * @param Base $controller |
|
224 | - * @return int|null if permission denied |
|
225 | - * @throws EE_Error |
|
226 | - * @throws RestException |
|
227 | - */ |
|
228 | - public static function registrationsCheckedInCount($wpdb_row, $request, $controller) |
|
229 | - { |
|
230 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
231 | - throw new EE_Error( |
|
232 | - sprintf( |
|
233 | - __( |
|
234 | - // @codingStandardsIgnoreStart |
|
235 | - 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
236 | - // @codingStandardsIgnoreEnd |
|
237 | - 'event_espresso' |
|
238 | - ), |
|
239 | - print_r($wpdb_row, true) |
|
240 | - ) |
|
241 | - ); |
|
242 | - } |
|
243 | - self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count'); |
|
244 | - return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true); |
|
245 | - } |
|
246 | - |
|
247 | - |
|
248 | - |
|
249 | - /** |
|
250 | - * Counts all the registrations who have checked out of one of this events' datetimes |
|
251 | - * See EE_Event::total_available_spaces( false ); |
|
252 | - * |
|
253 | - * @param array $wpdb_row |
|
254 | - * @param \WP_REST_Request $request |
|
255 | - * @param Base $controller |
|
256 | - * @return int |
|
257 | - * @throws EE_Error |
|
258 | - * @throws RestException |
|
259 | - */ |
|
260 | - public static function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
|
261 | - { |
|
262 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
263 | - throw new EE_Error( |
|
264 | - sprintf( |
|
265 | - __( |
|
266 | - // @codingStandardsIgnoreStart |
|
267 | - 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
268 | - // @codingStandardsIgnoreEnd |
|
269 | - 'event_espresso' |
|
270 | - ), |
|
271 | - print_r($wpdb_row, true) |
|
272 | - ) |
|
273 | - ); |
|
274 | - } |
|
275 | - self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count'); |
|
276 | - return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false); |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - |
|
281 | - /** |
|
282 | - * Gets the thumbnail image |
|
283 | - * |
|
284 | - * @param array $wpdb_row |
|
285 | - * @param \WP_REST_Request $request |
|
286 | - * @param Base $controller |
|
287 | - * @return array |
|
288 | - * @throws EE_Error |
|
289 | - */ |
|
290 | - public static function imageThumbnail($wpdb_row, $request, $controller) |
|
291 | - { |
|
292 | - return self::calculateImageData($wpdb_row, 'thumbnail'); |
|
293 | - } |
|
294 | - |
|
295 | - |
|
296 | - |
|
297 | - /** |
|
298 | - * Gets the medium image |
|
299 | - * |
|
300 | - * @param array $wpdb_row |
|
301 | - * @param \WP_REST_Request $request |
|
302 | - * @param Base $controller |
|
303 | - * @return array |
|
304 | - * @throws EE_Error |
|
305 | - */ |
|
306 | - public static function imageMedium($wpdb_row, $request, $controller) |
|
307 | - { |
|
308 | - return self::calculateImageData($wpdb_row, 'medium'); |
|
309 | - } |
|
310 | - |
|
311 | - |
|
312 | - |
|
313 | - /** |
|
314 | - * Gets the medium-large image |
|
315 | - * |
|
316 | - * @param array $wpdb_row |
|
317 | - * @param \WP_REST_Request $request |
|
318 | - * @param Base $controller |
|
319 | - * @return array |
|
320 | - * @throws EE_Error |
|
321 | - */ |
|
322 | - public static function imageMediumLarge($wpdb_row, $request, $controller) |
|
323 | - { |
|
324 | - return self::calculateImageData($wpdb_row, 'medium_large'); |
|
325 | - } |
|
326 | - |
|
327 | - |
|
328 | - |
|
329 | - /** |
|
330 | - * Gets the large image |
|
331 | - * |
|
332 | - * @param array $wpdb_row |
|
333 | - * @param \WP_REST_Request $request |
|
334 | - * @param Base $controller |
|
335 | - * @return array |
|
336 | - * @throws EE_Error |
|
337 | - */ |
|
338 | - public static function imageLarge($wpdb_row, $request, $controller) |
|
339 | - { |
|
340 | - return self::calculateImageData($wpdb_row, 'large'); |
|
341 | - } |
|
342 | - |
|
343 | - |
|
344 | - |
|
345 | - /** |
|
346 | - * Gets the post-thumbnail image |
|
347 | - * |
|
348 | - * @param array $wpdb_row |
|
349 | - * @param \WP_REST_Request $request |
|
350 | - * @param Base $controller |
|
351 | - * @return array |
|
352 | - * @throws EE_Error |
|
353 | - */ |
|
354 | - public static function imagePostThumbnail($wpdb_row, $request, $controller) |
|
355 | - { |
|
356 | - return self::calculateImageData($wpdb_row, 'post-thumbnail'); |
|
357 | - } |
|
358 | - |
|
359 | - |
|
360 | - |
|
361 | - /** |
|
362 | - * Gets the full size image |
|
363 | - * |
|
364 | - * @param array $wpdb_row |
|
365 | - * @param \WP_REST_Request $request |
|
366 | - * @param Base $controller |
|
367 | - * @return array |
|
368 | - * @throws EE_Error |
|
369 | - */ |
|
370 | - public static function imageFull($wpdb_row, $request, $controller) |
|
371 | - { |
|
372 | - return self::calculateImageData($wpdb_row, 'full'); |
|
373 | - } |
|
374 | - |
|
375 | - |
|
376 | - |
|
377 | - /** |
|
378 | - * Gets image specs and formats them for the display in the API, |
|
379 | - * according to the image size requested |
|
380 | - * |
|
381 | - * @param array $wpdb_row |
|
382 | - * @param string $image_size one of these: thumbnail, medium, medium_large, large, post-thumbnail, full |
|
383 | - * @return array|false if no such image exists. If array it will have keys 'url', 'width', 'height' and 'original' |
|
384 | - * @throws EE_Error |
|
385 | - */ |
|
386 | - protected static function calculateImageData($wpdb_row, $image_size) |
|
387 | - { |
|
388 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
389 | - throw new EE_Error( |
|
390 | - sprintf( |
|
391 | - __( |
|
392 | - // @codingStandardsIgnoreStart |
|
393 | - 'Cannot calculate image because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
394 | - // @codingStandardsIgnoreEnd |
|
395 | - 'event_espresso' |
|
396 | - ), |
|
397 | - print_r($wpdb_row, true) |
|
398 | - ) |
|
399 | - ); |
|
400 | - } |
|
401 | - $EVT_ID = $wpdb_row['Event_CPT.ID']; |
|
402 | - $attachment_id = get_post_thumbnail_id($EVT_ID); |
|
403 | - $data = wp_get_attachment_image_src($attachment_id, $image_size); |
|
404 | - if (! $data) { |
|
405 | - return null; |
|
406 | - } |
|
407 | - $generated = true; |
|
408 | - if (isset($data[3])) { |
|
409 | - $generated = $data[3]; |
|
410 | - } |
|
411 | - return array( |
|
412 | - 'url' => $data[0], |
|
413 | - 'width' => $data[1], |
|
414 | - 'height' => $data[2], |
|
415 | - 'generated' => $generated, |
|
416 | - ); |
|
417 | - } |
|
418 | - |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * Returns true if the array of data contains 'Event_CPT.ID'. False otherwise |
|
423 | - * @param array $wpdb_row |
|
424 | - * @return bool |
|
425 | - */ |
|
426 | - protected static function wpdbRowHasEventId($wpdb_row) |
|
427 | - { |
|
428 | - return (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID'])); |
|
429 | - } |
|
30 | + /** |
|
31 | + * Calculates the total spaces on the event (not subtracting sales, but taking |
|
32 | + * sales into account; so this is the optimum sales that CAN still be achieved) |
|
33 | + * See EE_Event::total_available_spaces( true ); |
|
34 | + * |
|
35 | + * @param array $wpdb_row |
|
36 | + * @param \WP_REST_Request $request |
|
37 | + * @param Base $controller |
|
38 | + * @return int |
|
39 | + * @throws EE_Error |
|
40 | + */ |
|
41 | + public static function optimumSalesAtStart($wpdb_row, $request, $controller) |
|
42 | + { |
|
43 | + $event_obj = null; |
|
44 | + if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
45 | + $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
46 | + } |
|
47 | + if ($event_obj instanceof EE_Event) { |
|
48 | + return $event_obj->total_available_spaces(); |
|
49 | + } |
|
50 | + throw new EE_Error( |
|
51 | + sprintf( |
|
52 | + __( |
|
53 | + // @codingStandardsIgnoreStart |
|
54 | + 'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found', |
|
55 | + // @codingStandardsIgnoreEnd |
|
56 | + 'event_espresso' |
|
57 | + ), |
|
58 | + $wpdb_row['Event_CPT.ID'], |
|
59 | + print_r($wpdb_row, true) |
|
60 | + ) |
|
61 | + ); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * Calculates the total spaces on the event (ignoring all sales; so this is the optimum |
|
68 | + * sales that COULD have been achieved) |
|
69 | + * See EE_Event::total_available_spaces( true ); |
|
70 | + * |
|
71 | + * @param array $wpdb_row |
|
72 | + * @param \WP_REST_Request $request |
|
73 | + * @param Base $controller |
|
74 | + * @return int |
|
75 | + * @throws EE_Error |
|
76 | + */ |
|
77 | + public static function optimumSalesNow($wpdb_row, $request, $controller) |
|
78 | + { |
|
79 | + $event_obj = null; |
|
80 | + if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
81 | + $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
82 | + } |
|
83 | + if ($event_obj instanceof EE_Event) { |
|
84 | + return $event_obj->total_available_spaces(true); |
|
85 | + } |
|
86 | + throw new EE_Error( |
|
87 | + sprintf( |
|
88 | + __( |
|
89 | + // @codingStandardsIgnoreStart |
|
90 | + 'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found', |
|
91 | + // @codingStandardsIgnoreEnd |
|
92 | + 'event_espresso' |
|
93 | + ), |
|
94 | + $wpdb_row['Event_CPT.ID'], |
|
95 | + print_r($wpdb_row, true) |
|
96 | + ) |
|
97 | + ); |
|
98 | + } |
|
99 | + |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * Like optimum_sales_now, but minus total sales so far. |
|
104 | + * See EE_Event::spaces_remaining_for_sale( true ); |
|
105 | + * |
|
106 | + * @param array $wpdb_row |
|
107 | + * @param \WP_REST_Request $request |
|
108 | + * @param Base $controller |
|
109 | + * @return int |
|
110 | + * @throws EE_Error |
|
111 | + */ |
|
112 | + public static function spacesRemaining($wpdb_row, $request, $controller) |
|
113 | + { |
|
114 | + $event_obj = null; |
|
115 | + if (Event::wpdbRowHasEventId($wpdb_row)) { |
|
116 | + $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']); |
|
117 | + } |
|
118 | + if ($event_obj instanceof EE_Event) { |
|
119 | + return $event_obj->spaces_remaining_for_sale(); |
|
120 | + } |
|
121 | + throw new EE_Error( |
|
122 | + sprintf( |
|
123 | + __( |
|
124 | + // @codingStandardsIgnoreStart |
|
125 | + 'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found', |
|
126 | + // @codingStandardsIgnoreEnd |
|
127 | + 'event_espresso' |
|
128 | + ), |
|
129 | + $wpdb_row['Event_CPT.ID'], |
|
130 | + print_r($wpdb_row, true) |
|
131 | + ) |
|
132 | + ); |
|
133 | + } |
|
134 | + |
|
135 | + |
|
136 | + |
|
137 | + /** |
|
138 | + * Counts the number of approved registrations for this event (regardless |
|
139 | + * of how many datetimes each registrations' ticket purchase is for) |
|
140 | + * |
|
141 | + * @param array $wpdb_row |
|
142 | + * @param \WP_REST_Request $request |
|
143 | + * @param Base $controller |
|
144 | + * @return int |
|
145 | + * @throws EE_Error |
|
146 | + */ |
|
147 | + public static function spotsTaken($wpdb_row, $request, $controller) |
|
148 | + { |
|
149 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
150 | + throw new EE_Error( |
|
151 | + sprintf( |
|
152 | + __( |
|
153 | + // @codingStandardsIgnoreStart |
|
154 | + 'Cannot calculate spots_taken because the database row %1$s does not have a valid entry for "Event_CPT.ID"', |
|
155 | + // @codingStandardsIgnoreEnd |
|
156 | + 'event_espresso' |
|
157 | + ), |
|
158 | + print_r($wpdb_row, true) |
|
159 | + ) |
|
160 | + ); |
|
161 | + } |
|
162 | + return EEM_Registration::instance()->count( |
|
163 | + array( |
|
164 | + array( |
|
165 | + 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
166 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
167 | + ), |
|
168 | + ), |
|
169 | + 'REG_ID', |
|
170 | + true |
|
171 | + ); |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + |
|
176 | + /** |
|
177 | + * Counts the number of pending-payment registrations for this event (regardless |
|
178 | + * of how many datetimes each registrations' ticket purchase is for) |
|
179 | + * |
|
180 | + * @param array $wpdb_row |
|
181 | + * @param \WP_REST_Request $request |
|
182 | + * @param Base $controller |
|
183 | + * @return int |
|
184 | + * @throws EE_Error |
|
185 | + * @throws RestException |
|
186 | + */ |
|
187 | + public static function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
|
188 | + { |
|
189 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
190 | + throw new EE_Error( |
|
191 | + sprintf( |
|
192 | + __( |
|
193 | + // @codingStandardsIgnoreStart |
|
194 | + 'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
195 | + // @codingStandardsIgnoreEnd |
|
196 | + 'event_espresso' |
|
197 | + ), |
|
198 | + print_r($wpdb_row, true) |
|
199 | + ) |
|
200 | + ); |
|
201 | + } |
|
202 | + self::verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment'); |
|
203 | + return EEM_Registration::instance()->count( |
|
204 | + array( |
|
205 | + array( |
|
206 | + 'EVT_ID' => $wpdb_row['Event_CPT.ID'], |
|
207 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
208 | + ), |
|
209 | + ), |
|
210 | + 'REG_ID', |
|
211 | + true |
|
212 | + ); |
|
213 | + } |
|
214 | + |
|
215 | + |
|
216 | + |
|
217 | + /** |
|
218 | + * Counts all the registrations who have checked into one of this events' datetimes |
|
219 | + * See EE_Event::total_available_spaces( false ); |
|
220 | + * |
|
221 | + * @param array $wpdb_row |
|
222 | + * @param \WP_REST_Request $request |
|
223 | + * @param Base $controller |
|
224 | + * @return int|null if permission denied |
|
225 | + * @throws EE_Error |
|
226 | + * @throws RestException |
|
227 | + */ |
|
228 | + public static function registrationsCheckedInCount($wpdb_row, $request, $controller) |
|
229 | + { |
|
230 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
231 | + throw new EE_Error( |
|
232 | + sprintf( |
|
233 | + __( |
|
234 | + // @codingStandardsIgnoreStart |
|
235 | + 'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
236 | + // @codingStandardsIgnoreEnd |
|
237 | + 'event_espresso' |
|
238 | + ), |
|
239 | + print_r($wpdb_row, true) |
|
240 | + ) |
|
241 | + ); |
|
242 | + } |
|
243 | + self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count'); |
|
244 | + return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true); |
|
245 | + } |
|
246 | + |
|
247 | + |
|
248 | + |
|
249 | + /** |
|
250 | + * Counts all the registrations who have checked out of one of this events' datetimes |
|
251 | + * See EE_Event::total_available_spaces( false ); |
|
252 | + * |
|
253 | + * @param array $wpdb_row |
|
254 | + * @param \WP_REST_Request $request |
|
255 | + * @param Base $controller |
|
256 | + * @return int |
|
257 | + * @throws EE_Error |
|
258 | + * @throws RestException |
|
259 | + */ |
|
260 | + public static function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
|
261 | + { |
|
262 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
263 | + throw new EE_Error( |
|
264 | + sprintf( |
|
265 | + __( |
|
266 | + // @codingStandardsIgnoreStart |
|
267 | + 'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
268 | + // @codingStandardsIgnoreEnd |
|
269 | + 'event_espresso' |
|
270 | + ), |
|
271 | + print_r($wpdb_row, true) |
|
272 | + ) |
|
273 | + ); |
|
274 | + } |
|
275 | + self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count'); |
|
276 | + return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false); |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + |
|
281 | + /** |
|
282 | + * Gets the thumbnail image |
|
283 | + * |
|
284 | + * @param array $wpdb_row |
|
285 | + * @param \WP_REST_Request $request |
|
286 | + * @param Base $controller |
|
287 | + * @return array |
|
288 | + * @throws EE_Error |
|
289 | + */ |
|
290 | + public static function imageThumbnail($wpdb_row, $request, $controller) |
|
291 | + { |
|
292 | + return self::calculateImageData($wpdb_row, 'thumbnail'); |
|
293 | + } |
|
294 | + |
|
295 | + |
|
296 | + |
|
297 | + /** |
|
298 | + * Gets the medium image |
|
299 | + * |
|
300 | + * @param array $wpdb_row |
|
301 | + * @param \WP_REST_Request $request |
|
302 | + * @param Base $controller |
|
303 | + * @return array |
|
304 | + * @throws EE_Error |
|
305 | + */ |
|
306 | + public static function imageMedium($wpdb_row, $request, $controller) |
|
307 | + { |
|
308 | + return self::calculateImageData($wpdb_row, 'medium'); |
|
309 | + } |
|
310 | + |
|
311 | + |
|
312 | + |
|
313 | + /** |
|
314 | + * Gets the medium-large image |
|
315 | + * |
|
316 | + * @param array $wpdb_row |
|
317 | + * @param \WP_REST_Request $request |
|
318 | + * @param Base $controller |
|
319 | + * @return array |
|
320 | + * @throws EE_Error |
|
321 | + */ |
|
322 | + public static function imageMediumLarge($wpdb_row, $request, $controller) |
|
323 | + { |
|
324 | + return self::calculateImageData($wpdb_row, 'medium_large'); |
|
325 | + } |
|
326 | + |
|
327 | + |
|
328 | + |
|
329 | + /** |
|
330 | + * Gets the large image |
|
331 | + * |
|
332 | + * @param array $wpdb_row |
|
333 | + * @param \WP_REST_Request $request |
|
334 | + * @param Base $controller |
|
335 | + * @return array |
|
336 | + * @throws EE_Error |
|
337 | + */ |
|
338 | + public static function imageLarge($wpdb_row, $request, $controller) |
|
339 | + { |
|
340 | + return self::calculateImageData($wpdb_row, 'large'); |
|
341 | + } |
|
342 | + |
|
343 | + |
|
344 | + |
|
345 | + /** |
|
346 | + * Gets the post-thumbnail image |
|
347 | + * |
|
348 | + * @param array $wpdb_row |
|
349 | + * @param \WP_REST_Request $request |
|
350 | + * @param Base $controller |
|
351 | + * @return array |
|
352 | + * @throws EE_Error |
|
353 | + */ |
|
354 | + public static function imagePostThumbnail($wpdb_row, $request, $controller) |
|
355 | + { |
|
356 | + return self::calculateImageData($wpdb_row, 'post-thumbnail'); |
|
357 | + } |
|
358 | + |
|
359 | + |
|
360 | + |
|
361 | + /** |
|
362 | + * Gets the full size image |
|
363 | + * |
|
364 | + * @param array $wpdb_row |
|
365 | + * @param \WP_REST_Request $request |
|
366 | + * @param Base $controller |
|
367 | + * @return array |
|
368 | + * @throws EE_Error |
|
369 | + */ |
|
370 | + public static function imageFull($wpdb_row, $request, $controller) |
|
371 | + { |
|
372 | + return self::calculateImageData($wpdb_row, 'full'); |
|
373 | + } |
|
374 | + |
|
375 | + |
|
376 | + |
|
377 | + /** |
|
378 | + * Gets image specs and formats them for the display in the API, |
|
379 | + * according to the image size requested |
|
380 | + * |
|
381 | + * @param array $wpdb_row |
|
382 | + * @param string $image_size one of these: thumbnail, medium, medium_large, large, post-thumbnail, full |
|
383 | + * @return array|false if no such image exists. If array it will have keys 'url', 'width', 'height' and 'original' |
|
384 | + * @throws EE_Error |
|
385 | + */ |
|
386 | + protected static function calculateImageData($wpdb_row, $image_size) |
|
387 | + { |
|
388 | + if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
389 | + throw new EE_Error( |
|
390 | + sprintf( |
|
391 | + __( |
|
392 | + // @codingStandardsIgnoreStart |
|
393 | + 'Cannot calculate image because the database row %1$s does not have an entry for "Event_CPT.ID"', |
|
394 | + // @codingStandardsIgnoreEnd |
|
395 | + 'event_espresso' |
|
396 | + ), |
|
397 | + print_r($wpdb_row, true) |
|
398 | + ) |
|
399 | + ); |
|
400 | + } |
|
401 | + $EVT_ID = $wpdb_row['Event_CPT.ID']; |
|
402 | + $attachment_id = get_post_thumbnail_id($EVT_ID); |
|
403 | + $data = wp_get_attachment_image_src($attachment_id, $image_size); |
|
404 | + if (! $data) { |
|
405 | + return null; |
|
406 | + } |
|
407 | + $generated = true; |
|
408 | + if (isset($data[3])) { |
|
409 | + $generated = $data[3]; |
|
410 | + } |
|
411 | + return array( |
|
412 | + 'url' => $data[0], |
|
413 | + 'width' => $data[1], |
|
414 | + 'height' => $data[2], |
|
415 | + 'generated' => $generated, |
|
416 | + ); |
|
417 | + } |
|
418 | + |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * Returns true if the array of data contains 'Event_CPT.ID'. False otherwise |
|
423 | + * @param array $wpdb_row |
|
424 | + * @return bool |
|
425 | + */ |
|
426 | + protected static function wpdbRowHasEventId($wpdb_row) |
|
427 | + { |
|
428 | + return (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID'])); |
|
429 | + } |
|
430 | 430 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | * @author Mike Nelson |
19 | 19 | * |
20 | 20 | */ |
21 | -if (! defined('EVENT_ESPRESSO_VERSION')) { |
|
21 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
22 | 22 | exit('No direct script access allowed'); |
23 | 23 | } |
24 | 24 | |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public static function spotsTaken($wpdb_row, $request, $controller) |
148 | 148 | { |
149 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
149 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
150 | 150 | throw new EE_Error( |
151 | 151 | sprintf( |
152 | 152 | __( |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | */ |
187 | 187 | public static function spotsTakenPendingPayment($wpdb_row, $request, $controller) |
188 | 188 | { |
189 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
189 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
190 | 190 | throw new EE_Error( |
191 | 191 | sprintf( |
192 | 192 | __( |
@@ -227,7 +227,7 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public static function registrationsCheckedInCount($wpdb_row, $request, $controller) |
229 | 229 | { |
230 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
230 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
231 | 231 | throw new EE_Error( |
232 | 232 | sprintf( |
233 | 233 | __( |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | */ |
260 | 260 | public static function registrationsCheckedOutCount($wpdb_row, $request, $controller) |
261 | 261 | { |
262 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
262 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
263 | 263 | throw new EE_Error( |
264 | 264 | sprintf( |
265 | 265 | __( |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | */ |
386 | 386 | protected static function calculateImageData($wpdb_row, $image_size) |
387 | 387 | { |
388 | - if (! Event::wpdbRowHasEventId($wpdb_row)) { |
|
388 | + if ( ! Event::wpdbRowHasEventId($wpdb_row)) { |
|
389 | 389 | throw new EE_Error( |
390 | 390 | sprintf( |
391 | 391 | __( |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $EVT_ID = $wpdb_row['Event_CPT.ID']; |
402 | 402 | $attachment_id = get_post_thumbnail_id($EVT_ID); |
403 | 403 | $data = wp_get_attachment_image_src($attachment_id, $image_size); |
404 | - if (! $data) { |
|
404 | + if ( ! $data) { |
|
405 | 405 | return null; |
406 | 406 | } |
407 | 407 | $generated = true; |
@@ -14,17 +14,17 @@ |
||
14 | 14 | * ------------------------------------------------------------------------ |
15 | 15 | */ |
16 | 16 | /** |
17 | - * |
|
18 | - * Class EE_Receipt_Line_Item_Display_Strategy |
|
19 | - * |
|
20 | - * Description |
|
21 | - * |
|
22 | - * @package Event Espresso |
|
23 | - * @subpackage core |
|
24 | - * @author Brent Christensen |
|
25 | - * |
|
26 | - * |
|
27 | - */ |
|
17 | + * |
|
18 | + * Class EE_Receipt_Line_Item_Display_Strategy |
|
19 | + * |
|
20 | + * Description |
|
21 | + * |
|
22 | + * @package Event Espresso |
|
23 | + * @subpackage core |
|
24 | + * @author Brent Christensen |
|
25 | + * |
|
26 | + * |
|
27 | + */ |
|
28 | 28 | |
29 | 29 | class EE_Receipt_Line_Item_Display_Strategy implements EEI_Line_Item_Display { |
30 | 30 |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Line_Item_Display |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Line_Item_Display |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Line_Item_Display { |
15 | 15 | |
16 | 16 | private $strategy = NULL; |
@@ -1,16 +1,16 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Default_Line_Item_Display_Strategy |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Default_Line_Item_Display_Strategy |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | |
15 | 15 | class EE_Default_Line_Item_Display_Strategy implements EEI_Line_Item_Display { |
16 | 16 | |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | // quantity td |
165 | 165 | $html .= EEH_HTML::td( $line_item->quantity(), '', 'item_l jst-rght' ); |
166 | 166 | $tax_rate = $line_item->is_taxable() |
167 | - && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes |
|
167 | + && EE_Registry::instance()->CFG->tax_settings->prices_displayed_including_taxes |
|
168 | 168 | ? 1 + ( $this->_tax_rate / 100 ) |
169 | 169 | : 1; |
170 | 170 | // price td |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
2 | 2 | /** |
3 | - * |
|
4 | - * Class EE_Invoice_Line_Item_Display_Strategy |
|
5 | - * |
|
6 | - * Description |
|
7 | - * |
|
8 | - * @package Event Espresso |
|
9 | - * @subpackage core |
|
10 | - * @author Brent Christensen |
|
11 | - * |
|
12 | - * |
|
13 | - */ |
|
3 | + * |
|
4 | + * Class EE_Invoice_Line_Item_Display_Strategy |
|
5 | + * |
|
6 | + * Description |
|
7 | + * |
|
8 | + * @package Event Espresso |
|
9 | + * @subpackage core |
|
10 | + * @author Brent Christensen |
|
11 | + * |
|
12 | + * |
|
13 | + */ |
|
14 | 14 | class EE_Invoice_Line_Item_Display_Strategy implements EEI_Line_Item_Display { |
15 | 15 | |
16 | 16 | /** |
@@ -11,49 +11,49 @@ discard block |
||
11 | 11 | * |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Select_Display_Strategy extends EE_Display_Strategy_Base{ |
|
14 | +class EE_Select_Display_Strategy extends EE_Display_Strategy_Base { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * |
18 | 18 | * @throws EE_Error |
19 | 19 | * @return string of html to display the field |
20 | 20 | */ |
21 | - function display(){ |
|
22 | - if( ! $this->_input instanceof EE_Form_Input_With_Options_Base){ |
|
23 | - throw new EE_Error( sprintf( __( 'Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso' ))); |
|
21 | + function display() { |
|
22 | + if ( ! $this->_input instanceof EE_Form_Input_With_Options_Base) { |
|
23 | + throw new EE_Error(sprintf(__('Cannot use Select Display Strategy with an input that doesn\'t have options', 'event_espresso'))); |
|
24 | 24 | } |
25 | 25 | |
26 | - $html = EEH_HTML::nl( 0, 'select' ); |
|
26 | + $html = EEH_HTML::nl(0, 'select'); |
|
27 | 27 | $html .= '<select'; |
28 | - $html .= ' id="' . $this->_input->html_id() . '"'; |
|
29 | - $html .= ' name="' . $this->_input->html_name() . '"'; |
|
30 | - $class = $this->_input->required() ? $this->_input->required_css_class() . ' ' . $this->_input->html_class() : $this->_input->html_class(); |
|
31 | - $html .= ' class="' . $class . '"'; |
|
28 | + $html .= ' id="'.$this->_input->html_id().'"'; |
|
29 | + $html .= ' name="'.$this->_input->html_name().'"'; |
|
30 | + $class = $this->_input->required() ? $this->_input->required_css_class().' '.$this->_input->html_class() : $this->_input->html_class(); |
|
31 | + $html .= ' class="'.$class.'"'; |
|
32 | 32 | // add html5 required |
33 | 33 | $html .= $this->_input->required() ? ' required' : ''; |
34 | - $html .= ' style="' . $this->_input->html_style() . '"'; |
|
35 | - $html .= ' ' . $this->_input->other_html_attributes(); |
|
34 | + $html .= ' style="'.$this->_input->html_style().'"'; |
|
35 | + $html .= ' '.$this->_input->other_html_attributes(); |
|
36 | 36 | $html .= '>'; |
37 | 37 | |
38 | - if ( EEH_Array::is_multi_dimensional_array( $this->_input->options() )) { |
|
39 | - EEH_HTML::indent( 1, 'optgroup' ); |
|
40 | - foreach( $this->_input->options() as $opt_group_label => $opt_group ){ |
|
38 | + if (EEH_Array::is_multi_dimensional_array($this->_input->options())) { |
|
39 | + EEH_HTML::indent(1, 'optgroup'); |
|
40 | + foreach ($this->_input->options() as $opt_group_label => $opt_group) { |
|
41 | 41 | if ( ! empty($opt_group_label)) { |
42 | - $html .= EEH_HTML::nl(0, 'optgroup') . '<optgroup label="' . esc_attr($opt_group_label) . '">'; |
|
42 | + $html .= EEH_HTML::nl(0, 'optgroup').'<optgroup label="'.esc_attr($opt_group_label).'">'; |
|
43 | 43 | } |
44 | - EEH_HTML::indent( 1, 'option' ); |
|
45 | - $html .= $this->_display_options( $opt_group ); |
|
44 | + EEH_HTML::indent(1, 'option'); |
|
45 | + $html .= $this->_display_options($opt_group); |
|
46 | 46 | EEH_HTML::indent( -1, 'option' ); |
47 | 47 | if ( ! empty($opt_group_label)) { |
48 | - $html .= EEH_HTML::nl( 0, 'optgroup' ) . '</optgroup>'; |
|
48 | + $html .= EEH_HTML::nl(0, 'optgroup').'</optgroup>'; |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | EEH_HTML::indent( -1, 'optgroup' ); |
52 | 52 | } else { |
53 | - $html.=$this->_display_options( $this->_input->options() ); |
|
53 | + $html .= $this->_display_options($this->_input->options()); |
|
54 | 54 | } |
55 | 55 | |
56 | - $html.= EEH_HTML::nl( 0, 'select' ) . '</select>'; |
|
56 | + $html .= EEH_HTML::nl(0, 'select').'</select>'; |
|
57 | 57 | return $html; |
58 | 58 | } |
59 | 59 | |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | * @param array $options |
65 | 65 | * @return string |
66 | 66 | */ |
67 | - protected function _display_options($options){ |
|
67 | + protected function _display_options($options) { |
|
68 | 68 | $html = ''; |
69 | - EEH_HTML::indent( 1, 'option' ); |
|
70 | - foreach( $options as $value => $display_text ){ |
|
69 | + EEH_HTML::indent(1, 'option'); |
|
70 | + foreach ($options as $value => $display_text) { |
|
71 | 71 | //even if this input uses EE_Text_Normalization if one of the array keys is a numeric string, like "123", |
72 | 72 | //PHP will have converted it to a PHP integer (eg 123). So we need to make sure it's a string |
73 | - $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one( $value ); |
|
74 | - $selected = $this->_check_if_option_selected($unnormalized_value ) ? ' selected="selected"' : ''; |
|
75 | - $html.= EEH_HTML::nl( 0, 'option' ) . '<option value="' . esc_attr($unnormalized_value ) . '"' . $selected . '>' . $display_text . '</option>'; |
|
73 | + $unnormalized_value = $this->_input->get_normalization_strategy()->unnormalize_one($value); |
|
74 | + $selected = $this->_check_if_option_selected($unnormalized_value) ? ' selected="selected"' : ''; |
|
75 | + $html .= EEH_HTML::nl(0, 'option').'<option value="'.esc_attr($unnormalized_value).'"'.$selected.'>'.$display_text.'</option>'; |
|
76 | 76 | } |
77 | 77 | EEH_HTML::indent( -1, 'option' ); |
78 | 78 | return $html; |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param string|int $option_value unnormalized value option (string). How it will appear in the HTML. |
87 | 87 | * @return string |
88 | 88 | */ |
89 | - protected function _check_if_option_selected($option_value ){ |
|
89 | + protected function _check_if_option_selected($option_value) { |
|
90 | 90 | return $option_value === $this->_input->raw_value(); |
91 | 91 | } |
92 | 92 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | * |
13 | 13 | * |
14 | 14 | */ |
15 | -class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy{ |
|
15 | +class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy { |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * Arguments that will be passed into the select2 javascript constructor |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @param array $select2_js_args pass in the EXACT array of JS arguments you want |
26 | 26 | * to pass into the select2 js/html input. See https://select2.github.io |
27 | 27 | */ |
28 | - public function __construct( $select2_js_args = array() ) { |
|
28 | + public function __construct($select2_js_args = array()) { |
|
29 | 29 | $this->_select2_js_args = $select2_js_args; |
30 | 30 | parent::__construct(); |
31 | 31 | } |
@@ -37,12 +37,12 @@ discard block |
||
37 | 37 | public function enqueue_js() { |
38 | 38 | // need to first deregister the select2 script in case some other plugin **cough cough Toolset Types cough** |
39 | 39 | // is carelessly registering an older version of Select2 on admin pages that don't even belong to them |
40 | - wp_deregister_script( 'select2' ); |
|
41 | - wp_deregister_style( 'select2' ); |
|
42 | - wp_register_script( 'select2', EE_GLOBAL_ASSETS_URL . 'scripts/select2.min.js', array(), '4.0.2', true ); |
|
43 | - wp_register_style( 'select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all' ); |
|
44 | - wp_enqueue_script( 'form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true ); |
|
45 | - wp_enqueue_style( 'select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all' ); |
|
40 | + wp_deregister_script('select2'); |
|
41 | + wp_deregister_style('select2'); |
|
42 | + wp_register_script('select2', EE_GLOBAL_ASSETS_URL.'scripts/select2.min.js', array(), '4.0.2', true); |
|
43 | + wp_register_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
44 | + wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL.'scripts/form_section_select2_init.js', array('select2'), '1.0.0', true); |
|
45 | + wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all'); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | * Sets the exact js args which will be passed into the select2 js/html input |
58 | 58 | * @param array $js_args |
59 | 59 | */ |
60 | - public function set_js_args( $js_args ) { |
|
60 | + public function set_js_args($js_args) { |
|
61 | 61 | $this->_select2_js_args = $js_args; |
62 | 62 | } |
63 | 63 | |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | * @param array $other_js_data |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public function get_other_js_data( $other_js_data = array() ) { |
|
70 | - $other_js_data = parent::get_other_js_data( $other_js_data ); |
|
71 | - if( ! isset( $other_js_data[ 'select2s' ] ) ) { |
|
69 | + public function get_other_js_data($other_js_data = array()) { |
|
70 | + $other_js_data = parent::get_other_js_data($other_js_data); |
|
71 | + if ( ! isset($other_js_data['select2s'])) { |
|
72 | 72 | $other_js_data['select2s'] = array(); |
73 | 73 | } |
74 | - $other_js_data[ 'select2s' ][ $this->_input->html_id() ] = $this->get_js_args(); |
|
74 | + $other_js_data['select2s'][$this->_input->html_id()] = $this->get_js_args(); |
|
75 | 75 | return $other_js_data; |
76 | 76 | } |
77 | 77 | } |
78 | 78 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * Class EE_Country_Select_Input |
4 | 4 | * |
@@ -11,23 +11,23 @@ discard block |
||
11 | 11 | * |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Country_Select_Input extends EE_Select_Input{ |
|
14 | +class EE_Country_Select_Input extends EE_Select_Input { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $country_options |
18 | 18 | * @param array $input_settings |
19 | 19 | * @return EE_Country_Select_Input |
20 | 20 | */ |
21 | - public function __construct( $country_options = NULL, $input_settings = array() ){ |
|
21 | + public function __construct($country_options = NULL, $input_settings = array()) { |
|
22 | 22 | $country_options = apply_filters( |
23 | 23 | 'FHEE__EE_Country_Select_Input____construct__country_options', |
24 | - $this->get_country_answer_options( $country_options ), |
|
24 | + $this->get_country_answer_options($country_options), |
|
25 | 25 | $this |
26 | 26 | ); |
27 | - $input_settings['html_class'] = isset( $input_settings['html_class'] ) |
|
28 | - ? $input_settings['html_class'] . ' ee-country-select-js' |
|
27 | + $input_settings['html_class'] = isset($input_settings['html_class']) |
|
28 | + ? $input_settings['html_class'].' ee-country-select-js' |
|
29 | 29 | : 'ee-country-select-js'; |
30 | - parent::__construct( $country_options, $input_settings ); |
|
30 | + parent::__construct($country_options, $input_settings); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | * @param array $country_options |
39 | 39 | * @return array |
40 | 40 | */ |
41 | - public function get_country_answer_options( $country_options = NULL ){ |
|
41 | + public function get_country_answer_options($country_options = NULL) { |
|
42 | 42 | // if passed something that is NOT an array |
43 | - if ( ! is_array( $country_options )) { |
|
43 | + if ( ! is_array($country_options)) { |
|
44 | 44 | // get possibly cached list of countries |
45 | 45 | $countries = EEM_Country::instance()->get_all_active_countries(); |
46 | - if ( ! empty( $countries )) { |
|
47 | - $country_options[ '' ] = ''; |
|
48 | - foreach( $countries as $country ){ |
|
49 | - if ( $country instanceof EE_Country ) { |
|
50 | - $country_options[ $country->ID() ] = $country->name(); |
|
46 | + if ( ! empty($countries)) { |
|
47 | + $country_options[''] = ''; |
|
48 | + foreach ($countries as $country) { |
|
49 | + if ($country instanceof EE_Country) { |
|
50 | + $country_options[$country->ID()] = $country->name(); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } else { |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php if (!defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); } |
|
2 | 2 | /** |
3 | 3 | * |
4 | 4 | * Class EE_Checkbox_Multi_Input |
@@ -11,16 +11,16 @@ discard block |
||
11 | 11 | * |
12 | 12 | * |
13 | 13 | */ |
14 | -class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base{ |
|
14 | +class EE_Checkbox_Multi_Input extends EE_Form_Input_With_Options_Base { |
|
15 | 15 | |
16 | 16 | /** |
17 | 17 | * @param array $input_settings |
18 | 18 | * @param array | EE_Question_Option[] $answer_options |
19 | 19 | */ |
20 | - public function __construct( $answer_options, $input_settings = array() ) { |
|
21 | - $this->_set_display_strategy( new EE_Checkbox_Display_Strategy() ); |
|
22 | - $this->_add_validation_strategy( new EE_Many_Valued_Validation_Strategy( array( new EE_Enum_Validation_Strategy( isset( $input_settings[ 'validation_error_message' ] ) ? $input_settings[ 'validation_error_message' ] : NULL ) ))); |
|
20 | + public function __construct($answer_options, $input_settings = array()) { |
|
21 | + $this->_set_display_strategy(new EE_Checkbox_Display_Strategy()); |
|
22 | + $this->_add_validation_strategy(new EE_Many_Valued_Validation_Strategy(array(new EE_Enum_Validation_Strategy(isset($input_settings['validation_error_message']) ? $input_settings['validation_error_message'] : NULL)))); |
|
23 | 23 | $this->_multiple_selections = TRUE; |
24 | - parent::__construct( $answer_options, $input_settings ); |
|
24 | + parent::__construct($answer_options, $input_settings); |
|
25 | 25 | } |
26 | 26 | } |
27 | 27 | \ No newline at end of file |