From e26bd5872e2bbb852e100be3c2fbe2320e98ba8b Mon Sep 17 00:00:00 2001 From: Piotr Delawski Date: Wed, 24 Jul 2024 16:49:37 +0200 Subject: [PATCH 1/3] Deprecate `wp_stream_register_column_defaults` filter --- classes/class-list-table.php | 52 +++++++++++++++++------------------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/classes/class-list-table.php b/classes/class-list-table.php index 64f8dddd7..68a036fdf 100644 --- a/classes/class-list-table.php +++ b/classes/class-list-table.php @@ -391,37 +391,33 @@ public function column_default( $item, $column_name ) { * Registers new Columns to be inserted into the table. The cell contents of this column is set * below with 'wp_stream_insert_column_default_' * - * @param array $new_columns Columns injected in the table. + * @since 3.5.1 + * @deprecated 4.0.1 Use the {@see 'wp_stream_list_table_columns'} filter instead. + * + * @param array $new_columns Columns injected in the table. * * @return array */ - $inserted_columns = apply_filters( 'wp_stream_register_column_defaults', array() ); - - if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) { - foreach ( $inserted_columns as $column_title ) { - /** - * If column title inserted via wp_stream_register_column_defaults ($column_title) exists - * among columns registered with get_columns ($column_name) and there is an action associated - * with this column, do the action - * - * Also, note that the action name must include the $column_title registered - * with wp_stream_register_column_defaults - */ - if ( $column_title === $column_name ) { - /** - * Allows for the addition of content under a specified column. - * - * @param string $out Column content. - * @param object $record Record with row content. - * @param string $column_name Column name. - * - * @return string - */ - $out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $out, $record, $column_name ); - break; - } - } - } + apply_filters_deprecated( + 'wp_stream_register_column_defaults', + array( array() ), + /* translators: %s is the Stream version number. It is part of a filter deprecation notice and is preceded by: "{hook_name} is deprecated since version %s of Stream". */ + sprintf( __( '%s of Stream', 'stream' ), '4.0.1' ), + 'wp_stream_list_table_columns', + __( 'Usage of this filter is redundant. Instead, define custom column name and title using the `wp_stream_list_table_columns` filter and provide the default value using the `wp_stream_insert_column_default_{$column_name}` filter.', 'stream' ) + ); + + /** + * Allows for the addition of content under a specified column. + * + * @param string $out Column content. + * @param object $record Record with row content. + * @param string $column_name Column name. + * + * @return string + */ + $out = (string) apply_filters( "wp_stream_insert_column_default_{$column_name}", $out, $record, $column_name ); + break; } $allowed_tags = wp_kses_allowed_html( 'post' ); From fb9033c5b8bbec6c0ada4769517334177fff7d1c Mon Sep 17 00:00:00 2001 From: Piotr Delawski Date: Thu, 25 Jul 2024 09:54:05 +0200 Subject: [PATCH 2/3] Refine deprecation notice --- classes/class-list-table.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-list-table.php b/classes/class-list-table.php index 68a036fdf..2ae9ad6b6 100644 --- a/classes/class-list-table.php +++ b/classes/class-list-table.php @@ -404,7 +404,7 @@ public function column_default( $item, $column_name ) { /* translators: %s is the Stream version number. It is part of a filter deprecation notice and is preceded by: "{hook_name} is deprecated since version %s of Stream". */ sprintf( __( '%s of Stream', 'stream' ), '4.0.1' ), 'wp_stream_list_table_columns', - __( 'Usage of this filter is redundant. Instead, define custom column name and title using the `wp_stream_list_table_columns` filter and provide the default value using the `wp_stream_insert_column_default_{$column_name}` filter.', 'stream' ) + __( 'This filter is being deprecated as it is redundant. You can define custom column names and titles using the `wp_stream_list_table_columns` filter then provide the value for the custom columns using the `wp_stream_insert_column_default_{$column_name}` filter.', 'stream' ) ); /** From 31bcb0f039ff852298bfd1a7573e5e8492eb0229 Mon Sep 17 00:00:00 2001 From: Piotr Delawski Date: Thu, 25 Jul 2024 10:11:35 +0200 Subject: [PATCH 3/3] Ensure list table layout fine even with custom columns added --- ui/css/admin.css | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ui/css/admin.css b/ui/css/admin.css index ec9e1b737..8acceff23 100644 --- a/ui/css/admin.css +++ b/ui/css/admin.css @@ -86,12 +86,15 @@ } .toplevel_page_wp_stream .column-date { - min-width: 10%; + width: 120px; white-space: nowrap; } .toplevel_page_wp_stream .column-date .timeago { - padding-right: 1em; + display: inline-block; + overflow: hidden; + text-overflow: ellipsis; + max-width: 100%; } .toplevel_page_wp_stream .column-user_id { @@ -102,6 +105,17 @@ width: auto; } +/* +Ensure the summary column is not squeezed if there are custom columns added. + +This is because columns width is set to 12% by default (above). Adding a single +custom column leaves less space for the auto-width summary column. Having 2 or +more custom columns squeezes the summary column to a narrow strip. +*/ +.toplevel_page_wp_stream :where(.wp-list-table tr:has(> *:nth-child(7))) .column-summary { + width: 30%; +} + .toplevel_page_wp_stream .column-ip { white-space: nowrap; overflow: hidden;