From aaefb3b5d5ef6e2df5d433d729759d923f7af576 Mon Sep 17 00:00:00 2001 From: barryhughes <3594411+barryhughes@users.noreply.github.com> Date: Thu, 5 May 2022 02:39:03 +0000 Subject: [PATCH] Per existing order admin list, hide various columns by default. --- .../src/Internal/Admin/Orders/ListTable.php | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/plugins/woocommerce/src/Internal/Admin/Orders/ListTable.php b/plugins/woocommerce/src/Internal/Admin/Orders/ListTable.php index 841fb329cc3..4d3671ed371 100644 --- a/plugins/woocommerce/src/Internal/Admin/Orders/ListTable.php +++ b/plugins/woocommerce/src/Internal/Admin/Orders/ListTable.php @@ -6,6 +6,7 @@ use Automattic\WooCommerce\Internal\DataStores\Orders\OrdersTableDataStore; use WC_Order; use WC_Order_Data_Store_Interface; use WP_List_Table; +use WP_Screen; /** * Admin list table for orders as managed by the OrdersTableDataStore. @@ -34,6 +35,7 @@ class ListTable extends WP_List_Table { public function setup(): void { add_filter( 'manage_woocommerce_page_wc-orders_columns', array( $this, 'get_columns' ) ); add_filter( 'set_screen_option_edit_orders_per_page', array( $this, 'set_items_per_page' ), 10, 3 ); + add_filter( 'default_hidden_columns', array( $this, 'default_hidden_columns' ), 10, 2 ); $this->items_per_page(); set_screen_options(); } @@ -328,6 +330,29 @@ class ListTable extends WP_List_Table { ); } + /** + * Specify the columns we wish to hide by default. + * + * @param array $hidden Columns set to be hidden. + * @param WP_Screen $screen Screen object. + * + * @return array + */ + public function default_hidden_columns( array $hidden, WP_Screen $screen ) { + if ( isset( $screen->id ) && 'woocommerce_page_wc-orders' === $screen->id ) { + $hidden = array_merge( + $hidden, + array( + 'billing', + 'ship_to', + 'actions', + ) + ); + } + + return $hidden; + } + /** * Checklist column, used for selecting items for processing by a bulk action. *