PHP function to get WordPress plugin version

Wordpress Logo BlueSo you're working on a WordPress plugin and you want to get current plugin version using PHP for display inside your plugin settings or on your plugin front end. Hardcoding the plugin version and changing it every release is no fun so in this article I'm bringing you my little PHP function I use with my Quick Chat for WordPress plugin to get current plugin version.

As always with WordPress development you need to be extra careful with your PHP and Javascript function names so you should prefix your every function with your plugin name. So here is PHP function you can use inside your plugin PHP file to get plugin version:

function plugin_name_get_version() {
    $plugin_data = get_plugin_data( __FILE__ );
    $plugin_version = $plugin_data['Version'];
    return $plugin_version;
}

Keep in mind that get_plugin_data() is available only on site backend. I guess it needs no additional explanation. Enjoy!

DevGenii

A quality focused Magento specialized web development agency. Get in touch!

3 thoughts on “PHP function to get WordPress plugin version

  1. micky

    Thanks for really outstanding collection of these plugins. I am shocked that after being a WordPress blogger form past 4 years, I still did not know many of these, which are so interesting.I am definitely going to use them in my several news & niche blogs.Thanks again.

    Reply
    1. Marko Author

      Hello Marco,
      you can use quick-chat.css to define border, for example (I’m in hospital right now, writing this from my head so check it before using) “div.quick-chat-container{border: 1px solid #000}” without the quotes at the end of quick-chat.css.

      Regards!

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *