| @@ -123,10 +123,10 @@ | ||
| 123 | 123 | $slug = 'tablepress'; |
| 124 | 124 | if ( 'list' !== $action ) { |
| 125 | 125 | $slug .= '_' . $action; |
| 126 | 126 | } |
| 127 | - /* translators: %1$s: Page title, %2$s: Plugin name (TablePress) */ | |
| 128 | - $page_hook = add_submenu_page( 'tablepress', sprintf( __( '%1$s ‹ %2$s', 'tablepress' ), $entry['page_title'], 'TablePress' ), $entry['admin_menu_title'], $entry['required_cap'], $slug, $callback ); // @phpstan-ignore argument.type, argument.type | |
| 127 | + // @phpstan-ignore argument.type, argument.type | |
| 128 | + $page_hook = add_submenu_page( 'tablepress', sprintf( __( '%1$s ‹ %2$s', 'tablepress' ), $entry['page_title'], 'TablePress' ), $entry['admin_menu_title'], $entry['required_cap'], $slug, $callback ); | |
| 129 | 129 | if ( false !== $page_hook ) { |
| 130 | 130 | $this->page_hooks[] = $page_hook; |
| 131 | 131 | } |
| 132 | 132 | } |
| @@ -186,8 +186,17 @@ | ||
| 186 | 186 | * |
| 187 | 187 | * @since 2.2.0 |
| 188 | 188 | */ |
| 189 | 189 | public function enqueue_block_editor_assets(): void { |
| 190 | + /* | |
| 191 | + * Register the `react-jsx-runtime` polyfill, if it is not already registered. | |
| 192 | + * This is needed as a polyfill for WP < 6.6, and can be removed once WP 6.6 is the minimum requirement for TablePress. | |
| 193 | + */ | |
| 194 | + if ( ! wp_script_is( 'react-jsx-runtime', 'registered' ) ) { | |
| 195 | + wp_register_script( 'react-jsx-runtime', plugins_url( 'admin/js/react-jsx-runtime.min.js', TABLEPRESS__FILE__ ), array( 'react' ), TablePress::version, true ); | |
| 196 | + } | |
| 197 | + | |
| 198 | + // Add table information for the block editor to the page. | |
| 190 | 199 | $handle = generate_block_asset_handle( 'tablepress/table', 'editorScript' ); |
| 191 | 200 | $data = $this->get_block_editor_data(); |
| 192 | 201 | wp_add_inline_script( $handle, $data, 'before' ); |
| 193 | 202 | } |
| @@ -295,14 +304,15 @@ | ||
| 295 | 304 | return; |
| 296 | 305 | } |
| 297 | 306 | |
| 298 | 307 | // Only load the toolbar integration if the Block Editor is not used. |
| 299 | - if ( 'block' === TablePress::site_used_editor() ) { | |
| 308 | + if ( TablePress::site_uses_block_editor() ) { | |
| 300 | 309 | return; |
| 301 | 310 | } |
| 302 | 311 | |
| 303 | 312 | add_thickbox(); // The files are usually already loaded by media upload functions. |
| 304 | - TablePress::enqueue_script( | |
| 313 | + $admin_page = TablePress::load_class( 'TablePress_Admin_Page', 'class-admin-page-helper.php', 'classes' ); | |
| 314 | + $admin_page->enqueue_script( | |
| 305 | 315 | 'quicktags-button', |
| 306 | 316 | array( 'quicktags', 'media-upload' ), |
| 307 | 317 | array( |
| 308 | 318 | 'editor_button' => array( |
| @@ -453,9 +463,9 @@ | ||
| 453 | 463 | if ( tb_tp_fs()->is_free_plan() ) { |
| 454 | 464 | echo '<p style="font-size:14px;">'; |
| 455 | 465 | _e( 'This TablePress Extension was retired.', 'tablepress' ); |
| 456 | 466 | echo ' '; |
| 457 | - _e( '<strong>The plugin does no longer work</strong> and will no longer receive updates or support!', 'tablepress' ); | |
| 467 | + _e( '<strong>The plugin does no longer work with TablePress 3</strong> and will no longer receive updates or support!', 'tablepress' ); | |
| 458 | 468 | echo '<br>'; |
| 459 | 469 | _e( 'Keeping it activated can lead to errors on your website!', 'tablepress' ); |
| 460 | 470 | echo ' <strong>' . sprintf( __( '<a href="%s">Find out what you can do to continue using its features!</a>', 'tablepress' ), 'https://tablepress.org/upgrade-extensions/?utm_source=plugin&utm_medium=textlink&utm_content=plugins-list-table' ) . '</strong>'; |
| 461 | 471 | echo '</p>'; |
| @@ -516,12 +526,12 @@ | ||
| 516 | 526 | } |
| 517 | 527 | |
| 518 | 528 | // Pre-define some view data. |
| 519 | 529 | $data = array( |
| 520 | - 'view_actions' => $this->view_actions, | |
| 521 | - 'message' => ( ! empty( $_GET['message'] ) ) ? $_GET['message'] : false, | |
| 522 | - 'error_details' => ( ! empty( $_GET['error_details'] ) ) ? rawurldecode( wp_unslash( $_GET['error_details'] ) ) : '', | |
| 523 | - 'site_used_editor' => TablePress::site_used_editor(), | |
| 530 | + 'view_actions' => $this->view_actions, | |
| 531 | + 'message' => ( ! empty( $_GET['message'] ) ) ? $_GET['message'] : false, | |
| 532 | + 'error_details' => ( ! empty( $_GET['error_details'] ) ) ? $_GET['error_details'] : '', | |
| 533 | + 'site_uses_block_editor' => TablePress::site_uses_block_editor(), | |
| 524 | 534 | ); |
| 525 | 535 | |
| 526 | 536 | // Depending on the action, load more necessary data for the corresponding view. |
| 527 | 537 | switch ( $action ) { |
| @@ -633,11 +643,11 @@ | ||
| 633 | 643 | $importer = TablePress::load_class( 'TablePress_Import', 'class-import.php', 'classes' ); |
| 634 | 644 | $data['import_type'] = ( ! empty( $_GET['import_type'] ) ) ? $_GET['import_type'] : 'add'; |
| 635 | 645 | $data['import_existing_table'] = ( ! empty( $_GET['import_existing_table'] ) ) ? $_GET['import_existing_table'] : ''; |
| 636 | 646 | $data['import_source'] = ( ! empty( $_GET['import_source'] ) ) ? $_GET['import_source'] : 'file-upload'; |
| 637 | - $data['import_url'] = ( ! empty( $_GET['import_url'] ) ) ? rawurldecode( wp_unslash( $_GET['import_url'] ) ) : 'https://'; | |
| 638 | - $data['import_server'] = ( ! empty( $_GET['import_server'] ) ) ? rawurldecode( wp_unslash( $_GET['import_server'] ) ) : ABSPATH; | |
| 639 | - $data['import_form-field'] = ( ! empty( $_GET['import_form-field'] ) ) ? rawurldecode( wp_unslash( $_GET['import_form-field'] ) ) : ''; | |
| 647 | + $data['import_url'] = ( ! empty( $_GET['import_url'] ) ) ? wp_unslash( $_GET['import_url'] ) : 'https://'; | |
| 648 | + $data['import_server'] = ( ! empty( $_GET['import_server'] ) ) ? wp_unslash( $_GET['import_server'] ) : ABSPATH; | |
| 649 | + $data['import_form-field'] = ( ! empty( $_GET['import_form-field'] ) ) ? wp_unslash( $_GET['import_form-field'] ) : ''; | |
| 640 | 650 | $data['legacy_import'] = ( ! empty( $_GET['legacy_import'] ) ) ? $_GET['legacy_import'] : 'false'; |
| 641 | 651 | break; |
| 642 | 652 | } |
| 643 | 653 | |
| @@ -1210,9 +1220,9 @@ | ||
| 1210 | 1220 | 'import_source' => $import_config['source'], |
| 1211 | 1221 | 'legacy_import' => $import_config['legacy_import'], |
| 1212 | 1222 | ); |
| 1213 | 1223 | if ( in_array( $import_config['source'], array( 'url', 'server' ), true ) ) { |
| 1214 | - $redirect_parameters[ "import_{$import_config['source']}" ] = rawurlencode( $import_config[ $import_config['source'] ] ); | |
| 1224 | + $redirect_parameters[ "import_{$import_config['source']}" ] = $import_config[ $import_config['source'] ]; | |
| 1215 | 1225 | } |
| 1216 | 1226 | if ( is_wp_error( $import ) ) { |
| 1217 | 1227 | $redirect_parameters['error_details'] = TablePress::get_wp_error_string( $import ); |
| 1218 | 1228 | } elseif ( 0 < count( $import['errors'] ) ) { |
| @@ -1382,12 +1392,12 @@ | ||
| 1382 | 1392 | $render_options['html_id'] = "tablepress-{$table['id']}"; |
| 1383 | 1393 | $render_options['block_preview'] = true; |
| 1384 | 1394 | $_render->set_input( $table, $render_options ); |
| 1385 | 1395 | $view_data = array( |
| 1386 | - 'table_id' => $table_id, | |
| 1387 | - 'head_html' => $_render->get_preview_css(), | |
| 1388 | - 'body_html' => $_render->get_output( 'html' ), | |
| 1389 | - 'site_used_editor' => TablePress::site_used_editor(), | |
| 1396 | + 'table_id' => $table_id, | |
| 1397 | + 'head_html' => $_render->get_preview_css(), | |
| 1398 | + 'body_html' => $_render->get_output( 'html' ), | |
| 1399 | + 'site_uses_block_editor' => TablePress::site_uses_block_editor(), | |
| 1390 | 1400 | ); |
| 1391 | 1401 | |
| 1392 | 1402 | $custom_css = TablePress::$model_options->get( 'custom_css' ); |
| 1393 | 1403 | $use_custom_css = ( TablePress::$model_options->get( 'use_custom_css' ) && '' !== $custom_css ); |