[ 'label' => esc_html__('Email', 'daytidy'), 'enabled' => true, ], ]); } /** * @return mixed[] */ public static function triggers(): array { $all = [ self::TRIGGER_BOOKING_CREATED => [ 'label' => esc_html__('Booking Created', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_REGISTRANT, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_CONFIRMED => [ 'label' => esc_html__('Booking Confirmed', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_REGISTRANT, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_DECLINED => [ 'label' => esc_html__('Booking Declined', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_REGISTRANT, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_CANCELLED => [ 'label' => esc_html__('Booking Cancelled', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_REGISTRANT, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_COMPLETED => [ 'label' => esc_html__('Booking Completed', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_REGISTRANT, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_PAID => [ 'label' => esc_html__('Booking Paid', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_PAYMENT_FAILED => [ 'label' => esc_html__('Booking Payment Failed', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_REFUNDED => [ 'label' => esc_html__('Booking Refunded', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_RESCHEDULED => [ 'label' => esc_html__('Booking Rescheduled', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_REGISTRANT, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_BOOKING_REMINDER_BEFORE_START => [ 'label' => esc_html__('Booking Reminder Before Start', 'daytidy'), 'contexts' => [ self::CONTEXT_ADMIN, self::CONTEXT_OFFERING_HOST, self::CONTEXT_PRIMARY_BOOKER, self::CONTEXT_REGISTRANT, self::CONTEXT_CUSTOM, ], ], self::TRIGGER_CUSTOMER_PORTAL_VERIFICATION_CODE => [ 'label' => esc_html__('Customer Portal Verification Code', 'daytidy'), 'contexts' => [ self::CONTEXT_PRIMARY_BOOKER, ], ], ]; return apply_filters('DayTidy/F__DayTidy/Notifications__triggers/triggers', $all); } public static function allowsExtraRecipients(string $trigger): bool { $allowed = $trigger !== self::TRIGGER_CUSTOMER_PORTAL_VERIFICATION_CODE; return (bool) apply_filters( 'DayTidy/F__DayTidy/Notifications__allows_extra_recipients/allowed', $allowed, $trigger ); } /** * @return string[] */ public static function triggerOptions(): array { $options = []; foreach (self::triggers() as $key => $trigger) $options[$key] = $trigger['label']; return $options; } /** * @return mixed[] */ public static function contexts(?string $trigger = null): array { $contexts = apply_filters('DayTidy/F__DayTidy/Notifications__contexts/contexts', [ self::CONTEXT_ADMIN => [ 'label' => esc_html__('Admin', 'daytidy'), 'description' => esc_html__('Website administrator email.', 'daytidy'), ], self::CONTEXT_OFFERING_HOST => [ 'label' => esc_html__('Offering Host', 'daytidy'), 'description' => esc_html__('Hosts assigned to the booked offering.', 'daytidy'), ], self::CONTEXT_PRIMARY_BOOKER => [ 'label' => esc_html__('Primary Booker', 'daytidy'), 'description' => esc_html__('First person who completed the booking form.', 'daytidy'), ], self::CONTEXT_REGISTRANT => [ 'label' => esc_html__('Registrant', 'daytidy'), 'description' => esc_html__('Each participant with an email address.', 'daytidy'), ], self::CONTEXT_CUSTOM => [ 'label' => esc_html__('Custom Recipients', 'daytidy'), 'description' => esc_html__('Users, roles, or custom email addresses selected by the admin.', 'daytidy'), ], ], $trigger); if (!$trigger) return $contexts; $triggers = self::triggers(); $allowed = $triggers[$trigger]['contexts'] ?? array_keys($contexts); return array_intersect_key($contexts, array_flip($allowed)); } /** * @return string[] */ public static function collectionKeys(): array { return ['participant_list', 'option_list', 'session_list']; } /** * @return mixed[] */ public static function placeholders(): array { return apply_filters('DayTidy/F__DayTidy/Notifications__placeholders/placeholders', [ esc_html__('General', 'daytidy') => [ 'site_name' => esc_html__('Website name', 'daytidy'), 'site_url' => esc_html__('Website URL', 'daytidy'), 'admin_email' => esc_html__('Website admin email', 'daytidy'), 'date' => esc_html__('Current date', 'daytidy'), 'time' => esc_html__('Current time', 'daytidy'), 'datetime' => esc_html__('Current session', 'daytidy'), ], esc_html__('Booking', 'daytidy') => [ 'booking_id' => esc_html__('Booking post ID', 'daytidy'), 'booking_ref' => esc_html__('Booking reference', 'daytidy'), 'booking_email' => esc_html__('Booker email', 'daytidy'), 'booking_first_name' => esc_html__('Booker first name', 'daytidy'), 'booking_last_name' => esc_html__('Booker last name', 'daytidy'), 'booking_total' => esc_html__('Booking total', 'daytidy'), 'booking_payable' => esc_html__('Booking payable amount', 'daytidy'), 'booking_gateway' => esc_html__('Payment gateway name', 'daytidy'), 'booking_gateway_ref_id' => esc_html__('Gateway reference ID', 'daytidy'), 'booking_status' => esc_html__('Booking status', 'daytidy'), 'booking_payment_status' => esc_html__('Payment status', 'daytidy'), 'booking_coupon' => esc_html__('Coupon code', 'daytidy'), 'booking_portal_url' => esc_html__('Customer portal booking URL', 'daytidy'), 'booking_verification_code' => esc_html__('Customer portal verification code', 'daytidy'), 'booking_verification_code_expiry_minutes' => esc_html__('Customer portal verification code expiry minutes', 'daytidy'), ], esc_html__('Offering', 'daytidy') => [ 'offering_id' => esc_html__('Offering post ID', 'daytidy'), 'offering_title' => esc_html__('Offering title', 'daytidy'), 'offering_link' => esc_html__('Offering frontend link', 'daytidy'), 'offering_admin_link' => esc_html__('Offering admin edit link', 'daytidy'), ], esc_html__('Recipient', 'daytidy') => [ 'recipient_email' => esc_html__('Current recipient email', 'daytidy'), 'recipient_name' => esc_html__('Current recipient name', 'daytidy'), 'recipient_context' => esc_html__('Current recipient type', 'daytidy'), ], esc_html__('Collections', 'daytidy') => [ 'participant_list' => esc_html__('Rendered participant list', 'daytidy'), 'option_list' => esc_html__('Rendered option list', 'daytidy'), 'session_list' => esc_html__('Rendered session list', 'daytidy'), ], esc_html__('Collection Items', 'daytidy') => [ 'participant_name' => esc_html__('Participant name inside participant list', 'daytidy'), 'participant_email' => esc_html__('Participant email inside participant list', 'daytidy'), 'participant_fields' => esc_html__('Participant fields inside participant list', 'daytidy'), 'option_title' => esc_html__('Option title inside option list', 'daytidy'), 'option_quantity' => esc_html__('Option quantity inside option list', 'daytidy'), 'option_price' => esc_html__('Option price inside option list', 'daytidy'), 'session_item' => esc_html__('Formatted session inside session list', 'daytidy'), 'date_item' => esc_html__('Formatted date inside session list', 'daytidy'), 'time_item' => esc_html__('Formatted time inside session list', 'daytidy'), ], ]); } }