| @@ -8,18 +8,14 @@ | ||
| 8 | 8 | // phpcs:disable WordPress.Security.NonceVerification.Recommended, WordPress.Security.NonceVerification.Missing -- verified on page |
| 9 | 9 | namespace WPDataAccess\List_Table; |
| 10 | 10 | |
| 11 | 11 | use WPDataAccess\Connection\WPDADB; |
| 12 | -use WPDataAccess\Dashboard\WPDA_Dashboard; | |
| 13 | 12 | use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Exist; |
| 14 | -use WPDataAccess\Data_Dictionary\WPDA_Dictionary_Lists; | |
| 15 | 13 | use WPDataAccess\Data_Dictionary\WPDA_List_Columns; |
| 16 | 14 | use WPDataAccess\Macro\WPDA_Macro; |
| 17 | 15 | use WPDataAccess\Plugin_Table_Models\WPDA_CSV_Uploads_Model; |
| 18 | 16 | use WPDataAccess\Plugin_Table_Models\WPDA_Media_Model; |
| 19 | -use WPDataAccess\Utilities\WPDA_Import; | |
| 20 | 17 | use WPDataAccess\Utilities\WPDA_Message_Box; |
| 21 | -use WPDataAccess\Utilities\WPDA_Repository; | |
| 22 | 18 | use WPDataAccess\Wordpress_Original; |
| 23 | 19 | use WPDataAccess\WPDA; |
| 24 | 20 | use WPDataProjects\WPDP; |
| 25 | 21 | use WPDataAccess\Plugin_Table_Models\WPDA_Table_Settings_Model; |
| @@ -210,15 +206,8 @@ | ||
| 210 | 206 | */ |
| 211 | 207 | protected $column_headers; |
| 212 | 208 | |
| 213 | 209 | /** |
| 214 | - * Reference to import object | |
| 215 | - * | |
| 216 | - * @var WPDA_Import | |
| 217 | - */ | |
| 218 | - protected $wpda_import = null; | |
| 219 | - | |
| 220 | - /** | |
| 221 | 210 | * Child tab clicked (used for parent child relationships only) |
| 222 | 211 | * |
| 223 | 212 | * @var null |
| 224 | 213 | */ |
| @@ -366,9 +355,9 @@ | ||
| 366 | 355 | * |
| 367 | 356 | * A list of rows for a specific table is based on WordPress class WP_List_Table. |
| 368 | 357 | * |
| 369 | 358 | * WPDA_List_Table can be used to build list tables for views as well. View based list tables however, do not |
| 370 | - * support insert, update, delete, import and export actions. | |
| 359 | + * support insert, update, delete and export actions. | |
| 371 | 360 | * |
| 372 | 361 | * A table name is not the only thing we need to build a list table. We also need to have access to the |
| 373 | 362 | * table columns. If no table columns are provided execution is stopped as well. |
| 374 | 363 | * |
| @@ -403,10 +392,8 @@ | ||
| 403 | 392 | * 'allow_update' => (string) on|off |
| 404 | 393 | * |
| 405 | 394 | * 'allow_delete' => (string) on|off |
| 406 | 395 | * |
| 407 | - * 'allow_import' => (string) on|off | |
| 408 | - * | |
| 409 | 396 | * 'hide_navigation' => (boolean) |
| 410 | 397 | * |
| 411 | 398 | * 'default_where' => (string) |
| 412 | 399 | * |
| @@ -479,17 +466,8 @@ | ||
| 479 | 466 | } elseif ( WPDA::is_wpda_table( $this->table_name ) ) { |
| 480 | 467 | $this->subtitle = '<span class="dashicons dashicons-warning"></span> ' . WPDA::get_table_type_text( WPDA::TABLE_TYPE_WPDA ); |
| 481 | 468 | } |
| 482 | 469 | } |
| 483 | - if ( !(isset( $args['allow_import'] ) && 'off' === $args['allow_import']) ) { | |
| 484 | - try { | |
| 485 | - // Instantiate WPDA_Import. | |
| 486 | - $this->wpda_import = new WPDA_Import(( is_admin() ? "?page={$this->page}" : '' ), $this->schema_name, $this->table_name); | |
| 487 | - } catch ( \Exception $e ) { | |
| 488 | - // If import is turned off instantiation will fail. Handle is set to null (check in future calls). | |
| 489 | - $this->wpda_import = null; | |
| 490 | - } | |
| 491 | - } | |
| 492 | 470 | if ( isset( $args['bulk_export_enabled'] ) ) { |
| 493 | 471 | $this->bulk_export_enabled = $args['bulk_export_enabled']; |
| 494 | 472 | } |
| 495 | 473 | if ( isset( $args['search_box_enabled'] ) ) { |
| @@ -1349,12 +1327,8 @@ | ||
| 1349 | 1327 | * |
| 1350 | 1328 | * @see WPDA_List_Table::display() |
| 1351 | 1329 | */ |
| 1352 | 1330 | public function show() { |
| 1353 | - // Check for import requested. | |
| 1354 | - if ( null !== $this->wpda_import ) { | |
| 1355 | - $this->wpda_import->check_post(); | |
| 1356 | - } | |
| 1357 | 1331 | // Prepare list table items. |
| 1358 | 1332 | $this->prepare_items(); |
| 1359 | 1333 | // Show list table. |
| 1360 | 1334 | ?> |
| @@ -1428,12 +1402,8 @@ | ||
| 1428 | 1402 | <input type="text" name="_wpnonce" id="wpda_row_export_form__wpnonce" /> |
| 1429 | 1403 | </form> |
| 1430 | 1404 | </div> |
| 1431 | 1405 | <?php |
| 1432 | - // Add import container. | |
| 1433 | - if ( null !== $this->wpda_import ) { | |
| 1434 | - $this->wpda_import->add_container(); | |
| 1435 | - } | |
| 1436 | 1406 | // Add custom code before the list table. |
| 1437 | 1407 | do_action_ref_array( 'wpda_before_list_table', array($this) ); |
| 1438 | 1408 | // Prepare url. |
| 1439 | 1409 | if ( is_admin() ) { |
| @@ -1594,19 +1564,15 @@ | ||
| 1594 | 1564 | |
| 1595 | 1565 | /** |
| 1596 | 1566 | * Add button to page header |
| 1597 | 1567 | * |
| 1598 | - * By default "add new" and "import" buttons are added (depending on the settings). Overwrite this method to | |
| 1568 | + * "Add new" button is added (depending on the settings). Overwrite this method to | |
| 1599 | 1569 | * add your own buttons. |
| 1600 | 1570 | * |
| 1601 | 1571 | * @since 1.0.1 |
| 1602 | 1572 | */ |
| 1603 | 1573 | protected function add_header_button() { |
| 1604 | - if ( 'off' === $this->allow_insert ) { | |
| 1605 | - if ( null !== $this->wpda_import ) { | |
| 1606 | - $this->wpda_import->add_button(); | |
| 1607 | - } | |
| 1608 | - } else { | |
| 1574 | + if ( 'off' !== $this->allow_insert ) { | |
| 1609 | 1575 | // phpcs:ignore -- 8.1 proof |
| 1610 | 1576 | if ( WPDA::is_wpda_table( $this->table_name ) || ('on' === WPDA::get_option( WPDA::OPTION_BE_ALLOW_INSERT ) && count( $this->wpda_list_columns->get_table_primary_key() )) > 0 ) { |
| 1611 | 1577 | $storage_type = ( WPDA::is_wpda_table( $this->table_name ) ? __( 'respository', 'wp-data-access' ) : __( 'table', 'wp-data-access' ) ); |
| 1612 | 1578 | // Prepare url. |
| @@ -1645,22 +1611,11 @@ | ||
| 1645 | 1611 | <?php |
| 1646 | 1612 | echo esc_attr__( 'Add New', 'wp-data-access' ); |
| 1647 | 1613 | ?> |
| 1648 | 1614 | </button> |
| 1649 | - <?php | |
| 1650 | - // Add import button to title. | |
| 1651 | - if ( null !== $this->wpda_import ) { | |
| 1652 | - $this->wpda_import->add_button(); | |
| 1653 | - } | |
| 1654 | - ?> | |
| 1655 | 1615 | </div> |
| 1656 | 1616 | </form> |
| 1657 | 1617 | <?php |
| 1658 | - } else { | |
| 1659 | - // Add import button to title. | |
| 1660 | - if ( null !== $this->wpda_import ) { | |
| 1661 | - $this->wpda_import->add_button(); | |
| 1662 | - } | |
| 1663 | 1618 | } |
| 1664 | 1619 | } |
| 1665 | 1620 | } |
| 1666 | 1621 | |
| @@ -2631,8 +2586,11 @@ | ||
| 2631 | 2586 | * Add full export to CSV and JSON buttons |
| 2632 | 2587 | * Needs to be granted in project page configuration |
| 2633 | 2588 | */ |
| 2634 | 2589 | protected function add_full_table_downloads() { |
| 2590 | + if ( !WPDA::current_user_is_admin() ) { | |
| 2591 | + return; | |
| 2592 | + } | |
| 2635 | 2593 | } |
| 2636 | 2594 | |
| 2637 | 2595 | // Override to add arguments to CSV and JSON full table exports. |
| 2638 | 2596 | protected function add_full_table_downloads_add_args() { |