PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.4
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.4
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / classes / models / FrmEntryFormatter.php

FrmEntryFormatter.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 5.4, at classes/models/FrmEntryFormatter.php

933 lines 20.9 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 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * @since 2.04
8 */
9 class FrmEntryFormatter {
10
11 /**
12 * @var stdClass
13 * @since 2.04
14 */
15 protected $entry = null;
16
17 /**
18 * @var FrmEntryValues
19 * @since 2.04
20 */
21 protected $entry_values = null;
22
23 /**
24 * @var bool
25 * @since 2.04
26 */
27 protected $is_plain_text = false;
28
29 /**
30 * @var bool
31 * @since 2.04
32 */
33 protected $include_user_info = false;
34
35 /**
36 * @var bool
37 * @since 2.04
38 */
39 protected $include_blank = false;
40
41 /**
42 * @var string
43 * @since 2.04
44 */
45 protected $format = 'text';
46
47 /**
48 * @var string
49 * @since 2.05
50 */
51 protected $array_key = 'key';
52
53 /**
54 * @var string
55 * @since 2.04
56 */
57 protected $direction = 'ltr';
58
59 /**
60 * @var FrmTableHTMLGenerator
61 * @since 2.04
62 */
63 protected $table_generator = null;
64
65 /**
66 * @var bool
67 * @since 2.04
68 */
69 protected $is_clickable = false;
70
71 /**
72 * @var array
73 * @since 2.04
74 */
75 protected $include_extras = array();
76
77 /**
78 * @var array
79 * @since 3.0
80 */
81 protected $single_cell_fields = array();
82
83 /**
84 * @var array
85 * @since 3.0
86 */
87 protected $atts = array();
88
89 /**
90 * FrmEntryFormat constructor
91 *
92 * @since 2.04
93 *
94 * @param $atts
95 */
96 public function __construct( $atts ) {
97 $this->init_entry( $atts );
98
99 if ( $this->entry === null || $this->entry === false ) {
100 return;
101 }
102
103 $this->init_is_plain_text( $atts );
104 $this->init_format( $atts );
105 $this->init_array_key( $atts );
106 $this->init_include_blank( $atts );
107 $this->init_direction( $atts );
108 $this->init_include_user_info( $atts );
109 $this->init_include_extras( $atts );
110 $this->init_single_cell_fields();
111 $this->init_entry_values( $atts );
112
113 if ( $this->format === 'table' ) {
114 $this->init_table_generator( $atts );
115 $this->init_is_clickable( $atts );
116 }
117
118 $this->init_atts( $atts );
119 }
120
121 /**
122 * Set the entry property
123 *
124 * @since 2.04
125 *
126 * @param array $atts
127 */
128 protected function init_entry( $atts ) {
129 if ( isset( $atts['entry'] ) && is_object( $atts['entry'] ) ) {
130
131 if ( isset( $atts['entry']->metas ) ) {
132 $this->entry = $atts['entry'];
133 } else {
134 $this->entry = FrmEntry::getOne( $atts['entry']->id, true );
135 }
136 } elseif ( ! empty( $atts['id'] ) ) {
137 $this->entry = FrmEntry::getOne( $atts['id'], true );
138 }
139 }
140
141 /**
142 * Set the entry values property
143 *
144 * @since 2.04
145 *
146 * @param array $atts
147 */
148 protected function init_entry_values( $atts ) {
149 $entry_atts = $this->prepare_entry_attributes( $atts );
150 $this->entry_values = new FrmEntryValues( $this->entry->id, $entry_atts );
151 }
152
153 /**
154 * Prepare attributes array for FrmEntryValues constructor
155 *
156 * @since 2.05
157 *
158 * @param array $atts
159 *
160 * @return array
161 */
162 protected function prepare_entry_attributes( $atts ) {
163 $entry_atts = array();
164
165 $conditionally_add = array( 'include_fields', 'fields', 'exclude_fields', 'entry' );
166 foreach ( $conditionally_add as $index ) {
167 if ( isset( $atts[ $index ] ) ) {
168 $entry_atts[ $index ] = $atts[ $index ];
169 }
170 }
171
172 return $entry_atts;
173 }
174
175 /**
176 * Set the format property
177 *
178 * @since 2.04
179 *
180 * @param array $atts
181 */
182 protected function init_format( $atts ) {
183 if ( $atts['format'] === 'array' ) {
184
185 $this->format = 'array';
186
187 } elseif ( $atts['format'] === 'json' ) {
188
189 $this->format = 'json';
190
191 } elseif ( $atts['format'] === 'text' ) {
192
193 if ( $this->is_plain_text === true ) {
194 $this->format = 'plain_text_block';
195 } else {
196 $this->format = 'table';
197 }
198 }
199
200 /**
201 * Allows modifying the format property of FrmEntryFormatter object.
202 *
203 * @since 5.0.16
204 *
205 * @param string $format The format.
206 * @param array $args Includes `atts`, `entry`.
207 */
208 $this->format = apply_filters(
209 'frm_entry_formatter_format',
210 $this->format,
211 array(
212 'atts' => $atts,
213 'entry' => $this->entry,
214 )
215 );
216 }
217
218 /**
219 * Set the array_key property that sets whether the keys in the
220 * returned array are field keys or ids
221 *
222 * @since 2.05
223 *
224 * @param array $atts
225 */
226 protected function init_array_key( $atts ) {
227 if ( isset( $atts['array_key'] ) && $atts['array_key'] == 'id' ) {
228 $this->array_key = 'id';
229 }
230 }
231
232 /**
233 * Set the is_plain_text property
234 *
235 * @since 2.04
236 *
237 * @param array $atts
238 */
239 protected function init_is_plain_text( $atts ) {
240 if ( isset( $atts['plain_text'] ) && $atts['plain_text'] ) {
241 $this->is_plain_text = true;
242 } elseif ( $atts['format'] !== 'text' ) {
243 $this->is_plain_text = true;
244 }
245 }
246
247 /**
248 * Set the include_blank property
249 *
250 * @since 2.04
251 *
252 * @param array $atts
253 */
254 protected function init_include_blank( $atts ) {
255 if ( isset( $atts['include_blank'] ) && $atts['include_blank'] ) {
256 $this->include_blank = true;
257 }
258 }
259
260 /**
261 * Set the direction property
262 *
263 * @since 2.04
264 *
265 * @param array $atts
266 */
267 protected function init_direction( $atts ) {
268 if ( isset( $atts['direction'] ) && $atts['direction'] === 'rtl' ) {
269 $this->direction = 'rtl';
270 }
271 }
272
273 /**
274 * Set the include_user_info property
275 *
276 * @since 2.04
277 *
278 * @param array $atts
279 */
280 protected function init_include_user_info( $atts ) {
281 if ( isset( $atts['user_info'] ) && $atts['user_info'] ) {
282 $this->include_user_info = true;
283 }
284 }
285
286 /**
287 * Which fields to skip by default
288 *
289 * @since 3.0
290 */
291 protected function skip_fields() {
292 return array( 'captcha', 'html' );
293 }
294
295 /**
296 * Set the include_extras property
297 *
298 * @since 3.0
299 *
300 * @param array $atts
301 */
302 protected function init_include_extras( $atts ) {
303 if ( isset( $atts['include_extras'] ) && $atts['include_extras'] ) {
304 $this->include_extras = array_map( 'strtolower', array_map( 'trim', explode( ',', $atts['include_extras'] ) ) );
305 }
306 }
307
308 /**
309 * Initialize the single_cell_fields property
310 *
311 * @since 3.0
312 */
313 protected function init_single_cell_fields() {
314 $this->single_cell_fields = array( 'html' );
315 }
316
317 /**
318 * Set the table_generator property
319 *
320 * @since 2.04
321 *
322 * @param array $atts
323 */
324 protected function init_table_generator( $atts ) {
325 $this->table_generator = new FrmTableHTMLGenerator( 'entry', $atts );
326 }
327
328 /**
329 * Set the is_clickable property
330 *
331 * @since 2.04
332 *
333 * @param array $atts
334 */
335 protected function init_is_clickable( $atts ) {
336 if ( isset( $atts['clickable'] ) && $atts['clickable'] ) {
337 $this->is_clickable = true;
338 }
339 }
340
341 /**
342 * Save the passed atts for other calls. Exclude some attributes to prevent
343 * interaction with processing field values like time format.
344 *
345 * @since 3.0
346 */
347 protected function init_atts( $atts ) {
348 $atts['source'] = 'entry_formatter';
349 $atts['wpautop'] = false;
350 $atts['return_array'] = true;
351
352 $unset = array( 'id', 'entry', 'form_id', 'format' );
353 foreach ( $unset as $param ) {
354 if ( isset( $atts[ $param ] ) ) {
355 unset( $atts[ $param ] );
356 }
357 }
358
359 $this->atts = $atts;
360 }
361
362 /**
363 * Get the field key or ID, depending on array_key property
364 *
365 * @since 2.05
366 *
367 * @param FrmFieldValue $field_value
368 *
369 * @return string|int
370 */
371 protected function get_key_or_id( $field_value ) {
372 return $this->array_key == 'key' ? $field_value->get_field_key() : $field_value->get_field_id();
373 }
374
375 /**
376 * Package and return the formatted entry values
377 *
378 * @since 2.04
379 *
380 * @return array|string
381 */
382 public function get_formatted_entry_values() {
383 if ( $this->entry === null || $this->entry === false ) {
384 return '';
385 }
386
387 if ( $this->format === 'json' ) {
388 $content = json_encode( $this->prepare_array() );
389
390 } elseif ( $this->format === 'array' ) {
391 $content = $this->prepare_array();
392
393 } elseif ( $this->format === 'table' ) {
394 $content = $this->prepare_html_table();
395
396 } elseif ( $this->format === 'plain_text_block' ) {
397 $content = $this->prepare_plain_text_block();
398
399 } else {
400 $content = '';
401 }
402
403 /**
404 * Allows modifying the formatted entry values content.
405 *
406 * @since 5.0.16
407 *
408 * @param string $content The formatted entry values content.
409 * @param array $args Includes `entry`, `atts`, `format`, `entry_values`.
410 */
411 return apply_filters(
412 'frm_formatted_entry_values_content',
413 $content,
414 array(
415 'entry' => $this->entry,
416 'atts' => $this->atts,
417 'format' => $this->format,
418 'entry_values' => $this->entry_values,
419 )
420 );
421 }
422
423 /**
424 * Return the formatted HTML table with entry values
425 *
426 * @since 2.04
427 *
428 * @return string
429 */
430 protected function prepare_html_table() {
431 $content = $this->table_generator->generate_table_header();
432
433 $this->add_field_values_to_content( $content );
434 $this->add_user_info_to_html_table( $content );
435
436 $content .= $this->table_generator->generate_table_footer();
437
438 if ( $this->is_clickable ) {
439 $content = make_clickable( $content );
440 }
441
442 return $content;
443 }
444
445 /**
446 * Add field values to table or plain text content
447 *
448 * @since 2.05
449 *
450 * @param string $content
451 */
452 protected function add_field_values_to_content( &$content ) {
453 foreach ( $this->entry_values->get_field_values() as $field_id => $field_value ) {
454
455 /**
456 * @var FrmFieldValue $field_value
457 */
458 $field_value->prepare_displayed_value( $this->atts );
459 $this->add_field_value_to_content( $field_value, $content );
460 }
461 }
462
463 /**
464 * Return the formatted plain text content
465 *
466 * @since 2.04
467 *
468 * @return string
469 */
470 protected function prepare_plain_text_block() {
471 $content = '';
472
473 $this->add_field_values_to_content( $content );
474 $this->add_user_info_to_plain_text_content( $content );
475
476 return $content;
477 }
478
479 /**
480 * Prepare the array output
481 *
482 * @since 2.04
483 *
484 * @return array
485 */
486 protected function prepare_array() {
487 $array_output = array();
488
489 $this->push_field_values_to_array( $this->entry_values->get_field_values(), $array_output );
490
491 return $array_output;
492 }
493
494 /**
495 * Push field values to array content
496 *
497 * @since 2.04
498 *
499 * @param array $field_values
500 * @param array $output
501 */
502 protected function push_field_values_to_array( $field_values, &$output ) {
503 foreach ( $field_values as $field_value ) {
504 /**
505 * @var FrmFieldValue $field_value
506 */
507 $field_value->prepare_displayed_value( $this->atts );
508 $this->push_single_field_to_array( $field_value, $output );
509 }
510 }
511
512 /**
513 * Push a single field to the array content
514 *
515 * @since 2.04
516 *
517 * @param FrmFieldValue $field_value
518 * @param array $output
519 */
520 protected function push_single_field_to_array( $field_value, &$output ) {
521 if ( $this->include_field_in_content( $field_value ) ) {
522
523 $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
524
525 $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
526
527 $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
528 if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
529 $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
530 }
531 }
532 }
533
534 /**
535 * Add a row of values to the plain text content
536 *
537 * @since 2.04
538 *
539 * @param string $label
540 * @param mixed $display_value
541 * @param string $content
542 */
543 protected function add_plain_text_row( $label, $display_value, &$content ) {
544 $display_value = $this->prepare_display_value_for_plain_text_content( $display_value );
545
546 if ( 'rtl' == $this->direction ) {
547 $content .= wp_kses_post( $display_value . ' :' . $label ) . "\r\n";
548 } else {
549 $content .= wp_kses_post( $label . ': ' . $display_value ) . "\r\n";
550 }
551 }
552
553 /**
554 * Add a field value to the HTML table or plain text content
555 *
556 * @since 2.04
557 *
558 * @param FrmFieldValue $field_value
559 * @param string $content
560 */
561 protected function add_field_value_to_content( $field_value, &$content ) {
562 if ( $this->is_extra_field( $field_value ) ) {
563 $this->add_row_for_extra_field( $field_value, $content );
564
565 } else {
566 $this->add_row_for_standard_field( $field_value, $content );
567 }
568 }
569
570 /**
571 * Add an extra field to plain text or html table content
572 *
573 * @since 3.0
574 *
575 * @param FrmFieldValue $field_value
576 * @param string $content
577 */
578 protected function add_row_for_extra_field( $field_value, &$content ) {
579 if ( ! $this->include_field_in_content( $field_value ) ) {
580 return;
581 }
582
583 if ( $this->format === 'plain_text_block' ) {
584 $this->add_plain_text_row_for_included_extra( $field_value, $content );
585 } elseif ( $this->format === 'table' ) {
586 $this->add_html_row_for_included_extra( $field_value, $content );
587 }
588 }
589
590 /**
591 * Add a standard row to plain text or html table content
592 *
593 * @since 3.0
594 *
595 * @param FrmFieldValue $field_value
596 * @param string $content
597 */
598 protected function add_row_for_standard_field( $field_value, &$content ) {
599 if ( ! $this->include_field_in_content( $field_value ) ) {
600 return;
601 }
602
603 if ( $this->format === 'plain_text_block' ) {
604 $this->add_plain_text_row( $field_value->get_field_label(), $field_value->get_displayed_value(), $content );
605 } elseif ( $this->format === 'table' ) {
606 $value_args = $this->package_value_args( $field_value );
607 $this->add_html_row( $value_args, $content );
608 }
609 }
610
611 /**
612 * Add a row to table for included extra
613 *
614 * @since 3.0
615 *
616 * @param FrmFieldValue $field_value
617 * @param string $content
618 */
619 protected function add_html_row_for_included_extra( $field_value, &$content ) {
620 $this->prepare_html_display_value_for_extra_fields( $field_value, $display_value );
621
622 if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
623 $this->add_single_cell_html_row( $display_value, $content );
624 } else {
625 $value_args = $this->package_value_args( $field_value );
626 $this->add_html_row( $value_args, $content );
627 }
628 }
629
630 /**
631 * Add a plain text row for included extra
632 *
633 * @since 3.0
634 *
635 * @param FrmFieldValue $field_value
636 * @param string $content
637 */
638 protected function add_plain_text_row_for_included_extra( $field_value, &$content ) {
639 $this->prepare_plain_text_display_value_for_extra_fields( $field_value, $display_value );
640
641 if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
642 $this->add_single_value_plain_text_row( $display_value, $content );
643 } else {
644 $this->add_plain_text_row( $field_value->get_field_label(), $display_value, $content );
645 }
646 }
647
648 /**
649 * Add a single cell row to an HTML table
650 *
651 * @since 3.0
652 *
653 * @param string $display_value
654 * @param string $content
655 */
656 protected function add_single_cell_html_row( $display_value, &$content ) {
657 // TODO: maybe move to FrmFieldValue
658 $display_value = $this->prepare_display_value_for_html_table( $display_value );
659
660 $content .= $this->table_generator->generate_single_cell_table_row( $display_value );
661 }
662
663 /**
664 * Add a single value plain text row
665 *
666 * @since 3.0
667 *
668 * @param string $display_value
669 * @param string $content
670 */
671 protected function add_single_value_plain_text_row( $display_value, &$content ) {
672 $content .= $this->prepare_display_value_for_plain_text_content( $display_value );
673 }
674
675 /**
676 * Prepare the display value for extra fields an HTML table
677 *
678 * @since 3.0
679 *
680 * @param FrmFieldValue $field_value
681 * @param mixed $display_value
682 */
683 protected function prepare_html_display_value_for_extra_fields( $field_value, &$display_value ) {
684 $display_value = $field_value->get_displayed_value();
685 }
686
687 /**
688 * Prepare a plain text value for extra fields
689 *
690 * @since 3.0
691 *
692 * @param FrmFieldValue $field_value
693 * @param mixed $display_value
694 */
695 protected function prepare_plain_text_display_value_for_extra_fields( $field_value, &$display_value ) {
696 $display_value = $field_value->get_displayed_value() . "\r\n";
697 }
698
699 /**
700 * Add a standard row to plain text or html table content
701 *
702 * @since 2.04
703 *
704 * @param FrmFieldValue $field_value
705 * @param string $content
706 */
707 protected function add_standard_row( $field_value, &$content ) {
708 if ( $this->format === 'plain_text_block' ) {
709 $this->add_plain_text_row( $field_value->get_field_label(), $field_value->get_displayed_value(), $content );
710 } elseif ( $this->format === 'table' ) {
711 $value_args = $this->package_value_args( $field_value );
712 $this->add_html_row( $value_args, $content );
713 }
714 }
715
716 /**
717 * Package the value arguments for an HTML row
718 *
719 * @since 2.04
720 *
721 * @param FrmFieldValue $field_value
722 *
723 * @return array
724 */
725 protected function package_value_args( $field_value ) {
726 return array(
727 'label' => $field_value->get_field_label(),
728 'value' => $field_value->get_displayed_value(),
729 'field_type' => $field_value->get_field_type(),
730 );
731 }
732
733 /**
734 * Add user info to an HTML table
735 *
736 * @since 2.04
737 *
738 * @param string $content
739 */
740 protected function add_user_info_to_html_table( &$content ) {
741 if ( $this->include_user_info ) {
742
743 foreach ( $this->entry_values->get_user_info() as $user_info ) {
744
745 $value_args = array(
746 'label' => $user_info['label'],
747 'value' => $user_info['value'],
748 'field_type' => 'none',
749 );
750
751 $this->add_html_row( $value_args, $content );
752 }
753 }
754 }
755
756 /**
757 * Add user info to plain text content
758 *
759 * @since 2.04
760 *
761 * @param string $content
762 */
763 protected function add_user_info_to_plain_text_content( &$content ) {
764 if ( $this->include_user_info ) {
765
766 foreach ( $this->entry_values->get_user_info() as $user_info ) {
767 $this->add_plain_text_row( $user_info['label'], $user_info['value'], $content );
768 }
769 }
770 }
771
772 /**
773 * Check if a field should be included in the content
774 *
775 * @since 2.04
776 *
777 * @param FrmFieldValue $field_value
778 *
779 * @return bool
780 */
781 protected function include_field_in_content( $field_value ) {
782 $include = true;
783
784 if ( $this->is_extra_field( $field_value ) ) {
785 $include = $this->is_extra_field_included( $field_value );
786 } elseif ( FrmAppHelper::is_empty_value( $field_value->get_displayed_value() ) && ! $this->include_blank ) {
787 $include = false;
788 }
789
790 return apply_filters( 'frm_include_field_in_content', $include, $field_value );
791 }
792
793 /**
794 * Check if a field is normally a skipped type
795 *
796 * @since 2.04
797 *
798 * @param FrmFieldValue $field_value
799 *
800 * @return bool
801 */
802 protected function is_extra_field( $field_value ) {
803 return in_array( $field_value->get_field_type(), $this->skip_fields() );
804 }
805
806 /**
807 * Check if an extra field is included
808 *
809 * @since 2.04
810 *
811 * @param FrmFieldValue $field_value
812 *
813 * @return bool
814 */
815 protected function is_extra_field_included( $field_value ) {
816 return in_array( $field_value->get_field_type(), $this->include_extras );
817 }
818
819 /**
820 * Add a row in an HTML table
821 *
822 * @since 2.04
823 *
824 * @param array $value_args
825 * $value_args = [
826 * 'label' => (string) The label. Required
827 * 'value' => (mixed) The value to add. Required
828 * 'field_type' => (string) The field type. Blank string if not a field.
829 * ]
830 * @param string $content
831 */
832 protected function add_html_row( $value_args, &$content ) {
833 $display_value = $this->prepare_display_value_for_html_table( $value_args['value'], $value_args['field_type'] );
834
835 $content .= $this->table_generator->generate_two_cell_table_row( $value_args['label'], $display_value );
836 }
837
838 /**
839 * Prepare the displayed value for an array
840 *
841 * @since 2.04
842 *
843 * @param mixed $value
844 *
845 * @return mixed|string
846 */
847 protected function prepare_display_value_for_array( $value ) {
848 return $this->strip_html( $value );
849 }
850
851 /**
852 * Prepare a field's display value for an HTML table
853 *
854 * @since 2.04
855 *
856 * @param mixed $display_value
857 * @param string $field_type
858 *
859 * @return mixed|string
860 */
861 protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) {
862 $display_value = $this->flatten_array( $display_value );
863 if ( ! isset( $this->atts['line_breaks'] ) || ! empty( $this->atts['line_breaks'] ) ) {
864 $display_value = str_replace( array( "\r\n", "\n" ), '<br/>', $display_value );
865 }
866
867 return $display_value;
868 }
869
870 /**
871 * Prepare a field's display value for plain text content
872 *
873 * @since 2.04
874 *
875 * @param mixed $display_value
876 *
877 * @return string|int
878 */
879 protected function prepare_display_value_for_plain_text_content( $display_value ) {
880 $display_value = $this->flatten_array( $display_value );
881 $display_value = $this->strip_html( $display_value );
882
883 return $display_value;
884 }
885
886 /**
887 * Flatten an array
888 *
889 * @since 2.04
890 *
891 * @param array|string|int $value
892 *
893 * @return string|int
894 */
895 protected function flatten_array( $value ) {
896 if ( is_array( $value ) ) {
897 $separator = isset( $this->atts['array_separator'] ) ? $this->atts['array_separator'] : ', ';
898 $value = implode( $separator, $value );
899 }
900
901 return $value;
902 }
903
904 /**
905 * Strip HTML if from email value if plain text is selected
906 *
907 * @since 2.0.21
908 *
909 * @param mixed $value
910 *
911 * @return mixed
912 */
913 protected function strip_html( $value ) {
914
915 if ( $this->is_plain_text ) {
916
917 if ( is_array( $value ) ) {
918 foreach ( $value as $key => $single_value ) {
919 $value[ $key ] = $this->strip_html( $single_value );
920 }
921 } elseif ( $this->is_plain_text && ! is_array( $value ) ) {
922 if ( strpos( $value, '<img' ) !== false ) {
923 $value = str_replace( array( '<img', 'src=', '/>', '"' ), '', $value );
924 $value = trim( $value );
925 }
926 $value = strip_tags( $value );
927 }
928 }
929
930 return $value;
931 }
932 }
933