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

Iranian hackers act as brokers promoting vital infrastructure entry

Iranian hackers are breaching vital infrastructure organizations to gather...

North Korean ScarCruft Exploits Home windows Zero-Day to Unfold RokRAT Malware

î ‚Oct 16, 2024î „Ravie LakshmananZero-Day / Home windows Safety The North...

Google: 70% of exploited flaws disclosed in 2023 have been zero-days

Mandiant safety analysts warn of a worrying new pattern...

10 Greatest Challenge Portfolio Administration (PPM) Software program for 2024

Challenge portfolio administration (PPM) assists managers in figuring out...

SolarWinds Net Assist Desk flaw is now exploited in assaults

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