Filter wpda_column_default
A filter named wpda_column_default was added to influence the layout of list table columns. The filter is not called on the first column to prevent links not being displayed correctly.
Example
function my_column_default(
$value,
$item,
$column_name,
$table_name,
$schema_name,
$wpda_list_columns,
$list_number,
$self
) {
if ( '' !== $value ) {
return $value;
}
if ( 'dutch' === $column_name ) {
return 'NL-' . $item[ $column_name ];
}
}
add_filter( 'wpda_column_default' , 'my_column_default' , 10 , 8 );
Note
You can use this filter in combination with action hook wpda_after_list_table to add interactive elements to your list tables.
Function declaration
wpda_column_default( $item, $column_name, $table_name, $schema_name, $wpda_list_columns, $list_number )
$value
Current column value
$item
Associative array containing the column name of all columns in the list table and their value
$column_name
Column name
$table_name
Database table name
$schema_name
Database (schema) name
$wpda_list_columns
Reference to column list (instance of class WPDA_List_Columns)
$list_number
Row number in the current list
$self
Calling WPDA_List_table object
Hi,
added the following to my theme functions.php:
function my_offers_custom_function ($item, $column_name) {
if (‘reference’ === $column_name) {
return $item[ $column_name ] . ‘.’;
}
}
add_filter(‘wpda_column_default’, ‘my_offers_custom_function’, 10, 2);
function my_offers_custom_elements() {
return “console.log(‘teste’);”;
}
add_action( ‘wpda_extend_list_table’, ‘my_offers_custom_elements’);
But it doesn’t add the ‘.’ to the end of the values in column reference.
And in the dev tools, doesn’t show the console.log…
Can you provide some guidance, please? TY
The the console.log is wrapped in html script tag, but was parsed in the comment.
Hi Miguel,
The description of filter wpda_column_default was outdated. The filter takes 6 arguments. I updated the example and the function declaration. Hope this helps! Sorry…
Action hook wpda_extend_list_table is just meant to add content, scripts or styles below your list table. I guess it works when you put the console.log in a script tag. Like this:
function my_offers_custom_elements() {
return ““;
}
add_action( ‘wpda_extend_list_table’, ‘my_offers_custom_elements’ );
Best regards,
Peter
Looks like my script tag was deleted… 🙂 New attempt:
function my_offers_custom_elements() {
return “< s c r i p t >console.log(‘teste’);< / s c r i p t >”;
}
Don’t forget to remove the spaces and change the quotes and the double quotes…