PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.14.1
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.14.1
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 +33 -192 6.27 → 6.14.1 View file →
@@ -89,43 +89,17 @@
89 89 * @var array
90 90 */
91 91 protected static $meta = array();
92 92
93 - /**
94 - * Whether to include the BOM (Byte Order Mark) in the CSV file.
95 - * Only applicable for UTF-8 exports.
96 - *
97 - * @since 6.17
98 - *
99 - * @var bool
100 - */
101 - private static $include_bom = false;
102 -
103 - /**
104 - * Get all options for the CSV export format dropdown.
105 - *
106 - * @since 6.17 The UTF-8 with BOM option was added.
107 - *
108 - * @return array
109 - */
110 93 public static function csv_format_options() {
111 94 $formats = array( 'UTF-8', 'ISO-8859-1', 'windows-1256', 'windows-1251', 'macintosh' );
95 + $formats = apply_filters( 'frm_csv_format_options', $formats );
112 96
113 - // Do not add the UTF-8 with BOM option if this function is called on Global Settings.
114 - // This is to improve compatibility with the Export View as CSV add-on (v1.10).
115 - // Otherwise, the option will appear twice since it is added in the add-on as well.
116 - $on_global_settings_page = 'formidable-settings' === FrmAppHelper::get_param( 'page' );
117 -
118 - if ( ! $on_global_settings_page ) {
119 - array_splice( $formats, 1, 0, 'UTF-8 with BOM' );
120 - }
121 -
122 - return apply_filters( 'frm_csv_format_options', $formats );
97 + return $formats;
123 98 }
124 99
125 100 /**
126 101 * @param array $atts
127 - *
128 102 * @return false|string|null returns a string file path or false if $atts['mode'] is set to 'file'.
129 103 */
130 104 public static function generate_csv( $atts ) {
131 105 global $frm_vars;
@@ -144,9 +118,8 @@
144 118
145 119 if ( 'file' === self::$mode ) {
146 120 $filepath = get_temp_dir() . $filename;
147 121 self::$fp = @fopen( $filepath, 'w' );
148 -
149 122 if ( ! self::$fp ) {
150 123 return false;
151 124 }
152 125 } elseif ( 'echo' === self::$mode ) {
@@ -159,9 +132,9 @@
159 132 'frm_item_metas',
160 133 array(
161 134 'item_id' => $atts['entry_ids'],
162 135 'field_id' => 0,
163 - 'meta_value like' => 's:7:"comment";',
136 + 'meta_value like' => '{',
164 137 ),
165 138 array(
166 139 'group_by' => 'item_id',
167 140 'order_by' => 'count(*) DESC',
@@ -171,21 +144,10 @@
171 144 self::$comment_count = $comment_count;
172 145
173 146 self::prepare_csv_headings();
174 147
175 - /**
176 - * For a target form with 50k entries (Locations List, with 7 fields), batch sizes of 100
177 - * were significantly faster and used less memory, so a filter was added.
178 - *
179 - * @since 6.17
180 - *
181 - * @param int $batch_size
182 - * @param int $form_id
183 - */
184 - $csv_export_batch_size = (int) apply_filters( 'frm_csv_export_batch_size', 20, self::$form_id );
185 -
186 - // Fetch posts in batches rather than loading the entire table into memory.
187 - while ( $next_set = array_splice( $atts['entry_ids'], 0, $csv_export_batch_size ) ) {
148 + // fetch 20 posts at a time rather than loading the entire table into memory
149 + while ( $next_set = array_splice( $atts['entry_ids'], 0, 20 ) ) {
188 150 self::prepare_next_csv_rows( $next_set );
189 151 }
190 152
191 153 self::after_generate_csv( $atts );
@@ -203,9 +165,8 @@
203 165 /**
204 166 * @since 6.8.4
205 167 *
206 168 * @param array $atts
207 - *
208 169 * @return void
209 170 */
210 171 private static function after_generate_csv( $atts ) {
211 172 /**
@@ -211,9 +172,8 @@
211 172 /**
212 173 * @since 6.8.4
213 174 *
214 175 * @param array $atts {
215 - *
216 176 * @type object $form
217 177 * @type array $entry_ids
218 178 * @type array $form_cols
219 179 * }
@@ -224,9 +184,8 @@
224 184 /**
225 185 * @since 5.0.16
226 186 *
227 187 * @param stdClass $form
228 - *
229 188 * @return string
230 189 */
231 190 private static function generate_csv_filename( $form ) {
232 191 $filename = gmdate( 'ymdHis', time() ) . '_' . sanitize_title_with_dashes( $form->name ) . '_formidable_entries.csv';
@@ -244,11 +203,8 @@
244 203 'meta' => self::$meta,
245 204 );
246 205 }
247 206
248 - /**
249 - * @return void
250 - */
251 207 private static function set_class_parameters() {
252 208 $args = self::get_standard_filter_args();
253 209 self::$separator = apply_filters( 'frm_csv_sep', self::$separator, $args );
254 210 self::$line_break = apply_filters( 'frm_csv_line_break', self::$line_break, $args );
@@ -255,28 +211,17 @@
255 211 self::$wp_date_format = apply_filters( 'frm_csv_date_format', self::$wp_date_format, $args );
256 212 self::get_csv_format();
257 213 self::$charset = get_option( 'blog_charset' );
258 214
259 - // phpcs:ignore WordPress.Security.NonceVerification.Missing
260 - $col_sep = ! empty( $_POST['csv_col_sep'] ) ? sanitize_text_field( wp_unslash( $_POST['csv_col_sep'] ) ) : self::$column_separator;
215 + $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
261 216
262 217 self::$column_separator = apply_filters( 'frm_csv_column_sep', $col_sep, $args );
263 218 }
264 219
265 - /**
266 - * @param object $form
267 - *
268 - * @return void
269 - */
270 220 private static function set_has_parent_id( $form ) {
271 221 self::$has_parent_id = $form->parent_form_id > 0;
272 222 }
273 223
274 - /**
275 - * @param string $filename
276 - *
277 - * @return void
278 - */
279 224 private static function print_file_headers( $filename ) {
280 225 header( 'Content-Description: File Transfer' );
281 226 header( 'Content-Disposition: attachment; filename="' . esc_attr( $filename ) . '"' );
282 227 header( 'Content-Type: text/csv; charset=' . self::$charset, true );
@@ -284,12 +229,8 @@
284 229 header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' );
285 230 header( 'Cache-Control: no-cache, must-revalidate' );
286 231 header( 'Pragma: no-cache' );
287 232
288 - if ( self::$include_bom ) {
289 - echo esc_html( chr( 239 ) . chr( 187 ) . chr( 191 ) );
290 - }
291 -
292 233 do_action(
293 234 'frm_csv_headers',
294 235 array(
295 236 'form_id' => self::$form_id,
@@ -297,28 +238,14 @@
297 238 )
298 239 );
299 240 }
300 241
301 - /**
302 - * Check the POST request data for the CSV format to use.
303 - *
304 - * @return void
305 - */
306 242 public static function get_csv_format() {
307 - $csv_format = FrmAppHelper::get_post_param( 'csv_format', 'UTF-8', 'sanitize_text_field' );
308 -
309 - if ( 'UTF-8 with BOM' === $csv_format ) {
310 - self::$include_bom = true;
311 - $csv_format = 'UTF-8';
312 - }
313 -
243 + $csv_format = FrmAppHelper::get_post_param( 'csv_format', 'UTF-8', 'sanitize_text_field' );
314 244 $csv_format = apply_filters( 'frm_csv_format', $csv_format, self::get_standard_filter_args() );
315 245 self::$to_encoding = $csv_format;
316 246 }
317 247
318 - /**
319 - * @return void
320 - */
321 248 private static function prepare_csv_headings() {
322 249 $headings = array();
323 250 self::csv_headings( $headings );
324 251 $headings = apply_filters(
@@ -334,16 +261,10 @@
334 261
335 262 self::print_csv_row( $headings );
336 263 }
337 264
338 - /**
339 - * @param object $col
340 - *
341 - * @return array
342 - */
343 265 private static function field_headings( $col ) {
344 266 $field_type_obj = FrmFieldFactory::get_field_factory( $col );
345 -
346 267 if ( ! empty( $field_type_obj->is_combo_field ) ) {
347 268 // This is combo field.
348 269 return $field_type_obj->get_export_headings();
349 270 }
@@ -349,20 +270,14 @@
349 270 }
350 271
351 272 $field_headings = array();
352 273 $separate_values = array( 'user_id', 'file', 'data', 'date' );
353 -
354 274 if ( ! empty( $col->field_options['separate_value'] ) && ! in_array( $col->type, $separate_values, true ) ) {
355 275 $field_headings[ $col->id . '_label' ] = strip_tags( $col->name . ' ' . __( '(label)', 'formidable' ) );
356 276 }
357 277
358 - if ( ! empty( $field_headings[ $col->id . '_label' ] ) ) {
359 - $field_headings[ $col->id ] = strip_tags( $col->name . ' ' . __( '(value)', 'formidable' ) );
360 - } else {
361 - $field_headings[ $col->id ] = strip_tags( $col->name );
362 - }
363 -
364 - return apply_filters(
278 + $field_headings[ $col->id ] = strip_tags( $col->name );
279 + $field_headings = apply_filters(
365 280 'frm_csv_field_columns',
366 281 $field_headings,
367 282 array_merge(
368 283 self::get_standard_filter_args(),
@@ -368,16 +283,13 @@
368 283 self::get_standard_filter_args(),
369 284 array( 'field' => $col )
370 285 )
371 286 );
287 +
288 + return $field_headings;
372 289 }
373 290
374 - /**
375 - * @param array $headings
376 - *
377 - * @return void
378 - */
379 - private static function csv_headings( &$headings ) { // phpcs:ignore SlevomatCodingStandard.Complexity.Cognitive.ComplexityTooHigh
291 + private static function csv_headings( &$headings ) {
380 292 $fields_by_repeater_id = array();
381 293 $repeater_ids = array();
382 294
383 295 foreach ( self::$fields as $col ) {
@@ -416,14 +328,13 @@
416 328 }
417 329 unset( $start, $end, $length, $row, $repeater_meta, $where );
418 330
419 331 $flat = array();
420 -
421 332 foreach ( $headings as $key => $heading ) {
422 333 if ( is_array( $heading ) ) {
423 - $repeater_id = str_replace( 'repeater', '', $key );
334 + $repeater_id = str_replace( 'repeater', '', $key );
335 +
424 336 $repeater_headings = array();
425 -
426 337 foreach ( $fields_by_repeater_id[ $repeater_id ] as $col ) {
427 338 $repeater_headings += self::field_headings( $col );
428 339 }
429 340
@@ -461,9 +372,8 @@
461 372 $headings['is_draft'] = __( 'Entry Status', 'formidable' );
462 373 $headings['ip'] = __( 'IP', 'formidable' );
463 374 $headings['id'] = __( 'ID', 'formidable' );
464 375 $headings['item_key'] = __( 'Key', 'formidable' );
465 -
466 376 if ( self::has_parent_id() ) {
467 377 $headings['parent_id'] = __( 'Parent ID', 'formidable' );
468 378 }
469 379
@@ -471,9 +381,8 @@
471 381 }
472 382
473 383 /**
474 384 * @param object $field
475 - *
476 385 * @return bool
477 386 */
478 387 private static function is_the_child_of_a_repeater( $field ) {
479 388 if ( $field->form_id === self::$form_id || empty( $field->field_options['in_section'] ) ) {
@@ -482,43 +391,28 @@
482 391
483 392 $section_id = $field->field_options['in_section'];
484 393 $section = FrmField::getOne( $section_id );
485 394
486 - return $section && FrmField::is_repeating_field( $section );
395 + if ( ! $section ) {
396 + return false;
397 + }
398 +
399 + return FrmField::is_repeating_field( $section );
487 400 }
488 401
489 - /**
490 - * @return bool
491 - */
492 402 private static function has_parent_id() {
493 403 return self::$has_parent_id;
494 404 }
495 405
496 - /**
497 - * @param array $next_set
498 - *
499 - * @return void
500 - */
501 406 private static function prepare_next_csv_rows( $next_set ) {
502 - if ( FrmAppHelper::pro_is_installed() ) {
503 - $where = array(
504 - 'or' => 1,
505 - 'id' => $next_set,
506 - 'parent_item_id' => $next_set,
507 - );
508 - // Order by parent_item_id so children will be first.
509 - $order_by = ' ORDER BY parent_item_id DESC';
510 - } else {
511 - // 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.
513 - $where = array(
514 - 'id' => $next_set,
515 - );
516 - $order_by = '';
517 - }
407 + // order by parent_item_id so children will be first
408 + $where = array(
409 + 'or' => 1,
410 + 'id' => $next_set,
411 + 'parent_item_id' => $next_set,
412 + );
413 + $entries = FrmEntry::getAll( $where, ' ORDER BY parent_item_id DESC', '', true, false );
518 414
519 - $entries = FrmEntry::getAll( $where, $order_by, '', true, false );
520 -
521 415 foreach ( $entries as $entry ) {
522 416 self::$entry = $entry;
523 417 unset( $entry );
524 418
@@ -529,11 +423,8 @@
529 423 }
530 424 }
531 425 }
532 426
533 - /**
534 - * @return void
535 - */
536 427 private static function prepare_csv_row() {
537 428 $row = array();
538 429 self::add_field_values_to_csv( $row );
539 430 self::add_entry_data_to_csv( $row );
@@ -549,13 +440,8 @@
549 440 );
550 441 self::print_csv_row( $row );
551 442 }
552 443
553 - /**
554 - * @param array $entries
555 - *
556 - * @return void
557 - */
558 444 private static function add_repeat_field_values_to_csv( &$entries ) {
559 445 if ( isset( self::$entry->metas ) ) {
560 446 // add child entries to the parent
561 447 foreach ( self::$entry->metas as $meta_id => $meta_value ) {
@@ -589,9 +475,8 @@
589 475 // add the embedded form id
590 476 if ( ! isset( $entries[ self::$entry->parent_item_id ]->embedded_fields ) ) {
591 477 $entries[ self::$entry->parent_item_id ]->embedded_fields = array();
592 478 }
593 -
594 479 $entries[ self::$entry->parent_item_id ]->embedded_fields[ self::$entry->id ] = self::$entry->form_id;
595 480 }
596 481
597 482 /**
@@ -599,9 +484,8 @@
599 484 * The export needs all of the meta to be filled in, so we put blank strings for every missing repeater child
600 485 *
601 486 * @param array $metas
602 487 * @param array $entries
603 - *
604 488 * @return array
605 489 */
606 490 private static function fill_missing_repeater_metas( $metas, &$entries ) {
607 491 $field_ids = array_keys( $metas );
@@ -612,9 +496,8 @@
612 496 return $metas;
613 497 }
614 498
615 499 $repeater_id = $field->field_options['in_section'];
616 -
617 500 if ( ! isset( self::$fields_by_repeater_id[ $repeater_id ] ) ) {
618 501 return $metas;
619 502 }
620 503
@@ -621,9 +504,9 @@
621 504 foreach ( self::$fields_by_repeater_id[ $repeater_id ] as $repeater_child ) {
622 505 if ( ! isset( $metas[ $repeater_child->id ] ) ) {
623 506 $metas[ $repeater_child->id ] = '';
624 507
625 - 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
508 + if ( ! isset( $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ] ) || ! is_array( $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ] ) ) {
626 509 $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ] = array();
627 510 }
628 511
629 512 $entries[ self::$entry->parent_item_id ]->metas[ $repeater_child->id ][] = '';
@@ -632,33 +515,21 @@
632 515
633 516 return $metas;
634 517 }
635 518
636 - /**
637 - * @param int|string $field_id
638 - *
639 - * @return false|object
640 - */
641 519 private static function get_field( $field_id ) {
642 520 $field_id = (int) $field_id;
643 -
644 521 foreach ( self::$fields as $field ) {
645 522 if ( $field_id === (int) $field->id ) {
646 523 return $field;
647 524 }
648 525 }
649 -
650 526 return false;
651 527 }
652 528
653 - /**
654 - * @param array $row
655 - *
656 - * @return void
657 - */
658 529 private static function add_field_values_to_csv( &$row ) {
659 530 foreach ( self::$fields as $col ) {
660 - $field_value = self::$entry->metas[ $col->id ] ?? false;
531 + $field_value = isset( self::$entry->metas[ $col->id ] ) ? self::$entry->metas[ $col->id ] : false;
661 532
662 533 FrmFieldsHelper::prepare_field_value( $field_value, $col->type );
663 534 self::add_array_values_to_columns( $row, compact( 'col', 'field_value' ) );
664 535
@@ -674,9 +545,8 @@
674 545 );
675 546
676 547 if ( ! empty( $col->field_options['separate_value'] ) ) {
677 548 $label_key = $col->id . '_label';
678 -
679 549 if ( self::is_the_child_of_a_repeater( $col ) ) {
680 550 $row[ $label_key ] = array();
681 551
682 552 if ( is_array( $field_value ) ) {
@@ -700,9 +570,8 @@
700 570 * @since 5.0.06
701 571 *
702 572 * @param mixed $field_value
703 573 * @param stdClass $field
704 - *
705 574 * @return string
706 575 */
707 576 private static function get_separate_value_label( $field_value, $field ) {
708 577 return FrmEntriesHelper::display_value(
@@ -713,9 +582,9 @@
713 582 'post_id' => self::$entry->post_id,
714 583 'show_icon' => false,
715 584 'entry_id' => self::$entry->id,
716 585 'sep' => self::$separator,
717 - '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
586 + '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,
718 587 )
719 588 );
720 589 }
721 590
@@ -720,13 +589,8 @@
720 589 }
721 590
722 591 /**
723 592 * @since 2.0.23
724 - *
725 - * @param array $row
726 - * @param array $atts
727 - *
728 - * @return void
729 593 */
730 594 private static function add_array_values_to_columns( &$row, $atts ) {
731 595 if ( is_array( $atts['field_value'] ) ) {
732 596 foreach ( $atts['field_value'] as $key => $sub_value ) {
@@ -733,9 +597,8 @@
733 597 if ( is_array( $sub_value ) ) {
734 598 // This is combo field inside repeater. The heading key has this format: [86_first[0]].
735 599 foreach ( $sub_value as $sub_key => $sub_sub_value ) {
736 600 $column_key = $atts['col']->id . '_' . $sub_key . '[' . $key . ']';
737 -
738 601 if ( ! is_numeric( $sub_key ) && isset( self::$headings[ $column_key ] ) ) {
739 602 $row[ $column_key ] = $sub_sub_value;
740 603 }
741 604 }
@@ -743,21 +606,15 @@
743 606 continue;
744 607 }
745 608
746 609 $column_key = $atts['col']->id . '_' . $key;
747 -
748 610 if ( ! is_numeric( $key ) && isset( self::$headings[ $column_key ] ) ) {
749 611 $row[ $column_key ] = $sub_value;
750 612 }
751 613 }
752 - }//end if
614 + }
753 615 }
754 616
755 - /**
756 - * @param array $row
757 - *
758 - * @return void
759 - */
760 617 private static function add_entry_data_to_csv( &$row ) {
761 618 $row['created_at'] = FrmAppHelper::get_formatted_time( self::$entry->created_at, self::$wp_date_format, ' ' );
762 619 $row['updated_at'] = FrmAppHelper::get_formatted_time( self::$entry->updated_at, self::$wp_date_format, ' ' );
763 620 $row['user_id'] = self::$entry->user_id;
@@ -765,19 +622,13 @@
765 622 $row['is_draft'] = self::$entry->is_draft;
766 623 $row['ip'] = self::$entry->ip;
767 624 $row['id'] = self::$entry->id;
768 625 $row['item_key'] = self::$entry->item_key;
769 -
770 626 if ( self::has_parent_id() ) {
771 627 $row['parent_id'] = self::$entry->parent_item_id;
772 628 }
773 629 }
774 630
775 - /**
776 - * @param array $rows
777 - *
778 - * @return void
779 - */
780 631 private static function print_csv_row( $rows ) {
781 632 $sep = '';
782 633 $echo = 'echo' === self::$mode;
783 634
@@ -785,9 +636,8 @@
785 636 if ( isset( $rows[ $k ] ) ) {
786 637 $row = $rows[ $k ];
787 638 } else {
788 639 $row = '';
789 -
790 640 // array indexed data is not at $rows[ $k ]
791 641 if ( $k[ strlen( $k ) - 1 ] === ']' ) {
792 642 $start = strrpos( $k, '[' );
793 643 $key = substr( $k, 0, $start++ );
@@ -806,9 +656,8 @@
806 656 $row = implode( self::$separator, FrmAppHelper::array_flatten( $row, 'reset' ) );
807 657 }
808 658
809 659 $val = self::encode_value( $row );
810 -
811 660 if ( 'return' !== self::$line_break ) {
812 661 $val = str_replace( array( "\r\n", "\r", "\n" ), self::$line_break, $val );
813 662 }
814 663
@@ -816,14 +665,12 @@
816 665 echo $sep . '"' . $val . '"'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
817 666 } else {
818 667 fwrite( self::$fp, $sep . '"' . $val . '"' );
819 668 }
820 -
821 669 $sep = self::$column_separator;
822 670
823 671 unset( $k, $row );
824 672 }//end foreach
825 -
826 673 if ( $echo ) {
827 674 echo "\n";
828 675 } else {
829 676 fwrite( self::$fp, "\n" );
@@ -829,13 +676,8 @@
829 676 fwrite( self::$fp, "\n" );
830 677 }
831 678 }
832 679
833 - /**
834 - * @param string $line
835 - *
836 - * @return string
837 - */
838 680 public static function encode_value( $line ) {
839 681 if ( '' === $line ) {
840 682 return $line;
841 683 }
@@ -846,9 +688,9 @@
846 688 case 'macintosh':
847 689 // this map was derived from the differences between the MacRoman and UTF-8 Charsets
848 690 // Reference:
849 691 // http://www.alanwood.net/demos/macroman.html.
850 - $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
692 + $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 );
851 693 break;
852 694 case 'ISO-8859-1':
853 695 $convmap = array( 256, 10000, 0, 0xffff );
854 696 }
@@ -867,11 +709,9 @@
867 709 /**
868 710 * Escape a " in a csv with another "
869 711 *
870 712 * @since 2.0
871 - *
872 713 * @param mixed $value
873 - *
874 714 * @return mixed
875 715 */
876 716 public static function escape_csv( $value ) {
877 717 if ( ! is_string( $value ) ) {
@@ -881,8 +721,9 @@
881 721 if ( '=' === $value[0] ) {
882 722 // escape the = to prevent vulnerability
883 723 $value = "'" . $value;
884 724 }
725 + $value = str_replace( '"', '""', $value );
885 726
886 - return str_replace( '"', '""', $value );
727 + return $value;
887 728 }
888 729 }