Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use $column_name instead of $column_title and deprecate redundant filter #1519

Merged
merged 3 commits into from
Jul 25, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 24 additions & 28 deletions classes/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' )
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 chore: Please help me refine the copy here. I'm not sure if that sounds well (and correct in general).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe ...

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. 

);

/**
* 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 );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 note: This is where the main fix is: note the change from $column_title to $column_name in the hook name.

break;
}

$allowed_tags = wp_kses_allowed_html( 'post' );
Expand Down
Loading