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 have the plugins list in 'wp-admin/plugins.php' page. For each plugin there is some meta info extracted by WP from each plugin file:

 /*
 * Plugin Name: somename
 * Version: 1.2.3 
 */ 

I want to filter the version of a plugin, to show it in the plugins list, but not to modify the plugin file, just filter the version value.

Update:

<?php
/*
 * Plugin Name: aTestPlugin
 * Version: old.version
 * Description: This plugin is just for testing purpose.
 * Plugin URI: http://wordpress.org/extend/plugins/atestplugin/
 * Author: mario
 * Author URI: http://www.atestplugin.example/
 */

function atestplugin_plugin_row_meta($meta, $file, $data, $status) { 
    // do some filtering ...
    if ( $data['Name'] == 'aTestPlugin' )
        $meta[0] = 'new.version';

    return $meta;
}
add_filter('plugin_row_meta', 'atestplugin_plugin_row_meta', 10, 4 );
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Maybe you are looking for the plugin_row_meta filter, where you could add a custom filter like this one:

add_filter('plugin_row_meta', 'custom_plugin_row_meta', 10, 4 );
function custom_plugin_row_meta($meta, $file, $data, $status) { 
    //
    // do some filtering on the version text of the Akismet plugin
    //
    if( $file === 'akismet/akismet.php' )
        // $meta[0] = "Version 3.14159265359"; // BAD
        $meta[0] = sprintf( '<strong>%s</strong>', $meta[0] ); // BETTER

    return $meta;
}

where we target the version text of the Akismet plugin as an example.

Before: before

After (with bolded version text): after

ps: It could be very confusing to the user if you are going to modify the displayed version number of a plugin! So I hope you are only making cosmetic changes to it ;-)

share|improve this answer
    
Yes this is what I asked. Thanks. Instead of if( $file === 'akismet/akismet.php' ) I can also use if ( $data['Name'] == 'Akismet' ). –  Mario Jun 13 '13 at 12:08
    
ok great, you better post the code in the question ... or adjust it in the comment text as you just did ;-) –  birgire Jun 13 '13 at 12:11
add comment

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.