$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>How can I apply a WP filter on specific plugin version|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

How can I apply a WP filter on specific plugin version

matteradmin9PV0评论

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

Post a comment

comment list (0)

  1. No comments so far