The table of plugins on the plugins admin screen uses WP_Plugins_List_Table
which extends the WP_List_Table
class. And there are hooks which you can use to modify the table columns, content, etc. Here are some of the hooks, which are relevant in your case:
-
plugin_row_meta
— allows you to add custom meta/content at the bottom of the “Description” column. -
manage_plugins_custom_column
— use this to display/echo
the content for a custom column. -
manage_plugins_columns
— allows you to add a custom column, but to make it sortable, you need to also add it using the hook below. Note: This hook is defined inwp-admin/includes/screen.php
. -
manage_plugins_sortable_columns
— this hook is defined in the parent list table class, and the hook allows you to add a sortable column.
Working Example
Preview
The Code
Note: The screen ID of the plugins admin screen (wp-admin/plugins.php
) is plugins
.
// Add the "Main File" column.
add_filter( 'manage_plugins_columns', 'my_add_main_file_column' );
function my_add_main_file_column( $columns ) {
$columns['main_file'] = 'Main File';
return $columns;
}
// Display the content for the "Main File" column.
add_action( 'manage_plugins_custom_column', 'my_the_main_file_column', 10, 2 );
function my_the_main_file_column( $column_name, $plugin_file ) {
if ( 'main_file' === $column_name ) {
echo $plugin_file;
}
}
// Add custom content in the "Description" column.
add_filter( 'plugin_row_meta', 'my_add_custom_plugin_meta' );
function my_add_custom_plugin_meta( $plugin_meta ) {
$plugin_meta[] = 'Custom data here';
return $plugin_meta;
}