PluginProbe ʕ •ᴥ•ʔ
LatePoint – Calendar Booking Plugin for Appointments and Events / 5.1.3
LatePoint – Calendar Booking Plugin for Appointments and Events v5.1.3
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 / misc / process_action.php
latepoint / lib / misc Last commit date
blocked_period.php 1 year ago booked_period.php 1 year ago booking_request.php 1 year ago booking_resource.php 1 year ago booking_slot.php 1 year ago filter.php 1 year ago process_action.php 1 year ago process_event.php 1 year ago role.php 1 year ago router.php 1 year ago step.php 1 year ago stripe_connect_customer.php 1 year ago time_period.php 1 year ago user.php 1 year ago work_period.php 1 year ago
process_action.php
494 lines
1 <?php
2 /*
3 * Copyright (c) 2022 LatePoint LLC. All rights reserved.
4 */
5
6 namespace LatePoint\Misc;
7
8 class ProcessAction{
9 public string $id;
10 public string $type = 'send_email';
11 public string $status = 'active';
12 public ?array $settings = [];
13 public array $prepared_data_for_run = [];
14 public array $replacement_vars = [];
15 public array $selected_data_objects = []; // example ['model' => 'booking', 'id' => INT]
16 public ProcessEvent $event;
17
18 function __construct($args = []){
19 $allowed_props = self::allowed_props();
20 foreach($args as $key => $arg){
21 if(in_array($key, $allowed_props)) $this->$key = $arg;
22 }
23 if(empty($this->id)) $this->id = self::generate_id();
24 switch($this->type){
25 case 'send_email':
26 $this->settings['to_email'] = $this->settings['to_email'] ?? '';
27 $this->settings['subject'] = $this->settings['subject'] ?? '';
28 $this->settings['content'] = $this->settings['content'] ?? '';
29 break;
30 case 'send_sms':
31 $this->settings['to_phone'] = $this->settings['to_phone'] ?? '';
32 $this->settings['content'] = $this->settings['content'] ?? '';
33 break;
34 case 'send_whatsapp':
35 $this->settings['to_phone'] = $this->settings['to_phone'] ?? '';
36 $this->settings['content'] = $this->settings['content'] ?? '';
37 break;
38 }
39 }
40
41 public function get_nice_type_name(){
42 return self::get_action_name_for_type($this->type);
43 }
44
45 public function get_descriptive_setting(){
46 switch($this->type) {
47 case 'send_email':
48 return $this->settings['to_email'] ?? '';
49 case 'send_sms':
50 return $this->settings['to_phone'] ?? '';
51 case 'send_whatsapp':
52 return $this->settings['to_phone'] ?? '';
53 }
54 }
55
56 public function generate_replacement_vars(){
57 $this->replacement_vars = \OsReplacerHelper::generate_replacement_vars_from_data_objects($this->selected_data_objects);
58 }
59
60 public function set_from_params($params){
61 if(!empty($params['id'])) $this->id = $params['id'];
62 if(!empty($params['type'])) $this->type = $params['type'];
63 if(!empty($params['settings'])) $this->settings = $params['settings'];
64 if(!empty($params['event'])) $this->event = new ProcessEvent(['type' => $params['event']['type']]);
65 }
66
67 public function load_settings_from_template($template_id){
68 $templates = \OsNotificationsHelper::load_templates_for_action_type($this->type);
69 foreach($templates as $template){
70 if($template['id'] == $template_id){
71 switch($this->type){
72 case 'send_email':
73 $this->settings['to_email'] = $template['to_email'];
74 $this->settings['subject'] = $template['subject'];
75 $this->settings['content'] = $template['content'];
76 break;
77 case 'send_sms':
78 $this->settings['to_phone'] = $template['to_phone'];
79 $this->settings['content'] = $template['content'];
80 break;
81 case 'send_whatsapp':
82 $this->settings['to_phone'] = $template['to_phone'];
83 $this->settings['content'] = $template['content'];
84 break;
85 }
86
87 /**
88 * Returns an array of process action settings, based on a selected template
89 *
90 * @since 4.7.0
91 * @hook latepoint_process_action_settings
92 *
93 * @param {array} $settings Array of settings to filter
94 * @param {array} $template Array of data representing selected template
95 * @param {ProcessAction} $action Instance of <code>ProcessAction</code> for which settings are being generated
96 *
97 * @returns {array} Filtered array of process action settings
98 */
99 $this->settings = apply_filters('latepoint_process_action_settings', $this->settings, $template, $this);
100 break;
101 }
102 }
103 }
104
105 public static function generate_form(ProcessAction $action, string $process_id = ''): string{
106 $descriptive_setting = $action->get_descriptive_setting() ? '<div class="process-action-descriptive-setting">'.$action->get_descriptive_setting().'</div>' : '';
107 $html = '<div class="process-action-form pa-type-'.$action->type.' pa-status-'.$action->status.'" data-id="'.$action->id.'">';
108 $html.= '<div class="process-action-heading">
109 <div class="process-action-status"></div>
110 <div class="process-action-icon"></div>
111 <div class="process-action-name">'.self::get_action_name_for_type($action->type).'</div>
112 '.$descriptive_setting.'
113 <div class="process-action-chevron"><i class="latepoint-icon latepoint-icon-chevron-down"></i></div>
114 <a href="#" class="process-action-remove os-remove-process-action"
115 data-os-prompt="'.__('Are you sure you want to delete this action?', 'latepoint').'"><i class="latepoint-icon latepoint-icon-cross"></i></a>
116 </div>';
117 $html.= '<div class="process-action-content">';
118 $html.= '<div class="os-row">';
119 $html.= \OsFormHelper::select_field('process[actions]['.$action->id.'][type]', __('Action Type', 'latepoint'), \LatePoint\Misc\ProcessAction::get_action_types_for_select(), $action->type, ['class' => 'process-action-type', 'data-action-id' => $action->id, 'data-process-id' => $process_id, 'data-route' => \OsRouterHelper::build_route_name('processes', 'load_action_settings')], ['class' => 'os-col-10']);
120 $html.= \OsFormHelper::select_field('process[actions]['.$action->id.'][status]', __('Status', 'latepoint'), [LATEPOINT_STATUS_ACTIVE => __('Active', 'latepoint'), LATEPOINT_STATUS_DISABLED => __('Disabled', 'latepoint')], $action->status, false, ['class' => 'os-col-2']);
121 $html.= '</div>';
122 $html.= '<div class="process-action-settings">';
123 $html.= self::generate_settings_fields($action, $process_id);
124 $html.= '</div>';
125 $html.= '<div class="process-buttons">
126 <a href="#" class="latepoint-btn latepoint-btn-danger pull-left os-remove-process-action"
127 data-os-prompt="'.__('Are you sure you want to delete this action?', 'latepoint').'" >'.__('Delete', 'latepoint').'</a>
128 <a href="#" data-route="'.\OsRouterHelper::build_route_name('processes', 'action_test_preview').'" class="latepoint-btn latepoint-btn-secondary os-run-process-action" ><i class="latepoint-icon latepoint-icon-play-circle"></i><span>'.__('Test this action', 'latepoint').'</span></a>
129 </div>';
130 $html.= '</div>';
131 $html.= '</div>';
132 return $html;
133 }
134
135
136 public static function generate_settings_fields(ProcessAction $action, string $process_id = ''){
137 $html = '';
138
139 if(in_array($action->type, ['send_email', 'send_sms'])){
140 $html.= '<div class="process-action-controls-wrapper">';
141 $html.= '<a href="#" data-os-after-call="latepoint_init_template_library" data-os-params="'.\OsUtilHelper::build_os_params(['action_id'=>$action->id, 'action_type'=>$action->type, 'process_id' => $process_id]).'" data-os-lightbox-classes="width-1000" data-os-action="'.\OsRouterHelper::build_route_name('notifications', 'templates_index').'" href="#" data-os-output-target="side-panel" class="latepoint-btn latepoint-btn-outline latepoint-btn-sm"><i class="latepoint-icon latepoint-icon-book"></i><span>'.__('Load from template', 'latepoint').'</span></a>';
142 $html.= '<a href="#" class="latepoint-btn latepoint-btn-outline latepoint-btn-sm open-template-variables-panel"><i class="latepoint-icon latepoint-icon-zap"></i><span>'.__('Show smart variables', 'latepoint').'</span></a>';
143 $html.= '</div>';
144 }
145
146 switch($action->type){
147 case 'send_email':
148 $html.= '<div class="os-row">';
149 $html.= \OsFormHelper::text_field('process[actions]['.$action->id.'][settings][to_email]', __('To Email', 'latepoint'), $action->settings['to_email'], ['theme' => 'simple', 'placeholder' => __('To email address', 'latepoint')], ['class' => 'os-col-6']);
150 $html.= \OsFormHelper::text_field('process[actions]['.$action->id.'][settings][subject]', __('Email Subject', 'latepoint'), $action->settings['subject'], ['theme' => 'simple', 'placeholder' => __('Email Subject', 'latepoint')], ['class' => 'os-col-6']);
151 $html.= '</div>';
152 $html.= \OsFormHelper::textarea_field('process[actions]['.$action->id.'][settings][content]', false, $action->settings['content'], ['id' => 'process_actions_'.$action->id.'_settings_content', 'class' => 'os-wp-editor-textarea']);
153 break;
154 case 'send_sms':
155 if(\OsSmsHelper::get_sms_processors()){
156 $html.= \OsFormHelper::text_field('process[actions]['.$action->id.'][settings][to_phone]', __('To Phone Number', 'latepoint'), $action->settings['to_phone'], ['theme' => 'simple', 'placeholder' => __('Phone Number', 'latepoint')]);
157 $html.= \OsFormHelper::textarea_field('process[actions]['.$action->id.'][settings][content]', __('Message Content', 'latepoint'), $action->settings['content'], ['theme' => 'simple', 'placeholder' => __('Message', 'latepoint'), 'rows' => 4]);
158 }else{
159 $html = \OsUtilHelper::generate_missing_addon_link(__('You have to enable an SMS processor to send text messages. Available in a premium version.', 'latepoint'));
160 }
161 break;
162 case 'send_whatsapp':
163 if(\OsWhatsappHelper::get_whatsapp_processors()){
164 $html.= '<div class="latepoint-whatsapp-templates-loader" data-route="'.esc_attr(\OsRouterHelper::build_route_name('whatsapp', 'load_templates_for_action')).'" data-selected-template-id="'.esc_attr($action->settings['template_id'] ?? '').'" data-process-id="'.esc_attr($process_id).'" data-process-action-id="'.esc_attr($action->id).'"></div>';
165 $html.= '<div class="latepoint-whatsapp-templates-holder">'.\OsFormHelper::get_hidden_fields_for_array($action->settings, 'process[actions]['.$action->id.']').'</div>';
166
167 }else{
168 $html = \OsUtilHelper::generate_missing_addon_link(__('You have to enable a WhatsApp processor to send messages. Available in a premium version.', 'latepoint'));
169 }
170 break;
171 case 'trigger_webhook':
172 $html = \OsUtilHelper::generate_missing_addon_link(__('Requires upgrade to a premium version', 'latepoint'));
173 break;
174 }
175
176 /**
177 * Filters HTML code (after) for Process Action settings form
178 *
179 * @since 4.7.0
180 * @hook latepoint_process_action_settings_fields_html_after
181 *
182 * @param {string} $html HTML content of the settings form
183 * @param {ProcessAction} $action ProcessAction object for which this settings form is being generated
184 *
185 * @returns {string} HTML content of the settings form
186 */
187 return apply_filters('latepoint_process_action_settings_fields_html_after', $html, $action);
188 }
189
190 public static function generate_id(): string{
191 return 'pa_'.\OsUtilHelper::random_text('alnum', 6);
192 }
193
194 public function settings_form(){
195 $html = '';
196 switch($this->type){
197 case 'send_email':
198 $html.= \OsFormHelper::text_field('action[actions]['.$this->id.'][to]', '', $this->settings['to'], ['theme' => 'simple', 'placeholder' => __('Email To', 'latepoint')]);
199 break;
200 case 'send_sms':
201 $html.= \OsFormHelper::text_field('action[actions]['.$this->id.'][to]', '', $this->settings['to'], ['theme' => 'simple', 'placeholder' => __('SMS To', 'latepoint')]);
202 break;
203 case 'send_whatsapp':
204 $html.= \OsFormHelper::text_field('action[actions]['.$this->id.'][to]', '', $this->settings['to'], ['theme' => 'simple', 'placeholder' => __('WhatsApp Message To', 'latepoint')]);
205 break;
206 case 'trigger_webhook':
207 $html.= \OsFormHelper::text_field('action[actions]['.$this->id.'][url]', '', $this->settings['url'], ['theme' => 'simple', 'placeholder' => __('Webhook URL', 'latepoint')]);
208 break;
209 }
210
211 return apply_filters('latepoint_process_action_settings_form_html', $html, $this);
212 }
213
214
215 public static function get_action_types(){
216 $action_types = ['send_email', 'send_sms', 'trigger_webhook', 'send_whatsapp'];
217
218 /**
219 * Returns an array of process action types that can be executed when an event is triggered
220 *
221 * @since 4.7.0
222 * @hook latepoint_process_action_types
223 *
224 * @param {array} $action_types Array of action types to filter
225 *
226 * @returns {array} Filtered array of action types
227 */
228 return apply_filters('latepoint_process_action_types', $action_types);
229 }
230
231 public static function get_action_name_for_type($type){
232 $names = [
233 'send_email' => __('Send Email', 'latepoint'),
234 'send_sms' => __('Send SMS', 'latepoint'),
235 'trigger_webhook' => __('HTTP Request (Webhook)', 'latepoint'),
236 'send_whatsapp' => __('Send WhatsApp Message', 'latepoint')
237 ];
238
239 /**
240 * Returns an array of process action types mapped to their displayable names
241 *
242 * @since 4.7.0
243 * @hook latepoint_process_action_names
244 *
245 * @param {array} $names Array of action types/names to filter
246 *
247 * @returns {array} Filtered array of action types/names
248 */
249 $names = apply_filters('latepoint_process_action_names', $names);
250
251 return $names[$type] ?? __('n/a', 'latepoint');
252 }
253
254 public static function get_action_types_for_select(){
255 $types = self::get_action_types();
256 $types_for_select = [];
257 foreach($types as $type){
258 $types_for_select[$type] = self::get_action_name_for_type($type);
259 }
260 return $types_for_select;
261 }
262
263 public function prepare_data_for_run(){
264 $this->generate_replacement_vars();
265 foreach($this->selected_data_objects as $data_object){
266 switch($data_object['model']) {
267 case 'order':
268 $this->prepared_data_for_run['activity_data']['order_id'] = $data_object['id'];
269 if(!empty($data_object['model_ready'])){
270 $this->prepared_data_for_run['activity_data']['customer_id'] = $data_object['model_ready']->customer_id;
271 }
272 break;
273 case 'booking':
274 $this->prepared_data_for_run['activity_data']['booking_id'] = $data_object['id'];
275 if(!empty($data_object['model_ready'])){
276 $this->prepared_data_for_run['activity_data']['agent_id'] = $data_object['model_ready']->agent_id;
277 $this->prepared_data_for_run['activity_data']['service_id'] = $data_object['model_ready']->service_id;
278 $this->prepared_data_for_run['activity_data']['customer_id'] = $data_object['model_ready']->customer_id;
279 }
280 break;
281 case 'customer':
282 $this->prepared_data_for_run['activity_data']['customer_id'] = $data_object['id'];
283 break;
284 case 'transaction':
285 $this->prepared_data_for_run['activity_data']['transaction_id'] = $data_object['id'];
286 break;
287 case 'payment_request':
288 $this->prepared_data_for_run['activity_data']['payment_request_id'] = $data_object['id'];
289 break;
290 }
291 }
292
293 switch($this->type) {
294 case 'send_email':
295 $this->prepared_data_for_run['to'] = \OsReplacerHelper::replace_all_vars($this->settings['to_email'], $this->replacement_vars);
296 $this->prepared_data_for_run['subject'] = \OsReplacerHelper::replace_all_vars($this->settings['subject'], $this->replacement_vars);
297 $this->prepared_data_for_run['content'] = \OsReplacerHelper::replace_all_vars($this->settings['content'], $this->replacement_vars);
298 break;
299 case 'send_sms':
300 $this->prepared_data_for_run['to'] = \OsReplacerHelper::replace_all_vars($this->settings['to_phone'], $this->replacement_vars);
301 $this->prepared_data_for_run['content'] = \OsReplacerHelper::replace_all_vars($this->settings['content'], $this->replacement_vars);
302 break;
303 case 'send_whatsapp':
304 $this->prepared_data_for_run['to'] = \OsReplacerHelper::replace_all_vars($this->settings['to_phone'], $this->replacement_vars);
305 $this->prepared_data_for_run['data']['type'] = 'template';
306 $this->prepared_data_for_run['data']['template_id'] = $this->settings['template_id'];
307 $this->prepared_data_for_run['data']['template_language'] = $this->settings['template_language'];
308 $this->prepared_data_for_run['data']['template_parameter_format'] = $this->settings['template_parameter_format'];
309 $this->prepared_data_for_run['data']['template_category'] = $this->settings['template_category'];
310 $this->prepared_data_for_run['data']['template_name'] = $this->settings['template_name'];
311
312 $selected_template = \OsWhatsappHelper::get_template($this->settings['template_id']);
313
314 $this->prepared_data_for_run['data']['variables'] = $this->settings['variables'] ?? [];
315 if(!empty($this->settings['variables'])){
316 foreach($this->settings['variables'] as $type => $variables){
317 $parameters = [];
318 foreach($variables as $key => $value){
319 $clean_key = str_replace(['{{', '}}'], '', $key);
320 $replaced_value = \OsReplacerHelper::replace_all_vars($value, $this->replacement_vars);
321 if(is_numeric($clean_key)){
322 $parameters[] = ['type' => 'text', 'text' => $replaced_value];
323 }else{
324 $parameters[] = ['type' => 'text', 'text' => $replaced_value, 'parameter_name' => $clean_key];
325 }
326 }
327 if(strtolower($type) == 'buttons'){
328 // each button has to have a separate component element, only URL typed buttons have variables in them
329 foreach($parameters as $index => $parameter){
330 $this->prepared_data_for_run['data']['components'][] = [
331 'type' => 'button',
332 'index' => $index,
333 'sub_type' => 'url',
334 'parameters' => $parameters
335 ];
336 }
337 }else{
338 $this->prepared_data_for_run['data']['components'][] = ['type' => $type, 'parameters' => $parameters];
339 }
340 }
341 }
342
343 $content_by_type['header'] = \OsWhatsappHelper::get_template_component_value_by_key($selected_template, 'HEADER', 'text');
344 $content_by_type['body'] = \OsWhatsappHelper::get_template_component_value_by_key($selected_template, 'BODY', 'text');
345 $content_by_type['buttons'] = \OsWhatsappHelper::get_template_component_value_by_key($selected_template, 'BUTTONS', 'buttons');
346
347
348 foreach($content_by_type as $content_type => $content){
349 if($content_type == 'buttons'){
350 if(!empty($content)){
351 foreach($content as $button){
352 // only URL can have variables
353 if($button['type'] == 'URL') $button['url'] = empty($this->settings['variables'][$content_type]) ? $button['url'] : \OsReplacerHelper::replace_all_vars(str_replace(array_keys($this->settings['variables'][$content_type]), array_values($this->settings['variables'][$content_type]), $button['url']), $this->replacement_vars);
354 $this->prepared_data_for_run['content_for_'.$content_type][] = $button;
355 }
356 }else{
357 $this->prepared_data_for_run['content_for_'.$content_type] = [];
358 }
359 }else{
360 $this->prepared_data_for_run['content_for_'.$content_type] = empty($this->settings['variables'][$content_type]) ? $content : \OsReplacerHelper::replace_all_vars(str_replace(array_keys($this->settings['variables'][$content_type]), array_values($this->settings['variables'][$content_type]), $content), $this->replacement_vars);
361 }
362 }
363 break;
364 }
365
366 /**
367 * Prepare data for action run
368 *
369 * @since 4.7.0
370 * @hook latepoint_process_prepare_data_for_run
371 *
372 * @param {ProcessAction} $action ProcessAction that was executed
373 *
374 * @returns {ProcessAction} $action ProcessAction with prepared data for action run
375 */
376 return apply_filters('latepoint_process_prepare_data_for_run', $this);
377 }
378
379
380 /**
381 * @param $prepare_data
382 * @return array [status => '', 'message' => '']
383 */
384 public function run($prepare_data = true){
385 $result = [
386 'status' => LATEPOINT_STATUS_SUCCESS,
387 'message' => __('Nothing to run', 'latepoint')
388 ];
389 if($prepare_data) $this->prepare_data_for_run();
390
391 switch($this->type) {
392 case 'send_email':
393 $notification_type = 'email';
394 $result = \OsNotificationsHelper::send($notification_type, $this->prepared_data_for_run);
395 break;
396 case 'send_sms':
397 $notification_type = 'sms';
398 $result = \OsNotificationsHelper::send($notification_type, $this->prepared_data_for_run);
399 break;
400 case 'send_whatsapp':
401 $notification_type = 'whatsapp';
402 $result = \OsNotificationsHelper::send($notification_type, $this->prepared_data_for_run);
403 break;
404 }
405
406
407 /**
408 * ProcessAction run result
409 *
410 * @since 4.7.0
411 * @hook latepoint_process_action_run
412 *
413 * @param {array} $result The array of data describing the status of the action run
414 * @param {ProcessAction} $action ProcessAction that was executed
415 *
416 * @returns {array} The array of descriptive data, possibly transformed by additional hooked ProcessAction handlers
417 */
418 return apply_filters('latepoint_process_action_run', $result, $this);
419 }
420
421
422 /**
423 * @return string
424 */
425 public function generate_preview(){
426 if(empty($this->prepared_data_for_run)){
427 $this->prepare_data_for_run();
428 // nothing was generated, probably because there is no object attached
429 if(empty($this->prepared_data_for_run)) return '<div class="action-preview-error">'.__('You have to create a booking to be able to test this action.', 'latepoint').'</div>';
430 }
431 $html = '<div class="action-preview-content-wrapper">';
432 $preview_content_html = '';
433 switch($this->type){
434 case 'send_email':
435 $preview_content_html.= '<div class="action-preview-subject"><span class="os-label">'.__('Subject:', 'latepoint').'</span> '.$this->prepared_data_for_run['subject'].'</div>';
436 $preview_content_html.= '<div class="action-preview-to"><span class="os-label">'.__('To:', 'latepoint').'</span><span class="os-value">'.esc_html($this->prepared_data_for_run['to']).'</div>';
437 $preview_content_html.= '<div class="action-preview-content">'.$this->prepared_data_for_run['content'].'</div>';
438 break;
439 case 'send_sms':
440 $preview_content_html.= '<div class="action-preview-to"><span class="os-label">'.__('To:', 'latepoint').'</span><span class="os-value">'.esc_html($this->prepared_data_for_run['to']).'</span></div>';
441 $preview_content_html.= '<div class="action-preview-content">'.$this->prepared_data_for_run['content'].'</div>';
442 break;
443 case 'send_whatsapp':
444 $preview_content_html.= '<div class="action-preview-to"><span class="os-label">'.__('To:', 'latepoint').'</span><span class="os-value">'.esc_html($this->prepared_data_for_run['to']).'</span></div>';
445 $preview_content_html.= '<div class="action-preview-content">';
446 $preview_content_html.= '<div class="latepoint-whatsapp-template-preview-messages">';
447 $preview_content_html.= '<div class="latepoint-whatsapp-template-preview-message">';
448 $preview_content_html.= '<div class="latepoint-whatsapp-template-preview-message-header">'.$this->prepared_data_for_run['content_for_header'].'</div>';
449 $preview_content_html.= '<div class="latepoint-whatsapp-template-preview-message-body">'.$this->prepared_data_for_run['content_for_body'].'</div>';
450 if($this->prepared_data_for_run['content_for_buttons']){
451 $preview_content_html.= '<div class="latepoint-whatsapp-template-preview-message-buttons">';
452 foreach($this->prepared_data_for_run['content_for_buttons'] as $button){
453 switch($button['type']){
454 case 'PHONE_NUMBER':
455 $preview_content_html.= '<a href="tel:'.esc_url($button['phone_number']).'" class="latepoint-whatsapp-template-preview-message-button"><i class="latepoint-icon latepoint-icon-phone"></i>'.esc_html($button['text']).'</a>';
456 break;
457 case 'URL':
458 $preview_content_html.= '<a href="'.esc_url($button['url']).'" class="latepoint-whatsapp-template-preview-message-button"><i class="latepoint-icon latepoint-icon-external-link"></i>'.esc_html($button['text']).'</a>';
459 break;
460 }
461 }
462 $preview_content_html.= '</div>';
463 }
464 $preview_content_html.= '</div>';
465 $preview_content_html.= '</div>';
466 $preview_content_html.= '</div>';
467 break;
468 }
469
470 /**
471 * Generates a preview html for ProcessAction testing
472 *
473 * @since 4.7.0
474 * @hook latepoint_process_action_generate_preview
475 *
476 * @param {string} $preview_content_html HTML that goes inside of a preview
477 * @param {ProcessAction} $action ProcessAction that is being tested
478 *
479 * @returns {string} HTML that goes inside of a preview
480 */
481 $preview_content_html = apply_filters('latepoint_process_action_generate_preview', $preview_content_html, $this);
482 $html.= $preview_content_html;
483 $html.= '</div>';
484 return $html;
485 }
486
487 public static function replace_variables($test){
488
489 }
490
491 public static function allowed_props(): array{
492 return ['id', 'type', 'settings', 'status'];
493 }
494 }