You need to know the version of your plugin in your code. How do you do that? Maybe a constant, maybe a hard-coded string somewhere. Whichever way you go, you have at least 2 places where the plugin version lives: your hard-coded string/constant/whatever, and the plugin header used by WordPress. Updating things in more than one place is a pain.
Use the get_file_data()
function to retrieve information about your plugin. Then use that in your code instead of hard-coding the value. BAM, only one place to update the version.
Why not use get_plugin_data()
instead?
That function is only loaded inside the /wp-admin/
section of the dashboard, while get_file_data()
is loaded everywhere.