0

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 );

1 Answer 1

2

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 ;-)

2
  • Yes this is what I asked. Thanks. Instead of if( $file === 'akismet/akismet.php' ) I can also use if ( $data['Name'] == 'Akismet' ).
    – user28867
    Jun 13, 2013 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, 2013 at 12:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy