PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / trunk
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More vtrunk
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
← All changes | classes/models/FrmEntryFormatter.php +137 -79 6.25 → trunk View file →
@@ -10,14 +10,15 @@
10 10
11 11 /**
12 12 * @since 2.04
13 13 *
14 - * @var stdClass|null
14 + * @var false|stdClass|null
15 15 */
16 16 protected $entry;
17 17
18 18 /**
19 19 * @var FrmEntryValues|null
20 + *
20 21 * @since 2.04
21 22 */
22 23 protected $entry_values;
23 24
@@ -22,8 +23,9 @@
22 23 protected $entry_values;
23 24
24 25 /**
25 26 * @var bool
27 + *
26 28 * @since 2.04
27 29 */
28 30 protected $is_plain_text = false;
29 31
@@ -28,8 +30,9 @@
28 30 protected $is_plain_text = false;
29 31
30 32 /**
31 33 * @var bool
34 + *
32 35 * @since 2.04
33 36 */
34 37 protected $include_user_info = false;
35 38
@@ -34,8 +37,9 @@
34 37 protected $include_user_info = false;
35 38
36 39 /**
37 40 * @var bool
41 + *
38 42 * @since 2.04
39 43 */
40 44 protected $include_blank = false;
41 45
@@ -40,8 +44,9 @@
40 44 protected $include_blank = false;
41 45
42 46 /**
43 47 * @var string
48 + *
44 49 * @since 2.04
45 50 */
46 51 protected $format = 'text';
47 52
@@ -46,8 +51,9 @@
46 51 protected $format = 'text';
47 52
48 53 /**
49 54 * @var string
55 + *
50 56 * @since 2.05
51 57 */
52 58 protected $array_key = 'key';
53 59
@@ -52,8 +58,9 @@
52 58 protected $array_key = 'key';
53 59
54 60 /**
55 61 * @var string
62 + *
56 63 * @since 2.04
57 64 */
58 65 protected $direction = 'ltr';
59 66
@@ -58,8 +65,9 @@
58 65 protected $direction = 'ltr';
59 66
60 67 /**
61 68 * @var FrmTableHTMLGenerator|null
69 + *
62 70 * @since 2.04
63 71 */
64 72 protected $table_generator;
65 73
@@ -64,8 +72,9 @@
64 72 protected $table_generator;
65 73
66 74 /**
67 75 * @var bool
76 + *
68 77 * @since 2.04
69 78 */
70 79 protected $is_clickable = false;
71 80
@@ -70,8 +79,9 @@
70 79 protected $is_clickable = false;
71 80
72 81 /**
73 82 * @var array
83 + *
74 84 * @since 2.04
75 85 */
76 86 protected $include_extras = array();
77 87
@@ -76,8 +86,9 @@
76 86 protected $include_extras = array();
77 87
78 88 /**
79 89 * @var array
90 + *
80 91 * @since 3.0
81 92 */
82 93 protected $single_cell_fields = array();
83 94
@@ -82,8 +93,9 @@
82 93 protected $single_cell_fields = array();
83 94
84 95 /**
85 96 * @var array
97 + *
86 98 * @since 3.0
87 99 */
88 100 protected $atts = array();
89 101
@@ -124,17 +136,14 @@
124 136 *
125 137 * @since 2.04
126 138 *
127 139 * @param array $atts
140 + *
141 + * @return void
128 142 */
129 143 protected function init_entry( $atts ) {
130 144 if ( isset( $atts['entry'] ) && is_object( $atts['entry'] ) ) {
131 -
132 - if ( isset( $atts['entry']->metas ) ) {
133 - $this->entry = $atts['entry'];
134 - } else {
135 - $this->entry = FrmEntry::getOne( $atts['entry']->id, true );
136 - }
145 + $this->entry = isset( $atts['entry']->metas ) ? $atts['entry'] : FrmEntry::getOne( $atts['entry']->id, true );
137 146 } elseif ( ! empty( $atts['id'] ) ) {
138 147 $this->entry = FrmEntry::getOne( $atts['id'], true );
139 148 }
140 149 }
@@ -144,8 +153,10 @@
144 153 *
145 154 * @since 2.04
146 155 *
147 156 * @param array $atts
157 + *
158 + * @return void
148 159 */
149 160 protected function init_entry_values( $atts ) {
150 161 $entry_atts = $this->prepare_entry_attributes( $atts );
151 162 $this->entry_values = new FrmEntryValues( $this->entry->id, $entry_atts );
@@ -160,11 +171,11 @@
160 171 *
161 172 * @return array
162 173 */
163 174 protected function prepare_entry_attributes( $atts ) {
164 - $entry_atts = array();
175 + $entry_atts = array();
176 + $conditionally_add = array( 'include_fields', 'fields', 'exclude_fields', 'entry' );
165 177
166 - $conditionally_add = array( 'include_fields', 'fields', 'exclude_fields', 'entry' );
167 178 foreach ( $conditionally_add as $index ) {
168 179 if ( isset( $atts[ $index ] ) ) {
169 180 $entry_atts[ $index ] = $atts[ $index ];
170 181 }
@@ -178,25 +189,18 @@
178 189 *
179 190 * @since 2.04
180 191 *
181 192 * @param array $atts
193 + *
194 + * @return void
182 195 */
183 196 protected function init_format( $atts ) {
184 197 if ( $atts['format'] === 'array' ) {
185 -
186 198 $this->format = 'array';
187 -
188 199 } elseif ( $atts['format'] === 'json' ) {
189 -
190 200 $this->format = 'json';
191 -
192 201 } elseif ( $atts['format'] === 'text' ) {
193 -
194 - if ( $this->is_plain_text === true ) {
195 - $this->format = 'plain_text_block';
196 - } else {
197 - $this->format = 'table';
198 - }
202 + $this->format = $this->is_plain_text === true ? 'plain_text_block' : 'table';
199 203 }
200 204
201 205 /**
202 206 * Allows modifying the format property of FrmEntryFormatter object.
@@ -222,8 +226,10 @@
222 226 *
223 227 * @since 2.05
224 228 *
225 229 * @param array $atts
230 + *
231 + * @return void
226 232 */
227 233 protected function init_array_key( $atts ) {
228 234 if ( isset( $atts['array_key'] ) && $atts['array_key'] === 'id' ) {
229 235 $this->array_key = 'id';
@@ -235,11 +241,13 @@
235 241 *
236 242 * @since 2.04
237 243 *
238 244 * @param array $atts
245 + *
246 + * @return void
239 247 */
240 248 protected function init_is_plain_text( $atts ) {
241 - if ( isset( $atts['plain_text'] ) && $atts['plain_text'] ) {
249 + if ( ! empty( $atts['plain_text'] ) ) {
242 250 $this->is_plain_text = true;
243 251 } elseif ( $atts['format'] !== 'text' ) {
244 252 $this->is_plain_text = true;
245 253 }
@@ -250,11 +258,13 @@
250 258 *
251 259 * @since 2.04
252 260 *
253 261 * @param array $atts
262 + *
263 + * @return void
254 264 */
255 265 protected function init_include_blank( $atts ) {
256 - if ( isset( $atts['include_blank'] ) && $atts['include_blank'] ) {
266 + if ( ! empty( $atts['include_blank'] ) ) {
257 267 $this->include_blank = true;
258 268 }
259 269 }
260 270
@@ -263,8 +273,10 @@
263 273 *
264 274 * @since 2.04
265 275 *
266 276 * @param array $atts
277 + *
278 + * @return void
267 279 */
268 280 protected function init_direction( $atts ) {
269 281 if ( isset( $atts['direction'] ) && $atts['direction'] === 'rtl' ) {
270 282 $this->direction = 'rtl';
@@ -276,11 +288,13 @@
276 288 *
277 289 * @since 2.04
278 290 *
279 291 * @param array $atts
292 + *
293 + * @return void
280 294 */
281 295 protected function init_include_user_info( $atts ) {
282 - if ( isset( $atts['user_info'] ) && $atts['user_info'] ) {
296 + if ( ! empty( $atts['user_info'] ) ) {
283 297 $this->include_user_info = true;
284 298 }
285 299 }
286 300
@@ -287,8 +301,10 @@
287 301 /**
288 302 * Which fields to skip by default
289 303 *
290 304 * @since 3.0
305 + *
306 + * @return array
291 307 */
292 308 protected function skip_fields() {
293 309 return array( 'captcha', 'html', FrmSubmitHelper::FIELD_TYPE );
294 310 }
@@ -298,11 +314,13 @@
298 314 *
299 315 * @since 3.0
300 316 *
301 317 * @param array $atts
318 + *
319 + * @return void
302 320 */
303 321 protected function init_include_extras( $atts ) {
304 - if ( isset( $atts['include_extras'] ) && $atts['include_extras'] ) {
322 + if ( ! empty( $atts['include_extras'] ) ) {
305 323 $this->include_extras = array_map( 'strtolower', array_map( 'trim', explode( ',', $atts['include_extras'] ) ) );
306 324 }
307 325 }
308 326
@@ -309,8 +327,10 @@
309 327 /**
310 328 * Initialize the single_cell_fields property
311 329 *
312 330 * @since 3.0
331 + *
332 + * @return void
313 333 */
314 334 protected function init_single_cell_fields() {
315 335 $this->single_cell_fields = array( 'html' );
316 336 }
@@ -320,8 +340,10 @@
320 340 *
321 341 * @since 2.04
322 342 *
323 343 * @param array $atts
344 + *
345 + * @return void
324 346 */
325 347 protected function init_table_generator( $atts ) {
326 348 $this->table_generator = new FrmTableHTMLGenerator( 'entry', $atts );
327 349 }
@@ -331,11 +353,13 @@
331 353 *
332 354 * @since 2.04
333 355 *
334 356 * @param array $atts
357 + *
358 + * @return void
335 359 */
336 360 protected function init_is_clickable( $atts ) {
337 - if ( isset( $atts['clickable'] ) && $atts['clickable'] ) {
361 + if ( ! empty( $atts['clickable'] ) ) {
338 362 $this->is_clickable = true;
339 363 }
340 364 }
341 365
@@ -343,8 +367,12 @@
343 367 * Save the passed atts for other calls. Exclude some attributes to prevent
344 368 * interaction with processing field values like time format.
345 369 *
346 370 * @since 3.0
371 + *
372 + * @param array $atts
373 + *
374 + * @return void
347 375 */
348 376 protected function init_atts( $atts ) {
349 377 $atts['source'] = 'entry_formatter';
350 378 $atts['wpautop'] = false;
@@ -350,8 +378,9 @@
350 378 $atts['wpautop'] = false;
351 379 $atts['return_array'] = true;
352 380
353 381 $unset = array( 'id', 'form_id', 'format' );
382 +
354 383 foreach ( $unset as $param ) {
355 384 if ( isset( $atts[ $param ] ) ) {
356 385 unset( $atts[ $param ] );
357 386 }
@@ -387,18 +416,14 @@
387 416 }
388 417
389 418 if ( $this->format === 'json' ) {
390 419 $content = json_encode( $this->prepare_array() );
391 -
392 420 } elseif ( $this->format === 'array' ) {
393 421 $content = $this->prepare_array();
394 -
395 422 } elseif ( $this->format === 'table' ) {
396 423 $content = $this->prepare_html_table();
397 -
398 424 } elseif ( $this->format === 'plain_text_block' ) {
399 425 $content = $this->prepare_plain_text_block();
400 -
401 426 } else {
402 427 $content = '';
403 428 }
404 429
@@ -436,13 +461,9 @@
436 461 $this->add_user_info_to_html_table( $content );
437 462
438 463 $content .= $this->table_generator->generate_table_footer();
439 464
440 - if ( $this->is_clickable ) {
441 - $content = make_clickable( $content );
442 - }
443 -
444 - return $content;
465 + return $this->is_clickable ? make_clickable( $content ) : $content;
445 466 }
446 467
447 468 /**
448 469 * Add field values to table or plain text content
@@ -449,12 +470,13 @@
449 470 *
450 471 * @since 2.05
451 472 *
452 473 * @param string $content
474 + *
475 + * @return void
453 476 */
454 477 protected function add_field_values_to_content( &$content ) {
455 478 foreach ( $this->entry_values->get_field_values() as $field_value ) {
456 -
457 479 /**
458 480 * @var FrmFieldValue $field_value
459 481 */
460 482 $field_value->prepare_displayed_value( $this->atts );
@@ -499,8 +521,10 @@
499 521 * @since 2.04
500 522 *
501 523 * @param array $field_values
502 524 * @param array $output
525 + *
526 + * @return void
503 527 */
504 528 protected function push_field_values_to_array( $field_values, &$output ) {
505 529 foreach ( $field_values as $field_value ) {
506 530 /**
@@ -517,20 +541,22 @@
517 541 * @since 2.04
518 542 *
519 543 * @param FrmFieldValue $field_value
520 544 * @param array $output
545 + *
546 + * @return void
521 547 */
522 548 protected function push_single_field_to_array( $field_value, &$output ) {
523 - if ( $this->include_field_in_content( $field_value ) ) {
549 + if ( ! $this->include_field_in_content( $field_value ) ) {
550 + return;
551 + }
524 552
525 - $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
553 + $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
554 + $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
555 + $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
526 556
527 - $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
528 -
529 - $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
530 - if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
531 - $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
532 - }
557 + if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
558 + $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
533 559 }
534 560 }
535 561
536 562 /**
@@ -540,13 +566,15 @@
540 566 *
541 567 * @param string $label
542 568 * @param mixed $display_value
543 569 * @param string $content
570 + *
571 + * @return void
544 572 */
545 573 protected function add_plain_text_row( $label, $display_value, &$content ) {
546 574 $display_value = $this->prepare_display_value_for_plain_text_content( $display_value );
547 575
548 - if ( 'rtl' == $this->direction ) {
576 + if ( 'rtl' === $this->direction ) {
549 577 $content .= wp_kses_post( $display_value . ' :' . $label ) . "\r\n";
550 578 } else {
551 579 $content .= wp_kses_post( $label . ': ' . $display_value ) . "\r\n";
552 580 }
@@ -558,13 +586,14 @@
558 586 * @since 2.04
559 587 *
560 588 * @param FrmFieldValue $field_value
561 589 * @param string $content
590 + *
591 + * @return void
562 592 */
563 593 protected function add_field_value_to_content( $field_value, &$content ) {
564 594 if ( $this->is_extra_field( $field_value ) ) {
565 595 $this->add_row_for_extra_field( $field_value, $content );
566 -
567 596 } else {
568 597 $this->add_row_for_standard_field( $field_value, $content );
569 598 }
570 599 }
@@ -575,8 +604,10 @@
575 604 * @since 3.0
576 605 *
577 606 * @param FrmFieldValue $field_value
578 607 * @param string $content
608 + *
609 + * @return void
579 610 */
580 611 protected function add_row_for_extra_field( $field_value, &$content ) {
581 612 if ( ! $this->include_field_in_content( $field_value ) ) {
582 613 return;
@@ -595,8 +626,10 @@
595 626 * @since 3.0
596 627 *
597 628 * @param FrmFieldValue $field_value
598 629 * @param string $content
630 + *
631 + * @return void
599 632 */
600 633 protected function add_row_for_standard_field( $field_value, &$content ) {
601 634 if ( ! $this->include_field_in_content( $field_value ) ) {
602 635 return;
@@ -616,13 +649,15 @@
616 649 * @since 3.0
617 650 *
618 651 * @param FrmFieldValue $field_value
619 652 * @param string $content
653 + *
654 + * @return void
620 655 */
621 656 protected function add_html_row_for_included_extra( $field_value, &$content ) {
622 657 $this->prepare_html_display_value_for_extra_fields( $field_value, $display_value );
623 658
624 - if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
659 + if ( in_array( $field_value->get_field_type(), $this->single_cell_fields, true ) ) {
625 660 $this->add_single_cell_html_row( $display_value, $content );
626 661 } else {
627 662 $value_args = $this->package_value_args( $field_value );
628 663 $this->add_html_row( $value_args, $content );
@@ -635,13 +670,15 @@
635 670 * @since 3.0
636 671 *
637 672 * @param FrmFieldValue $field_value
638 673 * @param string $content
674 + *
675 + * @return void
639 676 */
640 677 protected function add_plain_text_row_for_included_extra( $field_value, &$content ) {
641 678 $this->prepare_plain_text_display_value_for_extra_fields( $field_value, $display_value );
642 679
643 - if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
680 + if ( in_array( $field_value->get_field_type(), $this->single_cell_fields, true ) ) {
644 681 $this->add_single_value_plain_text_row( $display_value, $content );
645 682 } else {
646 683 $this->add_plain_text_row( $field_value->get_field_label(), $display_value, $content );
647 684 }
@@ -653,8 +690,10 @@
653 690 * @since 3.0
654 691 *
655 692 * @param string $display_value
656 693 * @param string $content
694 + *
695 + * @return void
657 696 */
658 697 protected function add_single_cell_html_row( $display_value, &$content ) {
659 698 // TODO: maybe move to FrmFieldValue
660 699 $display_value = $this->prepare_display_value_for_html_table( $display_value );
@@ -668,8 +707,10 @@
668 707 * @since 3.0
669 708 *
670 709 * @param string $display_value
671 710 * @param string $content
711 + *
712 + * @return void
672 713 */
673 714 protected function add_single_value_plain_text_row( $display_value, &$content ) {
674 715 $content .= $this->prepare_display_value_for_plain_text_content( $display_value );
675 716 }
@@ -680,8 +721,10 @@
680 721 * @since 3.0
681 722 *
682 723 * @param FrmFieldValue $field_value
683 724 * @param mixed $display_value
725 + *
726 + * @return void
684 727 */
685 728 protected function prepare_html_display_value_for_extra_fields( $field_value, &$display_value ) {
686 729 $display_value = $field_value->get_displayed_value();
687 730 }
@@ -692,8 +735,10 @@
692 735 * @since 3.0
693 736 *
694 737 * @param FrmFieldValue $field_value
695 738 * @param mixed $display_value
739 + *
740 + * @return void
696 741 */
697 742 protected function prepare_plain_text_display_value_for_extra_fields( $field_value, &$display_value ) {
698 743 $display_value = $field_value->get_displayed_value() . "\r\n";
699 744 }
@@ -704,8 +749,10 @@
704 749 * @since 2.04
705 750 *
706 751 * @param FrmFieldValue $field_value
707 752 * @param string $content
753 + *
754 + * @return void
708 755 */
709 756 protected function add_standard_row( $field_value, &$content ) {
710 757 if ( $this->format === 'plain_text_block' ) {
711 758 $this->add_plain_text_row( $field_value->get_field_label(), $field_value->get_displayed_value(), $content );
@@ -737,22 +784,24 @@
737 784 *
738 785 * @since 2.04
739 786 *
740 787 * @param string $content
788 + *
789 + * @return void
741 790 */
742 791 protected function add_user_info_to_html_table( &$content ) {
743 - if ( $this->include_user_info ) {
792 + if ( ! $this->include_user_info ) {
793 + return;
794 + }
744 795
745 - foreach ( $this->entry_values->get_user_info() as $user_info ) {
796 + foreach ( $this->entry_values->get_user_info() as $user_info ) {
797 + $value_args = array(
798 + 'label' => $user_info['label'],
799 + 'value' => $user_info['value'],
800 + 'field_type' => 'none',
801 + );
746 802
747 - $value_args = array(
748 - 'label' => $user_info['label'],
749 - 'value' => $user_info['value'],
750 - 'field_type' => 'none',
751 - );
752 -
753 - $this->add_html_row( $value_args, $content );
754 - }
803 + $this->add_html_row( $value_args, $content );
755 804 }
756 805 }
757 806
758 807 /**
@@ -760,15 +809,18 @@
760 809 *
761 810 * @since 2.04
762 811 *
763 812 * @param string $content
813 + *
814 + * @return void
764 815 */
765 816 protected function add_user_info_to_plain_text_content( &$content ) {
766 - if ( $this->include_user_info ) {
817 + if ( ! $this->include_user_info ) {
818 + return;
819 + }
767 820
768 - foreach ( $this->entry_values->get_user_info() as $user_info ) {
769 - $this->add_plain_text_row( $user_info['label'], $user_info['value'], $content );
770 - }
821 + foreach ( $this->entry_values->get_user_info() as $user_info ) {
822 + $this->add_plain_text_row( $user_info['label'], $user_info['value'], $content );
771 823 }
772 824 }
773 825
774 826 /**
@@ -801,9 +853,9 @@
801 853 *
802 854 * @return bool
803 855 */
804 856 protected function is_extra_field( $field_value ) {
805 - return in_array( $field_value->get_field_type(), $this->skip_fields() );
857 + return in_array( $field_value->get_field_type(), $this->skip_fields(), true );
806 858 }
807 859
808 860 /**
809 861 * Check if an extra field is included
@@ -814,9 +866,9 @@
814 866 *
815 867 * @return bool
816 868 */
817 869 protected function is_extra_field_included( $field_value ) {
818 - return in_array( $field_value->get_field_type(), $this->include_extras );
870 + return in_array( $field_value->get_field_type(), $this->include_extras, true );
819 871 }
820 872
821 873 /**
822 874 * Add a row in an HTML table
@@ -829,13 +881,19 @@
829 881 * 'value' => (mixed) The value to add. Required
830 882 * 'field_type' => (string) The field type. Blank string if not a field.
831 883 * ]
832 884 * @param string $content
885 + *
886 + * @return void
833 887 */
834 888 protected function add_html_row( $value_args, &$content ) {
835 889 $display_value = $this->prepare_display_value_for_html_table( $value_args['value'], $value_args['field_type'] );
836 890
837 - $content .= $this->table_generator->generate_two_cell_table_row( $value_args['label'], $display_value );
891 + $content .= $this->table_generator->generate_two_cell_table_row(
892 + $value_args['label'],
893 + $display_value,
894 + array( 'field_type' => $value_args['field_type'] )
895 + );
838 896 }
839 897
840 898 /**
841 899 * Prepare the displayed value for an array
@@ -861,10 +919,11 @@
861 919 * @return mixed|string
862 920 */
863 921 protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) {
864 922 $display_value = $this->flatten_array( $display_value );
923 +
865 924 if ( ! isset( $this->atts['line_breaks'] ) || ! empty( $this->atts['line_breaks'] ) ) {
866 - $display_value = str_replace( array( "\r\n", "\n" ), '<br/>', $display_value );
925 + return str_replace( array( "\r\n", "\n" ), '<br/>', $display_value );
867 926 }
868 927
869 928 return $display_value;
870 929 }
@@ -879,11 +938,9 @@
879 938 * @return int|string
880 939 */
881 940 protected function prepare_display_value_for_plain_text_content( $display_value ) {
882 941 $display_value = $this->flatten_array( $display_value );
883 - $display_value = $this->strip_html( $display_value );
884 -
885 - return $display_value;
942 + return $this->strip_html( $display_value );
886 943 }
887 944
888 945 /**
889 946 * Flatten an array
@@ -912,22 +969,23 @@
912 969 *
913 970 * @return mixed
914 971 */
915 972 protected function strip_html( $value ) {
973 + if ( ! $this->is_plain_text ) {
974 + return $value;
975 + }
916 976
917 - if ( $this->is_plain_text ) {
977 + if ( is_array( $value ) ) {
978 + foreach ( $value as $key => $single_value ) {
979 + $value[ $key ] = $this->strip_html( $single_value );
980 + }
981 + } elseif ( $this->is_plain_text && ! is_array( $value ) ) {
982 + if ( str_contains( $value, '<img' ) ) {
983 + $value = str_replace( array( '<img', 'src=', '/>', '"' ), '', $value );
984 + $value = trim( $value );
985 + }
918 986
919 - if ( is_array( $value ) ) {
920 - foreach ( $value as $key => $single_value ) {
921 - $value[ $key ] = $this->strip_html( $single_value );
922 - }
923 - } elseif ( $this->is_plain_text && ! is_array( $value ) ) {
924 - if ( strpos( $value, '<img' ) !== false ) {
925 - $value = str_replace( array( '<img', 'src=', '/>', '"' ), '', $value );
926 - $value = trim( $value );
927 - }
928 - $value = strip_tags( $value );
929 - }
987 + $value = strip_tags( $value );
930 988 }
931 989
932 990 return $value;
933 991 }