In case you are right here to looking for wordpress
get_plugin_version and show by way of plugin_row_meta then you’re at proper place
we are going to see right here let’s begin it.
1. Outline
the get_plugin_version() operate:
PHP
operate my_plugin_version() {
// Retrieve
the plugin’s model quantity from the plugin header
$plugin_data
= get_plugin_data( __FILE__ );
return $plugin_data[‘Version’];
}
2. Use plugin_row_meta() to show the model quantity:
PHP
operate my_plugin_row_meta( $plugin_meta, $plugin_file
) {
// Verify if
the present plugin file matches the one you need to show the model for
if ( $plugin_file
== plugin_basename( __FILE__ ) ) {
// Add
the model quantity to the plugin row metadata
$plugin_meta[]
= sprintf( __( ‘Model: %s’, ‘my-plugin’ ), my_plugin_version() );
}
return $plugin_meta;
}
add_filter( ‘plugin_row_meta’, ‘my_plugin_row_meta’, 10,
2 );
Clarification:
- The get_plugin_version() operate retrieves the
plugin’s model quantity from the plugin header utilizing get_plugin_data(). - The my_plugin_row_meta() operate checks if the present
plugin file matches the one you need to show the model for. - If it matches, the operate
provides the model quantity to the plugin row metadata utilizing sprintf(). - The add_filter() operate hooks the my_plugin_row_meta() operate into the plugin_row_meta filter, making certain that the
model quantity is displayed within the plugin listing.
Key Factors:
- Substitute __FILE__ with the precise path to your
plugin file. - Substitute ‘my-plugin’ with the textual content area of your
plugin. - Regulate the filter precedence (10)
if wanted to regulate the order by which the model quantity is displayed.
By following
these steps, you’ll efficiently show the plugin’s model quantity within the
plugin listing inside your WordPress admin space. If you wish to see extra associated articles then hold studying saeeddeveloper web site 🙂
Thanks for studying 🙂