How to get plugin data programatically – get_plugin_data

A really great and clever little function in WordPress I only just recently discovered is the get_plugin_data function. This function will return the data you enter into the header of your WordPress plugin, so you can use a clever template structure for when you create new plugins.

The plugin will return an array of the following information:

‘Name’ – Name of the plugin, must be unique.
‘Title’ – Title of the plugin and the link to the plugin’s website.
‘Description’ – Description of what the plugin does and/or notes
from the author.
‘Author’ – The author’s name
‘AuthorURI’ – The author’s web site address.
‘Version’ – The plugin version number.
‘PluginURI’ – Plugin web site address.
‘TextDomain’ – Plugin’s text domain for localization.
‘DomainPath’ – Plugin’s relative directory path to .mo files.

So, if your plugin follows the proper structure expected of a WordPress plugin, you can dynamically get the information about your plugin. For instance, I use it to display the current version in the header of the Settings page in my plugins.

Previously, I could easily forget to change the version number all places where I use it, but now it is no problem.

Example:

$seoboosterpropluginfo=get_plugin_data(__FILE__);
$version=$seoboosterpropluginfo['Version'];
echo "I'm running v. $version";
Read also  Fastest FTP client for MacOS
Popular searches to this page
  • wordpress get_plugin_data

Free eBook - 

Guide to success with SEO

Join the newsletter for more interesting articles, discount code for SEO Booster Pro and much more.

Guide to success

with SEO 2018

FREE

We respect your privacy and do not share your details with others

Join our newsletter and get a free eBook, interesting articles, discount codes and much more.