Skip to content

Commit

Permalink
Merge pull request #1185 from Nikschavan/1184-custom-column-values
Browse files Browse the repository at this point in the history
Fix: column value getting overridden when multiple custom columns are added
  • Loading branch information
kidunot89 authored Jan 5, 2021
2 parents b8a08b5 + 1232b34 commit 687222a
Show file tree
Hide file tree
Showing 3 changed files with 702 additions and 315 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.env
.idea
.DS_Store
/node_modules/
Expand Down
18 changes: 9 additions & 9 deletions classes/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,11 @@ 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.
*
* @return array
*/
$new_columns = array();
$inserted_columns = apply_filters( 'wp_stream_register_column_defaults', $new_columns );
$inserted_columns = apply_filters( 'wp_stream_register_column_defaults', array() );

if ( ! empty( $inserted_columns ) && is_array( $inserted_columns ) ) {
foreach ( $inserted_columns as $column_title ) {
Expand All @@ -404,21 +405,20 @@ public function column_default( $item, $column_name ) {
* Also, note that the action name must include the $column_title registered
* with wp_stream_register_column_defaults
*/
if ( $column_title === $column_name && has_filter( "wp_stream_insert_column_default_{$column_title}" ) ) {
if ( $column_title === $column_name ) {
/**
* Allows for the addition of content under a specified column.
*
* @param object $record Contents of the row
* @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}", $column_name, $record );
} else {
$out = $column_name;
$out = apply_filters( "wp_stream_insert_column_default_{$column_title}", $out, $record, $column_name );
break;
}
}
} else {
$out = $column_name;
}
}

Expand Down
Loading

0 comments on commit 687222a

Please sign in to comment.