| @@ -111,10 +111,8 @@ | ||
| 111 | 111 | protected $edit_form_class; |
| 112 | 112 | |
| 113 | 113 | /** |
| 114 | 114 | * Reference to list table |
| 115 | - * | |
| 116 | - * @var WPDA_List_Table|WPDA_List_Table_Menu | |
| 117 | 115 | */ |
| 118 | 116 | protected $wpda_list_table; |
| 119 | 117 | |
| 120 | 118 | /** |
| @@ -509,33 +507,15 @@ | ||
| 509 | 507 | |
| 510 | 508 | /** |
| 511 | 509 | * Display list table |
| 512 | 510 | * |
| 513 | - * There are two type of list tables here: | |
| 514 | - * + List of tables in the WordPress database schema | |
| 515 | - * + List of rows in a specific table | |
| 516 | - * | |
| 517 | 511 | * A list of tables in the WordPress database schema is in fact a list of rows as well. The MySQL base table |
| 518 | 512 | * (which is in fact a view) used to show this information is 'information_schema.tables'. The list of tables |
| 519 | 513 | * contains a link to a list table for every table. |
| 520 | 514 | * |
| 521 | - * The list of rows is provided by class {@see WPDA_List_Table}. WPDA_List_Table extends WordPress class | |
| 522 | - * WP_List_Table. | |
| 523 | - * | |
| 524 | - * The list of tables is provided by class {@see WPDA_List_Table_Menu}. WPDA_List_Table_Menu extends class | |
| 525 | - * WPDA_List_Table. | |
| 526 | - * | |
| 527 | 515 | * @since 1.0.0 |
| 528 | - * | |
| 529 | - * @see WPDA_List_Table | |
| 530 | - * @see WPDA_List_Table_Menu | |
| 531 | 516 | */ |
| 532 | 517 | protected function display_list_table() { |
| 533 | - if ( '' === $this->table_name ) { | |
| 534 | - // List all tables in the database. | |
| 535 | - $this->list_table_class = 'WPDataAccess\\List_Table\\WPDA_List_Table_Menu'; | |
| 536 | - } | |
| 537 | - | |
| 538 | 518 | $args = array( |
| 539 | 519 | 'wpdaschema_name' => $this->schema_name, |
| 540 | 520 | 'table_name' => $this->table_name, |
| 541 | 521 | 'wpda_list_columns' => $this->wpda_list_columns, |
| @@ -603,168 +583,143 @@ | ||
| 603 | 583 | $this->set_screen_option(); |
| 604 | 584 | $screen = get_current_screen(); |
| 605 | 585 | |
| 606 | 586 | if ( is_object( $screen ) && $screen->id === $this->page_hook_suffix ) { |
| 607 | - if ( '' === $this->table_name ) { | |
| 608 | - // The WordPress Database Table List doesn't have a table_name at this stage. Use the base table | |
| 609 | - // defined in WPDA_List_Table_Menu instead. | |
| 610 | - $table_name = str_replace( '.', '_', WPDA_List_Table::LIST_BASE_TABLE ); | |
| 611 | - // Set default column display values for repository tables if screen options is activated | |
| 612 | - // for the first time | |
| 613 | - if ( is_admin() && | |
| 614 | - false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 615 | - ) { | |
| 616 | - $hidden = array( | |
| 617 | - 'create_time', | |
| 618 | - 'data_size', | |
| 619 | - 'index_size', | |
| 620 | - 'overhead', | |
| 621 | - 'table_collation', | |
| 622 | - ); | |
| 587 | + // Set default column display values for repository tables if screen options is activated | |
| 588 | + // for the first time | |
| 589 | + if ( WPDA_Design_Table_Model::get_base_table_name() === $this->table_name ) { | |
| 590 | + if ( is_admin() && | |
| 591 | + false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 592 | + ) { | |
| 593 | + $hidden = array( | |
| 594 | + 'wpda_table_design', | |
| 595 | + ); | |
| 623 | 596 | |
| 624 | - update_user_meta( | |
| 625 | - get_current_user_id(), | |
| 626 | - self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 627 | - $hidden | |
| 628 | - ); | |
| 629 | - } | |
| 630 | - } else { | |
| 631 | - // Set default column display values for repository tables if screen options is activated | |
| 632 | - // for the first time | |
| 633 | - if ( WPDA_Design_Table_Model::get_base_table_name() === $this->table_name ) { | |
| 634 | - if ( is_admin() && | |
| 635 | - false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 636 | - ) { | |
| 637 | - $hidden = array( | |
| 638 | - 'wpda_table_design', | |
| 639 | - ); | |
| 597 | + update_user_meta( | |
| 598 | + get_current_user_id(), | |
| 599 | + self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 600 | + $hidden | |
| 601 | + ); | |
| 602 | + } | |
| 603 | + } elseif ( WPDA_Publisher_Model::get_base_table_name() === $this->table_name ) { | |
| 604 | + if ( is_admin() && | |
| 605 | + false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 606 | + ) { | |
| 607 | + $hidden = array( | |
| 608 | + 'pub_table_name', | |
| 609 | + 'pub_column_names', | |
| 610 | + 'pub_sort_icons', | |
| 611 | + 'pub_styles', | |
| 612 | + 'pub_style_premium', | |
| 613 | + 'pub_style_user', | |
| 614 | + 'pub_style_color', | |
| 615 | + 'pub_style_space', | |
| 616 | + 'pub_style_corner', | |
| 617 | + 'pub_style_modal_width', | |
| 618 | + 'pub_responsive_popup_title', | |
| 619 | + 'pub_responsive_cols', | |
| 620 | + 'pub_responsive_type', | |
| 621 | + 'pub_responsive_modal_hyperlinks', | |
| 622 | + 'pub_responsive_icon', | |
| 623 | + 'pub_flat_scrollx', | |
| 624 | + 'pub_format', | |
| 625 | + 'pub_default_where', | |
| 626 | + 'pub_default_orderby', | |
| 627 | + 'pub_table_options_searching', | |
| 628 | + 'pub_table_options_ordering', | |
| 629 | + 'pub_table_options_paging', | |
| 630 | + 'pub_table_options_advanced', | |
| 631 | + 'pub_table_options_serverside', | |
| 632 | + 'pub_table_options_nl2br', | |
| 633 | + 'pub_show_advanced_settings', | |
| 634 | + 'pub_extentions', | |
| 635 | + 'pub_query', | |
| 636 | + 'pub_cpt', | |
| 637 | + 'pub_cpt_fields', | |
| 638 | + 'pub_cpt_query', | |
| 639 | + 'pub_cpt_format', | |
| 640 | + ); | |
| 640 | 641 | |
| 641 | - update_user_meta( | |
| 642 | - get_current_user_id(), | |
| 643 | - self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 644 | - $hidden | |
| 645 | - ); | |
| 646 | - } | |
| 647 | - } elseif ( WPDA_Publisher_Model::get_base_table_name() === $this->table_name ) { | |
| 648 | - if ( is_admin() && | |
| 649 | - false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 650 | - ) { | |
| 651 | - $hidden = array( | |
| 652 | - 'pub_table_name', | |
| 653 | - 'pub_column_names', | |
| 654 | - 'pub_sort_icons', | |
| 655 | - 'pub_styles', | |
| 656 | - 'pub_style_premium', | |
| 657 | - 'pub_style_user', | |
| 658 | - 'pub_style_color', | |
| 659 | - 'pub_style_space', | |
| 660 | - 'pub_style_corner', | |
| 661 | - 'pub_style_modal_width', | |
| 662 | - 'pub_responsive_popup_title', | |
| 663 | - 'pub_responsive_cols', | |
| 664 | - 'pub_responsive_type', | |
| 665 | - 'pub_responsive_modal_hyperlinks', | |
| 666 | - 'pub_responsive_icon', | |
| 667 | - 'pub_flat_scrollx', | |
| 668 | - 'pub_format', | |
| 669 | - 'pub_default_where', | |
| 670 | - 'pub_default_orderby', | |
| 671 | - 'pub_table_options_searching', | |
| 672 | - 'pub_table_options_ordering', | |
| 673 | - 'pub_table_options_paging', | |
| 674 | - 'pub_table_options_advanced', | |
| 675 | - 'pub_table_options_serverside', | |
| 676 | - 'pub_table_options_nl2br', | |
| 677 | - 'pub_show_advanced_settings', | |
| 678 | - 'pub_extentions', | |
| 679 | - 'pub_query', | |
| 680 | - 'pub_cpt', | |
| 681 | - 'pub_cpt_fields', | |
| 682 | - 'pub_cpt_query', | |
| 683 | - 'pub_cpt_format', | |
| 684 | - ); | |
| 642 | + update_user_meta( | |
| 643 | + get_current_user_id(), | |
| 644 | + self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 645 | + $hidden | |
| 646 | + ); | |
| 647 | + } | |
| 648 | + } elseif ( WPDP_Project_Model::get_base_table_name() === $this->table_name ) { | |
| 649 | + if ( is_admin() && | |
| 650 | + false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 651 | + ) { | |
| 652 | + $hidden = array( | |
| 653 | + 'project_description', | |
| 654 | + 'project_sequence', | |
| 655 | + ); | |
| 685 | 656 | |
| 686 | - update_user_meta( | |
| 687 | - get_current_user_id(), | |
| 688 | - self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 689 | - $hidden | |
| 690 | - ); | |
| 691 | - } | |
| 692 | - } elseif ( WPDP_Project_Model::get_base_table_name() === $this->table_name ) { | |
| 693 | - if ( is_admin() && | |
| 694 | - false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 695 | - ) { | |
| 696 | - $hidden = array( | |
| 697 | - 'project_description', | |
| 698 | - 'project_sequence', | |
| 699 | - ); | |
| 657 | + update_user_meta( | |
| 658 | + get_current_user_id(), | |
| 659 | + self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 660 | + $hidden | |
| 661 | + ); | |
| 700 | 662 | |
| 701 | - update_user_meta( | |
| 702 | - get_current_user_id(), | |
| 703 | - self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 704 | - $hidden | |
| 705 | - ); | |
| 663 | + // Set default columns for project pages | |
| 664 | + if ( false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . WPDP_Page_Model::get_base_table_name() ) ) { | |
| 665 | + $hidden = array( | |
| 666 | + 'project_id', | |
| 667 | + 'page_schema_name', | |
| 668 | + 'page_setname', | |
| 669 | + 'page_allow_insert', | |
| 670 | + 'page_allow_delete', | |
| 671 | + 'page_allow_import', | |
| 672 | + 'page_allow_bulk', | |
| 673 | + 'page_allow_full_export', | |
| 674 | + 'page_content', | |
| 675 | + 'page_title', | |
| 676 | + 'page_subtitle', | |
| 677 | + 'page_where', | |
| 678 | + 'page_orderby', | |
| 679 | + 'page_sequence', | |
| 680 | + ); | |
| 706 | 681 | |
| 707 | - // Set default columns for project pages | |
| 708 | - if ( false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . WPDP_Page_Model::get_base_table_name() ) ) { | |
| 709 | - $hidden = array( | |
| 710 | - 'project_id', | |
| 711 | - 'page_schema_name', | |
| 712 | - 'page_setname', | |
| 713 | - 'page_allow_insert', | |
| 714 | - 'page_allow_delete', | |
| 715 | - 'page_allow_import', | |
| 716 | - 'page_allow_bulk', | |
| 717 | - 'page_allow_full_export', | |
| 718 | - 'page_content', | |
| 719 | - 'page_title', | |
| 720 | - 'page_subtitle', | |
| 721 | - 'page_where', | |
| 722 | - 'page_orderby', | |
| 723 | - 'page_sequence', | |
| 724 | - ); | |
| 682 | + update_user_meta( | |
| 683 | + get_current_user_id(), | |
| 684 | + self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . WPDP_Page_Model::get_base_table_name(), | |
| 685 | + $hidden | |
| 686 | + ); | |
| 687 | + } | |
| 688 | + } | |
| 689 | + } elseif ( WPDP_Project_Design_Table_Model::get_base_table_name() === $this->table_name ) { | |
| 690 | + if ( is_admin() && | |
| 691 | + false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 692 | + ) { | |
| 693 | + $hidden = array(); | |
| 725 | 694 | |
| 726 | - update_user_meta( | |
| 727 | - get_current_user_id(), | |
| 728 | - self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . WPDP_Page_Model::get_base_table_name(), | |
| 729 | - $hidden | |
| 730 | - ); | |
| 731 | - } | |
| 732 | - } | |
| 733 | - } elseif ( WPDP_Project_Design_Table_Model::get_base_table_name() === $this->table_name ) { | |
| 734 | - if ( is_admin() && | |
| 735 | - false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 736 | - ) { | |
| 737 | - $hidden = array(); | |
| 695 | + update_user_meta( | |
| 696 | + get_current_user_id(), | |
| 697 | + self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 698 | + $hidden | |
| 699 | + ); | |
| 700 | + } | |
| 701 | + } elseif ( WPDA_CSV_Uploads_Model::get_base_table_name() === $this->table_name ) { | |
| 702 | + if ( is_admin() && | |
| 703 | + false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 704 | + ) { | |
| 705 | + $hidden = array( | |
| 706 | + 'csv_real_file_name', | |
| 707 | + 'csv_mapping', | |
| 708 | + 'csv_encoding', | |
| 709 | + ); | |
| 738 | 710 | |
| 739 | - update_user_meta( | |
| 740 | - get_current_user_id(), | |
| 741 | - self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 742 | - $hidden | |
| 743 | - ); | |
| 744 | - } | |
| 745 | - } elseif ( WPDA_CSV_Uploads_Model::get_base_table_name() === $this->table_name ) { | |
| 746 | - if ( is_admin() && | |
| 747 | - false === get_user_option( self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name ) | |
| 748 | - ) { | |
| 749 | - $hidden = array( | |
| 750 | - 'csv_real_file_name', | |
| 751 | - 'csv_mapping', | |
| 752 | - 'csv_encoding', | |
| 753 | - ); | |
| 711 | + update_user_meta( | |
| 712 | + get_current_user_id(), | |
| 713 | + self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 714 | + $hidden | |
| 715 | + ); | |
| 716 | + } | |
| 717 | + } | |
| 754 | 718 | |
| 755 | - update_user_meta( | |
| 756 | - get_current_user_id(), | |
| 757 | - self::HIDDENCOLUMNS_PREFIX . get_current_screen()->id . $table_name, | |
| 758 | - $hidden | |
| 759 | - ); | |
| 760 | - } | |
| 761 | - } | |
| 719 | + // Allow external user to store defaults through action hook wpda_default_screen_option. | |
| 720 | + do_action( 'wpda_default_screen_option', $this->table_name, $table_name ); | |
| 762 | 721 | |
| 763 | - // Allow external user to store defaults through action hook wpda_default_screen_option. | |
| 764 | - do_action( 'wpda_default_screen_option', $this->table_name, $table_name ); | |
| 765 | - } | |
| 766 | - | |
| 767 | 722 | // Add column selection |
| 768 | 723 | if ( false !== $this->child_request ) { |
| 769 | 724 | if ( WPDP_Page_Model::get_base_table_name() === $this->child_request ) { |
| 770 | 725 | $cols = WPDP_Project_Page_List::column_headers_labels(); |
| @@ -831,11 +786,9 @@ | ||
| 831 | 786 | * @return array |
| 832 | 787 | * @since 1.0.0 |
| 833 | 788 | */ |
| 834 | 789 | public function get_column_headers() { |
| 835 | - if ( '' === $this->table_name ) { | |
| 836 | - return WPDA_List_Table_Menu::column_headers_labels(); | |
| 837 | - } elseif ( WPDA_Design_Table_Model::get_base_table_name() === $this->table_name ) { | |
| 790 | + if ( WPDA_Design_Table_Model::get_base_table_name() === $this->table_name ) { | |
| 838 | 791 | return WPDA_Design_Table_List_Table::column_headers_labels(); |
| 839 | 792 | } elseif ( WPDA_Publisher_Model::get_base_table_name() === $this->table_name ) { |
| 840 | 793 | return WPDA_Publisher_List_Table::column_headers_labels(); |
| 841 | 794 | } elseif ( WPDP_Project_Model::get_base_table_name() === $this->table_name ) { |