PluginProbe
TablePress – Tables in WordPress made easy / 3.0
TablePress – Tables in WordPress made easy v3.0
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 | controllers/controller-admin.php +34 -25 trunk3.0 View file →
@@ -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 }
@@ -199,9 +208,9 @@
199 208 */
200 209 public function enqueue_block_assets(): void {
201 210 // Load the TablePress default CSS and the user's "Custom CSS" in the block editor iframe.
202 211 if ( is_admin() ) {
203 - TablePress::$controller->maybe_enqueue_css();
212 + TablePress::$controller->enqueue_css();
204 213 }
205 214 }
206 215
207 216 /**
@@ -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(
@@ -366,9 +376,9 @@
366 376
367 377 $wp_admin_bar->add_menu( array(
368 378 'parent' => 'new-content',
369 379 'id' => 'new-tablepress-table',
370 - 'title' => __( 'TablePress table', 'tablepress' ),
380 + 'title' => __( 'TablePress Table', 'tablepress' ),
371 381 'href' => TablePress::url( array( 'action' => 'add' ) ),
372 382 ) );
373 383 }
374 384
@@ -385,9 +395,8 @@
385 395 'tablepress-datatables-alphabetsearch/tablepress-datatables-alphabetsearch.php',
386 396 'tablepress-datatables-column-filter-widgets/tablepress-datatables-column-filter-widgets.php',
387 397 'tablepress-datatables-columnfilter/tablepress-datatables-columnfilter.php',
388 398 'tablepress-datatables-fixedcolumns/tablepress-datatables-fixedcolumns.php',
389 - 'tablepress-datatables-inverted-filter/tablepress-datatables-inverted-filter.php',
390 399 'tablepress-datatables-row-details/tablepress-datatables-row-details.php',
391 400 'tablepress-datatables-rowgroup/tablepress-datatables-rowgroup.php',
392 401 'tablepress-responsive-tables/tablepress-responsive-tables.php',
393 402 );
@@ -453,9 +462,9 @@
453 462 if ( tb_tp_fs()->is_free_plan() ) {
454 463 echo '<p style="font-size:14px;">';
455 464 _e( 'This TablePress Extension was retired.', 'tablepress' );
456 465 echo ' ';
457 - _e( '<strong>The plugin does no longer work</strong> and will no longer receive updates or support!', 'tablepress' );
466 + _e( '<strong>The plugin does no longer work with TablePress 3</strong> and will no longer receive updates or support!', 'tablepress' );
458 467 echo '<br>';
459 468 _e( 'Keeping it activated can lead to errors on your website!', 'tablepress' );
460 469 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 470 echo '</p>';
@@ -516,18 +525,18 @@
516 525 }
517 526
518 527 // Pre-define some view data.
519 528 $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(),
529 + 'view_actions' => $this->view_actions,
530 + 'message' => ( ! empty( $_GET['message'] ) ) ? $_GET['message'] : false,
531 + 'error_details' => ( ! empty( $_GET['error_details'] ) ) ? $_GET['error_details'] : '',
532 + 'site_uses_block_editor' => TablePress::site_uses_block_editor(),
524 533 );
525 534
526 535 // Depending on the action, load more necessary data for the corresponding view.
527 536 switch ( $action ) {
528 537 case 'list':
529 - $data['table_id'] = ( isset( $_GET['table_id'] ) ) ? preg_replace( '/[^a-zA-Z0-9_-]/', '', $_GET['table_id'] ) : false;
538 + $data['table_id'] = ( ! empty( $_GET['table_id'] ) ) ? $_GET['table_id'] : false;
530 539 // Prime the post meta cache for cached loading of last_editor.
531 540 $data['table_ids'] = TablePress::$model_table->load_all( true );
532 541 $data['messages']['donation_nag'] = $this->maybe_show_donation_message();
533 542 $data['messages']['first_visit'] = ! $data['messages']['donation_nag'] && TablePress::$model_options->get( 'message_first_visit' );
@@ -570,9 +579,9 @@
570 579 $data['frontend_options']['custom_css'] = TablePress::$model_options->get( 'custom_css' );
571 580 $data['user_options']['parent_page'] = TablePress::$controller->parent_page;
572 581 break;
573 582 case 'edit':
574 - if ( ! isset( $_GET['table_id'] ) || ! preg_match( '/^[a-zA-Z0-9_-]+$/', $_GET['table_id'] ) ) {
583 + if ( empty( $_GET['table_id'] ) ) {
575 584 TablePress::redirect( array( 'action' => 'list', 'message' => 'error_no_table' ) );
576 585 }
577 586 // Load table, with table data, options, and visibility settings.
578 587 $data['table'] = TablePress::$model_table->load( $_GET['table_id'], true, true );
@@ -601,9 +610,9 @@
601 610
602 611 $data['tables'][ $table['id'] ] = $table['name'];
603 612 }
604 613 $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();
614 + $data['export_ids'] = ( ! empty( $_GET['table_id'] ) ) ? explode( ',', $_GET['table_id'] ) : array();
606 615 $exporter = TablePress::load_class( 'TablePress_Export', 'class-export.php', 'classes' );
607 616 $data['zip_support_available'] = $exporter->zip_support_available;
608 617 $data['export_formats'] = $exporter->export_formats;
609 618 $data['csv_delimiters'] = $exporter->csv_delimiters;
@@ -631,13 +640,13 @@
631 640 $data['table_ids'] = $table_ids; // Backward compatibility for the retired "Table Auto Update" Extension, which still relies on this variable name.
632 641 $data['tables_count'] = TablePress::$model_table->count_tables();
633 642 $importer = TablePress::load_class( 'TablePress_Import', 'class-import.php', 'classes' );
634 643 $data['import_type'] = ( ! empty( $_GET['import_type'] ) ) ? $_GET['import_type'] : 'add';
635 - $data['import_existing_table'] = $_GET['import_existing_table'] ?? '';
644 + $data['import_existing_table'] = ( ! empty( $_GET['import_existing_table'] ) ) ? $_GET['import_existing_table'] : '';
636 645 $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'] ) ) : '';
646 + $data['import_url'] = ( ! empty( $_GET['import_url'] ) ) ? wp_unslash( $_GET['import_url'] ) : 'https://';
647 + $data['import_server'] = ( ! empty( $_GET['import_server'] ) ) ? wp_unslash( $_GET['import_server'] ) : ABSPATH;
648 + $data['import_form-field'] = ( ! empty( $_GET['import_form-field'] ) ) ? wp_unslash( $_GET['import_form-field'] ) : '';
640 649 $data['legacy_import'] = ( ! empty( $_GET['legacy_import'] ) ) ? $_GET['legacy_import'] : 'false';
641 650 break;
642 651 }
643 652
@@ -1210,9 +1219,9 @@
1210 1219 'import_source' => $import_config['source'],
1211 1220 'legacy_import' => $import_config['legacy_import'],
1212 1221 );
1213 1222 if ( in_array( $import_config['source'], array( 'url', 'server' ), true ) ) {
1214 - $redirect_parameters[ "import_{$import_config['source']}" ] = rawurlencode( $import_config[ $import_config['source'] ] );
1223 + $redirect_parameters[ "import_{$import_config['source']}" ] = $import_config[ $import_config['source'] ];
1215 1224 }
1216 1225 if ( is_wp_error( $import ) ) {
1217 1226 $redirect_parameters['error_details'] = TablePress::get_wp_error_string( $import );
1218 1227 } elseif ( 0 < count( $import['errors'] ) ) {
@@ -1244,9 +1253,9 @@
1244 1253 *
1245 1254 * @since 1.0.0
1246 1255 */
1247 1256 public function handle_get_action_hide_message(): void {
1248 - $message_item = $_GET['item'] ?? '';
1257 + $message_item = ! empty( $_GET['item'] ) ? $_GET['item'] : '';
1249 1258 TablePress::check_nonce( 'hide_message', $message_item );
1250 1259
1251 1260 if ( ! current_user_can( 'tablepress_list_tables' ) ) {
1252 1261 wp_die( __( 'Sorry, you are not allowed to access this page.', 'default' ), 403 );
@@ -1382,12 +1391,12 @@
1382 1391 $render_options['html_id'] = "tablepress-{$table['id']}";
1383 1392 $render_options['block_preview'] = true;
1384 1393 $_render->set_input( $table, $render_options );
1385 1394 $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(),
1395 + 'table_id' => $table_id,
1396 + 'head_html' => $_render->get_preview_css(),
1397 + 'body_html' => $_render->get_output( 'html' ),
1398 + 'site_uses_block_editor' => TablePress::site_uses_block_editor(),
1390 1399 );
1391 1400
1392 1401 $custom_css = TablePress::$model_options->get( 'custom_css' );
1393 1402 $use_custom_css = ( TablePress::$model_options->get( 'use_custom_css' ) && '' !== $custom_css );