I recently came across that error when trying to install and activate a plugin on my self-hosted WordPress sites. The message simply said: „The plugin does not have a valid header“ Unfortunately, it was not really helpful to debug the problem. What made it even more mystifying was the fact that the plugin could still be activated from the list of plugins, but not directly after installation.
This problem is often caused by a wrong folder structure in the plugin – for example if the plugin’s main file is placed in a second level under the „wp-content/plugins/“ directory:
wp-content/plugins/my-plugin/my-plugin/ (files here)
In that case it helps to move everything up by one level:
wp-content/plugins/my-plugin/ (files here)
That, however, was not the case here. After some searching I found that the headers of some PHP files hidden in the sub-folders of the plugin looked similar to the mandatory header of plugin main files:
/* Plugin Name: ... Plugin URI: ... Author: ... ...
WordPress seemed to assume that one of those files was the actual main plugin file.
I fixed the issue by going through all files and changing the format of the headers to something that wouldn’t confuse the installer. Afterwards, the installation needed to be repeated from the start with the correct files.
Photo by transitpeople