PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.22
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.22
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/helpers/FrmCSVExportHelper.php +62 -159 6.286.22 View file →
@@ -113,19 +113,19 @@
113 113 // Do not add the UTF-8 with BOM option if this function is called on Global Settings.
114 114 // This is to improve compatibility with the Export View as CSV add-on (v1.10).
115 115 // Otherwise, the option will appear twice since it is added in the add-on as well.
116 116 $on_global_settings_page = 'formidable-settings' === FrmAppHelper::get_param( 'page' );
117 -
118 117 if ( ! $on_global_settings_page ) {
119 118 array_splice( $formats, 1, 0, 'UTF-8 with BOM' );
120 119 }
121 120
122 - return apply_filters( 'frm_csv_format_options', $formats );
121 + $formats = apply_filters( 'frm_csv_format_options', $formats );
122 +
123 + return $formats;
123 124 }
124 125
125 126 /**
126 127 * @param array $atts
127 - *
128 128 * @return false|string|null returns a string file path or false if $atts['mode'] is set to 'file'.
129 129 */
130 130 public static function generate_csv( $atts ) {
131 131 global $frm_vars;
@@ -144,9 +144,8 @@
144 144
145 145 if ( 'file' === self::$mode ) {
146 146 $filepath = get_temp_dir() . $filename;
147 147 self::$fp = @fopen( $filepath, 'w' );
148 -
149 148 if ( ! self::$fp ) {
150 149 return false;
151 150 }
152 151 } elseif ( 'echo' === self::$mode ) {
@@ -154,9 +153,9 @@
154 153 }
155 154
156 155 unset( $filename );
157 156
158 - self::$comment_count = FrmDb::get_count(
157 + $comment_count = FrmDb::get_count(
159 158 'frm_item_metas',
160 159 array(
161 160 'item_id' => $atts['entry_ids'],
162 161 'field_id' => 0,
@@ -167,8 +166,9 @@
167 166 'order_by' => 'count(*) DESC',
168 167 'limit' => 1,
169 168 )
170 169 );
170 + self::$comment_count = $comment_count;
171 171
172 172 self::prepare_csv_headings();
173 173
174 174 /**
@@ -202,9 +202,8 @@
202 202 /**
203 203 * @since 6.8.4
204 204 *
205 205 * @param array $atts
206 - *
207 206 * @return void
208 207 */
209 208 private static function after_generate_csv( $atts ) {
210 209 /**
@@ -210,9 +209,8 @@
210 209 /**
211 210 * @since 6.8.4
212 211 *
213 212 * @param array $atts {
214 - *
215 213 * @type object $form
216 214 * @type array $entry_ids
217 215 * @type array $form_cols
218 216 * }
@@ -223,9 +221,8 @@
223 221 /**
224 222 * @since 5.0.16
225 223 *
226 224 * @param stdClass $form
227 - *
228 225 * @return string
229 226 */
230 227 private static function generate_csv_filename( $form ) {
231 228 $filename = gmdate( 'ymdHis', time() ) . '_' . sanitize_title_with_dashes( $form->name ) . '_formidable_entries.csv';
@@ -243,11 +240,8 @@
243 240 'meta' => self::$meta,
244 241 );
245 242 }
246 243
247 - /**
248 - * @return void
249 - */
250 244 private static function set_class_parameters() {
251 245 $args = self::get_standard_filter_args();
252 246 self::$separator = apply_filters( 'frm_csv_sep', self::$separator, $args );
253 247 self::$line_break = apply_filters( 'frm_csv_line_break', self::$line_break, $args );
@@ -254,28 +248,17 @@
254 248 self::$wp_date_format = apply_filters( 'frm_csv_date_format', self::$wp_date_format, $args );
255 249 self::get_csv_format();
256 250 self::$charset = get_option( 'blog_charset' );
257 251
258 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
259 - $col_sep = ! empty( $_POST['csv_col_sep'] ) ? sanitize_text_field( wp_unslash( $_POST['csv_col_sep'] ) ) : self::$column_separator;
252 + $col_sep = ! empty( $_POST['csv_col_sep'] ) ? sanitize_text_field( wp_unslash( $_POST['csv_col_sep'] ) ) : self::$column_separator; // phpcs:ignore WordPress.Security.NonceVerification.Missing
260 253
261 254 self::$column_separator = apply_filters( 'frm_csv_column_sep', $col_sep, $args );
262 255 }
263 256
264 - /**
265 - * @param object $form
266 - *
267 - * @return void
268 - */
269 257 private static function set_has_parent_id( $form ) {
270 258 self::$has_parent_id = $form->parent_form_id > 0;
271 259 }
272 260
273 - /**
274 - * @param string $filename
275 - *
276 - * @return void
277 - */
278 261 private static function print_file_headers( $filename ) {
279 262 header( 'Content-Description: File Transfer' );
280 263 header( 'Content-Disposition: attachment; filename="' . esc_attr( $filename ) . '"' );
281 264 header( 'Content-Type: text/csv; charset=' . self::$charset, true );
@@ -313,11 +296,8 @@
313 296 $csv_format = apply_filters( 'frm_csv_format', $csv_format, self::get_standard_filter_args() );
314 297 self::$to_encoding = $csv_format;
315 298 }
316 299
317 - /**
318 - * @return void
319 - */
320 300 private static function prepare_csv_headings() {
321 301 $headings = array();
322 302 self::csv_headings( $headings );
323 303 $headings = apply_filters(
@@ -333,16 +313,10 @@
333 313
334 314 self::print_csv_row( $headings );
335 315 }
336 316
337 - /**
338 - * @param object $col
339 - *
340 - * @return array
341 - */
342 317 private static function field_headings( $col ) {
343 318 $field_type_obj = FrmFieldFactory::get_field_factory( $col );
344 -
345 319 if ( ! empty( $field_type_obj->is_combo_field ) ) {
346 320 // This is combo field.
347 321 return $field_type_obj->get_export_headings();
348 322 }
@@ -348,20 +322,14 @@
348 322 }
349 323
350 324 $field_headings = array();
351 325 $separate_values = array( 'user_id', 'file', 'data', 'date' );
352 -
353 326 if ( ! empty( $col->field_options['separate_value'] ) && ! in_array( $col->type, $separate_values, true ) ) {
354 327 $field_headings[ $col->id . '_label' ] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) );
355 328 }
356 329
357 - if ( ! empty( $field_headings[ $col->id . '_label' ] ) ) {
358 - $field_headings[ $col->id ] = strip_tags( $col->name . ' ' . __( '(value)', 'formidable' ) );
359 - } else {
360 - $field_headings[ $col->id ] = strip_tags( $col->name );
361 - }
362 -
363 - return apply_filters(
330 + $field_headings[ $col->id ] = strip_tags( $col->name );
331 + $field_headings = apply_filters(
364 332 'frm_csv_field_columns',
365 333 $field_headings,
366 334 array_merge(
367 335 self::get_standard_filter_args(),
@@ -367,16 +335,13 @@
367 335 self::get_standard_filter_args(),
368 336 array( 'field' => $col )
369 337 )
370 338 );
339 +
340 + return $field_headings;
371 341 }
372 342
373 - /**
374 - * @param array $headings
375 - *
376 - * @return void
377 - */
378 - private static function csv_headings( &$headings ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
343 + private static function csv_headings( &$headings ) {
379 344 $fields_by_repeater_id = array();
380 345 $repeater_ids = array();
381 346
382 347 foreach ( self::$fields as $col ) {
@@ -415,26 +380,24 @@
415 380 }
416 381 unset( $start, $end, $length, $row, $repeater_meta, $where );
417 382
418 383 $flat = array();
419 -
420 384 foreach ( $headings as $key => $heading ) {
421 - if ( ! is_array( $heading ) ) {
422 - $flat[ $key ] = $heading;
423 - continue;
424 - }
385 + if ( is_array( $heading ) ) {
386 + $repeater_id = str_replace( 'repeater', '', $key );
425 387
426 - $repeater_id = str_replace( 'repeater', '', $key );
427 - $repeater_headings = array();
388 + $repeater_headings = array();
389 + foreach ( $fields_by_repeater_id[ $repeater_id ] as $col ) {
390 + $repeater_headings += self::field_headings( $col );
391 + }
428 392
429 - foreach ( $fields_by_repeater_id[ $repeater_id ] as $col ) {
430 - $repeater_headings += self::field_headings( $col );
431 - }
432 -
433 - for ( $i = 0; $i < $max[ $repeater_id ]; $i++ ) {
434 - foreach ( $repeater_headings as $repeater_key => $repeater_name ) {
435 - $flat[ $repeater_key . '[' . $i . ']' ] = $repeater_name;
393 + for ( $i = 0; $i < $max[ $repeater_id ]; $i++ ) {
394 + foreach ( $repeater_headings as $repeater_key => $repeater_name ) {
395 + $flat[ $repeater_key . '[' . $i . ']' ] = $repeater_name;
396 + }
436 397 }
398 + } else {
399 + $flat[ $key ] = $heading;
437 400 }
438 401 }
439 402
440 403 self::$fields_by_repeater_id = $fields_by_repeater_id;
@@ -461,9 +424,8 @@
461 424 $headings['is_draft'] = __( 'Entry Status', 'formidable' );
462 425 $headings['ip'] = __( 'IP', 'formidable' );
463 426 $headings['id'] = __( 'ID', 'formidable' );
464 427 $headings['item_key'] = __( 'Key', 'formidable' );
465 -
466 428 if ( self::has_parent_id() ) {
467 429 $headings['parent_id'] = __( 'Parent ID', 'formidable' );
468 430 }
469 431
@@ -471,9 +433,8 @@
471 433 }
472 434
473 435 /**
474 436 * @param object $field
475 - *
476 437 * @return bool
477 438 */
478 439 private static function is_the_child_of_a_repeater( $field ) {
479 440 if ( $field->form_id === self::$form_id || empty( $field->field_options['in_section'] ) ) {
@@ -482,26 +443,22 @@
482 443
483 444 $section_id = $field->field_options['in_section'];
484 445 $section = FrmField::getOne( $section_id );
485 446
486 - return $section && FrmField::is_repeating_field( $section );
447 + if ( ! $section ) {
448 + return false;
449 + }
450 +
451 + return FrmField::is_repeating_field( $section );
487 452 }
488 453
489 - /**
490 - * @return bool
491 - */
492 454 private static function has_parent_id() {
493 455 return self::$has_parent_id;
494 456 }
495 457
496 - /**
497 - * @param array $next_set
498 - *
499 - * @return void
500 - */
501 458 private static function prepare_next_csv_rows( $next_set ) {
502 459 if ( FrmAppHelper::pro_is_installed() ) {
503 - $where = array(
460 + $where = array(
504 461 'or' => 1,
505 462 'id' => $next_set,
506 463 'parent_item_id' => $next_set,
507 464 );
@@ -508,9 +465,9 @@
508 465 // Order by parent_item_id so children will be first.
509 466 $order_by = ' ORDER BY parent_item_id DESC';
510 467 } else {
511 468 // When Pro is not installed, only query for direct ID matches only as we do not expect parent item id
512 - // Matches and the more simplified query is faster.
469 + // matches and the more simplified query is faster.
513 470 $where = array(
514 471 'id' => $next_set,
515 472 );
516 473 $order_by = '';
@@ -529,11 +486,8 @@
529 486 }
530 487 }
531 488 }
532 489
533 - /**
534 - * @return void
535 - */
536 490 private static function prepare_csv_row() {
537 491 $row = array();
538 492 self::add_field_values_to_csv( $row );
539 493 self::add_entry_data_to_csv( $row );
@@ -549,20 +503,15 @@
549 503 );
550 504 self::print_csv_row( $row );
551 505 }
552 506
553 - /**
554 - * @param array $entries
555 - *
556 - * @return void
557 - */
558 507 private static function add_repeat_field_values_to_csv( &$entries ) {
559 508 if ( isset( self::$entry->metas ) ) {
560 - // Add child entries to the parent
509 + // add child entries to the parent
561 510 foreach ( self::$entry->metas as $meta_id => $meta_value ) {
562 511 if ( ! is_numeric( $meta_id ) || '' === $meta_value ) {
563 - // If the hook is being used to include field keys in the metas array,
564 - // We need to skip the keys and only process field ids
512 + // if the hook is being used to include field keys in the metas array,
513 + // we need to skip the keys and only process field ids
565 514 continue;
566 515 }
567 516
568 517 if ( ! isset( $entries[ self::$entry->parent_item_id ] ) ) {
@@ -572,10 +521,10 @@
572 521
573 522 if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) {
574 523 $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = array();
575 524 } elseif ( ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] ) ) {
576 - // If the data is here, it should be an array but if this field has collected data
577 - // Both while inside and outside of the repeating section, it's possible this is a string.
525 + // if the data is here, it should be an array but if this field has collected data
526 + // both while inside and outside of the repeating section, it's possible this is a string.
578 527 $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ] = (array) $entries[ self::$entry->parent_item_id ]->metas[ $meta_id ];
579 528 }
580 529
581 530 // Add the repeated values.
@@ -585,13 +534,12 @@
585 534 self::$entry->metas = self::fill_missing_repeater_metas( self::$entry->metas, $entries );
586 535 $entries[ self::$entry->parent_item_id ]->metas += self::$entry->metas;
587 536 }//end if
588 537
589 - // Add the embedded form id
538 + // add the embedded form id
590 539 if ( ! isset( $entries[ self::$entry->parent_item_id ]->embedded_fields ) ) {
591 540 $entries[ self::$entry->parent_item_id ]->embedded_fields = array();
592 541 }
593 -
594 542 $entries[ self::$entry->parent_item_id ]->embedded_fields[ self::$entry->id ] = self::$entry->form_id;
595 543 }
596 544
597 545 /**
@@ -599,14 +547,14 @@
599 547 * The export needs all of the meta to be filled in, so we put blank strings for every missing repeater child
600 548 *
601 549 * @param array $metas
602 550 * @param array $entries
603 - *
604 551 * @return array
605 552 */
606 553 private static function fill_missing_repeater_metas( $metas, &$entries ) {
607 - $field_id = array_key_last( $metas );
608 - $field = self::get_field( $field_id );
554 + $field_ids = array_keys( $metas );
555 + $field_id = end( $field_ids );
556 + $field = self::get_field( $field_id );
609 557
610 558 if ( ! $field || empty( $field->field_options['in_section'] ) ) {
611 559 return $metas;
612 560 }
@@ -611,9 +559,8 @@
611 559 return $metas;
612 560 }
613 561
614 562 $repeater_id = $field->field_options['in_section'];
615 -
616 563 if ( ! isset( self::$fields_by_repeater_id[ $repeater_id ] ) ) {
617 564 return $metas;
618 565 }
619 566
@@ -620,9 +567,9 @@
620 567 foreach ( self::$fields_by_repeater_id[ $repeater_id ] as $repeater_child ) {
621 568 if ( ! isset( $metas[ $repeater_child->id ] ) ) {
622 569 $metas[ $repeater_child->id ] = '';
623 570
624 - if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ] ) || ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ] ) ) { // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
571 + if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ] ) || ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ] ) ) {
625 572 $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ] = array();
626 573 }
627 574
628 575 $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ][] = '';
@@ -631,33 +578,21 @@
631 578
632 579 return $metas;
633 580 }
634 581
635 - /**
636 - * @param int|string $field_id
637 - *
638 - * @return false|object
639 - */
640 582 private static function get_field( $field_id ) {
641 583 $field_id = (int) $field_id;
642 -
643 584 foreach ( self::$fields as $field ) {
644 585 if ( $field_id === (int) $field->id ) {
645 586 return $field;
646 587 }
647 588 }
648 -
649 589 return false;
650 590 }
651 591
652 - /**
653 - * @param array $row
654 - *
655 - * @return void
656 - */
657 592 private static function add_field_values_to_csv( &$row ) {
658 593 foreach ( self::$fields as $col ) {
659 - $field_value = self::$entry->metas[ $col->id ] ?? false;
594 + $field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false;
660 595
661 596 FrmFieldsHelper::prepare_field_value( $field_value, $col->type );
662 597 self::add_array_values_to_columns( $row, compact( 'col', 'field_value' ) );
663 598
@@ -673,9 +608,8 @@
673 608 );
674 609
675 610 if ( ! empty( $col->field_options['separate_value'] ) ) {
676 611 $label_key = $col->id . '_label';
677 -
678 612 if ( self::is_the_child_of_a_repeater( $col ) ) {
679 613 $row[ $label_key ] = array();
680 614
681 615 if ( is_array( $field_value ) ) {
@@ -699,9 +633,8 @@
699 633 * @since 5.0.06
700 634 *
701 635 * @param mixed $field_value
702 636 * @param stdClass $field
703 - *
704 637 * @return string
705 638 */
706 639 private static function get_separate_value_label( $field_value, $field ) {
707 640 return FrmEntriesHelper::display_value(
@@ -712,9 +645,9 @@
712 645 'post_id' => self::$entry->post_id,
713 646 'show_icon' => false,
714 647 'entry_id' => self::$entry->id,
715 648 'sep' => self::$separator,
716 - 'embedded_field_id' => isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[ self::$entry->id ] ) ? 'form' . self::$entry->embedded_fields[ self::$entry->id ] : 0, // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
649 + 'embedded_field_id' => isset( self::$entry->embedded_fields ) && isset( self::$entry->embedded_fields[ self::$entry->id ] ) ? 'form' . self::$entry->embedded_fields[ self::$entry->id ] : 0,
717 650 )
718 651 );
719 652 }
720 653
@@ -719,46 +652,32 @@
719 652 }
720 653
721 654 /**
722 655 * @since 2.0.23
723 - *
724 - * @param array $row
725 - * @param array $atts
726 - *
727 - * @return void
728 656 */
729 657 private static function add_array_values_to_columns( &$row, $atts ) {
730 - if ( ! is_array( $atts['field_value'] ) ) {
731 - return;
732 - }
658 + if ( is_array( $atts['field_value'] ) ) {
659 + foreach ( $atts['field_value'] as $key => $sub_value ) {
660 + if ( is_array( $sub_value ) ) {
661 + // This is combo field inside repeater. The heading key has this format: [86_first[0]].
662 + foreach ( $sub_value as $sub_key => $sub_sub_value ) {
663 + $column_key = $atts['col']->id . '_' . $sub_key . '[' . $key . ']';
664 + if ( ! is_numeric( $sub_key ) && isset( self::$headings[ $column_key ] ) ) {
665 + $row[ $column_key ] = $sub_sub_value;
666 + }
667 + }
733 668
734 - foreach ( $atts['field_value'] as $key => $sub_value ) {
735 - if ( is_array( $sub_value ) ) {
736 - // This is combo field inside repeater. The heading key has this format: [86_first[0]].
737 - foreach ( $sub_value as $sub_key => $sub_sub_value ) {
738 - $column_key = $atts['col']->id . '_' . $sub_key . '[' . $key . ']';
669 + continue;
670 + }
739 671
740 - if ( ! is_numeric( $sub_key ) && isset( self::$headings[ $column_key ] ) ) {
741 - $row[ $column_key ] = $sub_sub_value;
742 - }
672 + $column_key = $atts['col']->id . '_' . $key;
673 + if ( ! is_numeric( $key ) && isset( self::$headings[ $column_key ] ) ) {
674 + $row[ $column_key ] = $sub_value;
743 675 }
744 -
745 - continue;
746 676 }
747 -
748 - $column_key = $atts['col']->id . '_' . $key;
749 -
750 - if ( ! is_numeric( $key ) && isset( self::$headings[ $column_key ] ) ) {
751 - $row[ $column_key ] = $sub_value;
752 - }
753 677 }
754 678 }
755 679
756 - /**
757 - * @param array $row
758 - *
759 - * @return void
760 - */
761 680 private static function add_entry_data_to_csv( &$row ) {
762 681 $row['created_at'] = FrmAppHelper::get_formatted_time( self::$entry->created_at, self::$wp_date_format, ' ' );
763 682 $row['updated_at'] = FrmAppHelper::get_formatted_time( self::$entry->updated_at, self::$wp_date_format, ' ' );
764 683 $row['user_id'] = self::$entry->user_id;
@@ -766,19 +685,13 @@
766 685 $row['is_draft'] = self::$entry->is_draft;
767 686 $row['ip'] = self::$entry->ip;
768 687 $row['id'] = self::$entry->id;
769 688 $row['item_key'] = self::$entry->item_key;
770 -
771 689 if ( self::has_parent_id() ) {
772 690 $row['parent_id'] = self::$entry->parent_item_id;
773 691 }
774 692 }
775 693
776 - /**
777 - * @param array $rows
778 - *
779 - * @return void
780 - */
781 694 private static function print_csv_row( $rows ) {
782 695 $sep = '';
783 696 $echo = 'echo' === self::$mode;
784 697
@@ -786,9 +699,8 @@
786 699 if ( isset( $rows[ $k ] ) ) {
787 700 $row = $rows[ $k ];
788 701 } else {
789 702 $row = '';
790 -
791 703 // array indexed data is not at $rows[ $k ]
792 704 if ( $k[ strlen( $k ) - 1 ] === ']' ) {
793 705 $start = strrpos( $k, '[' );
794 706 $key = substr( $k, 0, $start++ );
@@ -802,14 +714,13 @@
802 714 }
803 715 }
804 716
805 717 if ( is_array( $row ) ) {
806 - // Implode the repeated field values
718 + // implode the repeated field values
807 719 $row = implode( self::$separator, FrmAppHelper::array_flatten( $row, 'reset' ) );
808 720 }
809 721
810 722 $val = self::encode_value( $row );
811 -
812 723 if ( 'return' !== self::$line_break ) {
813 724 $val = str_replace( array( "\r\n", "\r", "\n" ), self::$line_break, $val );
814 725 }
815 726
@@ -817,14 +728,12 @@
817 728 echo $sep . '"' . $val . '"'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
818 729 } else {
819 730 fwrite( self::$fp, $sep . '"' . $val . '"' );
820 731 }
821 -
822 732 $sep = self::$column_separator;
823 733
824 734 unset( $k, $row );
825 735 }//end foreach
826 -
827 736 if ( $echo ) {
828 737 echo "\n";
829 738 } else {
830 739 fwrite( self::$fp, "\n" );
@@ -830,13 +739,8 @@
830 739 fwrite( self::$fp, "\n" );
831 740 }
832 741 }
833 742
834 - /**
835 - * @param string $line
836 - *
837 - * @return string
838 - */
839 743 public static function encode_value( $line ) {
840 744 if ( '' === $line ) {
841 745 return $line;
842 746 }
@@ -844,12 +748,12 @@
844 748 $convmap = false;
845 749
846 750 switch ( self::$to_encoding ) {
847 751 case 'macintosh':
848 - // This map was derived from the differences between the MacRoman and UTF-8 Charsets
752 + // this map was derived from the differences between the MacRoman and UTF-8 Charsets
849 753 // Reference:
850 754 // http://www.alanwood.net/demos/macroman.html.
851 - $convmap = array( 256, 304, 0, 0xffff, 306, 337, 0, 0xffff, 340, 375, 0, 0xffff, 377, 401, 0, 0xffff, 403, 709, 0, 0xffff, 712, 727, 0, 0xffff, 734, 936, 0, 0xffff, 938, 959, 0, 0xffff, 961, 8210, 0, 0xffff, 8213, 8215, 0, 0xffff, 8219, 8219, 0, 0xffff, 8227, 8229, 0, 0xffff, 8231, 8239, 0, 0xffff, 8241, 8248, 0, 0xffff, 8251, 8259, 0, 0xffff, 8261, 8363, 0, 0xffff, 8365, 8481, 0, 0xffff, 8483, 8705, 0, 0xffff, 8707, 8709, 0, 0xffff, 8711, 8718, 0, 0xffff, 8720, 8720, 0, 0xffff, 8722, 8729, 0, 0xffff, 8731, 8733, 0, 0xffff, 8735, 8746, 0, 0xffff, 8748, 8775, 0, 0xffff, 8777, 8799, 0, 0xffff, 8801, 8803, 0, 0xffff, 8806, 9673, 0, 0xffff, 9675, 63742, 0, 0xffff, 63744, 64256, 0, 0xffff ); // phpcs:ignore SlevomatCodingStandard.Files.LineLength.LineTooLong
755 + $convmap = array( 256, 304, 0, 0xffff, 306, 337, 0, 0xffff, 340, 375, 0, 0xffff, 377, 401, 0, 0xffff, 403, 709, 0, 0xffff, 712, 727, 0, 0xffff, 734, 936, 0, 0xffff, 938, 959, 0, 0xffff, 961, 8210, 0, 0xffff, 8213, 8215, 0, 0xffff, 8219, 8219, 0, 0xffff, 8227, 8229, 0, 0xffff, 8231, 8239, 0, 0xffff, 8241, 8248, 0, 0xffff, 8251, 8259, 0, 0xffff, 8261, 8363, 0, 0xffff, 8365, 8481, 0, 0xffff, 8483, 8705, 0, 0xffff, 8707, 8709, 0, 0xffff, 8711, 8718, 0, 0xffff, 8720, 8720, 0, 0xffff, 8722, 8729, 0, 0xffff, 8731, 8733, 0, 0xffff, 8735, 8746, 0, 0xffff, 8748, 8775, 0, 0xffff, 8777, 8799, 0, 0xffff, 8801, 8803, 0, 0xffff, 8806, 9673, 0, 0xffff, 9675, 63742, 0, 0xffff, 63744, 64256, 0, 0xffff );
852 756 break;
853 757 case 'ISO-8859-1':
854 758 $convmap = array( 256, 10000, 0, 0xffff );
855 759 }
@@ -868,11 +772,9 @@
868 772 /**
869 773 * Escape a " in a csv with another "
870 774 *
871 775 * @since 2.0
872 - *
873 776 * @param mixed $value
874 - *
875 777 * @return mixed
876 778 */
877 779 public static function escape_csv( $value ) {
878 780 if ( ! is_string( $value ) ) {
@@ -882,8 +784,9 @@
882 784 if ( '=' === $value[0] ) {
883 785 // escape the = to prevent vulnerability
884 786 $value = "'" . $value;
885 787 }
788 + $value = str_replace( '"', '""', $value );
886 789
887 - return str_replace( '"', '""', $value );
790 + return $value;
888 791 }
889 792 }