WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Howdy, I recently cribbed W3TC to implement an "in-update" changelist display (very cool), in my plugin, but there's an awkward bit of code I'd prefer to avoid.

If you look at the top of this file, you'll see the following code:

define ( 'BMLT_CURRENT_VERSION', '2.1.16' ); // This needs to be kept in synch with the version above.

Ick. :P

That needs to be kept up to date, so the function can delta between your plugin, and the current stable version.

I have perused the Codex, and can't find it, but there has GOT to be an API function for getting the version of a plugin.

Any clues?

share|improve this question
up vote 3 down vote accepted

Here is an answer with some code that will do what you want it to do: Is there a way for a plug-in to get it's own version number?

share|improve this answer
I really appreciate that! – MAGNAWS May 25 '11 at 20:36

There is a function called get_plugin_data(). Try calling this from within the main plugin file if you need to:

$plugin_data = get_plugin_data( __FILE__ );
$plugin_version = $plugin_data['Version'];

But as is said in the answers to the other question, its better for performance to just define a PHP variable as you're doing.

share|improve this answer
Thanks! Hopefully, performance won't be a big deal, as this is only called once, and involves a curl call. I have just gotten into trouble from having multiple copies of the version number all over the place. – MAGNAWS May 25 '11 at 20:36
it doesn't seem to work. I get this warning Call to undefined function get_plugin_data(). – KeepMove Dec 5 '13 at 7:53
@AriSusanto Are you trying to use it on the front end? The WP plugin administration functions are only defined in the admin section. If you need to use this on the front end you'll have to include the file wp-admin/includes/plugin.php. – goldenapples Dec 6 '13 at 23:01
No, I use it on administration panel. – KeepMove Dec 7 '13 at 2:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.