PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.3.7
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.3.7
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / custom-field-types / class-wpsc-cf-textarea.php

class-wpsc-cf-textarea.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.3.7, at includes/custom-field-types/class-wpsc-cf-textarea.php

1,390 lines 42.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly!
4 }
5
6 if ( ! class_exists( 'WPSC_CF_Textarea' ) ) :
7
8 final class WPSC_CF_Textarea {
9
10 /**
11 * Slug for this custom field type
12 *
13 * @var string
14 */
15 public static $slug = 'cf_textarea';
16
17 /**
18 * Set whether this custom field type is of type date
19 *
20 * @var boolean
21 */
22 public static $is_date = false;
23
24 /**
25 * Set whether this custom field type has applicable to date range
26 *
27 * @var boolean
28 */
29 public static $has_date_range = false;
30
31 /**
32 * Set whether this custom field type has multiple values
33 *
34 * @var boolean
35 */
36 public static $has_multiple_val = false;
37
38 /**
39 * Data type for column created in tickets table
40 *
41 * @var string
42 */
43 public static $data_type = 'LONGTEXT NULL DEFAULT NULL';
44
45 /**
46 * Set whether this custom field type has reference to other class
47 *
48 * @var boolean
49 */
50 public static $has_ref = false;
51
52 /**
53 * Reference class for this custom field type so that its value(s) return with object or array of objects automatically. Empty string indicate no reference.
54 *
55 * @var string
56 */
57 public static $ref_class = '';
58
59 /**
60 * Set whether this custom field field type is system default (no fields can be created from it).
61 *
62 * @var boolean
63 */
64 public static $is_default = false;
65
66 /**
67 * Set whether this field type has extra information that can be used in ticket form, edit custom fields, etc.
68 *
69 * @var boolean
70 */
71 public static $has_extra_info = true;
72
73 /**
74 * Set whether this custom field type can accept personal info.
75 *
76 * @var boolean
77 */
78 public static $has_personal_info = true;
79
80 /**
81 * Set whether fields created from this custom field type is allowed in create ticket form
82 *
83 * @var boolean
84 */
85 public static $is_ctf = true;
86
87 /**
88 * Set whether fields created from this custom field type is allowed in ticket list
89 *
90 * @var boolean
91 */
92 public static $is_list = false;
93
94 /**
95 * Set whether fields created from this custom field type is allowed in ticket filter
96 *
97 * @var boolean
98 */
99 public static $is_filter = true;
100
101 /**
102 * Set whether fields created from this custom field type can be given character limits
103 *
104 * @var boolean
105 */
106 public static $has_char_limit = true;
107
108 /**
109 * Set whether fields created from this custom field type has custom options set in options table
110 *
111 * @var boolean
112 */
113 public static $has_options = false;
114
115 /**
116 * Set whether fields created from this custom field type can be auto-filled
117 *
118 * @var boolean
119 */
120 public static $is_auto_fill = true;
121
122 /**
123 * Set whether fields created from this custom field type can be available for ticket list sorting
124 *
125 * @var boolean
126 */
127 public static $is_sort = false;
128
129 /**
130 * Set whether fields created from this custom field type can have placeholder
131 *
132 * @var boolean
133 */
134 public static $is_placeholder = true;
135
136 /**
137 * Set whether fields created from this custom field type is applicable for visibility conditions in create ticket form
138 *
139 * @var boolean
140 */
141 public static $is_visibility_conditions = true;
142
143 /**
144 * Set whether fields created from this custom field type is applicable for macros
145 *
146 * @var boolean
147 */
148 public static $has_macro = true;
149
150 /**
151 * Set whether fields of this custom field type is applicalbe for search on ticket list page.
152 *
153 * @var boolean
154 */
155 public static $is_search = true;
156
157 /**
158 * Initialize the class
159 *
160 * @return void
161 */
162 public static function init() {
163
164 // Get object of this class.
165 add_filter( 'wpsc_load_ref_classes', array( __CLASS__, 'load_ref_class' ) );
166
167 // Set custom field type.
168 add_filter( 'wpsc_cf_types', array( __CLASS__, 'add_cf_type' ), 5 );
169
170 // ticket form.
171 add_action( 'wpsc_js_validate_ticket_form', array( __CLASS__, 'js_validate_ticket_form' ) );
172 add_filter( 'wpsc_create_ticket_data', array( __CLASS__, 'set_create_ticket_data' ), 10, 3 );
173 add_action( 'wpsc_js_clear_value_hidden_fields', array( __CLASS__, 'js_clear_value_hidden_fields' ) );
174
175 // create ticket data for rest api.
176 add_filter( 'wpsc_rest_create_ticket', array( __CLASS__, 'set_rest_ticket_data' ), 10, 3 );
177
178 // Ticket model.
179 add_filter( 'wpsc_ticket_search', array( __CLASS__, 'ticket_search' ), 10, 5 );
180 }
181
182 /**
183 * Load current class to reference classes
184 *
185 * @param array $classes - Associative array of class names indexed by its slug.
186 * @return array
187 */
188 public static function load_ref_class( $classes ) {
189
190 $classes[ self::$slug ] = array(
191 'class' => __CLASS__,
192 'save-key' => 'id',
193 );
194 return $classes;
195 }
196
197 /**
198 * Add custom field type to list
199 *
200 * @param array $cf_types - custom field types array.
201 * @return array
202 */
203 public static function add_cf_type( $cf_types ) {
204
205 $cf_types[ self::$slug ] = array(
206 'label' => esc_attr__( 'Textarea', 'supportcandy' ),
207 'class' => __CLASS__,
208 );
209 return $cf_types;
210 }
211
212 /**
213 * Print operators for ticket form filter
214 *
215 * @param WPSC_Custom_Field $cf - custom field object.
216 * @param array $filter - Existing filters (if any).
217 * @return void
218 */
219 public static function get_operators( $cf, $filter = array() ) {
220 ?>
221
222 <div class="item conditional">
223 <select class="operator" onchange="wpsc_tc_get_operand(this, '<?php echo esc_attr( $cf->slug ); ?>', '<?php echo esc_attr( wp_create_nonce( 'wpsc_tc_get_operand' ) ); ?>');">
224 <option value=""><?php esc_attr_e( 'Compare As', 'supportcandy' ); ?></option>
225 <option <?php isset( $filter['operator'] ) && selected( $filter['operator'], 'IN' ); ?> value="IN"><?php esc_attr_e( 'Matches', 'supportcandy' ); ?></option>
226 <option <?php isset( $filter['operator'] ) && selected( $filter['operator'], 'NOT IN' ); ?> value="NOT IN"><?php esc_attr_e( 'Not Matches', 'supportcandy' ); ?></option>
227 <option <?php isset( $filter['operator'] ) && selected( $filter['operator'], 'LIKE' ); ?> value="LIKE"><?php esc_attr_e( 'Has Words', 'supportcandy' ); ?></option>
228 </select>
229 </div>
230 <?php
231 }
232
233 /**
234 * Print operators for ticket form filter
235 *
236 * @param string $operator - condition operator on which operands should be returned.
237 * @param WPSC_Custom_Field $cf - custom field object.
238 * @param array $filter - Exising functions (if any).
239 * @return void
240 */
241 public static function get_operands( $operator, $cf, $filter = array() ) {
242
243 $value = isset( $filter['operand_val_1'] ) ? stripslashes( $filter['operand_val_1'] ) : ''
244 ?>
245 <div class="item conditional operand single">
246 <textarea class="operand_val_1" placeholder="<?php esc_attr_e( 'One condition per line!', 'supportcandy' ); ?>" style="width: 100%;"><?php echo esc_attr( $value ); ?></textarea>
247 </div>
248 <?php
249 }
250
251 /**
252 * Check condition for this type
253 *
254 * @param array $condition - condition data.
255 * @param WPSC_Custom_Field $cf - custom field object.
256 * @param mixed $value - value to compare.
257 * @return boolean
258 */
259 public static function is_valid( $condition, $cf, $value ) {
260
261 $response = false;
262 $value = stripslashes( $value );
263 $terms = explode( PHP_EOL, $condition['operand_val_1'] );
264
265 switch ( $condition['operator'] ) {
266
267 case 'IN':
268 foreach ( $terms as $term ) {
269 $term = trim( $term );
270 if ( $term == $value ) {
271 $response = true;
272 break;
273 }
274 }
275 break;
276
277 case 'NOT IN':
278 $response = true;
279 foreach ( $terms as $term ) {
280 $term = trim( $term );
281 if ( $term == $value ) {
282 $response = false;
283 break;
284 }
285 }
286 break;
287
288 case 'LIKE':
289 $response = false;
290 foreach ( $terms as $term ) {
291 $index = strpos( $value, trim( stripslashes( $term ) ) );
292 if ( is_numeric( $index ) ) {
293 $response = true;
294 break;
295 }
296 }
297 break;
298 }
299 return $response;
300 }
301
302 /**
303 * Parse filter and return sql query to be merged in ticket model query builder
304 *
305 * @param WPSC_Custom_Field $cf - custom field of this type.
306 * @param mixed $compare - comparison operator.
307 * @param mixed $val - value to compare.
308 * @return string
309 */
310 public static function parse_filter( $cf, $compare, $val ) {
311
312 $str = '';
313
314 switch ( $compare ) {
315
316 case 'IN':
317 $str = 'CONVERT(' . self::get_sql_slug( $cf ) . ' USING utf8) IN(\'' . implode( '\', \'', esc_sql( $val ) ) . '\')';
318 break;
319
320 case 'NOT IN':
321 $str = 'CONVERT(' . self::get_sql_slug( $cf ) . ' USING utf8) NOT IN(\'' . implode( '\', \'', esc_sql( $val ) ) . '\')';
322 break;
323
324 case 'LIKE':
325 $arr = array();
326 $val = explode( PHP_EOL, $val );
327 foreach ( $val as $term ) {
328 $term = str_replace( '*', '%', trim( $term ) );
329 $arr[] = 'CONVERT(' . self::get_sql_slug( $cf ) . ' USING utf8) LIKE \'%' . esc_sql( $term ) . '%\'';
330 }
331 $str = '(' . implode( ' OR ', $arr ) . ')';
332 break;
333
334 default:
335 $str = '1=1';
336 }
337
338 return $str;
339 }
340
341 /**
342 * Check ticket condition
343 *
344 * @param array $condition - array with condition data.
345 * @param WPSC_Custom_Field $cf - custom field object.
346 * @param WPSC_Ticket $ticket - ticket object.
347 * @return boolean
348 */
349 public static function is_valid_ticket_condition( $condition, $cf, $ticket ) {
350
351 $flag = true;
352 $value = stripslashes( $ticket->{$cf->slug} );
353 $terms = explode( PHP_EOL, $condition['operand_val_1'] );
354
355 switch ( $condition['operator'] ) {
356
357 case 'IN':
358 $flag = false;
359 foreach ( $terms as $term ) {
360 $term = trim( $term );
361 if ( $term == $value ) {
362 $flag = true;
363 break;
364 }
365 }
366 break;
367
368 case 'NOT IN':
369 foreach ( $terms as $term ) {
370 $term = trim( $term );
371 if ( $term == $value ) {
372 $flag = false;
373 break;
374 }
375 }
376 break;
377
378 case 'LIKE':
379 $flag = false;
380 foreach ( $terms as $term ) {
381 $index = strpos( $value, trim( stripslashes( $term ) ) );
382 if ( is_numeric( $index ) ) {
383 $flag = true;
384 break;
385 }
386 }
387 break;
388
389 default:
390 $flag = true;
391 }
392
393 return $flag;
394 }
395
396 /**
397 * Check customer condition
398 *
399 * @param array $condition - array with condition data.
400 * @param WPSC_Custom_Field $cf - custom field object.
401 * @param WPSC_Customer $customer - customer object.
402 * @return boolean
403 */
404 public static function is_valid_customer_condition( $condition, $cf, $customer ) {
405
406 $flag = true;
407 $value = stripslashes( $customer->{$cf->slug} );
408 $terms = explode( PHP_EOL, $condition['operand_val_1'] );
409
410 switch ( $condition['operator'] ) {
411
412 case 'IN':
413 $flag = false;
414 foreach ( $terms as $term ) {
415 $term = trim( $term );
416 if ( $term == $value ) {
417 $flag = true;
418 break;
419 }
420 }
421 break;
422
423 case 'NOT IN':
424 foreach ( $terms as $term ) {
425 $term = trim( $term );
426 if ( $term == $value ) {
427 $flag = false;
428 break;
429 }
430 }
431 break;
432
433 case 'LIKE':
434 $flag = false;
435 foreach ( $terms as $term ) {
436 $index = strpos( $value, trim( stripslashes( $term ) ) );
437 if ( is_numeric( $index ) ) {
438 $flag = true;
439 break;
440 }
441 }
442 break;
443
444 default:
445 $flag = true;
446 }
447
448 return $flag;
449 }
450
451 /**
452 * Print ticket form field
453 *
454 * @param WPSC_Custom_Field $cf - Custom field object.
455 * @param array $tff - Array of ticket form field settings for this field.
456 * @return string
457 */
458 public static function print_tff( $cf, $tff ) {
459
460 $val = '';
461 if ( $cf->field == 'ticket' ) {
462 $val = $cf->is_auto_fill && $cf->default_value ? $cf->default_value[0] : '';
463 } else {
464 $current_user = WPSC_Current_User::$current_user;
465 $val = $current_user->is_customer && $current_user->customer->{$cf->slug} ? $current_user->customer->{$cf->slug} : '';
466 }
467
468 ob_start();
469 ?>
470 <div class="<?php echo esc_attr( WPSC_Functions::get_tff_classes( $cf, $tff ) ); ?>" data-cft="<?php echo esc_attr( self::$slug ); ?>" data-slug="<?php echo esc_attr( $cf->slug ); ?>">
471 <div class="wpsc-tff-label">
472 <span class="name"><?php echo esc_attr( $cf->name ); ?></span>
473 <?php
474 if ( $tff['is-required'] ) {
475 ?>
476 <span class="required-indicator">*</span>
477 <?php
478 }
479 ?>
480 </div>
481 <span class="extra-info"><?php echo esc_attr( $cf->extra_info ); ?></span>
482 <textarea
483 type="text"
484 name="<?php echo esc_attr( $cf->slug ); ?>"
485 placeholder="<?php echo esc_attr( $cf->placeholder_text ); ?>"
486 onchange="wpsc_check_tff_visibility()"
487 maxlength="<?php echo $cf->char_limit ? intval( $cf->char_limit ) : ''; ?>"
488 autocomplete="off"><?php echo esc_attr( $val ); ?></textarea>
489 </div>
490 <?php
491 return ob_get_clean();
492 }
493
494 /**
495 * Validate this type field in create ticket
496 *
497 * @return void
498 */
499 public static function js_validate_ticket_form() {
500 ?>
501
502 case '<?php echo esc_attr( self::$slug ); ?>':
503 var val = customField.find('textarea').first().val().trim();
504 if (customField.hasClass('required') && !val) {
505 isValid = false;
506 alert(supportcandy.translations.req_fields_missing);
507 }
508 break;
509 <?php
510 echo PHP_EOL;
511 }
512
513 /**
514 * Return custom field value in $_POST
515 * Ignore phpcs nonce issue as we already checked where it is called from.
516 *
517 * @param string $slug - Custom field slug.
518 * @param mixed $cf - Custom field object or false.
519 * @return mixed
520 */
521 public static function get_tff_value( $slug, $cf = false ) {
522
523 return isset( $_POST[ $slug ] ) ? sanitize_textarea_field( wp_unslash( $_POST[ $slug ] ) ) : ''; // phpcs:ignore
524 }
525
526 /**
527 * Return default value for custom field of this type
528 *
529 * @param WPSC_Custom_Field $cf - custom field object.
530 * @return mixed
531 */
532 public static function get_default_value( $cf ) {
533
534 return $cf->default_value ? $cf->default_value[0] : '';
535 }
536
537 /**
538 * Check and return custom field value for new ticket to be created.
539 * This function is used by filter for set create ticket form and called directly by my-profile for each applicable custom fields.
540 * Ignore phpcs nonce issue as we already checked where it is called from.
541 *
542 * @param array $data - Array of values to to stored in ticket in an insert function.
543 * @param array $custom_fields - Array containing all applicable custom fields indexed by unique custom field types.
544 * @param boolean $is_my_profile - Whether it or not it is created from my-profile. This function is used by create ticket as well as my-profile. Due to customer fields handling is done same way, this flag gives apportunity to identify where it being called.
545 * @return array
546 */
547 public static function set_create_ticket_data( $data, $custom_fields, $is_my_profile ) {
548
549 if ( isset( $custom_fields[ self::$slug ] ) ) {
550 foreach ( $custom_fields[ self::$slug ] as $cf ) {
551 $value = self::get_tff_value( $cf->slug );
552
553 if (
554 $cf->char_limit && mb_strlen( $value ) > $cf->char_limit
555 ) {
556 wp_send_json_error( new WP_Error( 'WPSC_CF_Textarea', 'Character limit exceed!!' ), 400 );
557 }
558
559 if ( $cf->field == 'ticket' ) {
560
561 $default_val = self::get_default_value( $cf );
562 $data[ $cf->slug ] = $value ? $value : $default_val;
563
564 } elseif ( $cf->field == 'agentonly' ) {
565
566 $data[ $cf->slug ] = self::get_default_value( $cf );
567
568 } elseif ( $cf->field == 'customer' && $data['customer'] != 0 ) {
569
570 $tff = get_option( 'wpsc-tff' );
571 if ( ! $is_my_profile && ! isset( $tff[ $cf->slug ] ) ) {
572 continue;
573 }
574
575 $customer = new WPSC_Customer( $data['customer'] );
576 $prev_val = $customer->{$cf->slug};
577
578 if ( $customer->{$cf->slug} != $value ) {
579 $customer->{$cf->slug} = $value;
580 $customer->save();
581
582 // Set log for this change.
583 WPSC_Log::insert(
584 array(
585 'type' => 'customer',
586 'ref_id' => $customer->id,
587 'modified_by' => WPSC_Current_User::$current_user->customer->id,
588 'body' => wp_json_encode(
589 array(
590 'slug' => $cf->slug,
591 'prev' => $prev_val,
592 'new' => $value,
593 )
594 ),
595 'date_created' => ( new DateTime() )->format( 'Y-m-d H:i:s' ),
596 )
597 );
598 }
599 }
600 }
601 }
602 return $data;
603 }
604
605 /**
606 * Set create ticket data for rest api request
607 *
608 * @param array $data - create ticket data array.
609 * @param WP_REST_Request $request - rest request object.
610 * @param array $custom_fields - custom field objects indexed by unique custom field types.
611 * @return array
612 */
613 public static function set_rest_ticket_data( $data, $request, $custom_fields ) {
614
615 $current_user = WPSC_Current_User::$current_user;
616 $tff = get_option( 'wpsc-tff' );
617
618 if ( isset( $custom_fields[ self::$slug ] ) ) {
619 foreach ( $custom_fields[ self::$slug ] as $cf ) {
620
621 if (
622 ! in_array( $cf->field, array( 'ticket', 'agentonly', 'customer' ) ) ||
623 ( $cf->field == 'customer' && ! isset( $tff[ $cf->slug ] ) )
624 ) {
625 continue;
626 }
627
628 $value = sanitize_textarea_field( $request->get_param( $cf->slug ) );
629
630 if ( in_array( $cf->field, array( 'ticket', 'agentonly' ) ) ) {
631
632 $data[ $cf->slug ] = $cf->field == 'ticket' && $value ? $value : self::get_default_value( $cf );
633
634 } else {
635
636 $customer = new WPSC_Customer( $data['customer'] );
637 $existing_val = $customer->{$cf->slug};
638
639 if ( $value && $value != $existing_val ) {
640
641 $customer->{$cf->slug} = $value;
642 $customer->save();
643
644 // Set log for this change.
645 WPSC_Log::insert(
646 array(
647 'type' => 'customer',
648 'ref_id' => $customer->id,
649 'modified_by' => $current_user->customer->id,
650 'body' => wp_json_encode(
651 array(
652 'slug' => $cf->slug,
653 'prev' => $existing_val,
654 'new' => $value,
655 )
656 ),
657 'date_created' => ( new DateTime() )->format( 'Y-m-d H:i:s' ),
658 )
659 );
660 }
661 }
662 }
663 }
664
665 return $data;
666 }
667
668 /**
669 * Return slug string to be used in where condition of ticket model for this type of field
670 *
671 * @param WPSC_Custom_Field $cf - custom field object.
672 * @return string
673 */
674 public static function get_sql_slug( $cf ) {
675
676 $join_char = in_array( $cf->field, array( 'ticket', 'agentonly' ) ) ? 't.' : 'c.';
677 return $join_char . $cf->slug;
678 }
679
680 /**
681 * Add ticket search compatibility for fields of this custom field type.
682 *
683 * @param array $sql - Array of sql peices that can be joined later.
684 * @param array $filter - User filter.
685 * @param array $custom_fields - Custom fields array applicable for search.
686 * @param string $search - search string.
687 * @param array $allowed_search_fields - Allowed search fields.
688 * @return array
689 */
690 public static function ticket_search( $sql, $filter, $custom_fields, $search, $allowed_search_fields ) {
691
692 if ( isset( $custom_fields[ self::$slug ] ) ) {
693 foreach ( $custom_fields[ self::$slug ] as $cf ) {
694 if ( in_array( $cf->slug, $allowed_search_fields ) ) {
695
696 $join_char = in_array( $cf->field, array( 'ticket', 'agentonly' ) ) ? 't.' : 'c.';
697 $sql[] = 'CONVERT(' . $join_char . $cf->slug . ' USING utf8) LIKE \'%' . $search . '%\'';
698 }
699 }
700 }
701
702 return $sql;
703 }
704
705 /**
706 * Return val field for meta query of this type of custom field
707 *
708 * @param array $condition - condition data.
709 * @return mixed
710 */
711 public static function get_meta_value( $condition ) {
712
713 $operator = $condition['operator'];
714 switch ( $operator ) {
715
716 case 'IN':
717 case 'NOT IN':
718 $val = explode( PHP_EOL, $condition['operand_val_1'] );
719 $temp_val = array();
720 foreach ( $val as $value ) {
721 $value = trim( $value );
722 if ( $value ) {
723 $temp_val[] = $value;
724 }
725 }
726 return $temp_val ? $temp_val : false;
727
728 case 'LIKE':
729 return trim( $condition['operand_val_1'] );
730 }
731 return false;
732 }
733
734 /**
735 * Print generic input field for this type.
736 *
737 * @param WPSC_Custom_Field $cf - Custom field object.
738 * @param mixed $value - optional. Input field will be printed with given value if given.
739 * @return void
740 */
741 public static function print_cf_input( $cf, $value = '' ) {
742
743 ?>
744 <div class="wpsc-tff wpsc-sm-12 wpsc-md-12 wpsc-lg-12 wpsc-visible wpsc-xs-12" data-cft="<?php echo esc_attr( self::$slug ); ?>">
745 <div class="wpsc-tff-label">
746 <span class="name"><?php echo esc_attr( $cf->name ); ?></span>
747 </div>
748 <?php
749 $extra_info = stripslashes( $cf->extra_info );
750 if ( $extra_info ) :
751 ?>
752 <span class="extra-info"><?php echo esc_attr( $cf->extra_info ); ?></span>
753 <?php
754 endif
755 ?>
756 <textarea
757 type="text"
758 name="<?php echo esc_attr( $cf->slug ); ?>"
759 placeholder="<?php echo esc_attr( $cf->placeholder_text ); ?>"
760 maxlength="<?php echo $cf->char_limit ? intval( $cf->char_limit ) : ''; ?>"
761 autocomplete="off"><?php echo esc_attr( $value ); ?></textarea>
762 </div>
763 <?php
764 }
765
766 /**
767 * Get value for generic field from post.
768 * Ignore phpcs nonce issue as we already checked where it is called from.
769 *
770 * @param WPSC_Custom_Field $cf - custom field object.
771 * @return string
772 */
773 public static function get_cf_input_val( $cf ) {
774
775 return isset( $_POST[ $cf->slug ] ) ? sanitize_textarea_field( wp_unslash( $_POST[ $cf->slug ] ) ) : ''; // phpcs:ignore
776 }
777
778 /**
779 * Print edit ticket custom field in individual ticket
780 *
781 * @param WPSC_Custom_Field $cf - custom field object.
782 * @param WPSC_Ticket $ticket - ticket object.
783 * @return void
784 */
785 public static function print_edit_ticket_cf( $cf, $ticket ) {
786
787 ?>
788 <div class="wpsc-tff wpsc-sm-12 wpsc-md-12 wpsc-lg-12 wpsc-visible wpsc-xs-12" data-cft="<?php echo esc_attr( self::$slug ); ?>">
789 <div class="wpsc-tff-label">
790 <span class="name"><?php echo esc_attr( $cf->name ); ?></span>
791 </div>
792 <?php
793 $extra_info = stripslashes( $cf->extra_info );
794 if ( $extra_info ) :
795 ?>
796 <span class="extra-info"><?php echo esc_attr( $cf->extra_info ); ?></span>
797 <?php
798 endif
799 ?>
800 <textarea
801 type="text"
802 name="<?php echo esc_attr( $cf->slug ); ?>"
803 placeholder="<?php echo esc_attr( $cf->placeholder_text ); ?>"
804 maxlength="<?php echo $cf->char_limit ? intval( $cf->char_limit ) : ''; ?>"
805 autocomplete="off"><?php echo esc_attr( $ticket->{$cf->slug} ); ?></textarea>
806 </div>
807 <?php
808 }
809
810 /**
811 * Set edit individual ticket for this custom field type.
812 * Ignore phpcs nonce issue as we already checked where it is called from.
813 *
814 * @param WPSC_Custom_Field $cf - custom field object.
815 * @param WPSC_Ticket $ticket - ticket object.
816 * @return WPSC_Ticket
817 */
818 public static function set_edit_ticket_cf( $cf, $ticket ) {
819
820 $prev = $ticket->{$cf->slug} ? $ticket->{$cf->slug} : '';
821 $new = isset( $_POST[ $cf->slug ] ) ? sanitize_textarea_field( wp_unslash( $_POST[ $cf->slug ] ) ) : ''; // phpcs:ignore
822
823 // Exit if there is no change.
824 if ( $prev == $new ) {
825 return $ticket;
826 }
827
828 // Change value.
829 $ticket->{$cf->slug} = $new;
830 $ticket->save();
831
832 return $ticket;
833 }
834
835 /**
836 * Modify ticket field value of this custom field type using rest api
837 *
838 * @param WPSC_Ticket $ticket - ticket object.
839 * @param WPSC_Custom_Field $cf - custom field.
840 * @param mixed $value - value to be set.
841 * @return void
842 */
843 public static function set_rest_edit_ticket_cf( $ticket, $cf, $value ) {
844
845 $value = sanitize_textarea_field( $value );
846 if ( $ticket->{$cf->slug} != $value ) {
847 $ticket->{$cf->slug} = $value;
848 }
849 }
850
851 /**
852 * Insert log thread for this custom field type change
853 *
854 * @param WPSC_Custom_Field $cf - current custom field of this type.
855 * @param WPSC_Ticket $prev - ticket object before making any changes.
856 * @param WPSC_Ticket $new - ticket object after making changes.
857 * @param string $current_date - date string to be stored as create time.
858 * @param int $customer_id - current user customer id for blame.
859 * @return void
860 */
861 public static function insert_ticket_log( $cf, $prev, $new, $current_date, $customer_id ) {
862
863 // Exit if there is no change.
864 if ( $prev->{$cf->slug} == $new->{$cf->slug} ) {
865 return;
866 }
867
868 $prev_val = htmlspecialchars( $prev->{$cf->slug}, ENT_QUOTES );
869 $new_val = htmlspecialchars( $new->{$cf->slug}, ENT_QUOTES );
870
871 $thread = WPSC_Thread::insert(
872 array(
873 'ticket' => $prev->id,
874 'customer' => $customer_id,
875 'type' => 'log',
876 'body' => wp_json_encode(
877 array(
878 'slug' => $cf->slug,
879 'prev' => $prev_val,
880 'new' => $new_val,
881 )
882 ),
883 'date_created' => $current_date,
884 'date_updated' => $current_date,
885 )
886 );
887 }
888
889 /**
890 * Return data for this custom field while creating duplicate ticket
891 *
892 * @param WPSC_Custom_Field $cf - custom field object.
893 * @param WPSC_Ticket $ticket - ticket object.
894 * @return mixed
895 */
896 public static function get_duplicate_ticket_data( $cf, $ticket ) {
897
898 return $ticket->{$cf->slug};
899 }
900
901 /**
902 * Print edit field for this type in edit customer info
903 *
904 * @param WPSC_Custom_field $cf - custom field object.
905 * @param WPSC_Customer $customer - customer object.
906 * @param array $tff - ticket form field data.
907 * @return string
908 */
909 public static function print_edit_customer_info( $cf, $customer, $tff ) {
910
911 $val = $customer->id && $customer->{$cf->slug} ? stripslashes( htmlspecialchars( $customer->{$cf->slug} ) ) : '';
912
913 ob_start();
914 ?>
915 <div class="<?php echo esc_attr( WPSC_Functions::get_tff_classes( $cf, $tff ) ); ?>" data-cft="<?php echo esc_attr( self::$slug ); ?>">
916 <div class="wpsc-tff-label">
917 <span class="name"><?php echo esc_attr( $cf->name ); ?></span>
918 </div>
919 <span class="extra-info"><?php echo esc_attr( $cf->extra_info ); ?></span>
920 <textarea
921 type="text"
922 name="<?php echo esc_attr( $cf->slug ); ?>"
923 placeholder="<?php echo esc_attr( $cf->placeholder_text ); ?>"
924 maxlength="<?php echo $cf->char_limit ? intval( $cf->char_limit ) : ''; ?>"
925 autocomplete="off"><?php echo esc_attr( $val ); ?></textarea>
926 </div>
927 <?php
928 return ob_get_clean();
929 }
930
931 /**
932 * Print add new custom field setting properties
933 *
934 * @param string $field_class - Class name of the field.
935 * @return void
936 */
937 public static function get_add_new_custom_field_properties( $field_class ) {
938
939 if ( in_array( 'extra_info', $field_class::$allowed_properties ) ) :
940 ?>
941 <div data-type="textfield" data-required="false" class="wpsc-input-group extra-info">
942 <div class="label-container">
943 <label for=""><?php esc_attr_e( 'Extra info', 'supportcandy' ); ?></label>
944 </div>
945 <input name="extra_info" type="text" autocomplete="off" />
946 </div>
947 <?php
948 endif;
949
950 if ( in_array( 'default_value', $field_class::$allowed_properties ) ) :
951 ?>
952 <div data-type="textarea" data-required="false" class="wpsc-input-group default_value">
953 <div class="label-container">
954 <label for="">
955 <?php esc_attr_e( 'Default value', 'supportcandy' ); ?>
956 </label>
957 </div>
958 <textarea name="default_value" autocomplete="off"></textarea>
959 </div>
960 <?php
961 endif;
962
963 if ( in_array( 'is_auto_fill', $field_class::$allowed_properties ) ) :
964 ?>
965 <div data-type="single-select" data-required="false" class="wpsc-input-group is_auto_fill">
966 <div class="label-container">
967 <label for="">
968 <?php esc_attr_e( 'Auto-fill in ticket form', 'supportcandy' ); ?>
969 </label>
970 </div>
971 <select name="is_auto_fill">
972 <option value="0"><?php esc_attr_e( 'No', 'supportcandy' ); ?></option>
973 <option value="1"><?php esc_attr_e( 'Yes', 'supportcandy' ); ?></option>
974 </select>
975 </div>
976 <?php
977 endif;
978
979 if ( in_array( 'char_limit', $field_class::$allowed_properties ) ) :
980 ?>
981 <div data-type="number" data-required="false" class="wpsc-input-group char_limit">
982 <div class="label-container">
983 <label for="">
984 <?php esc_attr_e( 'Character limit', 'supportcandy' ); ?>
985 </label>
986 </div>
987 <input type="number" name="char_limit" autocomplete="off">
988 </div>
989 <?php
990 endif;
991
992 if ( in_array( 'placeholder_text', $field_class::$allowed_properties ) ) :
993 ?>
994 <div data-type="textfield" data-required="false" class="wpsc-input-group placeholder_text">
995 <div class="label-container">
996 <label for="">
997 <?php esc_attr_e( 'Placeholder', 'supportcandy' ); ?>
998 </label>
999 </div>
1000 <input type="text" name="placeholder_text" autocomplete="off">
1001 </div>
1002 <?php
1003 endif;
1004
1005 if ( in_array( 'is_personal_info', $field_class::$allowed_properties ) ) :
1006 ?>
1007 <div data-type="single-select" data-required="false" class="wpsc-input-group is_personal_info">
1008 <div class="label-container">
1009 <label for="">
1010 <?php esc_attr_e( 'Has personal info', 'supportcandy' ); ?>
1011 </label>
1012 </div>
1013 <select name="is_personal_info">
1014 <option value="0"><?php esc_attr_e( 'No', 'supportcandy' ); ?></option>
1015 <option value="1"><?php esc_attr_e( 'Yes', 'supportcandy' ); ?></option>
1016 </select>
1017 </div>
1018 <?php
1019 endif;
1020
1021 if ( in_array( 'allow_my_profile', $field_class::$allowed_properties ) ) :
1022 ?>
1023 <div data-type="single-select" data-required="false" class="wpsc-input-group allow_my_profile">
1024 <div class="label-container">
1025 <label for="">
1026 <?php esc_attr_e( 'Allow in my profile?', 'supportcandy' ); ?>
1027 </label>
1028 </div>
1029 <select name="allow_my_profile">
1030 <option value="0"><?php esc_attr_e( 'No', 'supportcandy' ); ?></option>
1031 <option value="1"><?php esc_attr_e( 'Yes', 'supportcandy' ); ?></option>
1032 </select>
1033 </div>
1034 <?php
1035 endif;
1036
1037 if ( in_array( 'allow_ticket_form', $field_class::$allowed_properties ) ) :
1038 ?>
1039 <div data-type="single-select" data-required="false" class="wpsc-input-group allow_ticket_form">
1040 <div class="label-container">
1041 <label for="">
1042 <?php esc_attr_e( 'Allow in ticket form?', 'supportcandy' ); ?>
1043 </label>
1044 </div>
1045 <select name="allow_ticket_form">
1046 <option value="0"><?php esc_attr_e( 'No', 'supportcandy' ); ?></option>
1047 <option value="1"><?php esc_attr_e( 'Yes', 'supportcandy' ); ?></option>
1048 </select>
1049 </div>
1050 <?php
1051 endif;
1052 }
1053
1054 /**
1055 * Print edit custom field properties
1056 *
1057 * @param WPSC_Custom_Fields $cf - custom field object.
1058 * @param string $field_class - class name of field category.
1059 * @return void
1060 */
1061 public static function get_edit_custom_field_properties( $cf, $field_class ) {
1062
1063 if ( in_array( 'extra_info', $field_class::$allowed_properties ) ) :
1064 ?>
1065 <div data-type="textfield" data-required="false" class="wpsc-input-group extra-info">
1066 <div class="label-container">
1067 <label for=""><?php esc_attr_e( 'Extra info', 'supportcandy' ); ?></label>
1068 </div>
1069 <input name="extra_info" type="text" value="<?php echo esc_attr( $cf->extra_info ); ?>" autocomplete="off" />
1070 </div>
1071 <?php
1072 endif;
1073
1074 if ( in_array( 'default_value', $field_class::$allowed_properties ) ) :
1075 $default_val = $cf->default_value ? $cf->default_value[0] : '';
1076 ?>
1077 <div data-type="textarea" data-required="false" class="wpsc-input-group default_value">
1078 <div class="label-container">
1079 <label for="">
1080 <?php esc_attr_e( 'Default value', 'supportcandy' ); ?>
1081 </label>
1082 </div>
1083 <textarea name="default_value" autocomplete="off"><?php echo $default_val ? esc_attr( $default_val ) : ''; ?></textarea>
1084 </div>
1085 <?php
1086 endif;
1087
1088 if ( in_array( 'is_auto_fill', $field_class::$allowed_properties ) ) :
1089 ?>
1090 <div data-type="single-select" data-required="false" class="wpsc-input-group is_auto_fill">
1091 <div class="label-container">
1092 <label for="">
1093 <?php esc_attr_e( 'Auto-fill in ticket form', 'supportcandy' ); ?>
1094 </label>
1095 </div>
1096 <select name="is_auto_fill">
1097 <option <?php selected( $cf->is_auto_fill, '0' ); ?> value="0"><?php esc_attr_e( 'No', 'supportcandy' ); ?></option>
1098 <option <?php selected( $cf->is_auto_fill, '1' ); ?> value="1"><?php esc_attr_e( 'Yes', 'supportcandy' ); ?></option>
1099 </select>
1100 </div>
1101 <?php
1102 endif;
1103
1104 if ( in_array( 'char_limit', $field_class::$allowed_properties ) ) :
1105 ?>
1106 <div data-type="number" data-required="false" class="wpsc-input-group char_limit">
1107 <div class="label-container">
1108 <label for="">
1109 <?php esc_attr_e( 'Character limit', 'supportcandy' ); ?>
1110 </label>
1111 </div>
1112 <input type="number" name="char_limit" value="<?php echo intval( $cf->char_limit ); ?>" autocomplete="off">
1113 </div>
1114 <?php
1115 endif;
1116
1117 if ( in_array( 'placeholder_text', $field_class::$allowed_properties ) ) :
1118 ?>
1119 <div data-type="textfield" data-required="false" class="wpsc-input-group placeholder_text">
1120 <div class="label-container">
1121 <label for="">
1122 <?php esc_attr_e( 'Placeholder', 'supportcandy' ); ?>
1123 </label>
1124 </div>
1125 <input type="text" name="placeholder_text" value="<?php echo esc_attr( $cf->placeholder_text ); ?>" autocomplete="off">
1126 </div>
1127 <?php
1128 endif;
1129
1130 if ( in_array( 'is_personal_info', $field_class::$allowed_properties ) ) :
1131 ?>
1132 <div data-type="single-select" data-required="false" class="wpsc-input-group is_personal_info">
1133 <div class="label-container">
1134 <label for="">
1135 <?php esc_attr_e( 'Has personal info', 'supportcandy' ); ?>
1136 </label>
1137 </div>
1138 <select name="is_personal_info">
1139 <option <?php selected( $cf->is_personal_info, '0' ); ?> value="0"><?php esc_attr_e( 'No', 'supportcandy' ); ?></option>
1140 <option <?php selected( $cf->is_personal_info, '1' ); ?> value="1"><?php esc_attr_e( 'Yes', 'supportcandy' ); ?></option>
1141 </select>
1142 </div>
1143 <?php
1144 endif;
1145
1146 if ( in_array( 'allow_my_profile', $field_class::$allowed_properties ) ) :
1147 ?>
1148 <div data-type="single-select" data-required="false" class="wpsc-input-group allow_my_profile">
1149 <div class="label-container">
1150 <label for="">
1151 <?php esc_attr_e( 'Allow in my profile?', 'supportcandy' ); ?>
1152 </label>
1153 </div>
1154 <select name="allow_my_profile">
1155 <option <?php selected( $cf->allow_my_profile, '0' ); ?> value="0"><?php esc_attr_e( 'No', 'supportcandy' ); ?></option>
1156 <option <?php selected( $cf->allow_my_profile, '1' ); ?> value="1"><?php esc_attr_e( 'Yes', 'supportcandy' ); ?></option>
1157 </select>
1158 </div>
1159 <?php
1160 endif;
1161
1162 if ( in_array( 'allow_ticket_form', $field_class::$allowed_properties ) ) :
1163 ?>
1164 <div data-type="single-select" data-required="false" class="wpsc-input-group allow_ticket_form">
1165 <div class="label-container">
1166 <label for="">
1167 <?php esc_attr_e( 'Allow in ticket form?', 'supportcandy' ); ?>
1168 </label>
1169 </div>
1170 <select name="allow_ticket_form">
1171 <option <?php selected( $cf->allow_ticket_form, '0' ); ?> value="0"><?php esc_attr_e( 'No', 'supportcandy' ); ?></option>
1172 <option <?php selected( $cf->allow_ticket_form, '1' ); ?> value="1"><?php esc_attr_e( 'Yes', 'supportcandy' ); ?></option>
1173 </select>
1174 </div>
1175 <?php
1176 endif;
1177 }
1178
1179 /**
1180 * Set custom field properties. Can be used by add/edit custom field.
1181 * Ignore phpcs nonce issue as we already checked where it is called from.
1182 *
1183 * @param WPSC_Custom_Field $cf - custom field object.
1184 * @param string $field_class - class of field category.
1185 * @return void
1186 */
1187 public static function set_cf_properties( $cf, $field_class ) {
1188
1189 // extra info.
1190 if ( in_array( 'extra_info', $field_class::$allowed_properties ) ) {
1191 $cf->extra_info = isset( $_POST['extra_info'] ) ? sanitize_text_field( wp_unslash( $_POST['extra_info'] ) ) : ''; // phpcs:ignore
1192 }
1193
1194 // default value.
1195 if ( in_array( 'default_value', $field_class::$allowed_properties ) ) {
1196 $default_value = isset( $_POST['default_value'] ) ? sanitize_textarea_field( wp_unslash( $_POST['default_value'] ) ) : ''; // phpcs:ignore
1197 $cf->default_value = $default_value ? array( $default_value ) : array();
1198 }
1199
1200 // auto fill.
1201 if ( in_array( 'is_auto_fill', $field_class::$allowed_properties ) ) {
1202 $cf->is_auto_fill = isset( $_POST['is_auto_fill'] ) ? sanitize_text_field( wp_unslash( $_POST['is_auto_fill'] ) ) : ''; // phpcs:ignore
1203 }
1204
1205 // char limit.
1206 if ( in_array( 'char_limit', $field_class::$allowed_properties ) ) {
1207 $cf->char_limit = isset( $_POST['char_limit'] ) ? intval( $_POST['char_limit'] ) : 0; //phpcs:ignore
1208 }
1209
1210 // check whether char limit is honored by default value.
1211 if ( $cf->default_value && $cf->char_limit && count( $cf->default_value ) > $cf->char_limit ) {
1212 wp_send_json_error( 'Incorrect request!', 400 );
1213 }
1214
1215 // placeholder!
1216 if ( in_array( 'placeholder_text', $field_class::$allowed_properties ) ) {
1217 $cf->placeholder_text = isset( $_POST['placeholder_text'] ) ? sanitize_text_field( wp_unslash( $_POST['placeholder_text'] ) ) : ''; // phpcs:ignore
1218 }
1219
1220 // personal info.
1221 if ( in_array( 'is_personal_info', $field_class::$allowed_properties ) ) {
1222 $cf->is_personal_info = isset( $_POST['is_personal_info'] ) ? intval( $_POST['is_personal_info'] ) : 0; // phpcs:ignore
1223 }
1224
1225 // my-profile.
1226 if ( in_array( 'allow_my_profile', $field_class::$allowed_properties ) ) {
1227 $cf->allow_my_profile = isset( $_POST['allow_my_profile'] ) ? intval( $_POST['allow_my_profile'] ) : 0; // phpcs:ignore
1228 }
1229
1230 // ticket form.
1231 if ( in_array( 'allow_ticket_form', $field_class::$allowed_properties ) ) {
1232 $cf->allow_ticket_form = isset( $_POST['allow_ticket_form'] ) ? intval( $_POST['allow_ticket_form'] ) : 0; // phpcs:ignore
1233 }
1234
1235 // save!
1236 $cf->save();
1237 }
1238
1239 /**
1240 * Returns printable ticket value for custom field. Can be used in export tickets, replace macros etc.
1241 *
1242 * @param WPSC_Custom_Field $cf - custom field object.
1243 * @param WPSC_Ticket $ticket - ticket object.
1244 * @param string $module - module name.
1245 * @return string
1246 */
1247 public static function get_ticket_field_val( $cf, $ticket, $module = '' ) {
1248
1249 return apply_filters( 'wpsc_ticket_field_val_textarea', $ticket->{$cf->slug}, $cf, $ticket, $module );
1250 }
1251
1252 /**
1253 * Print ticket value for given custom field on widget
1254 *
1255 * @param WPSC_Custom_Field $cf - custom field object.
1256 * @param WPSC_Ticket $ticket - ticket object.
1257 * @return void
1258 */
1259 public static function print_widget_ticket_field_val( $cf, $ticket ) {
1260
1261 $val = $ticket->{$cf->slug};
1262 if ( ! $val ) {
1263 return;
1264 }
1265
1266 $unique_id = uniqid( 'wpsc_' );
1267
1268 ?>
1269 <div class="<?php echo esc_attr( $unique_id ); ?>">
1270 <?php echo wp_kses_post( str_replace( PHP_EOL, '<br/>', esc_html( $val ) ) ); ?>
1271 </div>
1272 <script>jQuery('.<?php echo esc_attr( $unique_id ); ?>').parent().addClass('fullwidth');</script>
1273 <?php
1274 }
1275
1276 /**
1277 * Returns printable customer value for custom field. Can be used in export tickets, replace macros etc.
1278 *
1279 * @param WPSC_Custom_Field $cf - custom field object.
1280 * @param WPSC_Customer $customer - customer object.
1281 * @return string
1282 */
1283 public static function get_customer_field_val( $cf, $customer ) {
1284
1285 return $customer->{$cf->slug};
1286 }
1287
1288 /**
1289 * Print customer value for given custom field on widget
1290 *
1291 * @param WPSC_Custom_Field $cf - custom field object.
1292 * @param WPSC_Customer $customer - customer object.
1293 * @return void
1294 */
1295 public static function print_widget_customer_field_val( $cf, $customer ) {
1296
1297 $val = $customer->{$cf->slug};
1298 if ( ! $val ) {
1299 return;
1300 }
1301
1302 $unique_id = uniqid( 'wpsc_' );
1303
1304 ?>
1305 <div class="<?php echo esc_attr( $unique_id ); ?>">
1306 <?php echo wp_kses_post( str_replace( PHP_EOL, '<br/>', esc_html( $val ) ) ); ?>
1307 </div>
1308 <script>jQuery('.<?php echo esc_attr( $unique_id ); ?>').parent().addClass('fullwidth');</script>
1309 <?php
1310 }
1311
1312 /**
1313 * Print given value for custom field
1314 *
1315 * @param WPSC_Custom_Field $cf - custom field object.
1316 * @param mixed $val - value to convert and print.
1317 * @return void
1318 */
1319 public static function print_val( $cf, $val ) {
1320
1321 if ( ! $val ) {
1322 esc_attr_e( 'None', 'supportcandy' );
1323 return;
1324 }
1325
1326 echo wp_kses_post( str_replace( PHP_EOL, '<br/>', esc_html( $val ) ) );
1327 }
1328
1329 /**
1330 * Return printable value for history log macro
1331 *
1332 * @param WPSC_Custom_Field $cf - custom field object.
1333 * @param mixed $val - value to convert and return.
1334 * @return string
1335 */
1336 public static function get_history_log_val( $cf, $val ) {
1337
1338 return $val ? str_replace( PHP_EOL, '<br/>', esc_html( $val ) ) : esc_attr__( 'None', 'supportcandy' );
1339 }
1340
1341 /**
1342 * Print dashboard activity function
1343 *
1344 * @param WPSC_Custom_Field $cf - custom field object.
1345 * @param array $recent_logs - recent_logs object.
1346 * @param array $body - body object.
1347 * @param int $view - check if frontend.
1348 * @return string
1349 */
1350 public static function print_activity( $cf, $recent_logs, $body, $view ) {
1351
1352 $url = WPSC_Functions::get_ticket_url( $recent_logs->ticket->id, $view );
1353 if ( $body->new ) {
1354 $ta_value = $body->new;
1355 } else {
1356 $ta_value = 'None';
1357 }
1358 return esc_attr( $recent_logs->customer->name ) . ' updated the' . esc_attr( $cf->name ) . ' value of <a href="' . esc_attr( $url ) . '" target="_blank">#' . esc_attr( $recent_logs->ticket->id ) . '</a> to ' . esc_attr( $ta_value );
1359 }
1360
1361 /**
1362 * Return given value for custom field
1363 *
1364 * @param WPSC_Custom_Field $cf - custom field object.
1365 * @param mixed $val - value to convert and print.
1366 * @return string
1367 */
1368 public static function get_field_value( $cf, $val ) {
1369
1370 return $val ? wp_kses_post( str_replace( PHP_EOL, '<br/>', esc_html( $val ) ) ) : esc_attr__( 'None', 'supportcandy' );
1371 }
1372
1373 /**
1374 * Clear value of hidden fields
1375 *
1376 * @return void
1377 */
1378 public static function js_clear_value_hidden_fields() {
1379 ?>
1380 case '<?php echo esc_attr( self::$slug ); ?>':
1381 customField.find('textarea').first().val('');
1382 break;
1383 <?php
1384 echo PHP_EOL;
1385 }
1386 }
1387 endif;
1388
1389 WPSC_CF_Textarea::init();
1390