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.
$seoboosterpropluginfo=get_plugin_data(__FILE__); $version=$seoboosterpropluginfo['Version']; echo "I'm running v. $version";
- wordpress get_plugin_data