bookingpress.php
88 lines
| 1 | <?php |
| 2 | /** |
| 3 | * BookingPress core integrations file |
| 4 | * |
| 5 | * @since 1.0.0 |
| 6 | * @package SureTrigger |
| 7 | */ |
| 8 | |
| 9 | namespace SureTriggers\Integrations\BookingPress; |
| 10 | |
| 11 | use SureTriggers\Controllers\IntegrationsController; |
| 12 | use SureTriggers\Integrations\Integrations; |
| 13 | use SureTriggers\Traits\SingletonLoader; |
| 14 | |
| 15 | /** |
| 16 | * Class BookingPress |
| 17 | * |
| 18 | * @package SureTriggers\Integrations\BookingPress |
| 19 | */ |
| 20 | class BookingPress extends Integrations { |
| 21 | |
| 22 | use SingletonLoader; |
| 23 | |
| 24 | /** |
| 25 | * ID |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | protected $id = 'BookingPress'; |
| 30 | |
| 31 | /** |
| 32 | * SureTrigger constructor. |
| 33 | */ |
| 34 | public function __construct() { |
| 35 | $this->name = __( 'BookingPress', 'suretriggers' ); |
| 36 | $this->description = __( 'BookingPress is an appointment booking plugin for WordPress that lets you create services, manage bookings, and handle payments.', 'suretriggers' ); |
| 37 | parent::__construct(); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Is Plugin depended plugin is installed or not. |
| 42 | * |
| 43 | * @return bool |
| 44 | */ |
| 45 | public function is_plugin_installed() { |
| 46 | return defined( 'BOOKINGPRESS_VERSION' ); |
| 47 | } |
| 48 | |
| 49 | /** |
| 50 | * Get appointment context data from the database. |
| 51 | * |
| 52 | * @param int $appointment_id The bookingpress_appointment_booking_id. |
| 53 | * @return array |
| 54 | */ |
| 55 | public static function get_appointment_context( $appointment_id ) { |
| 56 | global $wpdb; |
| 57 | |
| 58 | $table = $wpdb->prefix . 'bookingpress_appointment_bookings'; |
| 59 | |
| 60 | $row = $wpdb->get_row( |
| 61 | $wpdb->prepare( |
| 62 | 'SELECT * FROM ' . esc_sql( $table ) . ' WHERE bookingpress_appointment_booking_id = %d', // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared |
| 63 | $appointment_id |
| 64 | ), |
| 65 | ARRAY_A |
| 66 | ); |
| 67 | |
| 68 | if ( empty( $row ) ) { |
| 69 | return []; |
| 70 | } |
| 71 | |
| 72 | $status_labels = [ |
| 73 | '1' => __( 'Approved', 'suretriggers' ), |
| 74 | '2' => __( 'Pending', 'suretriggers' ), |
| 75 | '3' => __( 'Canceled', 'suretriggers' ), |
| 76 | '4' => __( 'Rejected', 'suretriggers' ), |
| 77 | ]; |
| 78 | |
| 79 | $status_key = (string) $row['bookingpress_appointment_status']; |
| 80 | $row['appointment_status_label'] = isset( $status_labels[ $status_key ] ) ? $status_labels[ $status_key ] : $status_key; |
| 81 | |
| 82 | return $row; |
| 83 | } |
| 84 | |
| 85 | } |
| 86 | |
| 87 | IntegrationsController::register( BookingPress::class ); |
| 88 |