| @@ -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 | } |
| @@ -300,9 +309,10 @@ | ||
| 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>'; |
| @@ -518,9 +528,9 @@ | ||
| 518 | 528 | // Pre-define some view data. |
| 519 | 529 | $data = array( |
| 520 | 530 | 'view_actions' => $this->view_actions, |
| 521 | 531 | 'message' => ( ! empty( $_GET['message'] ) ) ? $_GET['message'] : false, |
| 522 | - 'error_details' => ( ! empty( $_GET['error_details'] ) ) ? rawurldecode( wp_unslash( $_GET['error_details'] ) ) : '', | |
| 532 | + 'error_details' => ( ! empty( $_GET['error_details'] ) ) ? $_GET['error_details'] : '', | |
| 523 | 533 | 'site_used_editor' => TablePress::site_used_editor(), |
| 524 | 534 | ); |
| 525 | 535 | |
| 526 | 536 | // Depending on the action, load more necessary data for the corresponding view. |
| @@ -525,9 +535,9 @@ | ||
| 525 | 535 | |
| 526 | 536 | // Depending on the action, load more necessary data for the corresponding view. |
| 527 | 537 | switch ( $action ) { |
| 528 | 538 | case 'list': |
| 529 | - $data['table_id'] = ( isset( $_GET['table_id'] ) ) ? preg_replace( '/[^a-zA-Z0-9_-]/', '', $_GET['table_id'] ) : false; | |
| 539 | + $data['table_id'] = ( ! empty( $_GET['table_id'] ) ) ? $_GET['table_id'] : false; | |
| 530 | 540 | // Prime the post meta cache for cached loading of last_editor. |
| 531 | 541 | $data['table_ids'] = TablePress::$model_table->load_all( true ); |
| 532 | 542 | $data['messages']['donation_nag'] = $this->maybe_show_donation_message(); |
| 533 | 543 | $data['messages']['first_visit'] = ! $data['messages']['donation_nag'] && TablePress::$model_options->get( 'message_first_visit' ); |
| @@ -570,9 +580,9 @@ | ||
| 570 | 580 | $data['frontend_options']['custom_css'] = TablePress::$model_options->get( 'custom_css' ); |
| 571 | 581 | $data['user_options']['parent_page'] = TablePress::$controller->parent_page; |
| 572 | 582 | break; |
| 573 | 583 | case 'edit': |
| 574 | - if ( ! isset( $_GET['table_id'] ) || ! preg_match( '/^[a-zA-Z0-9_-]+$/', $_GET['table_id'] ) ) { | |
| 584 | + if ( empty( $_GET['table_id'] ) ) { | |
| 575 | 585 | TablePress::redirect( array( 'action' => 'list', 'message' => 'error_no_table' ) ); |
| 576 | 586 | } |
| 577 | 587 | // Load table, with table data, options, and visibility settings. |
| 578 | 588 | $data['table'] = TablePress::$model_table->load( $_GET['table_id'], true, true ); |
| @@ -601,9 +611,9 @@ | ||
| 601 | 611 | |
| 602 | 612 | $data['tables'][ $table['id'] ] = $table['name']; |
| 603 | 613 | } |
| 604 | 614 | $data['tables_count'] = TablePress::$model_table->count_tables(); |
| 605 | - $data['export_ids'] = ( isset( $_GET['table_id'] ) && preg_match( '/^[,a-zA-Z0-9_-]+$/', $_GET['table_id'] ) ) ? explode( ',', $_GET['table_id'] ) : array(); | |
| 615 | + $data['export_ids'] = ( ! empty( $_GET['table_id'] ) ) ? explode( ',', $_GET['table_id'] ) : array(); | |
| 606 | 616 | $exporter = TablePress::load_class( 'TablePress_Export', 'class-export.php', 'classes' ); |
| 607 | 617 | $data['zip_support_available'] = $exporter->zip_support_available; |
| 608 | 618 | $data['export_formats'] = $exporter->export_formats; |
| 609 | 619 | $data['csv_delimiters'] = $exporter->csv_delimiters; |
| @@ -631,13 +641,13 @@ | ||
| 631 | 641 | $data['table_ids'] = $table_ids; // Backward compatibility for the retired "Table Auto Update" Extension, which still relies on this variable name. |
| 632 | 642 | $data['tables_count'] = TablePress::$model_table->count_tables(); |
| 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 | - $data['import_existing_table'] = $_GET['import_existing_table'] ?? ''; | |
| 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'] ) ) { |
| @@ -1244,9 +1254,9 @@ | ||
| 1244 | 1254 | * |
| 1245 | 1255 | * @since 1.0.0 |
| 1246 | 1256 | */ |
| 1247 | 1257 | public function handle_get_action_hide_message(): void { |
| 1248 | - $message_item = $_GET['item'] ?? ''; | |
| 1258 | + $message_item = ! empty( $_GET['item'] ) ? $_GET['item'] : ''; | |
| 1249 | 1259 | TablePress::check_nonce( 'hide_message', $message_item ); |
| 1250 | 1260 | |
| 1251 | 1261 | if ( ! current_user_can( 'tablepress_list_tables' ) ) { |
| 1252 | 1262 | wp_die( __( 'Sorry, you are not allowed to access this page.', 'default' ), 403 ); |