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 +22 -18 2.4 → 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 /**
@@ -34,8 +36,10 @@
34 36 // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited.
35 37
36 38 parent::setup( $action, $data );
37 39
40 + TablePress::enqueue_script( 'common', array( 'jquery-core', 'postbox' ) );
41 +
38 42 $this->add_text_box( 'no-javascript', array( $this, 'textbox_no_javascript' ), 'header' );
39 43
40 44 $this->process_action_messages( array(
41 45 'error_export' => __( 'Error: The export failed.', 'tablepress' ),
@@ -47,9 +51,9 @@
47 51 $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
48 52 if ( 0 === $data['tables_count'] ) {
49 53 $this->add_meta_box( 'no-tables', __( 'Export Tables', 'tablepress' ), array( $this, 'postbox_no_tables' ), 'normal' );
50 54 } else {
51 - $this->admin_page->enqueue_script( 'export' );
55 + TablePress::enqueue_script( 'export' );
52 56 $this->add_meta_box( 'export-form', __( 'Export Tables', 'tablepress' ), array( $this, 'postbox_export_form' ), 'normal' );
53 57 }
54 58 }
55 59
@@ -89,9 +93,14 @@
89 93 $add_url = TablePress::url( array( 'action' => 'add' ) );
90 94 $import_url = TablePress::url( array( 'action' => 'import' ) );
91 95 ?>
92 96 <p><?php _e( 'No tables found.', 'tablepress' ); ?></p>
93 - <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>
94 103 <?php
95 104 }
96 105
97 106 /**
@@ -102,25 +111,20 @@
102 111 * @param array<string, mixed> $data Data for this screen.
103 112 * @param array<string, mixed> $box Information about the meta box.
104 113 */
105 114 public function postbox_export_form( array $data, array $box ): void {
106 - $script_data = array(
107 - 'tables' => $this->admin_page->convert_to_json_parse_output( $data['tables'] ),
108 - 'exportFormats' => $this->admin_page->convert_to_json_parse_output( $data['export_formats'] ),
109 - 'csvDelimiters' => $this->admin_page->convert_to_json_parse_output( $data['csv_delimiters'] ),
110 - 'zipSupportAvailable' => $this->admin_page->convert_to_json_parse_output( $data['zip_support_available'] ),
111 - 'selectedTables' => $this->admin_page->convert_to_json_parse_output( $data['export_ids'] ),
112 - 'exportFormat' => $this->admin_page->convert_to_json_parse_output( $data['export_format'] ),
113 - '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 + ),
114 126 );
115 -
116 - echo "<script>\n";
117 - echo "window.tp = window.tp || {};\n";
118 - echo "tp.export = {};\n";
119 - foreach ( $script_data as $variable => $value ) {
120 - echo "tp.export.{$variable} = {$value};\n";
121 - }
122 - echo "</script>\n";
123 127
124 128 echo '<div id="tablepress-export-screen"></div>';
125 129 }
126 130