PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
tablepress / classes / exporters / class-exporter-json.php

class-exporter-json.php in TablePress – Tables in WordPress made easy 3.4, at classes/exporters/class-exporter-json.php

47 lines 1000 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * TablePress JSON Exporter Class
4 *
5 * @package TablePress
6 * @subpackage Export/Import
7 * @author Tobias Bäthge
8 * @since 3.4.0
9 */
10
11 declare(strict_types=1);
12
13 namespace TablePress\Export;
14
15 use TablePress\Export\Exporter_Interface;
16
17 // Prohibit direct script loading.
18 defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
19
20 /**
21 * TablePress JSON Exporter Class
22 *
23 * @package TablePress
24 * @subpackage Export/Import
25 * @since 3.4.0
26 */
27 class JSON_Exporter implements Exporter_Interface {
28
29 /**
30 * Exports a table to JSON format.
31 *
32 * @since 3.4.0
33 *
34 * @param array<string, mixed> $table Table to be exported.
35 * @param array<string, mixed> $options Format-specific options for the export.
36 * @return string Exported table.
37 */
38 public function export( array $table, array $options = array() ): string {
39 $output = wp_json_encode( $table, TABLEPRESS_JSON_OPTIONS );
40 if ( false === $output ) {
41 $output = '';
42 }
43 return $output;
44 }
45
46 } // class JSON_Exporter
47