Escapes a single value for a specific export format.
Description
See also
Parameters
- $value
-
(mixed) (Required) Value to escape.
- $export_format
-
(string) (Required) Export format identifier. May be 'xls', 'csv', 'json', 'xml' or 'html'.
Return
(mixed) Escaped value, usually a string.
Source
File: src/db-objects/elements/element-types/element-type.php
protected function escape_single_value_for_export( $value, $export_format ) { switch ( $export_format ) { case 'xls': case 'csv': if ( is_array( $value ) && is_string( $value[ key( $value ) ] ) ) { $value = implode( ', ', $value ); } if ( is_string( $value ) ) { if ( 'csv' === $export_format ) { // Replace CSV delimiter. $value = str_replace( ';', ',', $value ); } // Add paragraphs if there are linebreaks. if ( false !== strpos( $value, "\n" ) ) { $value = wpautop( $value ); } } break; case 'json': break; case 'xml': case 'html': if ( is_array( $value ) && is_string( $value[ key( $value ) ] ) ) { $value = implode( ', ', $value ); } $value = esc_html( $value ); } return $value; }
Changelog
Version | Description |
---|---|
1.0.0 | Introduced. |