PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 5.0
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v5.0
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 +75 -171 6.275.0 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,36 +177,26 @@
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 -
205 - /**
206 - * Allows modifying the format property of FrmEntryFormatter object.
207 - *
208 - * @since 5.0.16
209 - *
210 - * @param string $format The format.
211 - * @param array $args Includes `atts`, `entry`.
212 - */
213 - $this->format = apply_filters(
214 - 'frm_entry_formatter_format',
215 - $this->format,
216 - array(
217 - 'atts' => $atts,
218 - 'entry' => $this->entry,
219 - )
220 - );
221 199 }
222 200
223 201 /**
224 202 * Set the array_key property that sets whether the keys in the
@@ -226,13 +204,11 @@
226 204 *
227 205 * @since 2.05
228 206 *
229 207 * @param array $atts
230 - *
231 - * @return void
232 208 */
233 209 protected function init_array_key( $atts ) {
234 - if ( isset( $atts['array_key'] ) && $atts['array_key'] === 'id' ) {
210 + if ( isset( $atts['array_key'] ) && $atts['array_key'] == 'id' ) {
235 211 $this->array_key = 'id';
236 212 }
237 213 }
238 214
@@ -241,13 +217,11 @@
241 217 *
242 218 * @since 2.04
243 219 *
244 220 * @param array $atts
245 - *
246 - * @return void
247 221 */
248 222 protected function init_is_plain_text( $atts ) {
249 - if ( ! empty( $atts['plain_text'] ) ) {
223 + if ( isset( $atts['plain_text'] ) && $atts['plain_text'] ) {
250 224 $this->is_plain_text = true;
251 225 } elseif ( $atts['format'] !== 'text' ) {
252 226 $this->is_plain_text = true;
253 227 }
@@ -258,13 +232,11 @@
258 232 *
259 233 * @since 2.04
260 234 *
261 235 * @param array $atts
262 - *
263 - * @return void
264 236 */
265 237 protected function init_include_blank( $atts ) {
266 - if ( ! empty( $atts['include_blank'] ) ) {
238 + if ( isset( $atts['include_blank'] ) && $atts['include_blank'] ) {
267 239 $this->include_blank = true;
268 240 }
269 241 }
270 242
@@ -273,10 +245,8 @@
273 245 *
274 246 * @since 2.04
275 247 *
276 248 * @param array $atts
277 - *
278 - * @return void
279 249 */
280 250 protected function init_direction( $atts ) {
281 251 if ( isset( $atts['direction'] ) && $atts['direction'] === 'rtl' ) {
282 252 $this->direction = 'rtl';
@@ -288,13 +258,11 @@
288 258 *
289 259 * @since 2.04
290 260 *
291 261 * @param array $atts
292 - *
293 - * @return void
294 262 */
295 263 protected function init_include_user_info( $atts ) {
296 - if ( ! empty( $atts['user_info'] ) ) {
264 + if ( isset( $atts['user_info'] ) && $atts['user_info'] ) {
297 265 $this->include_user_info = true;
298 266 }
299 267 }
300 268
@@ -301,13 +269,11 @@
301 269 /**
302 270 * Which fields to skip by default
303 271 *
304 272 * @since 3.0
305 - *
306 - * @return array
307 273 */
308 274 protected function skip_fields() {
309 - return array( 'captcha', 'html', FrmSubmitHelper::FIELD_TYPE );
275 + return array( 'captcha', 'html' );
310 276 }
311 277
312 278 /**
313 279 * Set the include_extras property
@@ -314,13 +280,11 @@
314 280 *
315 281 * @since 3.0
316 282 *
317 283 * @param array $atts
318 - *
319 - * @return void
320 284 */
321 285 protected function init_include_extras( $atts ) {
322 - if ( ! empty( $atts['include_extras'] ) ) {
286 + if ( isset( $atts['include_extras'] ) && $atts['include_extras'] ) {
323 287 $this->include_extras = array_map( 'strtolower', array_map( 'trim', explode( ',', $atts['include_extras'] ) ) );
324 288 }
325 289 }
326 290
@@ -327,10 +291,8 @@
327 291 /**
328 292 * Initialize the single_cell_fields property
329 293 *
330 294 * @since 3.0
331 - *
332 - * @return void
333 295 */
334 296 protected function init_single_cell_fields() {
335 297 $this->single_cell_fields = array( 'html' );
336 298 }
@@ -340,10 +302,8 @@
340 302 *
341 303 * @since 2.04
342 304 *
343 305 * @param array $atts
344 - *
345 - * @return void
346 306 */
347 307 protected function init_table_generator( $atts ) {
348 308 $this->table_generator = new FrmTableHTMLGenerator( 'entry', $atts );
349 309 }
@@ -353,13 +313,11 @@
353 313 *
354 314 * @since 2.04
355 315 *
356 316 * @param array $atts
357 - *
358 - * @return void
359 317 */
360 318 protected function init_is_clickable( $atts ) {
361 - if ( ! empty( $atts['clickable'] ) ) {
319 + if ( isset( $atts['clickable'] ) && $atts['clickable'] ) {
362 320 $this->is_clickable = true;
363 321 }
364 322 }
365 323
@@ -367,12 +325,8 @@
367 325 * Save the passed atts for other calls. Exclude some attributes to prevent
368 326 * interaction with processing field values like time format.
369 327 *
370 328 * @since 3.0
371 - *
372 - * @param array $atts
373 - *
374 - * @return void
375 329 */
376 330 protected function init_atts( $atts ) {
377 331 $atts['source'] = 'entry_formatter';
378 332 $atts['wpautop'] = false;
@@ -377,10 +331,9 @@
377 331 $atts['source'] = 'entry_formatter';
378 332 $atts['wpautop'] = false;
379 333 $atts['return_array'] = true;
380 334
381 - $unset = array( 'id', 'form_id', 'format' );
382 -
335 + $unset = array( 'id', 'entry', 'form_id', 'format' );
383 336 foreach ( $unset as $param ) {
384 337 if ( isset( $atts[ $param ] ) ) {
385 338 unset( $atts[ $param ] );
386 339 }
@@ -385,10 +338,9 @@
385 338 unset( $atts[ $param ] );
386 339 }
387 340 }
388 341
389 - $this->atts = $atts;
390 - $this->atts['entry'] = $this->entry;
342 + $this->atts = $atts;
391 343 }
392 344
393 345 /**
394 346 * Get the field key or ID, depending on array_key property
@@ -396,12 +348,12 @@
396 348 * @since 2.05
397 349 *
398 350 * @param FrmFieldValue $field_value
399 351 *
400 - * @return int|string
352 + * @return string|int
401 353 */
402 354 protected function get_key_or_id( $field_value ) {
403 - return $this->array_key === 'key' ? $field_value->get_field_key() : $field_value->get_field_id();
355 + return $this->array_key == 'key' ? $field_value->get_field_key() : $field_value->get_field_id();
404 356 }
405 357
406 358 /**
407 359 * Package and return the formatted entry values
@@ -430,26 +382,9 @@
430 382 } else {
431 383 $content = '';
432 384 }
433 385
434 - /**
435 - * Allows modifying the formatted entry values content.
436 - *
437 - * @since 5.0.16
438 - *
439 - * @param string $content The formatted entry values content.
440 - * @param array $args Includes `entry`, `atts`, `format`, `entry_values`.
441 - */
442 - return apply_filters(
443 - 'frm_formatted_entry_values_content',
444 - $content,
445 - array(
446 - 'entry' => $this->entry,
447 - 'atts' => $this->atts,
448 - 'format' => $this->format,
449 - 'entry_values' => $this->entry_values,
450 - )
451 - );
386 + return $content;
452 387 }
453 388
454 389 /**
455 390 * Return the formatted HTML table with entry values
@@ -478,13 +413,12 @@
478 413 *
479 414 * @since 2.05
480 415 *
481 416 * @param string $content
482 - *
483 - * @return void
484 417 */
485 418 protected function add_field_values_to_content( &$content ) {
486 - foreach ( $this->entry_values->get_field_values() as $field_value ) {
419 + foreach ( $this->entry_values->get_field_values() as $field_id => $field_value ) {
420 +
487 421 /**
488 422 * @var FrmFieldValue $field_value
489 423 */
490 424 $field_value->prepare_displayed_value( $this->atts );
@@ -529,10 +463,8 @@
529 463 * @since 2.04
530 464 *
531 465 * @param array $field_values
532 466 * @param array $output
533 - *
534 - * @return void
535 467 */
536 468 protected function push_field_values_to_array( $field_values, &$output ) {
537 469 foreach ( $field_values as $field_value ) {
538 470 /**
@@ -548,18 +480,18 @@
548 480 *
549 481 * @since 2.04
550 482 *
551 483 * @param FrmFieldValue $field_value
552 - * @param array $output
553 - *
554 - * @return void
484 + * @param array $output
555 485 */
556 486 protected function push_single_field_to_array( $field_value, &$output ) {
557 487 if ( $this->include_field_in_content( $field_value ) ) {
558 - $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
488 +
489 + $displayed_value = $this->prepare_display_value_for_array( $field_value->get_displayed_value() );
490 +
559 491 $output[ $this->get_key_or_id( $field_value ) ] = $displayed_value;
560 - $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
561 492
493 + $has_separate_value = (bool) $field_value->get_field_option( 'separate_value' );
562 494 if ( $has_separate_value || $displayed_value !== $field_value->get_saved_value() ) {
563 495 $output[ $this->get_key_or_id( $field_value ) . '-value' ] = $field_value->get_saved_value();
564 496 }
565 497 }
@@ -570,17 +502,15 @@
570 502 *
571 503 * @since 2.04
572 504 *
573 505 * @param string $label
574 - * @param mixed $display_value
506 + * @param mixed $display_value
575 507 * @param string $content
576 - *
577 - * @return void
578 508 */
579 509 protected function add_plain_text_row( $label, $display_value, &$content ) {
580 510 $display_value = $this->prepare_display_value_for_plain_text_content( $display_value );
581 511
582 - if ( 'rtl' === $this->direction ) {
512 + if ( 'rtl' == $this->direction ) {
583 513 $content .= wp_kses_post( $display_value . ' :' . $label ) . "\r\n";
584 514 } else {
585 515 $content .= wp_kses_post( $label . ': ' . $display_value ) . "\r\n";
586 516 }
@@ -591,11 +521,9 @@
591 521 *
592 522 * @since 2.04
593 523 *
594 524 * @param FrmFieldValue $field_value
595 - * @param string $content
596 - *
597 - * @return void
525 + * @param string $content
598 526 */
599 527 protected function add_field_value_to_content( $field_value, &$content ) {
600 528 if ( $this->is_extra_field( $field_value ) ) {
601 529 $this->add_row_for_extra_field( $field_value, $content );
@@ -610,11 +538,9 @@
610 538 *
611 539 * @since 3.0
612 540 *
613 541 * @param FrmFieldValue $field_value
614 - * @param string $content
615 - *
616 - * @return void
542 + * @param string $content
617 543 */
618 544 protected function add_row_for_extra_field( $field_value, &$content ) {
619 545 if ( ! $this->include_field_in_content( $field_value ) ) {
620 546 return;
@@ -632,11 +558,9 @@
632 558 *
633 559 * @since 3.0
634 560 *
635 561 * @param FrmFieldValue $field_value
636 - * @param string $content
637 - *
638 - * @return void
562 + * @param string $content
639 563 */
640 564 protected function add_row_for_standard_field( $field_value, &$content ) {
641 565 if ( ! $this->include_field_in_content( $field_value ) ) {
642 566 return;
@@ -655,16 +579,14 @@
655 579 *
656 580 * @since 3.0
657 581 *
658 582 * @param FrmFieldValue $field_value
659 - * @param string $content
660 - *
661 - * @return void
583 + * @param string $content
662 584 */
663 585 protected function add_html_row_for_included_extra( $field_value, &$content ) {
664 586 $this->prepare_html_display_value_for_extra_fields( $field_value, $display_value );
665 587
666 - if ( in_array( $field_value->get_field_type(), $this->single_cell_fields, true ) ) {
588 + if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
667 589 $this->add_single_cell_html_row( $display_value, $content );
668 590 } else {
669 591 $value_args = $this->package_value_args( $field_value );
670 592 $this->add_html_row( $value_args, $content );
@@ -676,16 +598,14 @@
676 598 *
677 599 * @since 3.0
678 600 *
679 601 * @param FrmFieldValue $field_value
680 - * @param string $content
681 - *
682 - * @return void
602 + * @param string $content
683 603 */
684 604 protected function add_plain_text_row_for_included_extra( $field_value, &$content ) {
685 605 $this->prepare_plain_text_display_value_for_extra_fields( $field_value, $display_value );
686 606
687 - if ( in_array( $field_value->get_field_type(), $this->single_cell_fields, true ) ) {
607 + if ( in_array( $field_value->get_field_type(), $this->single_cell_fields ) ) {
688 608 $this->add_single_value_plain_text_row( $display_value, $content );
689 609 } else {
690 610 $this->add_plain_text_row( $field_value->get_field_label(), $display_value, $content );
691 611 }
@@ -697,10 +617,8 @@
697 617 * @since 3.0
698 618 *
699 619 * @param string $display_value
700 620 * @param string $content
701 - *
702 - * @return void
703 621 */
704 622 protected function add_single_cell_html_row( $display_value, &$content ) {
705 623 // TODO: maybe move to FrmFieldValue
706 624 $display_value = $this->prepare_display_value_for_html_table( $display_value );
@@ -714,10 +632,8 @@
714 632 * @since 3.0
715 633 *
716 634 * @param string $display_value
717 635 * @param string $content
718 - *
719 - * @return void
720 636 */
721 637 protected function add_single_value_plain_text_row( $display_value, &$content ) {
722 638 $content .= $this->prepare_display_value_for_plain_text_content( $display_value );
723 639 }
@@ -727,11 +643,9 @@
727 643 *
728 644 * @since 3.0
729 645 *
730 646 * @param FrmFieldValue $field_value
731 - * @param mixed $display_value
732 - *
733 - * @return void
647 + * @param mixed $display_value
734 648 */
735 649 protected function prepare_html_display_value_for_extra_fields( $field_value, &$display_value ) {
736 650 $display_value = $field_value->get_displayed_value();
737 651 }
@@ -741,11 +655,9 @@
741 655 *
742 656 * @since 3.0
743 657 *
744 658 * @param FrmFieldValue $field_value
745 - * @param mixed $display_value
746 - *
747 - * @return void
659 + * @param mixed $display_value
748 660 */
749 661 protected function prepare_plain_text_display_value_for_extra_fields( $field_value, &$display_value ) {
750 662 $display_value = $field_value->get_displayed_value() . "\r\n";
751 663 }
@@ -754,12 +666,10 @@
754 666 * Add a standard row to plain text or html table content
755 667 *
756 668 * @since 2.04
757 669 *
758 - * @param FrmFieldValue $field_value
759 - * @param string $content
760 - *
761 - * @return void
670 + * @param FrmProFieldValue $field_value
671 + * @param string $content
762 672 */
763 673 protected function add_standard_row( $field_value, &$content ) {
764 674 if ( $this->format === 'plain_text_block' ) {
765 675 $this->add_plain_text_row( $field_value->get_field_label(), $field_value->get_displayed_value(), $content );
@@ -791,14 +701,14 @@
791 701 *
792 702 * @since 2.04
793 703 *
794 704 * @param string $content
795 - *
796 - * @return void
797 705 */
798 706 protected function add_user_info_to_html_table( &$content ) {
799 707 if ( $this->include_user_info ) {
708 +
800 709 foreach ( $this->entry_values->get_user_info() as $user_info ) {
710 +
801 711 $value_args = array(
802 712 'label' => $user_info['label'],
803 713 'value' => $user_info['value'],
804 714 'field_type' => 'none',
@@ -814,13 +724,12 @@
814 724 *
815 725 * @since 2.04
816 726 *
817 727 * @param string $content
818 - *
819 - * @return void
820 728 */
821 729 protected function add_user_info_to_plain_text_content( &$content ) {
822 730 if ( $this->include_user_info ) {
731 +
823 732 foreach ( $this->entry_values->get_user_info() as $user_info ) {
824 733 $this->add_plain_text_row( $user_info['label'], $user_info['value'], $content );
825 734 }
826 735 }
@@ -856,9 +765,9 @@
856 765 *
857 766 * @return bool
858 767 */
859 768 protected function is_extra_field( $field_value ) {
860 - return in_array( $field_value->get_field_type(), $this->skip_fields(), true );
769 + return in_array( $field_value->get_field_type(), $this->skip_fields() );
861 770 }
862 771
863 772 /**
864 773 * Check if an extra field is included
@@ -869,9 +778,9 @@
869 778 *
870 779 * @return bool
871 780 */
872 781 protected function is_extra_field_included( $field_value ) {
873 - return in_array( $field_value->get_field_type(), $this->include_extras, true );
782 + return in_array( $field_value->get_field_type(), $this->include_extras );
874 783 }
875 784
876 785 /**
877 786 * Add a row in an HTML table
@@ -877,9 +786,9 @@
877 786 * Add a row in an HTML table
878 787 *
879 788 * @since 2.04
880 789 *
881 - * @param array $value_args
790 + * @param array $value_args
882 791 * $value_args = [
883 792 * 'label' => (string) The label. Required
884 793 * 'value' => (mixed) The value to add. Required
885 794 * 'field_type' => (string) The field type. Blank string if not a field.
@@ -884,19 +793,13 @@
884 793 * 'value' => (mixed) The value to add. Required
885 794 * 'field_type' => (string) The field type. Blank string if not a field.
886 795 * ]
887 796 * @param string $content
888 - *
889 - * @return void
890 797 */
891 798 protected function add_html_row( $value_args, &$content ) {
892 799 $display_value = $this->prepare_display_value_for_html_table( $value_args['value'], $value_args['field_type'] );
893 800
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 - );
801 + $content .= $this->table_generator->generate_two_cell_table_row( $value_args['label'], $display_value );
899 802 }
900 803
901 804 /**
902 805 * Prepare the displayed value for an array
@@ -915,9 +818,9 @@
915 818 * Prepare a field's display value for an HTML table
916 819 *
917 820 * @since 2.04
918 821 *
919 - * @param mixed $display_value
822 + * @param mixed $display_value
920 823 * @param string $field_type
921 824 *
922 825 * @return mixed|string
923 826 */
@@ -922,9 +825,8 @@
922 825 * @return mixed|string
923 826 */
924 827 protected function prepare_display_value_for_html_table( $display_value, $field_type = '' ) {
925 828 $display_value = $this->flatten_array( $display_value );
926 -
927 829 if ( ! isset( $this->atts['line_breaks'] ) || ! empty( $this->atts['line_breaks'] ) ) {
928 830 $display_value = str_replace( array( "\r\n", "\n" ), '<br/>', $display_value );
929 831 }
930 832
@@ -937,13 +839,15 @@
937 839 * @since 2.04
938 840 *
939 841 * @param mixed $display_value
940 842 *
941 - * @return int|string
843 + * @return string|int
942 844 */
943 845 protected function prepare_display_value_for_plain_text_content( $display_value ) {
944 846 $display_value = $this->flatten_array( $display_value );
945 - return $this->strip_html( $display_value );
847 + $display_value = $this->strip_html( $display_value );
848 +
849 + return $display_value;
946 850 }
947 851
948 852 /**
949 853 * Flatten an array
@@ -949,16 +853,15 @@
949 853 * Flatten an array
950 854 *
951 855 * @since 2.04
952 856 *
953 - * @param array|int|string $value
857 + * @param array|string|int $value
954 858 *
955 - * @return int|string
859 + * @return string|int
956 860 */
957 861 protected function flatten_array( $value ) {
958 862 if ( is_array( $value ) ) {
959 - $separator = $this->atts['array_separator'] ?? ', ';
960 - $value = implode( $separator, $value );
863 + $value = implode( ', ', $value );
961 864 }
962 865
963 866 return $value;
964 867 }
@@ -972,19 +875,20 @@
972 875 *
973 876 * @return mixed
974 877 */
975 878 protected function strip_html( $value ) {
879 +
976 880 if ( $this->is_plain_text ) {
881 +
977 882 if ( is_array( $value ) ) {
978 883 foreach ( $value as $key => $single_value ) {
979 884 $value[ $key ] = $this->strip_html( $single_value );
980 885 }
981 886 } elseif ( $this->is_plain_text && ! is_array( $value ) ) {
982 - if ( str_contains( $value, '<img' ) ) {
887 + if ( strpos( $value, '<img' ) !== false ) {
983 888 $value = str_replace( array( '<img', 'src=', '/>', '"' ), '', $value );
984 889 $value = trim( $value );
985 890 }
986 -
987 891 $value = strip_tags( $value );
988 892 }
989 893 }
990 894