PluginProbe
TablePress – Tables in WordPress made easy / 3.2
TablePress – Tables in WordPress made easy v3.2
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 2.4.4 All 44 releases
← All changes | views/view-import.php +28 -29 2.33.2 View file →
@@ -26,9 +26,9 @@
26 26 *
27 27 * @since 2.0.0
28 28 * @var string[]
29 29 */
30 - protected $wp_pointers = array( 'tp20_import_drag_drop_detect_format' );
30 + protected array $wp_pointers = array( 'tp20_import_drag_drop_detect_format' );
31 31
32 32 /**
33 33 * Set up the view with data and do things that are specific for this view.
34 34 *
@@ -44,12 +44,10 @@
44 44 parent::setup( $action, $data );
45 45
46 46 $this->add_text_box( 'no-javascript', array( $this, 'textbox_no_javascript' ), 'header' );
47 47
48 - $this->admin_page->enqueue_style( 'jsuites' );
49 - $this->admin_page->enqueue_style( 'import', array( 'tablepress-jsuites' ) );
50 - $this->admin_page->enqueue_script( 'jsuites' );
51 - $this->admin_page->enqueue_script( 'import', array( 'tablepress-jsuites' ) );
48 + $this->admin_page->enqueue_style( 'import' );
49 + $this->admin_page->enqueue_script( 'import' );
52 50
53 51 $this->process_action_messages( array(
54 52 'error_import' => __( 'Error: The import failed.', 'tablepress' ),
55 53 ) );
@@ -56,10 +54,12 @@
56 54
57 55 $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' );
58 56 $this->add_meta_box( 'import-form', __( 'Import Tables', 'tablepress' ), array( $this, 'postbox_import_form' ), 'normal' );
59 57 $screen = get_current_screen();
60 - add_filter( "postbox_classes_{$screen->id}_tablepress_{$this->action}-import-form", array( $this, 'postbox_classes' ) );
61 - $this->add_meta_box( 'tables-auto-import', __( 'Automatic Periodic Table Import', 'tablepress' ), array( $this, 'postbox_auto_import' ), 'additional' );
58 + add_filter( "postbox_classes_{$screen->id}_tablepress_{$this->action}-import-form", array( $this, 'postbox_classes' ) ); // @phpstan-ignore property.nonObject
59 + if ( ! TABLEPRESS_IS_PLAYGROUND_PREVIEW ) {
60 + $this->add_meta_box( 'tables-auto-import', __( 'Automatic Periodic Table Import', 'tablepress' ), array( $this, 'postbox_auto_import' ), 'additional' );
61 + }
62 62 }
63 63
64 64 /**
65 65 * Print the screen head text.
@@ -89,28 +89,24 @@
89 89 * @param array<string, mixed> $data Data for this screen.
90 90 * @param array<string, mixed> $box Information about the meta box.
91 91 */
92 92 public function postbox_import_form( array $data, array $box ): void {
93 - $script_data = array(
94 - 'tables' => $this->admin_page->convert_to_json_parse_output( $data['tables'] ),
95 - 'importSource' => $this->admin_page->convert_to_json_parse_output( $data['import_source'] ),
96 - 'importType' => $this->admin_page->convert_to_json_parse_output( $data['import_type'] ),
97 - 'importUrl' => $this->admin_page->convert_to_json_parse_output( esc_url( $data['import_url'] ) ),
98 - 'importServer' => $this->admin_page->convert_to_json_parse_output( $data['import_server'] ),
99 - 'importFormField' => $this->admin_page->convert_to_json_parse_output( $data['import_form-field'] ),
100 - 'importExistingTable' => $this->admin_page->convert_to_json_parse_output( $data['import_existing_table'] ),
101 - 'showImportSourceServer' => ( ( ! is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() ) ? 'true' : 'false',
102 - 'legacyImport' => $this->admin_page->convert_to_json_parse_output( $data['legacy_import'] ),
93 + $this->print_script_data_json(
94 + 'import',
95 + array(
96 + 'tables' => $data['tables'],
97 + 'importSource' => $data['import_source'],
98 + 'importType' => $data['import_type'],
99 + 'importUrl' => esc_url( $data['import_url'] ),
100 + 'importServer' => $data['import_server'],
101 + 'importFormField' => $data['import_form-field'],
102 + 'importExistingTable' => $data['import_existing_table'],
103 + 'showImportSourceServer' => ( ( ! is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() ),
104 + 'showImportSourceUrl' => current_user_can( 'tablepress_import_tables_url' ),
105 + 'legacyImport' => $data['legacy_import'],
106 + ),
103 107 );
104 108
105 - echo "<script>\n";
106 - echo "window.tp = window.tp || {};\n";
107 - echo "tp.import = {};\n";
108 - foreach ( $script_data as $variable => $value ) {
109 - echo "tp.import.{$variable} = {$value};\n";
110 - }
111 - echo "</script>\n";
112 -
113 109 echo '<div id="tablepress-import-screen"></div>';
114 110 }
115 111
116 112 /**
@@ -133,9 +129,9 @@
133 129 *
134 130 * @param array<string, mixed> $data Data for this screen.
135 131 * @param array<string, mixed> $box Information about the meta box.
136 132 *
137 - * @phpstan-ignore-next-line (PHPStan would like to see a type hint.)
133 + * @phpstan-ignore missingType.return (The method is extended elsewhere and can't have type hints.)
138 134 */
139 135 public function postbox_auto_import( /* array */ $data, /* array */ $box ) /* : void */ {
140 136 // Don't use type hints in the method declaration, as the method is extended in the TablePress Table Auto Update Extension which is no longer updated.
141 137
@@ -143,9 +139,12 @@
143 139 ?>
144 140 <p style="font-size:14px;">
145 141 <span class="dashicons dashicons-info-outline"></span>
146 142 <strong><?php _e( 'Pro Tip:', 'tablepress' ); ?></strong>
147 - <?php printf( __( 'You can automate the import of tables from URLs or server files with the <a href="%1$s">“%2$s” premium feature</a>!', 'tablepress' ), 'https://tablepress.org/modules/automatic-periodic-table-import/?utm_source=plugin&utm_medium=textlink&utm_content=import-screen', __( 'Automatic Periodic Table Import', 'tablepress' ) ); ?>
143 + <?php
144 + /* translators: %1$s: URL to TablePress website, %2$s: Module name */
145 + printf( __( 'You can automate the import of tables from URLs or server files with the <a href="%1$s">“%2$s” premium feature</a>!', 'tablepress' ), 'https://tablepress.org/modules/automatic-periodic-table-import/?utm_source=plugin&utm_medium=textlink&utm_content=import-screen', __( 'Automatic Periodic Table Import', 'tablepress' ) );
146 + ?>
148 147 </p>
149 148 <?php
150 149 endif;
151 150 }
@@ -156,9 +155,9 @@
156 155 * @since 2.0.0
157 156 */
158 157 public function wp_pointer_tp20_import_drag_drop_detect_format(): void {
159 158 $content = '<h3>' . __( 'TablePress feature: Drag and Drop Import with Format Detection', 'tablepress' ) . '</h3>';
160 - $content .= '<p>' . __( 'Did you know?', 'tablepress' ) . ' ' . __( 'The import of tables is now even more powerful! You can simply drag and drop your files into this area and TablePress will automatically detect the file format!', 'tablepress' ) . '</p>';
159 + $content .= '<p>' . __( 'Did you know?', 'tablepress' ) . ' ' . __( 'To import tables, you can simply drag and drop your spreadsheet files into this area and TablePress will automatically detect the file format!', 'tablepress' ) . '</p>';
161 160
162 161 $this->admin_page->print_wp_pointer_js(
163 162 'tp20_import_drag_drop_detect_format',
164 163 '#tables-import-file-upload-dropzone span',
@@ -164,9 +163,9 @@
164 163 '#tables-import-file-upload-dropzone span',
165 164 array(
166 165 'content' => $content,
167 166 'position' => array( 'edge' => 'bottom', 'align' => 'center' ),
168 - )
167 + ),
169 168 );
170 169 }
171 170
172 171 } // class TablePress_Import_View