How can I apply a WP filter on specific plugin version

admin2025-06-03  4

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: /
 * Author: mario
 * Author URI: /
 */

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

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/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 edited Feb 8, 2019 at 23:59 fuxia 107k39 gold badges255 silver badges461 bronze badges asked Jun 13, 2013 at 11:14 user28867user28867
Add a comment  | 

1 Answer 1

Reset to default 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:

After (with bolded version text):

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

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748928284a314896.html

最新回复(0)