| @@ -7,13 +7,16 @@ | ||
| 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 | /** |
| 15 | 17 | * Import Table View class |
| 18 | + * | |
| 16 | 19 | * @package TablePress |
| 17 | 20 | * @subpackage Views |
| 18 | 21 | * @author Tobias Bäthge |
| 19 | 22 | * @since 1.0.0 |
| @@ -22,12 +25,12 @@ | ||
| 22 | 25 | |
| 23 | 26 | /** |
| 24 | 27 | * List of WP feature pointers for this view. |
| 25 | 28 | * |
| 26 | - * @since 1.0.0 | |
| 27 | - * @var array | |
| 29 | + * @since 2.0.0 | |
| 30 | + * @var string[] | |
| 28 | 31 | */ |
| 29 | - protected $wp_pointers = array( 'tp100_wp_table_reloaded_import' ); | |
| 32 | + protected array $wp_pointers = array( 'tp20_import_drag_drop_detect_format' ); | |
| 30 | 33 | |
| 31 | 34 | /** |
| 32 | 35 | * Set up the view with data and do things that are specific for this view. |
| 33 | 36 | * |
| @@ -32,279 +35,141 @@ | ||
| 32 | 35 | * Set up the view with data and do things that are specific for this view. |
| 33 | 36 | * |
| 34 | 37 | * @since 1.0.0 |
| 35 | 38 | * |
| 36 | - * @param string $action Action for this view. | |
| 37 | - * @param array $data Data for this view. | |
| 39 | + * @param string $action Action for this view. | |
| 40 | + * @param array<string, mixed> $data Data for this view. | |
| 38 | 41 | */ |
| 39 | - public function setup( $action, array $data ) { | |
| 42 | + #[\Override] | |
| 43 | + public function setup( /* string */ $action, array $data ) /* : void */ { | |
| 44 | + // Don't use type hints in the method declaration to prevent PHP errors, as the method is inherited. | |
| 45 | + | |
| 40 | 46 | parent::setup( $action, $data ); |
| 41 | 47 | |
| 42 | - $this->admin_page->enqueue_script( 'import', array( 'jquery-core' ), array( | |
| 43 | - 'import' => array( | |
| 44 | - 'error_wp_table_reloaded_nothing_selected' => __( 'Error: You did not select what to import from WP-Table Reloaded!', 'tablepress' ), | |
| 45 | - ), | |
| 46 | - ) ); | |
| 48 | + TablePress::enqueue_script( 'common', array( 'jquery-core', 'postbox' ) ); | |
| 47 | 49 | |
| 50 | + $this->add_text_box( 'no-javascript', array( $this, 'textbox_no_javascript' ), 'header' ); | |
| 51 | + | |
| 52 | + TablePress::enqueue_style( 'import' ); | |
| 53 | + TablePress::enqueue_script( 'import' ); | |
| 54 | + | |
| 48 | 55 | $this->process_action_messages( array( |
| 49 | - 'error_import' => __( 'Error: The import failed.', 'tablepress' ), | |
| 50 | - 'error_no_zip_import' => __( 'Error: Import of ZIP files is not available on this server.', 'tablepress' ), | |
| 51 | - 'error_import_zip_open' => __( 'Error: The ZIP file could not be opened.', 'tablepress' ), | |
| 52 | - 'error_import_zip_content' => __( 'Error: The data in the ZIP file is invalid.', 'tablepress' ), | |
| 53 | - 'error_import_no_existing_id' => __( 'Error: You selected to replace or append to an existing table, but did not select a table.', 'tablepress' ), | |
| 54 | - 'error_import_source_invalid' => __( 'Error: The source for the import is invalid or could not be accessed.', 'tablepress' ), | |
| 55 | - 'error_import_data' => __( 'Error: The data for the import is invalid.', 'tablepress' ), | |
| 56 | - 'error_wp_table_reloaded_nothing_selected' => __( 'Error: You did not select what to import from WP-Table Reloaded!', 'tablepress' ), | |
| 57 | - 'error_wp_table_reloaded_not_installed' => __( 'Error: Existing WP-Table Reloaded tables were not found in the database.', 'tablepress' ), | |
| 58 | - 'error_import_wp_table_reloaded' => __( 'Error: The tables from WP-Table Reloaded could not be imported.', 'tablepress' ), | |
| 59 | - 'error_wp_table_reloaded_dump_file' => __( 'Error: The WP-Table Reloaded Dump File could not be imported!', 'tablepress' ), | |
| 56 | + 'error_import' => __( 'Error: The import failed.', 'tablepress' ), | |
| 60 | 57 | ) ); |
| 61 | 58 | |
| 62 | 59 | $this->add_text_box( 'head', array( $this, 'textbox_head' ), 'normal' ); |
| 63 | 60 | $this->add_meta_box( 'import-form', __( 'Import Tables', 'tablepress' ), array( $this, 'postbox_import_form' ), 'normal' ); |
| 64 | - if ( current_user_can( 'tablepress_import_tables_wptr' ) ) { | |
| 65 | - $this->add_meta_box( 'import-wp-table-reloaded', __( 'Import from WP-Table Reloaded', 'tablepress' ), array( $this, 'postbox_wp_table_reloaded_import' ), 'additional' ); | |
| 61 | + $screen = get_current_screen(); | |
| 62 | + add_filter( "postbox_classes_{$screen->id}_tablepress_{$this->action}-import-form", array( $this, 'postbox_classes' ) ); // @phpstan-ignore property.nonObject | |
| 63 | + if ( ! TABLEPRESS_IS_PLAYGROUND_PREVIEW ) { | |
| 64 | + $this->add_meta_box( 'tables-auto-import', __( 'Automatic Periodic Table Import', 'tablepress' ), array( $this, 'postbox_auto_import' ), 'additional' ); | |
| 66 | 65 | } |
| 67 | - | |
| 68 | - add_filter( 'default_hidden_meta_boxes', array( $this, 'hide_import_wptr_postbox' ), 10, 2 ); | |
| 69 | 66 | } |
| 70 | 67 | |
| 71 | 68 | /** |
| 72 | - * Hide the "Import from WP-Table Reloaded postbox" by default, if WP-Table Reloaded is not installed. It can still be opened manually from the "Screen Options". | |
| 73 | - * | |
| 74 | - * @since 1.0.0 | |
| 75 | - */ | |
| 76 | - public function hide_import_wptr_postbox( $hidden, $screen ) { | |
| 77 | - if ( 'tablepress_import' !== $screen->id ) { | |
| 78 | - return $hidden; | |
| 79 | - } | |
| 80 | - if ( ! $this->data['wp_table_reloaded_installed'] ) { | |
| 81 | - $hidden[] = 'tablepress_import-import-wp-table-reloaded'; | |
| 82 | - } | |
| 83 | - return $hidden; | |
| 84 | - } | |
| 85 | - | |
| 86 | - /** | |
| 87 | 69 | * Print the screen head text. |
| 88 | 70 | * |
| 89 | 71 | * @since 1.0.0 |
| 90 | 72 | * |
| 91 | - * @param array $data Data for this screen. | |
| 92 | - * @param array $box Information about the text box. | |
| 73 | + * @param array<string, mixed> $data Data for this screen. | |
| 74 | + * @param array<string, mixed> $box Information about the text box. | |
| 93 | 75 | */ |
| 94 | - public function textbox_head( array $data, array $box ) { | |
| 76 | + public function textbox_head( array $data, array $box ): void { | |
| 95 | 77 | ?> |
| 96 | 78 | <p> |
| 97 | - <?php _e( 'TablePress can import tables from existing data, like from a CSV, XLS, or XLSX file from a spreadsheet application (e.g. Excel), an HTML file resembling a webpage, or its own JSON format.', 'tablepress' ); ?> | |
| 98 | - <?php _e( 'You can also import existing tables from the WP-Table Reloaded plugin below.', 'tablepress' ); ?> | |
| 79 | + <?php _e( 'TablePress can import tables from common spreadsheet applications, like XLSX files from Excel, or CSV, ODS, HTML, and JSON files.', 'tablepress' ); ?> | |
| 99 | 80 | </p> |
| 100 | 81 | <p> |
| 101 | - <?php | |
| 102 | - _e( 'To import a table, select and enter the import source in the following form.', 'tablepress' ); | |
| 103 | - if ( 0 < $data['tables_count'] ) { | |
| 104 | - echo ' '; | |
| 105 | - _e( 'You can also choose to import it as a new table, to replace an existing table, or to append the rows to an existing table.', 'tablepress' ); | |
| 106 | - } | |
| 107 | - | |
| 108 | - ?> | |
| 82 | + <?php _e( 'To import tables, select and enter the import source in the following form.', 'tablepress' ); ?> | |
| 83 | + <?php _e( 'You can also choose to import it as a new table, to replace an existing table, or to append the rows to an existing table.', 'tablepress' ); ?> | |
| 109 | 84 | </p> |
| 110 | 85 | <?php |
| 111 | 86 | } |
| 112 | 87 | |
| 113 | 88 | /** |
| 114 | - * Print the content of the "Import Tables" post meta box. | |
| 89 | + * Prints the content of the "Import Tables" post meta box. | |
| 115 | 90 | * |
| 116 | 91 | * @since 1.0.0 |
| 117 | 92 | * |
| 118 | - * @param array $data Data for this screen. | |
| 119 | - * @param array $box Information about the meta box. | |
| 93 | + * @param array<string, mixed> $data Data for this screen. | |
| 94 | + * @param array<string, mixed> $box Information about the meta box. | |
| 120 | 95 | */ |
| 121 | - public function postbox_import_form( array $data, array $box ) { | |
| 122 | -?> | |
| 123 | -<table class="tablepress-postbox-table fixed"> | |
| 124 | -<tbody> | |
| 125 | - <tr id="row-import-source"> | |
| 126 | - <th class="column-1" scope="row" id="import-source-header"><?php _e( 'Import Source', 'tablepress' ); ?>:</th> | |
| 127 | - <td class="column-2"> | |
| 128 | - <label for="tables-import-source-file-upload"><input name="import[source]" id="tables-import-source-file-upload" type="radio" aria-labelledby="import-source-header" value="file-upload"<?php checked( $data['import_source'], 'file-upload', true ); ?> /> <?php _e( 'File Upload', 'tablepress' ); ?></label> | |
| 129 | - <label for="tables-import-source-url"><input name="import[source]" id="tables-import-source-url" type="radio" aria-labelledby="import-source-header" value="url"<?php checked( $data['import_source'], 'url', true ); ?> /> <?php _e( 'URL', 'tablepress' ); ?></label> | |
| 130 | - <?php if ( ( ! is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() ) { ?> | |
| 131 | - <label for="tables-import-source-server"><input name="import[source]" id="tables-import-source-server" type="radio" aria-labelledby="import-source-header" value="server"<?php checked( $data['import_source'], 'server', true ); ?> /> <?php _e( 'File on server', 'tablepress' ); ?></label> | |
| 132 | - <?php } ?> | |
| 133 | - <label for="tables-import-source-form-field"><input name="import[source]" id="tables-import-source-form-field" type="radio" aria-labelledby="import-source-header" value="form-field"<?php checked( $data['import_source'], 'form-field', true ); ?> /> <?php _e( 'Manual Input', 'tablepress' ); ?></label> | |
| 134 | - </td> | |
| 135 | - </tr> | |
| 136 | - <tr id="row-import-source-file-upload" class="bottom-border"> | |
| 137 | - <th class="column-1 top-align" scope="row"><label for="tables-import-file-upload"><?php _e( 'Select file', 'tablepress' ); ?>:</label></th> | |
| 138 | - <td class="column-2"> | |
| 139 | - <input name="import_file_upload" id="tables-import-file-upload" type="file" class="large-text" style="box-sizing: border-box;" /> | |
| 140 | - <?php | |
| 141 | - if ( $data['zip_support_available'] ) { | |
| 142 | - echo '<br /><span class="description">' . __( 'You can import multiple tables by placing them in a ZIP file.', 'tablepress' ) . '</span>'; | |
| 143 | - } | |
| 144 | - ?> | |
| 145 | - </td> | |
| 146 | - </tr> | |
| 147 | - <tr id="row-import-source-url" class="bottom-border"> | |
| 148 | - <th class="column-1 top-align" scope="row"><label for="tables-import-url"><?php _e( 'File URL', 'tablepress' ); ?>:</label></th> | |
| 149 | - <td class="column-2"> | |
| 150 | - <input type="text" name="import[url]" id="tables-import-url" class="large-text" value="<?php echo esc_attr( $data['import_url'] ); ?>" /> | |
| 151 | - <?php | |
| 152 | - if ( $data['zip_support_available'] ) { | |
| 153 | - echo '<br /><span class="description">' . __( 'You can import multiple tables by placing them in a ZIP file.', 'tablepress' ) . '</span>'; | |
| 154 | - } | |
| 155 | - ?> | |
| 156 | - </td> | |
| 157 | - </tr> | |
| 158 | - <?php if ( ( ! is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() ) { ?> | |
| 159 | - <tr id="row-import-source-server" class="bottom-border"> | |
| 160 | - <th class="column-1 top-align" scope="row"><label for="tables-import-server"><?php _e( 'Server Path to file', 'tablepress' ); ?>:</label></th> | |
| 161 | - <td class="column-2"> | |
| 162 | - <input type="text" name="import[server]" id="tables-import-server" class="large-text" value="<?php echo esc_attr( $data['import_server'] ); ?>" /> | |
| 163 | - <?php | |
| 164 | - if ( $data['zip_support_available'] ) { | |
| 165 | - echo '<br /><span class="description">' . __( 'You can import multiple tables by placing them in a ZIP file.', 'tablepress' ) . '</span>'; | |
| 166 | - } | |
| 167 | - ?> | |
| 168 | - </td> | |
| 169 | - </tr> | |
| 170 | - <?php } ?> | |
| 171 | - <tr id="row-import-source-form-field" class="bottom-border"> | |
| 172 | - <th class="column-1 top-align" scope="row"><label for="tables-import-form-field"><?php _e( 'Import data', 'tablepress' ); ?>:</label></th> | |
| 173 | - <td class="column-2"> | |
| 174 | - <textarea name="import[form_field]" id="tables-import-form-field" rows="15" cols="40" class="large-text"><?php echo esc_textarea( $data['import_form_field'] ); ?></textarea> | |
| 175 | - </td> | |
| 176 | - </tr> | |
| 177 | - <tr class="top-border bottom-border"> | |
| 178 | - <th class="column-1" scope="row"><label for="tables-import-format"><?php _e( 'Import Format', 'tablepress' ); ?>:</label></th> | |
| 179 | - <td class="column-2"> | |
| 180 | - <select id="tables-import-format" name="import[format]"> | |
| 181 | - <?php | |
| 182 | - foreach ( $data['import_formats'] as $format => $name ) { | |
| 183 | - $selected = selected( $format, $data['import_format'], false ); | |
| 184 | - echo "<option{$selected} value=\"{$format}\">{$name}</option>"; | |
| 185 | - } | |
| 186 | - ?> | |
| 187 | - </select> | |
| 188 | - <?php | |
| 189 | - if ( ! $data['html_import_support_available'] ) { | |
| 190 | - echo '<br /><span class="description">' . __( 'Import of HTML files is not available on your server.', 'tablepress' ) . '</span>'; | |
| 191 | - } | |
| 192 | - ?> | |
| 193 | - </td> | |
| 194 | - </tr> | |
| 195 | - <tr id="row-import-type" class="top-border"> | |
| 196 | - <th class="column-1" scope="row" id="import-type-header"><?php _e( 'Add, Replace, or Append?', 'tablepress' ); ?>:</th> | |
| 197 | - <td class="column-2"> | |
| 198 | - <label for="tables-import-type-add"><input name="import[type]" id="tables-import-type-add" type="radio" aria-labelledby="import-type-header" value="add"<?php checked( $data['import_type'], 'add', true ); ?> /> <?php _e( 'Add as new table', 'tablepress' ); ?></label> | |
| 199 | - <label for="tables-import-type-replace"><input name="import[type]" id="tables-import-type-replace" type="radio" aria-labelledby="import-type-header" value="replace"<?php checked( $data['import_type'], 'replace', true ); ?><?php disabled( $data['tables_count'] > 0, false, true ); ?> /> <?php _e( 'Replace existing table', 'tablepress' ); ?></label> | |
| 200 | - <label for="tables-import-type-append"><input name="import[type]" id="tables-import-type-append" type="radio" aria-labelledby="import-type-header" value="append"<?php checked( $data['import_type'], 'append', true ); ?><?php disabled( $data['tables_count'] > 0, false, true ); ?> /> <?php _e( 'Append rows to existing table', 'tablepress' ); ?></label> | |
| 201 | - </td> | |
| 202 | - </tr> | |
| 203 | - <tr id="row-import-existing-table" class="bottom-border"> | |
| 204 | - <th class="column-1" scope="row"><label for="tables-import-existing-table"><?php _e( 'Table to replace or append to', 'tablepress' ); ?>:</label></th> | |
| 205 | - <td class="column-2"> | |
| 206 | - <select id="tables-import-existing-table" name="import[existing_table]"<?php disabled( $data['tables_count'] > 0, false, true ); ?>> | |
| 207 | - <option value=""><?php _e( '— Select —', 'tablepress' ); ?></option> | |
| 208 | - <?php | |
| 209 | - foreach ( $data['table_ids'] as $table_id ) { | |
| 210 | - $table = TablePress::$model_table->load( $table_id, false, false ); // Load table, without table data, options, and visibility settings | |
| 211 | - if ( ! current_user_can( 'tablepress_edit_table', $table['id'] ) ) { | |
| 212 | - continue; | |
| 213 | - } | |
| 214 | - if ( '' === trim( $table['name'] ) ) { | |
| 215 | - $table['name'] = __( '(no name)', 'tablepress' ); | |
| 216 | - } | |
| 217 | - $text = esc_html( sprintf( __( 'ID %1$s: %2$s', 'tablepress' ), $table['id'], $table['name'] ) ); | |
| 218 | - $selected = selected( $table['id'], $data['import_existing_table'], false ); | |
| 219 | - echo "<option{$selected} value=\"{$table['id']}\">{$text}</option>"; | |
| 220 | - } | |
| 221 | - ?> | |
| 222 | - </select> | |
| 223 | - </td> | |
| 224 | - </tr> | |
| 225 | - <tr class="top-border"> | |
| 226 | - <td class="column-1"></td> | |
| 227 | - <td class="column-2"><input type="submit" value="<?php echo esc_attr_x( 'Import', 'button', 'tablepress' ); ?>" class="button button-primary button-large" name="submit" /></td> | |
| 228 | - </tr> | |
| 229 | -</tbody> | |
| 230 | -</table> | |
| 231 | -<?php | |
| 96 | + public function postbox_import_form( array $data, array $box ): void { | |
| 97 | + $this->print_script_data_json( | |
| 98 | + 'import', | |
| 99 | + array( | |
| 100 | + 'tables' => $data['tables'], | |
| 101 | + 'importSource' => $data['import_source'], | |
| 102 | + 'importType' => $data['import_type'], | |
| 103 | + 'importUrl' => $data['import_url'], | |
| 104 | + 'importServer' => $data['import_server'], | |
| 105 | + 'importFormField' => $data['import_form-field'], | |
| 106 | + 'importExistingTable' => $data['import_existing_table'], | |
| 107 | + 'showImportSourceServer' => ( ( ! is_multisite() && current_user_can( 'manage_options' ) ) || is_super_admin() ), | |
| 108 | + 'showImportSourceUrl' => current_user_can( 'tablepress_import_tables_url' ), | |
| 109 | + 'legacyImport' => $data['legacy_import'], | |
| 110 | + ), | |
| 111 | + ); | |
| 112 | + | |
| 113 | + echo '<div id="tablepress-import-screen"></div>'; | |
| 232 | 114 | } |
| 233 | 115 | |
| 234 | 116 | /** |
| 235 | - * Print the content of the "Import from WP-Table Reloaded" post meta box. | |
| 117 | + * Adds the "no-validation-highlighting" class to the "Import Tables" post meta box. | |
| 236 | 118 | * |
| 237 | - * @since 1.0.0 | |
| 119 | + * @since 2.2.0 | |
| 238 | 120 | * |
| 239 | - * @param array $data Data for this screen. | |
| 240 | - * @param array $box Information about the meta box. | |
| 121 | + * @param string[] $classes The array of postbox classes. | |
| 122 | + * @return string[] The modified array of postbox classes. | |
| 241 | 123 | */ |
| 242 | - public function postbox_wp_table_reloaded_import( array $data, array $box ) { | |
| 243 | - ?> | |
| 244 | -<p> | |
| 245 | - <?php _e( 'To import all tables from a WP-Table Reloaded installation, choose the relevant import source below.', 'tablepress' ); ?> | |
| 246 | -<br /> | |
| 247 | - <?php _e( 'If WP-Table Reloaded is installed on this site, the “WordPress database” option is recommended.', 'tablepress' ); ?> | |
| 248 | - <?php _e( 'If you want to import tables from another site, create a “WP-Table Reloaded Dump File” there and upload it below, after choosing “WP-Table Reloaded Dump File”.', 'tablepress' ); ?> | |
| 249 | -<br /> | |
| 250 | - <?php printf( __( 'Before doing this, it is highly recommended to read the <a href="%s">migration guide</a> on the TablePress website.', 'tablepress' ), 'https://tablepress.org/migration-from-wp-table-reloaded/' ); ?> | |
| 251 | -</p> | |
| 252 | -<table class="tablepress-postbox-table fixed"> | |
| 253 | -<tbody> | |
| 254 | - <tr id="row-import-wp-table-reloaded-source"> | |
| 255 | - <th class="column-1" scope="row"><?php _e( 'Import Source', 'tablepress' ); ?>:</th> | |
| 256 | - <td class="column-2"> | |
| 257 | - <label for="import-wp-table-reloaded-source-db"><input name="import[wp_table_reloaded][source]" id="import-wp-table-reloaded-source-db" type="radio" value="db" <?php | |
| 258 | - checked( $data['import_wp_table_reloaded_source'], 'db', true ); | |
| 259 | - disabled( $data['wp_table_reloaded_installed'], false, true ); | |
| 260 | - ?> /> <?php _e( 'WordPress database', 'tablepress' ); ?></label> | |
| 261 | - <label for="import-wp-table-reloaded-source-dump-file"><input name="import[wp_table_reloaded][source]" id="import-wp-table-reloaded-source-dump-file" type="radio" value="dump-file"<?php checked( $data['import_wp_table_reloaded_source'], 'dump-file', true ); ?> /> <?php _e( 'WP-Table Reloaded Dump File', 'tablepress' ); ?></label> | |
| 262 | - </td> | |
| 263 | - </tr> | |
| 264 | - <tr id="row-import-wp-table-reloaded-source-dump-file" class="bottom-border"> | |
| 265 | - <th class="column-1 top-align" scope="row"><label for="tables-import-wp-table-reloaded-dump-file"><?php _e( 'Select file', 'tablepress' ); ?>:</label></th> | |
| 266 | - <td class="column-2"> | |
| 267 | - <input name="import_wp_table_reloaded_file_upload" id="tables-import-wp-table-reloaded-dump-file" type="file" class="large-text" style="box-sizing: border-box;" /> | |
| 268 | - </td> | |
| 269 | - </tr> | |
| 270 | - <tr id="row-import-wp-table-reloaded-source-db" class="bottom-border"> | |
| 271 | - <td class="column-1 top-align" scope="row" style="padding:2px;"></td> | |
| 272 | - <td class="column-2" style="padding:2px;"></td> | |
| 273 | - </tr> | |
| 274 | - <tr class="top-border"> | |
| 275 | - <th class="column-1" scope="row"><?php _e( 'Import tables', 'tablepress' ); ?>:</th> | |
| 276 | - <td class="column-2"><label for="import-wp-table-reloaded-tables"> <input type="checkbox" id="import-wp-table-reloaded-tables" name="import[wp_table_reloaded][tables]" value="true" checked="checked" /> <?php _e( 'Import all tables and their settings from WP-Table Reloaded.', 'tablepress' ); ?> <span class="description"><?php _e( '(recommended)', 'tablepress' ); ?></span></label></td> | |
| 277 | - </tr> | |
| 278 | - <tr class="bottom-border"> | |
| 279 | - <th class="column-1" scope="row"><?php _e( 'Import styling', 'tablepress' ); ?>:</th> | |
| 280 | - <td class="column-2"><label for="import-wp-table-reloaded-css"> <input type="checkbox" id="import-wp-table-reloaded-css" name="import[wp_table_reloaded][css]" value="true" checked="checked" /> <?php _e( 'Try to automatically convert the “Custom CSS” code from the “Plugin Options” screen of WP-Table Reloaded.', 'tablepress' ); ?></label></td> | |
| 281 | - </tr> | |
| 282 | - <tr class="top-border"> | |
| 283 | - <td class="column-1" scope="row"></td> | |
| 284 | - <td class="column-2"><input type="submit" value="<?php echo esc_attr_x( 'Import from WP-Table Reloaded', 'button', 'tablepress' ); ?>" class="button button-large" id="submit_wp_table_reloaded_import" name="submit_wp_table_reloaded_import" /></td> | |
| 285 | - </tr> | |
| 286 | -</tbody> | |
| 287 | -</table> | |
| 288 | - <?php | |
| 124 | + public function postbox_classes( array $classes ): array { | |
| 125 | + $classes[] = 'no-validation-highlighting'; | |
| 126 | + return $classes; | |
| 289 | 127 | } |
| 290 | 128 | |
| 291 | 129 | /** |
| 292 | - * Set the content for the WP feature pointer about the WP-Table Reloaded import feature. | |
| 130 | + * Prints the content of the "Automatic Periodic Table Import Screen" post meta box. | |
| 293 | 131 | * |
| 294 | - * @since 1.0.0 | |
| 132 | + * @since 2.2.0 | |
| 133 | + * | |
| 134 | + * @param array<string, mixed> $data Data for this screen. | |
| 135 | + * @param array<string, mixed> $box Information about the meta box. | |
| 136 | + * | |
| 137 | + * @phpstan-ignore missingType.return (The method is extended elsewhere and can't have type hints.) | |
| 295 | 138 | */ |
| 296 | - public function wp_pointer_tp100_wp_table_reloaded_import() { | |
| 297 | - if ( ! $this->data['wp_table_reloaded_installed'] ) { | |
| 298 | - return; | |
| 299 | - } | |
| 139 | + public function postbox_auto_import( /* array */ $data, /* array */ $box ) /* : void */ { | |
| 140 | + // 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. | |
| 300 | 141 | |
| 301 | - $content = '<h3>' . __( 'TablePress Feature: Import from WP-Table Reloaded', 'tablepress' ) . '</h3>'; | |
| 302 | - $content .= '<p>' . __( 'You can import your existing tables and “Custom CSS” from WP-Table Reloaded into TablePress.', 'tablepress' ) . '</p>'; | |
| 142 | + if ( tb_tp_fs()->is_free_plan() ) : | |
| 143 | + ?> | |
| 144 | + <p style="font-size:14px;"> | |
| 145 | + <span class="dashicons dashicons-info-outline"></span> | |
| 146 | + <strong><?php _e( 'Pro Tip:', 'tablepress' ); ?></strong> | |
| 147 | + <?php | |
| 148 | + /* translators: %1$s: URL to TablePress website, %2$s: Module name */ | |
| 149 | + 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' ) ); | |
| 150 | + ?> | |
| 151 | + </p> | |
| 152 | + <?php | |
| 153 | + endif; | |
| 154 | + } | |
| 303 | 155 | |
| 304 | - $this->admin_page->print_wp_pointer_js( 'tp100_wp_table_reloaded_import', '#tablepress_import-import-wp-table-reloaded', array( | |
| 305 | - 'content' => $content, | |
| 306 | - 'position' => array( 'edge' => 'bottom', 'align' => 'left', 'offset' => '16 -16' ), | |
| 307 | - ) ); | |
| 156 | + /** | |
| 157 | + * Sets the content for the WP feature pointer about the drag and drop import and format detection on the "Import" screen. | |
| 158 | + * | |
| 159 | + * @since 2.0.0 | |
| 160 | + */ | |
| 161 | + public function wp_pointer_tp20_import_drag_drop_detect_format(): void { | |
| 162 | + $content = '<h3>' . __( 'TablePress feature: Drag and Drop Import with Format Detection', 'tablepress' ) . '</h3>'; | |
| 163 | + $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>'; | |
| 164 | + | |
| 165 | + $this->print_wp_pointer_js( | |
| 166 | + 'tp20_import_drag_drop_detect_format', | |
| 167 | + '#tables-import-file-upload-dropzone span', | |
| 168 | + array( | |
| 169 | + 'content' => $content, | |
| 170 | + 'position' => array( 'edge' => 'bottom', 'align' => 'center' ), | |
| 171 | + ), | |
| 172 | + ); | |
| 308 | 173 | } |
| 309 | 174 | |
| 310 | 175 | } // class TablePress_Import_View |