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
← All changes | views/view-export.php +24 -19 2.2.3 → 3.4 View file →
@@ -7,8 +7,10 @@
7 7 * @author Tobias Bäthge
8 8 * @since 1.0.0
9 9 */
10 10
11 +declare(strict_types=1);
12 +
11 13 // Prohibit direct script loading.
12 14 defined( 'ABSPATH' ) || die( 'No direct script access allowed!' );
13 15
14 16 /**
@@ -28,13 +30,16 @@
28 30 *
29 31 * @param string $action Action for this view.
30 32 * @param array<string, mixed> $data Data for this view.
31 33 */
34 + #[\Override]
32 35 public function setup( /* string */ $action, array $data ) /* : void */ {
33 36 // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited.
34 37
35 38 parent::setup( $action, $data );
36 39
40 + TablePress::enqueue_script( 'common', array( 'jquery-core', 'postbox' ) );
41 +
37 42 $this->add_text_box( 'no-javascript', array( $this, 'textbox_no_javascript' ), 'header' );
38 43
39 44 $this->process_action_messages( array(
40 45 'error_export' => __( 'Error: The export failed.', 'tablepress' ),
@@ -46,9 +51,9 @@
46 51 $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
47 52 if ( 0 === $data['tables_count'] ) {
48 53 $this->add_meta_box( 'no-tables', __( 'Export Tables', 'tablepress' ), array( $this, 'postbox_no_tables' ), 'normal' );
49 54 } else {
50 - $this->admin_page->enqueue_script( 'export' );
55 + TablePress::enqueue_script( 'export' );
51 56 $this->add_meta_box( 'export-form', __( 'Export Tables', 'tablepress' ), array( $this, 'postbox_export_form' ), 'normal' );
52 57 }
53 58 }
54 59
@@ -68,9 +73,9 @@
68 73 </p>
69 74 <p>
70 75 <?php _e( 'To export, select the tables and the desired export format.', 'tablepress' ); ?>
71 76 <?php _e( 'If you choose more than one table, the exported files will automatically be stored in a ZIP archive file.', 'tablepress' ); ?>
72 - <br />
77 + <br>
73 78 <?php _e( 'Be aware that for the CSV and HTML formats only the table data, but no table options are exported!', 'tablepress' ); ?>
74 79 <?php _e( 'For the JSON format, the table data and the table options are exported.', 'tablepress' ); ?>
75 80 </p>
76 81 <?php
@@ -88,9 +93,14 @@
88 93 $add_url = TablePress::url( array( 'action' => 'add' ) );
89 94 $import_url = TablePress::url( array( 'action' => 'import' ) );
90 95 ?>
91 96 <p><?php _e( 'No tables found.', 'tablepress' ); ?></p>
92 - <p><?php printf( __( 'You should <a href="%1$s">add</a> or <a href="%2$s">import</a> a table to get started!', 'tablepress' ), $add_url, $import_url ); ?></p>
97 + <p>
98 + <?php
99 + /* translators: %1$s: URL to add table page, %2$s: URL to import table page */
100 + printf( __( 'You should <a href="%1$s">add</a> or <a href="%2$s">import</a> a table to get started!', 'tablepress' ), $add_url, $import_url );
101 + ?>
102 + </p>
93 103 <?php
94 104 }
95 105
96 106 /**
@@ -101,25 +111,20 @@
101 111 * @param array<string, mixed> $data Data for this screen.
102 112 * @param array<string, mixed> $box Information about the meta box.
103 113 */
104 114 public function postbox_export_form( array $data, array $box ): void {
105 - $script_data = array(
106 - 'tables' => $this->admin_page->convert_to_json_parse_output( $data['tables'] ),
107 - 'exportFormats' => $this->admin_page->convert_to_json_parse_output( $data['export_formats'] ),
108 - 'csvDelimiters' => $this->admin_page->convert_to_json_parse_output( $data['csv_delimiters'] ),
109 - 'zipSupportAvailable' => $this->admin_page->convert_to_json_parse_output( $data['zip_support_available'] ),
110 - 'selectedTables' => $this->admin_page->convert_to_json_parse_output( $data['export_ids'] ),
111 - 'exportFormat' => $this->admin_page->convert_to_json_parse_output( $data['export_format'] ),
112 - 'csvDelimiter' => $this->admin_page->convert_to_json_parse_output( $data['csv_delimiter'] ),
115 + $this->print_script_data_json(
116 + 'export',
117 + array(
118 + 'tables' => $data['tables'],
119 + 'exportFormats' => $data['export_formats'],
120 + 'csvDelimiters' => $data['csv_delimiters'],
121 + 'zipSupportAvailable' => $data['zip_support_available'],
122 + 'selectedTables' => $data['export_ids'],
123 + 'exportFormat' => $data['export_format'],
124 + 'csvDelimiter' => $data['csv_delimiter'],
125 + ),
113 126 );
114 -
115 - echo "<script>\n";
116 - echo "window.tp = window.tp || {};\n";
117 - echo "tp.export = {};\n";
118 - foreach ( $script_data as $variable => $value ) {
119 - echo "tp.export.{$variable} = {$value};\n";
120 - }
121 - echo "</script>\n";
122 127
123 128 echo '<div id="tablepress-export-screen"></div>';
124 129 }
125 130