Skip to content

Commit

Permalink
"column_default()" custom column support fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
kidunot89 committed Nov 25, 2020
1 parent 535e527 commit ebeb46b
Show file tree
Hide file tree
Showing 3 changed files with 737 additions and 270 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
22 changes: 9 additions & 13 deletions classes/class-list-table.php
Original file line number Diff line number Diff line change
Expand Up @@ -389,19 +389,14 @@ 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 ) {

// Set default value of column to column name.
if ( empty( $out ) ) {
$out = $column_name;
}

/**
* 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
Expand All @@ -410,19 +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 );
$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 ebeb46b

Please sign in to comment.