Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm trying to add a column to plugin table screen using "manage_plugins_custom_column", but without success.

This extra column will show a custom value that was placed inside the plugin file.

I hope someone could help!

Thanks! Daniel

---------------- edit ----------------

This is the working code that creates the column "Version":

function add_plugins_column( $columns ) {
$columns = array(
"name" => __( 'Plugin', '' ),
"version" => __( 'Version', '' ),
"description" => __( 'Description', '' ),
);
return $columns;
} add_filter( 'manage_plugins_columns', 'add_plugins_column' );

function render_plugins_column( $column, $plugin_file, $plugin_data ) {
switch ($column) {
case "version": echo $plugin_data['Version']; break;
}
} add_action( 'manage_plugins_custom_column' , 'render_plugins_column', 10, 3 );
share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

First, you have to add the custom column to the plugin column names:

function wpa65189_add_plugins_column( $columns ) {
    $columns['wpa65189_column'] = 'wpa65189 Custom Column';
    return $columns;
}
add_filter( 'manage_plugins_columns', 'wpa65189_add_plugins_column' );

Then output your column data for your plugin:

function wpa65189_render_plugins_column( $column_name, $plugin_file, $plugin_data ) {
    if ( 'wpa65189_column' == $column_name && 'My Plugin Name' == $plugin_data['Name'] ) :
        echo 'My Plugin custom column data';
    endif;
}
add_action( 'manage_plugins_custom_column' , 'wpa65189_render_plugins_column', 10, 3 );
share|improve this answer
    
Thanks Milo! Your code works great! Just one more question: How can I show a plugin header information like version in this column? –  Daniel Sep 17 '12 at 17:59
    
$plugin_data array contains all the header info, for version echo $plugin_data['Version'] –  Milo Sep 17 '12 at 18:13
    
I already tried this, but doesn't work for me. My function looks like this: function render_plugins_column( $column ) { switch ($column) { case "version": echo $plugin_data['Version']; break; }} add_action( 'manage_plugins_custom_column' , 'render_plugins_column', 10, 3 ); –  Daniel Sep 17 '12 at 18:24
1  
$column will contain the name of any custom columns, your function doesn't work because there is no column named 'version' unless you add one. –  Milo Sep 17 '12 at 18:41
1  
your render_plugins_column function is missing the 2nd and 3rd arguments: render_plugins_column( $column, $plugin_file, $plugin_data ) –  Milo Sep 17 '12 at 19:13
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.