PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.5
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.5
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 +73 -134 6.275.5 View file →
@@ -8,24 +8,21 @@
8 8 */
9 9 class FrmEntryFormatter {
10 10
11 11 /**
12 + * @var stdClass
12 13 * @since 2.04
13 - *
14 - * @var stdClass|null
15 14 */
16 - protected $entry;
15 + protected $entry = null;
17 16
18 17 /**
19 - * @var FrmEntryValues|null
20 - *
18 + * @var FrmEntryValues
21 19 * @since 2.04
22 20 */
23 - protected $entry_values;
21 + protected $entry_values = null;
24 22
25 23 /**
26 24 * @var bool
27 - *
28 25 * @since 2.04
29 26 */
30 27 protected $is_plain_text = false;
31 28
@@ -30,9 +27,8 @@
30 27 protected $is_plain_text = false;
31 28
32 29 /**
33 30 * @var bool
34 - *
35 31 * @since 2.04
36 32 */
37 33 protected $include_user_info = false;
38 34
@@ -37,9 +33,8 @@
37 33 protected $include_user_info = false;
38 34
39 35 /**
40 36 * @var bool
41 - *
42 37 * @since 2.04
43 38 */
44 39 protected $include_blank = false;
45 40
@@ -44,9 +39,8 @@
44 39 protected $include_blank = false;
45 40
46 41 /**
47 42 * @var string
48 - *
49 43 * @since 2.04
50 44 */
51 45 protected $format = 'text';
52 46
@@ -51,9 +45,8 @@
51 45 protected $format = 'text';
52 46
53 47 /**
54 48 * @var string
55 - *
56 49 * @since 2.05
57 50 */
58 51 protected $array_key = 'key';
59 52
@@ -58,23 +51,20 @@
58 51 protected $array_key = 'key';
59 52
60 53 /**
61 54 * @var string
62 - *
63 55 * @since 2.04
64 56 */
65 57 protected $direction = 'ltr';
66 58
67 59 /**
68 - * @var FrmTableHTMLGenerator|null
69 - *
60 + * @var FrmTableHTMLGenerator
70 61 * @since 2.04
71 62 */
72 - protected $table_generator;
63 + protected $table_generator = null;
73 64
74 65 /**
75 66 * @var bool
76 - *
77 67 * @since 2.04
78 68 */
79 69 protected $is_clickable = false;
80 70
@@ -79,9 +69,8 @@
79 69 protected $is_clickable = false;
80 70
81 71 /**
82 72 * @var array
83 - *
84 73 * @since 2.04
85 74 */
86 75 protected $include_extras = array();
87 76
@@ -86,9 +75,8 @@
86 75 protected $include_extras = array();
87 76
88 77 /**
89 78 * @var array
90 - *
91 79 * @since 3.0
92 80 */
93 81 protected $single_cell_fields = array();
94 82
@@ -93,9 +81,8 @@
93 81 protected $single_cell_fields = array();
94 82
95 83 /**
96 84 * @var array
97 - *
98 85 * @since 3.0
99 86 */
100 87 protected $atts = array();
101 88
@@ -103,9 +90,9 @@
103 90 * FrmEntryFormat constructor
104 91 *
105 92 * @since 2.04
106 93 *
107 - * @param array $atts
94 + * @param $atts
108 95 */
109 96 public function __construct( $atts ) {
110 97 $this->init_entry( $atts );
111 98
@@ -136,14 +123,17 @@
136 123 *
137 124 * @since 2.04
138 125 *
139 126 * @param array $atts
140 - *
141 - * @return void
142 127 */
143 128 protected function init_entry( $atts ) {
144 129 if ( isset( $atts['entry'] ) && is_object( $atts['entry'] ) ) {
145 - $this->entry = isset( $atts['entry']->metas ) ? $atts['entry'] : FrmEntry::getOne( $atts['entry']->id, true );
130 +
131 + if ( isset( $atts['entry']->metas ) ) {
132 + $this->entry = $atts['entry'];
133 + } else {
134 + $this->entry = FrmEntry::getOne( $atts['entry']->id, true );
135 + }
146 136 } elseif ( ! empty( $atts['id'] ) ) {
147 137 $this->entry = FrmEntry::getOne( $atts['id'], true );
148 138 }
149 139 }
@@ -153,10 +143,8 @@
153 143 *
154 144 * @since 2.04
155 145 *
156 146 * @param array $atts
157 - *
158 - * @return void
159 147 */
160 148 protected function init_entry_values( $atts ) {
161 149 $entry_atts = $this->prepare_entry_attributes( $atts );
162 150 $this->entry_values = new FrmEntryValues( $this->entry->id, $entry_atts );
@@ -171,11 +159,11 @@
171 159 *
172 160 * @return array
173 161 */
174 162 protected function prepare_entry_attributes( $atts ) {
175 - $entry_atts = array();
163 + $entry_atts = array();
164 +
176 165 $conditionally_add = array( 'include_fields', 'fields', 'exclude_fields', 'entry' );
177 -
178 166 foreach ( $conditionally_add as $index ) {
179 167 if ( isset( $atts[ $index ] ) ) {
180 168 $entry_atts[ $index ] = $atts[ $index ];
181 169 }
@@ -189,18 +177,25 @@
189 177 *
190 178 * @since 2.04
191 179 *
192 180 * @param array $atts
193 - *
194 - * @return void
195 181 */
196 182 protected function init_format( $atts ) {
197 183 if ( $atts['format'] === 'array' ) {
184 +
198 185 $this->format = 'array';
186 +
199 187 } elseif ( $atts['format'] === 'json' ) {
188 +
200 189 $this->format = 'json';
190 +
201 191 } elseif ( $atts['format'] === 'text' ) {
202 - $this->format = $this->is_plain_text === true ? 'plain_text_block' : 'table';
192 +
193 + if ( $this->is_plain_text === true ) {
194 + $this->format = 'plain_text_block';
195 + } else {
196 + $this->format = 'table';
197 + }
203 198 }
204 199
205 200 /**
206 201 * Allows modifying the format property of FrmEntryFormatter object.
@@ -226,13 +221,11 @@
226 221 *
227 222 * @since 2.05
228 223 *
229 224 * @param array $atts
230 - *
231 - * @return void
232 225 */
233 226 protected function init_array_key( $atts ) {
234 - if ( isset( $atts['array_key'] ) && $atts['array_key'] === 'id' ) {
227 + if ( isset( $atts['array_key'] ) && $atts['array_key'] == 'id' ) {
235 228 $this->array_key = 'id';
236 229 }
237 230 }
238 231
@@ -241,13 +234,11 @@
241 234 *
242 235 * @since 2.04
243 236 *
244 237 * @param array $atts
245 - *
246 - * @return void
247 238 */
248 239 protected function init_is_plain_text( $atts ) {
249 - if ( ! empty( $atts['plain_text'] ) ) {
240 + if ( isset( $atts['plain_text'] ) && $atts['plain_text'] ) {
250 241 $this->is_plain_text = true;
251 242 } elseif ( $atts['format'] !== 'text' ) {
252 243 $this->is_plain_text = true;
253 244 }
@@ -258,13 +249,11 @@
258 249 *
259 250 * @since 2.04
260 251 *
261 252 * @param array $atts
262 - *
263 - * @return void
264 253 */
265 254 protected function init_include_blank( $atts ) {
266 - if ( ! empty( $atts['include_blank'] ) ) {
255 + if ( isset( $atts['include_blank'] ) && $atts['include_blank'] ) {
267 256 $this->include_blank = true;
268 257 }
269 258 }
270 259
@@ -273,10 +262,8 @@
273 262 *
274 263 * @since 2.04
275 264 *
276 265 * @param array $atts
277 - *
278 - * @return void
279 266 */
280 267 protected function init_direction( $atts ) {
281 268 if ( isset( $atts['direction'] ) && $atts['direction'] === 'rtl' ) {
282 269 $this->direction = 'rtl';
@@ -288,13 +275,11 @@
288 275 *
289 276 * @since 2.04
290 277 *
291 278 * @param array $atts
292 - *
293 - * @return void
294 279 */
295 280 protected function init_include_user_info( $atts ) {
296 - if ( ! empty( $atts['user_info'] ) ) {
281 + if ( isset( $atts['user_info'] ) && $atts['user_info'] ) {
297 282 $this->include_user_info = true;
298 283 }
299 284 }
300 285
@@ -301,13 +286,11 @@
301 286 /**
302 287 * Which fields to skip by default
303 288 *
304 289 * @since 3.0
305 - *
306 - * @return array
307 290 */
308 291 protected function skip_fields() {
309 - return array( 'captcha', 'html', FrmSubmitHelper::FIELD_TYPE );
292 + return array( 'captcha', 'html' );
310 293 }
311 294
312 295 /**
313 296 * Set the include_extras property
@@ -314,13 +297,11 @@
314 297 *
315 298 * @since 3.0
316 299 *
317 300 * @param array $atts
318 - *
319 - * @return void
320 301 */
321 302 protected function init_include_extras( $atts ) {
322 - if ( ! empty( $atts['include_extras'] ) ) {
303 + if ( isset( $atts['include_extras'] ) && $atts['include_extras'] ) {
323 304 $this->include_extras = array_map( 'strtolower', array_map( 'trim', explode( ',', $atts['include_extras'] ) ) );
324 305 }
325 306 }
326 307
@@ -327,10 +308,8 @@
327 308 /**
328 309 * Initialize the single_cell_fields property
329 310 *
330 311 * @since 3.0
331 - *
332 - * @return void
333 312 */
334 313 protected function init_single_cell_fields() {
335 314 $this->single_cell_fields = array( 'html' );
336 315 }
@@ -340,10 +319,8 @@
340 319 *
341 320 * @since 2.04
342 321 *
343 322 * @param array $atts
344 - *
345 - * @return void
346 323 */
347 324 protected function init_table_generator( $atts ) {
348 325 $this->table_generator = new FrmTableHTMLGenerator( 'entry', $atts );
349 326 }
@@ -353,13 +330,11 @@
353 330 *
354 331 * @since 2.04
355 332 *
356 333 * @param array $atts
357 - *
358 - * @return void
359 334 */
360 335 protected function init_is_clickable( $atts ) {
361 - if ( ! empty( $atts['clickable'] ) ) {
336 + if ( isset( $atts['clickable'] ) && $atts['clickable'] ) {
362 337 $this->is_clickable = true;
363 338 }
364 339 }
365 340
@@ -367,12 +342,8 @@
367 342 * Save the passed atts for other calls. Exclude some attributes to prevent
368 343 * interaction with processing field values like time format.
369 344 *
370 345 * @since 3.0
371 - *
372 - * @param array $atts
373 - *
374 - * @return void
375 346 */
376 347 protected function init_atts( $atts ) {
377 348 $atts['source'] = 'entry_formatter';
378 349 $atts['wpautop'] = false;
@@ -377,10 +348,9 @@
377 348 $atts['source'] = 'entry_formatter';
378 349 $atts['wpautop'] = false;
379 350 $atts['return_array'] = true;
380 351
381 - $unset = array( 'id', 'form_id', 'format' );
382 -
352 + $unset = array( 'id', 'entry', 'form_id', 'format' );
383 353 foreach ( $unset as $param ) {
384 354 if ( isset( $atts[ $param ] ) ) {
385 355 unset( $atts[ $param ] );
386 356 }
@@ -385,10 +355,9 @@
385 355 unset( $atts[ $param ] );
386 356 }
387 357 }
388 358
389 - $this->atts = $atts;
390 - $this->atts['entry'] = $this->entry;
359 + $this->atts = $atts;
391 360 }
392 361
393 362 /**
394 363 * Get the field key or ID, depending on array_key property
@@ -396,12 +365,12 @@
396 365 * @since 2.05
397 366 *
398 367 * @param FrmFieldValue $field_value
399 368 *
400 - * @return int|string
369 + * @return string|int
401 370 */
402 371 protected function get_key_or_id( $field_value ) {
403 - return $this->array_key === 'key' ? $field_value->get_field_key() : $field_value->get_field_id();
372 + return $this->array_key == 'key' ? $field_value->get_field_key() : $field_value->get_field_id();
404 373 }
405 374
406 375 /**
407 376 * Package and return the formatted entry values
@@ -478,13 +447,12 @@
478 447 *
479 448 * @since 2.05
480 449 *
481 450 * @param string $content
482 - *
483 - * @return void
484 451 */
485 452 protected function add_field_values_to_content( &$content ) {
486 - foreach ( $this->entry_values->get_field_values() as $field_value ) {
453 + foreach ( $this->entry_values->get_field_values() as $field_id => $field_value ) {
454 +
487 455 /**
488 456 * @var FrmFieldValue $field_value
489 457 */
490 458 $field_value->prepare_displayed_value( $this->atts );
@@ -529,10 +497,8 @@
529 497 * @since 2.04
530 498 *
531 499 * @param array $field_values
532 500 * @param array $output
533 - *
534 - * @return void
535 501 */
536 502 protected function push_field_values_to_array( $field_values, &$output ) {
537 503 foreach ( $field_values as $field_value ) {
538 504 /**
@@ -548,18 +514,18 @@
548 514 *
549 515 * @since 2.04
550 516 *
551 517 * @param FrmFieldValue $field_value
552 - * @param array $output
553 - *
554 - * @return void
518 + * @param array $output
555 519 */
556 520 protected function push_single_field_to_array( $field_value, &$output ) {
557 521 if ( $this->include_field_in_content( $field_value ) ) {
558 - $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
522 +
523 + $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
524 +
559 525 $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
560 - $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
561 526
527 + $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
562 528 if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
563 529 $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
564 530 }
565 531 }
@@ -570,17 +536,15 @@
570 536 *
571 537 * @since 2.04
572 538 *
573 539 * @param string $label
574 - * @param mixed $display_value
540 + * @param mixed $display_value
575 541 * @param string $content
576 - *
577 - * @return void
578 542 */
579 543 protected function add_plain_text_row( $label, $display_value, &$content ) {
580 544 $display_value = $this->prepare_display_value_for_plain_text_content( $display_value );
581 545
582 - if ( 'rtl' === $this->direction ) {
546 + if ( 'rtl' == $this->direction ) {
583 547 $content .= wp_kses_post( $display_value . ' :' . $label ) . "\r\n";
584 548 } else {
585 549 $content .= wp_kses_post( $label . ': ' . $display_value ) . "\r\n";
586 550 }
@@ -591,11 +555,9 @@
591 555 *
592 556 * @since 2.04
593 557 *
594 558 * @param FrmFieldValue $field_value
595 - * @param string $content
596 - *
597 - * @return void
559 + * @param string $content
598 560 */
599 561 protected function add_field_value_to_content( $field_value, &$content ) {
600 562 if ( $this->is_extra_field( $field_value ) ) {
601 563 $this->add_row_for_extra_field( $field_value, $content );
@@ -610,11 +572,9 @@
610 572 *
611 573 * @since 3.0
612 574 *
613 575 * @param FrmFieldValue $field_value
614 - * @param string $content
615 - *
616 - * @return void
576 + * @param string $content
617 577 */
618 578 protected function add_row_for_extra_field( $field_value, &$content ) {
619 579 if ( ! $this->include_field_in_content( $field_value ) ) {
620 580 return;
@@ -632,11 +592,9 @@
632 592 *
633 593 * @since 3.0
634 594 *
635 595 * @param FrmFieldValue $field_value
636 - * @param string $content
637 - *
638 - * @return void
596 + * @param string $content
639 597 */
640 598 protected function add_row_for_standard_field( $field_value, &$content ) {
641 599 if ( ! $this->include_field_in_content( $field_value ) ) {
642 600 return;
@@ -655,16 +613,14 @@
655 613 *
656 614 * @since 3.0
657 615 *
658 616 * @param FrmFieldValue $field_value
659 - * @param string $content
660 - *
661 - * @return void
617 + * @param string $content
662 618 */
663 619 protected function add_html_row_for_included_extra( $field_value, &$content ) {
664 620 $this->prepare_html_display_value_for_extra_fields( $field_value, $display_value );
665 621
666 - if ( in_array( $field_value->get_field_type(), $this->single_cell_fields, true ) ) {
622 + if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
667 623 $this->add_single_cell_html_row( $display_value, $content );
668 624 } else {
669 625 $value_args = $this->package_value_args( $field_value );
670 626 $this->add_html_row( $value_args, $content );
@@ -676,16 +632,14 @@
676 632 *
677 633 * @since 3.0
678 634 *
679 635 * @param FrmFieldValue $field_value
680 - * @param string $content
681 - *
682 - * @return void
636 + * @param string $content
683 637 */
684 638 protected function add_plain_text_row_for_included_extra( $field_value, &$content ) {
685 639 $this->prepare_plain_text_display_value_for_extra_fields( $field_value, $display_value );
686 640
687 - if ( in_array( $field_value->get_field_type(), $this->single_cell_fields, true ) ) {
641 + if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
688 642 $this->add_single_value_plain_text_row( $display_value, $content );
689 643 } else {
690 644 $this->add_plain_text_row( $field_value->get_field_label(), $display_value, $content );
691 645 }
@@ -697,10 +651,8 @@
697 651 * @since 3.0
698 652 *
699 653 * @param string $display_value
700 654 * @param string $content
701 - *
702 - * @return void
703 655 */
704 656 protected function add_single_cell_html_row( $display_value, &$content ) {
705 657 // TODO: maybe move to FrmFieldValue
706 658 $display_value = $this->prepare_display_value_for_html_table( $display_value );
@@ -714,10 +666,8 @@
714 666 * @since 3.0
715 667 *
716 668 * @param string $display_value
717 669 * @param string $content
718 - *
719 - * @return void
720 670 */
721 671 protected function add_single_value_plain_text_row( $display_value, &$content ) {
722 672 $content .= $this->prepare_display_value_for_plain_text_content( $display_value );
723 673 }
@@ -727,11 +677,9 @@
727 677 *
728 678 * @since 3.0
729 679 *
730 680 * @param FrmFieldValue $field_value
731 - * @param mixed $display_value
732 - *
733 - * @return void
681 + * @param mixed $display_value
734 682 */
735 683 protected function prepare_html_display_value_for_extra_fields( $field_value, &$display_value ) {
736 684 $display_value = $field_value->get_displayed_value();
737 685 }
@@ -741,11 +689,9 @@
741 689 *
742 690 * @since 3.0
743 691 *
744 692 * @param FrmFieldValue $field_value
745 - * @param mixed $display_value
746 - *
747 - * @return void
693 + * @param mixed $display_value
748 694 */
749 695 protected function prepare_plain_text_display_value_for_extra_fields( $field_value, &$display_value ) {
750 696 $display_value = $field_value->get_displayed_value() . "\r\n";
751 697 }
@@ -755,11 +701,9 @@
755 701 *
756 702 * @since 2.04
757 703 *
758 704 * @param FrmFieldValue $field_value
759 - * @param string $content
760 - *
761 - * @return void
705 + * @param string $content
762 706 */
763 707 protected function add_standard_row( $field_value, &$content ) {
764 708 if ( $this->format === 'plain_text_block' ) {
765 709 $this->add_plain_text_row( $field_value->get_field_label(), $field_value->get_displayed_value(), $content );
@@ -791,14 +735,14 @@
791 735 *
792 736 * @since 2.04
793 737 *
794 738 * @param string $content
795 - *
796 - * @return void
797 739 */
798 740 protected function add_user_info_to_html_table( &$content ) {
799 741 if ( $this->include_user_info ) {
742 +
800 743 foreach ( $this->entry_values->get_user_info() as $user_info ) {
744 +
801 745 $value_args = array(
802 746 'label' => $user_info['label'],
803 747 'value' => $user_info['value'],
804 748 'field_type' => 'none',
@@ -814,13 +758,12 @@
814 758 *
815 759 * @since 2.04
816 760 *
817 761 * @param string $content
818 - *
819 - * @return void
820 762 */
821 763 protected function add_user_info_to_plain_text_content( &$content ) {
822 764 if ( $this->include_user_info ) {
765 +
823 766 foreach ( $this->entry_values->get_user_info() as $user_info ) {
824 767 $this->add_plain_text_row( $user_info['label'], $user_info['value'], $content );
825 768 }
826 769 }
@@ -856,9 +799,9 @@
856 799 *
857 800 * @return bool
858 801 */
859 802 protected function is_extra_field( $field_value ) {
860 - return in_array( $field_value->get_field_type(), $this->skip_fields(), true );
803 + return in_array( $field_value->get_field_type(), $this->skip_fields() );
861 804 }
862 805
863 806 /**
864 807 * Check if an extra field is included
@@ -869,9 +812,9 @@
869 812 *
870 813 * @return bool
871 814 */
872 815 protected function is_extra_field_included( $field_value ) {
873 - return in_array( $field_value->get_field_type(), $this->include_extras, true );
816 + return in_array( $field_value->get_field_type(), $this->include_extras );
874 817 }
875 818
876 819 /**
877 820 * Add a row in an HTML table
@@ -877,9 +820,9 @@
877 820 * Add a row in an HTML table
878 821 *
879 822 * @since 2.04
880 823 *
881 - * @param array $value_args
824 + * @param array $value_args
882 825 * $value_args = [
883 826 * 'label' => (string) The label. Required
884 827 * 'value' => (mixed) The value to add. Required
885 828 * 'field_type' => (string) The field type. Blank string if not a field.
@@ -884,19 +827,13 @@
884 827 * 'value' => (mixed) The value to add. Required
885 828 * 'field_type' => (string) The field type. Blank string if not a field.
886 829 * ]
887 830 * @param string $content
888 - *
889 - * @return void
890 831 */
891 832 protected function add_html_row( $value_args, &$content ) {
892 833 $display_value = $this->prepare_display_value_for_html_table( $value_args['value'], $value_args['field_type'] );
893 834
894 - $content .= $this->table_generator->generate_two_cell_table_row(
895 - $value_args['label'],
896 - $display_value,
897 - array( 'field_type' => $value_args['field_type'] )
898 - );
835 + $content .= $this->table_generator->generate_two_cell_table_row( $value_args['label'], $display_value );
899 836 }
900 837
901 838 /**
902 839 * Prepare the displayed value for an array
@@ -915,9 +852,9 @@
915 852 * Prepare a field's display value for an HTML table
916 853 *
917 854 * @since 2.04
918 855 *
919 - * @param mixed $display_value
856 + * @param mixed $display_value
920 857 * @param string $field_type
921 858 *
922 859 * @return mixed|string
923 860 */
@@ -922,9 +859,8 @@
922 859 * @return mixed|string
923 860 */
924 861 protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) {
925 862 $display_value = $this->flatten_array( $display_value );
926 -
927 863 if ( ! isset( $this->atts['line_breaks'] ) || ! empty( $this->atts['line_breaks'] ) ) {
928 864 $display_value = str_replace( array( "\r\n", "\n" ), '<br/>', $display_value );
929 865 }
930 866
@@ -937,13 +873,15 @@
937 873 * @since 2.04
938 874 *
939 875 * @param mixed $display_value
940 876 *
941 - * @return int|string
877 + * @return string|int
942 878 */
943 879 protected function prepare_display_value_for_plain_text_content( $display_value ) {
944 880 $display_value = $this->flatten_array( $display_value );
945 - return $this->strip_html( $display_value );
881 + $display_value = $this->strip_html( $display_value );
882 +
883 + return $display_value;
946 884 }
947 885
948 886 /**
949 887 * Flatten an array
@@ -949,15 +887,15 @@
949 887 * Flatten an array
950 888 *
951 889 * @since 2.04
952 890 *
953 - * @param array|int|string $value
891 + * @param array|string|int $value
954 892 *
955 - * @return int|string
893 + * @return string|int
956 894 */
957 895 protected function flatten_array( $value ) {
958 896 if ( is_array( $value ) ) {
959 - $separator = $this->atts['array_separator'] ?? ', ';
897 + $separator = isset( $this->atts['array_separator'] ) ? $this->atts['array_separator'] : ', ';
960 898 $value = implode( $separator, $value );
961 899 }
962 900
963 901 return $value;
@@ -972,19 +910,20 @@
972 910 *
973 911 * @return mixed
974 912 */
975 913 protected function strip_html( $value ) {
914 +
976 915 if ( $this->is_plain_text ) {
916 +
977 917 if ( is_array( $value ) ) {
978 918 foreach ( $value as $key => $single_value ) {
979 919 $value[ $key ] = $this->strip_html( $single_value );
980 920 }
981 921 } elseif ( $this->is_plain_text && ! is_array( $value ) ) {
982 - if ( str_contains( $value, '<img' ) ) {
922 + if ( strpos( $value, '<img' ) !== false ) {
983 923 $value = str_replace( array( '<img', 'src=', '/>', '"' ), '', $value );
984 924 $value = trim( $value );
985 925 }
986 -
987 926 $value = strip_tags( $value );
988 927 }
989 928 }
990 929