PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.29
Booktics – Appointment Booking Calendar for Service Businesses v1.0.29
1.0.29 1.0.28 1.0.27 1.0.26 1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 All 31 releases
← All changes | core/service/controllers/service-controller.php +187 -147 1.0.2 → 1.0.29 View file →
@@ -7,8 +7,9 @@
7 7 use Booktics\Models\Team_Member_Model;
8 8 use Booktics\Services\Schedule_Manager;
9 9 use Booktics\Services\Schedule_Record;
10 10 use Booktics\Taxonomy\Category;
11 +use Booktics\Service\Helpers\Service_Helper;
11 12 use Exception;
12 13 use WP_Error;
13 14 use WP_HTTP_Response;
14 15 use WP_REST_Server;
@@ -149,14 +150,13 @@
149 150 $service = $service->to_array();
150 151
151 152 $team_member_ids = is_array( $service['team_member'] )
152 153 ? array_unique( $service['team_member'] ) : array( $service['team_member'] );
153 - $service['team_member_details'] = $this->team_member_details( $team_member_ids );
154 + $service['team_member_details'] = Service_Helper::team_member_details( $team_member_ids );
154 155 $service['team_member'] = $team_member_ids;
155 156
156 - $category_ids = is_array( $service['categories'] )
157 - ? array_unique( $service['categories'] ) : array( $service['categories'] );
158 - $service['category_details'] = $this->category_details( $category_ids );
157 + $category_ids = $this->get_service_category_ids( $service['id'] );
158 + $service['category_details'] = Service_Helper::category_details( $category_ids );
159 159 $service['categories'] = $category_ids;
160 160
161 161 $schedule_record = ( new Schedule_Record() )
162 162 ->get_schedules( $id, 'service' );
@@ -164,9 +164,9 @@
164 164 : $schedule_record['schedule'];
165 165
166 166 $service['custom'] = $schedule_record['custom'];
167 167 $service['holiday'] = $schedule_record['holiday'];
168 - $service['shortcode'] = '[booktics-service-view id="' . $service['id'] . '"]';
168 + $service['shortcode'] = '[booktics_service_view id="' . $service['id'] . '"]';
169 169 $service = apply_filters( 'booktics_service_format', $service );
170 170
171 171 return $this->response( $service );
172 172 }
@@ -195,8 +195,9 @@
195 195
196 196 $args = array(
197 197 'per_page' => $per_page,
198 198 'paged' => $paged,
199 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Meta query is necessary for filtering services by meta fields
199 200 'meta_query' => array(),
200 201 );
201 202
202 203 if ( ! empty( $request['team_member_id'] ) ) {
@@ -206,16 +207,8 @@
206 207 'compare' => 'LIKE',
207 208 );
208 209 }
209 210
210 - if ( ! empty( $request['category_id'] ) ) {
211 - $args['meta_query'][] = array(
212 - 'key' => 'categories',
213 - 'value' => sprintf( 'i:%d;', intval( $request['category_id'] ) ),
214 - 'compare' => 'LIKE',
215 - );
216 - }
217 -
218 211 if ( ! empty( $request['search'] ) ) {
219 212 $args['s'] = sanitize_text_field( $request['search'] );
220 213 }
221 214
@@ -222,8 +215,30 @@
222 215 if ( ! empty( $args['meta_query'] ) ) {
223 216 $args['meta_query']['relation'] = 'AND';
224 217 }
225 218
219 + $args = apply_filters( 'booktics_service_args', $args, $request );
220 +
221 + // Get service IDs for category BEFORE pagination to ensure correct total count
222 + $service_ids_for_category = null;
223 + if ( ! empty( $request['category_id'] ) ) {
224 + $service_ids_for_category = get_term_meta( absint( $request['category_id'] ), 'booktics_category_services', true );
225 +
226 + // If category filter is applied, add post__in to args to filter BEFORE pagination
227 + if ( ! empty( $service_ids_for_category ) && is_array( $service_ids_for_category ) ) {
228 + $args['post__in'] = $service_ids_for_category;
229 + } elseif ( ! empty( $service_ids_for_category ) ) {
230 + // If category has no services, return early
231 + return $this->response( array(
232 + 'items' => array(),
233 + 'total' => 0,
234 + 'per_page' => $per_page,
235 + 'current_page' => $paged,
236 + 'last_page' => 0,
237 + ) );
238 + }
239 + }
240 +
226 241 $data = Service_Model::paginate( $per_page, $paged, $args );
227 242
228 243 if ( ! $data ) {
229 244 return $this->error( __( 'No service found', 'booktics' ), 404 );
@@ -232,20 +247,20 @@
232 247 if ( ! empty( $data['items'] ) ) {
233 248 $enhanced_items = array();
234 249 foreach ( $data['items'] as $service ) {
235 250 $service_array = $service->to_array();
251 +
236 252 if ( ! empty( $service_array['team_member'] ) ) {
237 253 $team_member_ids = is_array( $service->team_member ) ? array_unique( $service->team_member ) : array( $service->team_member );
238 254 $service->team_member = $team_member_ids;
239 - $service_array['team_member_details'] = $this->team_member_details( $team_member_ids );
255 + $service_array['team_member_details'] = Service_Helper::team_member_details( $team_member_ids );
240 256 }
241 -
242 - if ( ! empty( $service_array['categories'] ) ) {
243 - $category_ids = is_array( $service->categories ) ? array_unique( $service->categories ) : array( $service->categories );
257 + $category_ids = $this->get_service_category_ids( $service_array['id'] );
258 + if ( ! empty( $category_ids ) ) {
244 259 $service->categories = $category_ids;
245 - $service_array['category_details'] = $this->category_details( $category_ids );
260 + $service_array['category_details'] = Service_Helper::category_details( $category_ids );
246 261 }
247 - $service_array['shortcode'] = '[booktics-service-view id="' . $service_array['id'] . '"]';
262 + $service_array['shortcode'] = '[booktics_service_view id="' . $service_array['id'] . '"]';
248 263 $service_array = apply_filters( 'booktics_service_format', $service_array );
249 264 $enhanced_items[] = $service_array;
250 265 }
251 266 $data['items'] = $enhanced_items;
@@ -254,8 +269,39 @@
254 269 return $this->response( $data );
255 270 }
256 271
257 272 /**
273 + * Get all category IDs linked to a given service
274 + *
275 + * @param int $service_id
276 + * @return array
277 + */
278 + private function get_service_category_ids( int $service_id ): array {
279 + $args = array(
280 + 'taxonomy' => 'booktics_service_category', // Category taxonomy
281 + 'hide_empty' => false,
282 + // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- Meta query is necessary for services by category ID
283 + 'meta_query' => array(
284 + array(
285 + 'key' => 'booktics_category_services',
286 + 'value' => sprintf( 'i:%d;', $service_id ),
287 + 'compare' => 'LIKE',
288 + ),
289 + ),
290 + 'fields' => 'ids', // returning only ids
291 + );
292 +
293 + $categories = get_terms( $args );
294 +
295 + if ( is_wp_error( $categories ) || empty( $categories ) ) {
296 + return [];
297 + }
298 +
299 + return $categories;
300 + }
301 +
302 +
303 + /**
258 304 * Check if a given request has access to get items.
259 305 *
260 306 * @param $request
261 307 *
@@ -282,15 +328,20 @@
282 328 $service = Service_Model::create( $data );
283 329
284 330 do_action( 'booktics_service_created', $service, $request );
285 331
332 + if ( ! empty( $data['team_member'] ) && is_array( $data['team_member'] ) ) {
333 + $this->update_team_members( $service->id, $data['team_member'] );
334 + $this->remove_service_from_other_team_members( $service->id, $data['team_member'] );
335 + }
336 +
286 337 if ( is_wp_error( $service ) ) {
287 338 return $this->error( $service->get_error_message() );
288 339 }
289 340 $service = $service->to_array();
290 - $service['shortcode'] = '[booktics-service-view id="' . $service['id'] . '"]';
291 - $service['category_details'] = array();
292 - $service['team_member_details'] = array();
341 + $service['shortcode'] = '[booktics_service_view id="' . $service['id'] . '"]';
342 + $service['category_details'] = Service_Helper::category_details( $service['categories'] );
343 + $service['team_member_details'] = Service_Helper::team_member_details( $service['team_member'] );
293 344 $service = apply_filters( 'booktics_service_format', $service );
294 345
295 346 return $this->response( $service, __( 'Successfully created service', 'booktics' ) );
296 347 }
@@ -302,9 +353,9 @@
302 353 *
303 354 * @return WP_Error
304 355 */
305 356 public function create_item_permissions_check( $request ): bool {
306 - return true;
357 + return current_user_can( 'manage_options' );
307 358 }
308 359
309 360 /**
310 361 * Update one item from the collection.
@@ -334,67 +385,91 @@
334 385 return $this->error( $result->get_error_message() );
335 386 }
336 387
337 388 if ( ! empty( $data['team_member'] ) && is_array( $data['team_member'] ) ) {
338 - foreach ( $data['team_member'] as $team_member_id ) {
339 - $team_member_model = ( new Team_Member_Model( $team_member_id ) );
340 - $team_member = $team_member_model->find( $team_member_id );
341 - $team_member_services = $team_member->services == '' ? array() : $team_member->services;
389 + $this->update_team_members( $id, $data['team_member'] );
390 + $this->remove_service_from_other_team_members( $id, $data['team_member'] );
391 + }
342 392
343 - if ( ! in_array( (int) $id, $team_member_services ) ) {
344 - $team_member_services[] = (int) $id;
345 - if ( $team_member ) {
346 - $team_member->update(
347 - array(
348 - 'services' => $team_member_services,
349 - )
350 - );
351 - }
393 + $input_data = json_decode( $request->get_body(), true );
394 + $this->update_service_schedule( $id, $input_data );
395 +
396 + do_action( 'booktics_service_updated', $service, $request );
397 +
398 + $response = $this->format_service_response( $id );
399 + return $this->response( $response, __( 'Successfully updated service', 'booktics' ) );
400 + }
401 +
402 + /**
403 + * Update team members for a service
404 + */
405 + private function update_team_members( $service_id, $team_members ) {
406 + foreach ( $team_members as $team_member_id ) {
407 + $team_member_model = ( new Team_Member_Model( $team_member_id ) );
408 + $team_member = $team_member_model->find( $team_member_id );
409 + $team_member_services = $team_member->services == '' ? array() : $team_member->services;
410 +
411 + if ( ! in_array( (int) $service_id, $team_member_services ) ) {
412 + $team_member_services[] = (int) $service_id;
413 + if ( $team_member ) {
414 + $team_member->update(
415 + array(
416 + 'services' => $team_member_services,
417 + )
418 + );
352 419 }
353 420 }
421 + }
422 + }
354 423
355 - // Remove service from other team members
424 + /**
425 + * Remove service from other team members not in the list
426 + */
427 + private function remove_service_from_other_team_members( $service_id, $team_members ) {
428 + $other_team_members = ( new Team_Member_Model() )
429 + ->where( 'services', $service_id, 'LIKE' )
430 + ->all( array() );
356 431
357 - $other_team_members = ( new Team_Member_Model() )
358 - ->where( 'services', $id, 'LIKE' )
359 - ->all( array() );
360 -
361 - if ( ! empty( $other_team_members['items'] ) ) {
362 - foreach ( $other_team_members['items'] as $other_team_member ) {
363 - if ( ! in_array( $other_team_member['id'], $data['team_member'] ) ) {
364 - $other_services = $other_team_member['services'];
365 - if ( ( $key = array_search( $id, $other_services ) ) !== false ) {
366 - unset( $other_services[ $key ] );
367 - ( new Team_Member_Model( $other_team_member['id'] ) )->update(
368 - array(
369 - 'services' => array_values( $other_services ),
370 - )
371 - );
372 - }
432 + if ( ! empty( $other_team_members['items'] ) ) {
433 + foreach ( $other_team_members['items'] as $other_team_member ) {
434 + if ( ! in_array( $other_team_member['id'], $team_members ) ) {
435 + $other_services = $other_team_member['services'];
436 + if ( ( $key = array_search( $service_id, $other_services ) ) !== false ) {
437 + unset( $other_services[ $key ] );
438 + ( new Team_Member_Model( $other_team_member['id'] ) )->update(
439 + array(
440 + 'services' => array_values( $other_services ),
441 + )
442 + );
373 443 }
374 444 }
375 445 }
376 446 }
447 + }
377 448
378 - $input_data = json_decode( $request->get_body(), true );
449 + /**
450 + * Update the service schedule if provided
451 + */
452 + private function update_service_schedule( $service_id, $input_data ) {
379 453 if ( isset( $input_data['schedule'] ) || isset( $input_data['custom'] ) || isset( $input_data['holiday'] ) ) {
380 454 $service_schedule = Schedule_Manager::make( $input_data );
381 - $service_schedule->with_service_id( $request['id'] );
455 + $service_schedule->with_service_id( $service_id );
382 456 $service_schedule->save();
383 457 }
458 + }
384 459
385 - do_action( 'booktics_service_updated', $service, $request );
386 -
387 - $response = Service_Model::find( $id )->to_array();
388 - $response['shortcode'] = '[booktics-service-view id="' . $response['id'] . '"]';
389 - $response['team_member_details'] = $this->team_member_details( $response['team_member'] );
460 + /**
461 + * Format the service response after update
462 + */
463 + private function format_service_response( $service_id ) {
464 + $response = Service_Model::find( $service_id )->to_array();
465 + $response['shortcode'] = '[booktics_service_view id="' . $response['id'] . '"]';
466 + $response['team_member_details'] = Service_Helper::team_member_details( $response['team_member'] );
390 467 if ( ! empty( $response['categories'] ) ) {
391 468 $category_ids = is_array( $response['categories'] ) ? $response['categories'] : array( $response['categories'] );
392 - $response['category_details'] = $this->category_details( $category_ids );
469 + $response['category_details'] = Service_Helper::category_details( $category_ids );
393 470 }
394 - $response = apply_filters( 'booktics_service_format', $response );
395 -
396 - return $this->response( $response, __( 'Successfully updated service', 'booktics' ) );
471 + return apply_filters( 'booktics_service_format', $response );
397 472 }
398 473
399 474 /**
400 475 * Check if a given request has access to update a specific item.
@@ -403,9 +478,9 @@
403 478 *
404 479 * @return WP_Error
405 480 */
406 481 public function update_item_permissions_check( $request ) {
407 - return true;
482 + return current_user_can( 'manage_options' );
408 483 }
409 484
410 485 /**
411 486 * Delete one item from the collection.
@@ -428,9 +503,9 @@
428 503 if ( is_wp_error( $deleted ) ) {
429 504 return $this->error( $deleted->get_error_message() );
430 505 }
431 506
432 - return $this->response( (array) $service, __( 'Successfully deleted service', 'booktics' ) );
507 + return $this->response( $service, __( 'Successfully deleted service', 'booktics' ) );
433 508 }
434 509
435 510 /**
436 511 * Check if a given request has access to delete a specific item.
@@ -450,9 +525,9 @@
450 525 *
451 526 * @return WP_HTTP_Response
452 527 */
453 528 public function delete_items( $request ) {
454 - $ids = $request['ids'];
529 + $ids = isset( $request['ids'] ) ? $request['ids'] : array();
455 530
456 531 if ( ! is_array( $ids ) ) {
457 532 return $this->error( __( 'Ids should be an array of items ids', 'booktics' ) );
458 533 }
@@ -468,14 +543,14 @@
468 543 ++$count;
469 544 }
470 545 }
471 546
472 - if ( $count === 0 ) {
547 + if ( 0 === $count ) {
473 548 return $this->error( __( 'No item deleted.', 'booktics' ) );
474 549 }
550 + /* translators: 1: deleted count, 2: total count */
551 + $message = sprintf( __( 'Deleted %1$d items of %2$d', 'booktics' ), $count, $total );
475 552
476 - $message = sprintf( 'Deleted %d items of %d', $count, $total );
477 -
478 553 return $this->response( array(), $message );
479 554 }
480 555
481 556 /**
@@ -508,8 +583,19 @@
508 583
509 584 if ( is_wp_error( $validate ) ) {
510 585 return $validate;
511 586 }
587 + if ( empty( $data['team_member'] ) ) {
588 + $admin_query = new \WP_User_Query(
589 + array(
590 + 'role' => array( 'administrator', 'booktics_team_member' ),
591 + )
592 + );
593 + $admins = $admin_query->get_results();
594 + $admin = reset( $admins );
595 + $team_member_id = $admin->id;
596 + $data['team_member'] = array( $team_member_id );
597 + }
512 598
513 599 $data['title'] = ! empty( $data['title'] ) ? sanitize_text_field( $data['title'] ) : '';
514 600 $data['description'] = ! empty( $data['description'] ) ? sanitize_text_field( $data['description'] ) : '';
515 601 $data['content'] = ! empty( $data['content'] ) ? sanitize_text_field( $data['content'] ) : '';
@@ -515,10 +601,12 @@
515 601 $data['content'] = ! empty( $data['content'] ) ? sanitize_text_field( $data['content'] ) : '';
516 602 $data['link'] = ! empty( $data['link'] ) ? sanitize_text_field( $data['link'] ) : '';
517 603 $data['image'] = ! empty( $data['image'] ) ? esc_url_raw( $data['image'] ) : '';
518 604 $data['image_id'] = ! empty( $data['image_id'] ) ? esc_url_raw( $data['image_id'] ) : '';
519 - $data['interval_time'] = ! empty( $data['interval_time'] ) ? sanitize_text_field( $data['interval_time'] ) : '';
520 - $data['before_buffer_time'] = ! empty( $data['before_buffer_time'] ) ? sanitize_text_field( $data['before_buffer_time'] ) : '';
605 + $data['interval_time'] = ! empty( $data['interval_time'] ) ? sanitize_text_field( $data['interval_time'] ) : 0;
606 + $data['before_buffer_time'] = ! empty( $data['before_buffer_time'] ) ? sanitize_text_field( $data['before_buffer_time'] ) : 0;
607 + $data['after_buffer_time'] = ! empty( $data['after_buffer_time'] ) ? sanitize_text_field( $data['after_buffer_time'] ) : 0;
608 + $data['show_end_time'] = ! empty( $data['show_end_time'] ) ? sanitize_text_field( $data['show_end_time'] ) : false;
521 609 $data['status'] = ! empty( $data['status'] ) ? sanitize_text_field( $data['status'] ) : 'deactive';
522 610 $data['team_member'] = empty( $data['team_member'] ) ? array() : array_unique( $data['team_member'] );
523 611 $data['categories'] = empty( $data['categories'] ) ? array() : array_unique( $data['categories'] );
524 612 $sanitized_durations = array();
@@ -527,9 +615,9 @@
527 615 if ( is_array( $duration ) ) {
528 616 $sanitized_durations[] = array(
529 617 'id' => ! empty( $duration['id'] ) ? sanitize_text_field( $duration['id'] ) : '',
530 618 'name' => ! empty( $duration['name'] ) ? sanitize_text_field( $duration['name'] ) : '',
531 - 'duration_time' => ! empty( $duration['duration_time'] ) ? sanitize_text_field( $duration['duration_time'] ) : '',
619 + 'duration_time' => ! empty( $duration['duration_time'] ) ? sanitize_text_field( $duration['duration_time'] ) : 0,
532 620 'duration_unit' => ! empty( $duration['duration_unit'] ) ? sanitize_text_field( $duration['duration_unit'] ) : '',
533 621 'charge_amount' => ! empty( $duration['charge_amount'] ) ? (float) number_format( (float) $duration['charge_amount'], 4, '.', '' ) : '0.0000',
534 622 'deposit_amount' => ! empty( $duration['deposit_amount'] ) ? (float) number_format( (float) $duration['deposit_amount'], 4, '.', '' ) : '0.0000',
535 623 );
@@ -539,12 +627,12 @@
539 627 $sanitized_durations = array(
540 628 array(
541 629 'id' => 'default',
542 630 'name' => 'default',
543 - 'duration_time' => '30',
631 + 'duration_time' => 30,
544 632 'duration_unit' => 'min',
545 - 'charge_amount' => '0.0000',
546 - 'deposit_amount' => '0.0000',
633 + 'charge_amount' => 0,
634 + 'deposit_amount' => 0,
547 635 ),
548 636 );
549 637 }
550 638 $data['additional_durations'] = $sanitized_durations;
@@ -572,31 +660,30 @@
572 660
573 661 if ( ! $service ) {
574 662 return $this->error( __( 'Service not found', 'booktics' ), 404 );
575 663 }
664 + $clone_data = [
665 + 'title' => $service->title . __( ' Copy', 'booktics' ),
666 + 'description' => $service->description,
667 + 'content' => $service->content,
668 + 'image' => $service->image,
669 + 'image_id' => $service->image_id,
670 + 'categories' => $service->categories,
671 + 'interval_time' => $service->interval_time,
672 + 'before_buffer_time' => $service->before_buffer_time,
673 + 'after_buffer_time' => $service->after_buffer_time,
674 + 'team_member' => $service->team_member,
675 + 'show_end_time' => $service->show_end_time,
676 + 'additional_durations' => $service->additional_durations,
677 + 'enable_custom_holiday' => $service->enable_custom_holiday,
678 + 'enable_custom_schedule' => $service->enable_custom_schedule,
679 + 'enable_additional_service_duration' => $service->enable_additional_service_duration,
680 + ];
576 681
577 - $cloned = Service_Model::create(
578 - array(
579 - 'title' => $service->title . __( ' Copy', 'booktics' ),
580 - 'description' => $service->description,
581 - 'content' => $service->content,
582 - 'image' => $service->image,
583 - 'image_id' => $service->image_id,
584 - 'categories' => $service->categories,
585 - 'interval_time' => $service->interval_time,
586 - 'before_buffer_time' => $service->before_buffer_time,
587 - 'after_buffer_time' => $service->after_buffer_time,
588 - 'team_member' => $service->team_member,
589 - 'show_end_time' => $service->show_end_time,
590 - 'additional_durations' => $service->additional_durations,
591 - 'enable_custom_holiday' => $service->enable_custom_holiday,
592 - 'enable_custom_schedule' => $service->enable_custom_schedule,
593 - 'enable_additional_service_duration' => $service->enable_additional_service_duration,
594 - 'custom_field' => $service->custom_field,
595 - 'extra_services' => $service->extra_services,
596 - )
597 - );
682 + $clone_data = apply_filters( 'booktics_clone_service_data', $clone_data, $service );
598 683
684 + $cloned = Service_Model::create( $clone_data );
685 +
599 686 if ( is_wp_error( $cloned ) ) {
600 687 return $this->error( $cloned->get_error_message() );
601 688 }
602 689
@@ -609,11 +696,12 @@
609 696 $service_schedule = Schedule_Manager::make( $schedule_data );
610 697 $service_schedule->with_service_id( $cloned->id );
611 698 $service_schedule->save();
612 699
613 - $team_member_details = $this->team_member_details( $service->team_member );
700 + $team_member_details = Service_Helper::team_member_details( $service->team_member );
614 701 $cloned = $cloned->to_array();
615 702 $cloned['team_member_details'] = $team_member_details;
703 + $cloned['category_details'] = Service_Helper::category_details( $cloned['categories'] );
616 704
617 705 $clone_schedule_record = ( new Schedule_Record() )
618 706 ->get_schedules( $cloned['id'], 'service' );
619 707 $cloned['schedule'] = empty( $clone_schedule_record['schedule'] ) ? (object) array()
@@ -619,58 +707,10 @@
619 707 $cloned['schedule'] = empty( $clone_schedule_record['schedule'] ) ? (object) array()
620 708 : $clone_schedule_record['schedule'];
621 709 $cloned['custom'] = $clone_schedule_record['custom'];
622 710 $cloned['holiday'] = $clone_schedule_record['holiday'];
711 + $cloned['shortcode'] = '[booktics_service_view id="' . $cloned['id'] . '"]';
623 712 $cloned = apply_filters( 'booktics_service_format', $cloned );
624 713
625 714 return $this->response( $cloned, __( 'Successfully cloned service', 'booktics' ) );
626 - }
627 -
628 - /**
629 - * Map team member details
630 - *
631 - * @param $team_member_ids
632 - *
633 - * @return array
634 - */
635 - private function team_member_details( $team_member_ids ): array {
636 - $team_member_details = array();
637 - foreach ( $team_member_ids as $team_member_id ) {
638 - $team_member = ( new Team_Member_Model() )->find( $team_member_id );
639 - if ( $team_member ) {
640 - $team_member = $team_member->to_array();
641 - $team_member_details[] = array(
642 - 'id' => $team_member['id'],
643 - 'display_name' => $team_member['display_name'],
644 - 'email' => $team_member['email'],
645 - 'image' => $team_member['image'],
646 - );
647 - }
648 - }
649 -
650 - return $team_member_details;
651 - }
652 -
653 - /**
654 - * Get category details for given category IDs.
655 - *
656 - * @param array|int[] $category_ids
657 - *
658 - * @return array
659 - */
660 - private function category_details( $category_ids ): array {
661 - $category_details = array();
662 - foreach ( $category_ids as $category_id ) {
663 - $category = get_term( $category_id, ( new Category() )->get_name() );
664 -
665 - if ( $category ) {
666 - $category = $category->to_array();
667 - $category_details[] = array(
668 - 'id' => $category['term_id'],
669 - 'name' => $category['name'],
670 - );
671 - }
672 - }
673 -
674 - return $category_details;
675 715 }
676 716 }