wordpress get_plugin_version and show by way of plugin_row_meta

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’];

}

Wordpress get plugin and display via plugin

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:

  1. The get_plugin_version() operate retrieves the
    plugin’s model quantity from the plugin header utilizing
    get_plugin_data().
  2. The my_plugin_row_meta() operate checks if the present
    plugin file matches the one you need to show the model for.
  3. If it matches, the operate
    provides the model quantity to the plugin row metadata utilizing
    sprintf().
  4. 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 🙂 

Recent articles

SolarWinds Net Assist Desk flaw is now exploited in assaults

CISA has added three flaws to its 'Recognized Exploited...

North Korean Hackers Deploy Linux FASTCash Malware for ATM Cashouts

North Korean hackers goal Linux-based cost switches with new...

US disrupts Nameless Sudan DDoS operation, indicts 2 Sudanese brothers

America Division of Justice unsealed an indictment at present...

FIDO Alliance Drafts New Protocol to Simplify Passkey Transfers Throughout Totally different Platforms

î ‚Oct 16, 2024î „Ravie LakshmananKnowledge Privateness / Passwordless The FIDO Alliance...