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

Adding multiple columns to the stream table using filters only display the last column correctly #1184

Closed
Nikschavan opened this issue Oct 1, 2020 · 1 comment · Fixed by #1185
Labels

Comments

@Nikschavan
Copy link
Contributor

Nikschavan commented Oct 1, 2020

Bug Report

All the columns before the last one just display the column title as the column value.

Here is a sample code which can be tried to reproduce this case -

add_filter(
	'wp_stream_list_table_columns',
	function ( array $columns ) : array {
		$columns['test_column_1'] = 'test_column_1';
		$columns['test_column_2'] = 'test_column_2';

		return $columns;
	}
);

add_filter(
	'wp_stream_insert_column_default_test_column_1',
	function ( string $column_name, \WP_Stream\Record $record ) : string {
		return 'test_column_1  - ' . $record->ID;
	},
	10,
	2
);

add_filter(
	'wp_stream_insert_column_default_test_column_2',
	function ( string $column_name, \WP_Stream\Record $record ) : string {
		return 'test_column_2 - ' . $record->ID;
	}
	,
	10,
	2
);

add_filter(
	'wp_stream_register_column_defaults',
	function ( array $new_columns ) : array {
		$new_columns[] = 'test_column_1';
		$new_columns[] = 'test_column_2';

		return $new_columns;
	}
);

In this snippet, I am adding two columns to the stream table but the first column only displays the column name test_column_1 in all the columns and the second column displays the correct value test_column_2 - <record-id>

Any ideas on how this can be fixed?

Expected Behavior

All columns that are added display the correct expected value.

Actual Behavior

Only the last column displays the correct value for the record.

@Nikschavan
Copy link
Contributor Author

Created a PR #1185 which fixes this issue

@Nikschavan Nikschavan changed the title Adding two columns multiple columns to the stream table using filters only display the last column correctly Adding multiple columns to the stream table using filters only display the last column correctly Oct 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants