PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.8.2
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.8.2
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 6.8.2, at classes/models/FrmEntryFormatter.php

934 lines 21.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 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 array $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', '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 $this->atts['entry'] = $this->entry;
361 }
362
363 /**
364 * Get the field key or ID, depending on array_key property
365 *
366 * @since 2.05
367 *
368 * @param FrmFieldValue $field_value
369 *
370 * @return string|int
371 */
372 protected function get_key_or_id( $field_value ) {
373 return $this->array_key == 'key' ? $field_value->get_field_key() : $field_value->get_field_id();
374 }
375
376 /**
377 * Package and return the formatted entry values
378 *
379 * @since 2.04
380 *
381 * @return array|string
382 */
383 public function get_formatted_entry_values() {
384 if ( $this->entry === null || $this->entry === false ) {
385 return '';
386 }
387
388 if ( $this->format === 'json' ) {
389 $content = json_encode( $this->prepare_array() );
390
391 } elseif ( $this->format === 'array' ) {
392 $content = $this->prepare_array();
393
394 } elseif ( $this->format === 'table' ) {
395 $content = $this->prepare_html_table();
396
397 } elseif ( $this->format === 'plain_text_block' ) {
398 $content = $this->prepare_plain_text_block();
399
400 } else {
401 $content = '';
402 }
403
404 /**
405 * Allows modifying the formatted entry values content.
406 *
407 * @since 5.0.16
408 *
409 * @param string $content The formatted entry values content.
410 * @param array $args Includes `entry`, `atts`, `format`, `entry_values`.
411 */
412 return apply_filters(
413 'frm_formatted_entry_values_content',
414 $content,
415 array(
416 'entry' => $this->entry,
417 'atts' => $this->atts,
418 'format' => $this->format,
419 'entry_values' => $this->entry_values,
420 )
421 );
422 }
423
424 /**
425 * Return the formatted HTML table with entry values
426 *
427 * @since 2.04
428 *
429 * @return string
430 */
431 protected function prepare_html_table() {
432 $content = $this->table_generator->generate_table_header();
433
434 $this->add_field_values_to_content( $content );
435 $this->add_user_info_to_html_table( $content );
436
437 $content .= $this->table_generator->generate_table_footer();
438
439 if ( $this->is_clickable ) {
440 $content = make_clickable( $content );
441 }
442
443 return $content;
444 }
445
446 /**
447 * Add field values to table or plain text content
448 *
449 * @since 2.05
450 *
451 * @param string $content
452 */
453 protected function add_field_values_to_content( &$content ) {
454 foreach ( $this->entry_values->get_field_values() as $field_id => $field_value ) {
455
456 /**
457 * @var FrmFieldValue $field_value
458 */
459 $field_value->prepare_displayed_value( $this->atts );
460 $this->add_field_value_to_content( $field_value, $content );
461 }
462 }
463
464 /**
465 * Return the formatted plain text content
466 *
467 * @since 2.04
468 *
469 * @return string
470 */
471 protected function prepare_plain_text_block() {
472 $content = '';
473
474 $this->add_field_values_to_content( $content );
475 $this->add_user_info_to_plain_text_content( $content );
476
477 return $content;
478 }
479
480 /**
481 * Prepare the array output
482 *
483 * @since 2.04
484 *
485 * @return array
486 */
487 protected function prepare_array() {
488 $array_output = array();
489
490 $this->push_field_values_to_array( $this->entry_values->get_field_values(), $array_output );
491
492 return $array_output;
493 }
494
495 /**
496 * Push field values to array content
497 *
498 * @since 2.04
499 *
500 * @param array $field_values
501 * @param array $output
502 */
503 protected function push_field_values_to_array( $field_values, &$output ) {
504 foreach ( $field_values as $field_value ) {
505 /**
506 * @var FrmFieldValue $field_value
507 */
508 $field_value->prepare_displayed_value( $this->atts );
509 $this->push_single_field_to_array( $field_value, $output );
510 }
511 }
512
513 /**
514 * Push a single field to the array content
515 *
516 * @since 2.04
517 *
518 * @param FrmFieldValue $field_value
519 * @param array $output
520 */
521 protected function push_single_field_to_array( $field_value, &$output ) {
522 if ( $this->include_field_in_content( $field_value ) ) {
523
524 $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
525
526 $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
527
528 $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
529 if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
530 $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
531 }
532 }
533 }
534
535 /**
536 * Add a row of values to the plain text content
537 *
538 * @since 2.04
539 *
540 * @param string $label
541 * @param mixed $display_value
542 * @param string $content
543 */
544 protected function add_plain_text_row( $label, $display_value, &$content ) {
545 $display_value = $this->prepare_display_value_for_plain_text_content( $display_value );
546
547 if ( 'rtl' == $this->direction ) {
548 $content .= wp_kses_post( $display_value . ' :' . $label ) . "\r\n";
549 } else {
550 $content .= wp_kses_post( $label . ': ' . $display_value ) . "\r\n";
551 }
552 }
553
554 /**
555 * Add a field value to the HTML table or plain text content
556 *
557 * @since 2.04
558 *
559 * @param FrmFieldValue $field_value
560 * @param string $content
561 */
562 protected function add_field_value_to_content( $field_value, &$content ) {
563 if ( $this->is_extra_field( $field_value ) ) {
564 $this->add_row_for_extra_field( $field_value, $content );
565
566 } else {
567 $this->add_row_for_standard_field( $field_value, $content );
568 }
569 }
570
571 /**
572 * Add an extra field to plain text or html table content
573 *
574 * @since 3.0
575 *
576 * @param FrmFieldValue $field_value
577 * @param string $content
578 */
579 protected function add_row_for_extra_field( $field_value, &$content ) {
580 if ( ! $this->include_field_in_content( $field_value ) ) {
581 return;
582 }
583
584 if ( $this->format === 'plain_text_block' ) {
585 $this->add_plain_text_row_for_included_extra( $field_value, $content );
586 } elseif ( $this->format === 'table' ) {
587 $this->add_html_row_for_included_extra( $field_value, $content );
588 }
589 }
590
591 /**
592 * Add a standard row to plain text or html table content
593 *
594 * @since 3.0
595 *
596 * @param FrmFieldValue $field_value
597 * @param string $content
598 */
599 protected function add_row_for_standard_field( $field_value, &$content ) {
600 if ( ! $this->include_field_in_content( $field_value ) ) {
601 return;
602 }
603
604 if ( $this->format === 'plain_text_block' ) {
605 $this->add_plain_text_row( $field_value->get_field_label(), $field_value->get_displayed_value(), $content );
606 } elseif ( $this->format === 'table' ) {
607 $value_args = $this->package_value_args( $field_value );
608 $this->add_html_row( $value_args, $content );
609 }
610 }
611
612 /**
613 * Add a row to table for included extra
614 *
615 * @since 3.0
616 *
617 * @param FrmFieldValue $field_value
618 * @param string $content
619 */
620 protected function add_html_row_for_included_extra( $field_value, &$content ) {
621 $this->prepare_html_display_value_for_extra_fields( $field_value, $display_value );
622
623 if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
624 $this->add_single_cell_html_row( $display_value, $content );
625 } else {
626 $value_args = $this->package_value_args( $field_value );
627 $this->add_html_row( $value_args, $content );
628 }
629 }
630
631 /**
632 * Add a plain text row for included extra
633 *
634 * @since 3.0
635 *
636 * @param FrmFieldValue $field_value
637 * @param string $content
638 */
639 protected function add_plain_text_row_for_included_extra( $field_value, &$content ) {
640 $this->prepare_plain_text_display_value_for_extra_fields( $field_value, $display_value );
641
642 if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
643 $this->add_single_value_plain_text_row( $display_value, $content );
644 } else {
645 $this->add_plain_text_row( $field_value->get_field_label(), $display_value, $content );
646 }
647 }
648
649 /**
650 * Add a single cell row to an HTML table
651 *
652 * @since 3.0
653 *
654 * @param string $display_value
655 * @param string $content
656 */
657 protected function add_single_cell_html_row( $display_value, &$content ) {
658 // TODO: maybe move to FrmFieldValue
659 $display_value = $this->prepare_display_value_for_html_table( $display_value );
660
661 $content .= $this->table_generator->generate_single_cell_table_row( $display_value );
662 }
663
664 /**
665 * Add a single value plain text row
666 *
667 * @since 3.0
668 *
669 * @param string $display_value
670 * @param string $content
671 */
672 protected function add_single_value_plain_text_row( $display_value, &$content ) {
673 $content .= $this->prepare_display_value_for_plain_text_content( $display_value );
674 }
675
676 /**
677 * Prepare the display value for extra fields an HTML table
678 *
679 * @since 3.0
680 *
681 * @param FrmFieldValue $field_value
682 * @param mixed $display_value
683 */
684 protected function prepare_html_display_value_for_extra_fields( $field_value, &$display_value ) {
685 $display_value = $field_value->get_displayed_value();
686 }
687
688 /**
689 * Prepare a plain text value for extra fields
690 *
691 * @since 3.0
692 *
693 * @param FrmFieldValue $field_value
694 * @param mixed $display_value
695 */
696 protected function prepare_plain_text_display_value_for_extra_fields( $field_value, &$display_value ) {
697 $display_value = $field_value->get_displayed_value() . "\r\n";
698 }
699
700 /**
701 * Add a standard row to plain text or html table content
702 *
703 * @since 2.04
704 *
705 * @param FrmFieldValue $field_value
706 * @param string $content
707 */
708 protected function add_standard_row( $field_value, &$content ) {
709 if ( $this->format === 'plain_text_block' ) {
710 $this->add_plain_text_row( $field_value->get_field_label(), $field_value->get_displayed_value(), $content );
711 } elseif ( $this->format === 'table' ) {
712 $value_args = $this->package_value_args( $field_value );
713 $this->add_html_row( $value_args, $content );
714 }
715 }
716
717 /**
718 * Package the value arguments for an HTML row
719 *
720 * @since 2.04
721 *
722 * @param FrmFieldValue $field_value
723 *
724 * @return array
725 */
726 protected function package_value_args( $field_value ) {
727 return array(
728 'label' => $field_value->get_field_label(),
729 'value' => $field_value->get_displayed_value(),
730 'field_type' => $field_value->get_field_type(),
731 );
732 }
733
734 /**
735 * Add user info to an HTML table
736 *
737 * @since 2.04
738 *
739 * @param string $content
740 */
741 protected function add_user_info_to_html_table( &$content ) {
742 if ( $this->include_user_info ) {
743
744 foreach ( $this->entry_values->get_user_info() as $user_info ) {
745
746 $value_args = array(
747 'label' => $user_info['label'],
748 'value' => $user_info['value'],
749 'field_type' => 'none',
750 );
751
752 $this->add_html_row( $value_args, $content );
753 }
754 }
755 }
756
757 /**
758 * Add user info to plain text content
759 *
760 * @since 2.04
761 *
762 * @param string $content
763 */
764 protected function add_user_info_to_plain_text_content( &$content ) {
765 if ( $this->include_user_info ) {
766
767 foreach ( $this->entry_values->get_user_info() as $user_info ) {
768 $this->add_plain_text_row( $user_info['label'], $user_info['value'], $content );
769 }
770 }
771 }
772
773 /**
774 * Check if a field should be included in the content
775 *
776 * @since 2.04
777 *
778 * @param FrmFieldValue $field_value
779 *
780 * @return bool
781 */
782 protected function include_field_in_content( $field_value ) {
783 $include = true;
784
785 if ( $this->is_extra_field( $field_value ) ) {
786 $include = $this->is_extra_field_included( $field_value );
787 } elseif ( FrmAppHelper::is_empty_value( $field_value->get_displayed_value() ) && ! $this->include_blank ) {
788 $include = false;
789 }
790
791 return apply_filters( 'frm_include_field_in_content', $include, $field_value );
792 }
793
794 /**
795 * Check if a field is normally a skipped type
796 *
797 * @since 2.04
798 *
799 * @param FrmFieldValue $field_value
800 *
801 * @return bool
802 */
803 protected function is_extra_field( $field_value ) {
804 return in_array( $field_value->get_field_type(), $this->skip_fields() );
805 }
806
807 /**
808 * Check if an extra field is included
809 *
810 * @since 2.04
811 *
812 * @param FrmFieldValue $field_value
813 *
814 * @return bool
815 */
816 protected function is_extra_field_included( $field_value ) {
817 return in_array( $field_value->get_field_type(), $this->include_extras );
818 }
819
820 /**
821 * Add a row in an HTML table
822 *
823 * @since 2.04
824 *
825 * @param array $value_args
826 * $value_args = [
827 * 'label' => (string) The label. Required
828 * 'value' => (mixed) The value to add. Required
829 * 'field_type' => (string) The field type. Blank string if not a field.
830 * ]
831 * @param string $content
832 */
833 protected function add_html_row( $value_args, &$content ) {
834 $display_value = $this->prepare_display_value_for_html_table( $value_args['value'], $value_args['field_type'] );
835
836 $content .= $this->table_generator->generate_two_cell_table_row( $value_args['label'], $display_value );
837 }
838
839 /**
840 * Prepare the displayed value for an array
841 *
842 * @since 2.04
843 *
844 * @param mixed $value
845 *
846 * @return mixed|string
847 */
848 protected function prepare_display_value_for_array( $value ) {
849 return $this->strip_html( $value );
850 }
851
852 /**
853 * Prepare a field's display value for an HTML table
854 *
855 * @since 2.04
856 *
857 * @param mixed $display_value
858 * @param string $field_type
859 *
860 * @return mixed|string
861 */
862 protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) {
863 $display_value = $this->flatten_array( $display_value );
864 if ( ! isset( $this->atts['line_breaks'] ) || ! empty( $this->atts['line_breaks'] ) ) {
865 $display_value = str_replace( array( "\r\n", "\n" ), '<br/>', $display_value );
866 }
867
868 return $display_value;
869 }
870
871 /**
872 * Prepare a field's display value for plain text content
873 *
874 * @since 2.04
875 *
876 * @param mixed $display_value
877 *
878 * @return string|int
879 */
880 protected function prepare_display_value_for_plain_text_content( $display_value ) {
881 $display_value = $this->flatten_array( $display_value );
882 $display_value = $this->strip_html( $display_value );
883
884 return $display_value;
885 }
886
887 /**
888 * Flatten an array
889 *
890 * @since 2.04
891 *
892 * @param array|string|int $value
893 *
894 * @return string|int
895 */
896 protected function flatten_array( $value ) {
897 if ( is_array( $value ) ) {
898 $separator = isset( $this->atts['array_separator'] ) ? $this->atts['array_separator'] : ', ';
899 $value = implode( $separator, $value );
900 }
901
902 return $value;
903 }
904
905 /**
906 * Strip HTML if from email value if plain text is selected
907 *
908 * @since 2.0.21
909 *
910 * @param mixed $value
911 *
912 * @return mixed
913 */
914 protected function strip_html( $value ) {
915
916 if ( $this->is_plain_text ) {
917
918 if ( is_array( $value ) ) {
919 foreach ( $value as $key => $single_value ) {
920 $value[ $key ] = $this->strip_html( $single_value );
921 }
922 } elseif ( $this->is_plain_text && ! is_array( $value ) ) {
923 if ( strpos( $value, '<img' ) !== false ) {
924 $value = str_replace( array( '<img', 'src=', '/>', '"' ), '', $value );
925 $value = trim( $value );
926 }
927 $value = strip_tags( $value );
928 }
929 }
930
931 return $value;
932 }
933 }
934