PluginProbe
Stream – Activity Log & Audit Trail / 3.10.0
Stream – Activity Log & Audit Trail v3.10.0
4.4.0 4.3.0 4.2.2 4.2.1 trunk 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1 3.1.1 3.10.0 3.2.0 3.2.1 3.2.2 3.2.3 All 50 releases
stream / exporters / class-exporter-csv.php

class-exporter-csv.php in Stream – Activity Log & Audit Trail 3.10.0, at exporters/class-exporter-csv.php

52 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * CSV Exporter
4 *
5 * @package WP_Stream
6 */
7
8 namespace WP_Stream;
9
10 /**
11 * Class - Exporter_CSV
12 */
13 class Exporter_CSV extends Exporter {
14 /**
15 * Exporter name
16 *
17 * @var string
18 */
19 public $name = 'CSV';
20
21 /**
22 * Exporter slug
23 *
24 * @var string
25 */
26 public $slug = 'csv';
27
28 /**
29 * Outputs CSV data for download
30 *
31 * @param array $data Array of data to output.
32 * @param array $columns Column names included in data set.
33 * @return void
34 */
35 public function output_file( $data, $columns ) {
36 if ( ! defined( 'WP_STREAM_TESTS' ) || ( defined( 'WP_STREAM_TESTS' ) && ! WP_STREAM_TESTS ) ) {
37 header( 'Content-type: text/csv' );
38 header( 'Content-Disposition: attachment; filename="stream.csv"' );
39 }
40
41 $output = join( ',', array_values( $columns ) ) . "\n";
42 foreach ( $data as $row ) {
43 $output .= join( ',', $row ) . "\n";
44 }
45
46 echo $output; // @codingStandardsIgnoreLine text-only output
47 if ( ! defined( 'WP_STREAM_TESTS' ) || ( defined( 'WP_STREAM_TESTS' ) && ! WP_STREAM_TESTS ) ) {
48 exit;
49 }
50 }
51 }
52