PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.6.6
LatePoint – Calendar Booking Plugin for Appointments and Events v5.6.6
5.6.6 5.6.5 5.6.4 5.6.3 5.6.2 5.6.1 5.6.0 5.5.2 5.5.1 5.5.0 5.4.2 trunk 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.1.8 5.1.9 5.1.91 5.1.92 5.1.93 5.1.94 5.2.0 5.2.1 5.2.10 5.2.11 5.2.2 5.2.3 5.2.4 5.2.5 5.2.6 5.2.7 5.2.8 5.2.9 5.3.0 5.3.1 5.3.2 5.4.0 5.4.1
latepoint / lib / helpers / sms_helper.php
latepoint / lib / helpers Last commit date
activities_helper.php 3 months ago agent_helper.php 3 months ago analytics_helper.php 1 week ago auth_helper.php 6 days ago blocks_helper.php 3 weeks ago booking_helper.php 4 days ago bricks_helper.php 3 months ago bundles_helper.php 4 days ago calendar_helper.php 2 days ago carts_helper.php 3 months ago connector_helper.php 3 months ago csv_helper.php 3 months ago customer_helper.php 1 month ago customer_import_helper.php 1 month ago database_helper.php 1 week ago debug_helper.php 3 months ago defaults_helper.php 3 months ago elementor_helper.php 3 months ago email_helper.php 3 months ago encrypt_helper.php 3 months ago events_helper.php 3 months ago form_helper.php 3 months ago icalendar_helper.php 3 months ago image_helper.php 3 months ago invoices_helper.php 3 weeks ago license_helper.php 3 months ago location_helper.php 3 months ago marketing_systems_helper.php 3 months ago meeting_systems_helper.php 3 months ago menu_helper.php 3 weeks ago meta_helper.php 3 months ago migrations_helper.php 3 months ago money_helper.php 3 months ago notifications_helper.php 3 months ago nps_survey_helper.php 3 months ago order_intent_helper.php 2 months ago orders_helper.php 3 months ago otp_helper.php 3 months ago pages_helper.php 3 months ago params_helper.php 3 months ago payments_helper.php 2 months ago plugin_version_update_helper.php 2 months ago price_breakdown_helper.php 3 months ago process_jobs_helper.php 3 months ago processes_helper.php 3 months ago razorpay_connect_helper.php 1 week ago replacer_helper.php 3 months ago resource_helper.php 4 days ago roles_helper.php 3 weeks ago router_helper.php 3 months ago service_helper.php 3 months ago sessions_helper.php 3 months ago settings_helper.php 1 week ago short_links_systems_helper.php 3 months ago shortcodes_helper.php 3 weeks ago sms_helper.php 3 months ago steps_helper.php 1 week ago stripe_connect_helper.php 1 week ago styles_helper.php 3 months ago support_topics_helper.php 3 months ago time_helper.php 2 months ago timeline_helper.php 2 months ago transaction_helper.php 1 month ago transaction_intent_helper.php 3 months ago util_helper.php 1 month ago version_specific_updates_helper.php 3 months ago whatsapp_helper.php 1 month ago work_periods_helper.php 3 months ago wp_datetime.php 3 months ago wp_user_helper.php 3 months ago
sms_helper.php
111 lines
1 <?php
2
3 class OsSmsHelper {
4
5
6
7 /**
8 * @param $to
9 * @param $content
10 *
11 * @return array [
12 * 'status' => string,
13 * 'message' => string,
14 * 'to' => string,
15 * 'content' => string,
16 * 'processor_code' => string,
17 * 'processor_name' => string,
18 * 'processed_datetime' => string,
19 * 'extra_data' => array
20 * ]
21 */
22 public static function send_sms( $to, $content, $activity_data = [] ): array {
23 $result = [
24 'status' => LATEPOINT_STATUS_ERROR,
25 'message' => __( 'No SMS processor is selected.', 'latepoint' ),
26 'to' => $to,
27 'content' => $content,
28 'processor_code' => '',
29 'processor_name' => '',
30 'processed_datetime' => '',
31 'extra_data' => [
32 'activity_data' => $activity_data,
33 ],
34 'errors' => [],
35 ];
36
37 if ( OsSettingsHelper::is_sms_allowed() && OsNotificationsHelper::is_notification_type_enabled( 'sms' ) ) {
38 /**
39 * Result of sending an SMS message to a recipient's phone number
40 *
41 * @param {array} $result The array of data describing the send operation
42 * @param {string} $to The recipient's phone number
43 * @param {string} $content The message to send to the recipient
44 *
45 * @since 4.7.0
46 * @hook latepoint_notifications_send_sms
47 * @returns {array} The array of descriptive data, possibly transformed by hooked SMS processor(s)
48 */
49 $result = apply_filters( 'latepoint_notifications_send_sms', $result, $to, $content );
50 } else {
51 $result['message'] = __( 'SMS notifications are disabled', 'latepoint' );
52 $result['errors'][] = __( 'SMS notifications are disabled', 'latepoint' );
53 }
54
55 self::log_sms( $result );
56
57 return $result;
58 }
59
60 /**
61 * @param $enabled_only
62 *
63 * @return array [
64 * 'code' => [
65 * 'code' => string,
66 * 'label' => string,
67 * 'image_url' => string
68 * ]
69 * ]
70 */
71 public static function get_sms_processors( $enabled_only = false ) {
72 $sms_processors = [];
73
74 /**
75 * Get the list of SMS processors registered in the LatePoint ecosystem
76 *
77 * @since 1.2.3
78 * @hook latepoint_sms_processors
79 *
80 * @param {array} $sms_processors The list of SMS processors being filtered
81 * @param {bool} $enabled_only True when filtering only enabled SMS processors, false otherwise
82 * @returns {array} The filtered list of SMS processors
83 */
84 return apply_filters( 'latepoint_sms_processors', $sms_processors, $enabled_only );
85 }
86
87 public static function is_sms_processor_enabled( string $sms_processor_code ): bool {
88 return ( OsNotificationsHelper::get_selected_processor_code_by_type( 'sms' ) == $sms_processor_code );
89 }
90
91 /**
92 * @param array $result
93 *
94 * @return OsActivityModel
95 */
96 public static function log_sms( array $result ) {
97 if ( empty( $result['processed_datetime'] ) ) {
98 $result['processed_datetime'] = OsTimeHelper::now_datetime_in_db_format();
99 }
100 $data = [
101 'code' => 'sms_sent',
102 'description' => wp_json_encode( $result ),
103 ];
104 if ( ! empty( $result['extra_data']['activity_data'] ) ) {
105 $data = array_merge( $data, $result['extra_data']['activity_data'] );
106 }
107 $activity = OsActivitiesHelper::create_activity( $data );
108 return $activity;
109 }
110 }
111