In this article, we will discuss all the possibilities because of which plugin activation error could occur and how to solve it. If you are getting the following error : “The plugin does not have a valid header.”
Then I am assuming that you have already set up WordPress in your system, know what plugins are, and probably already came across this error.

Table of Contents
What is this error?

function validate_plugin( $plugin ) {
if ( validate_file( $plugin ) ) {
return new WP_Error( 'plugin_invalid', __( 'Invalid plugin path.' ) );
}
if ( ! file_exists( WP_PLUGIN_DIR . '/' . $plugin ) ) {
return new WP_Error( 'plugin_not_found', __( 'Plugin file does not exist.' ) );
}
$installed_plugins = get_plugins();
if ( ! isset( $installed_plugins[ $plugin ] ) ) {
return new WP_Error( 'no_plugin_header', __( 'The plugin does not have a valid header.' ) );
}
return 0;
Why do you get the plugin does not have a valid header error?
It is easy to resolve this problem because why you got this problem in the first place is because of the reasons listed below:
• Installed a corrupted plugin.
• Wrong Folder structure.
• Caching problems.
How to overcome this error?
Starting from how you got the problem to is resolving strategies. There are two ways of installing a plugin:
• Directly installing the plugin on the WordPress Add Plugins page.
• Installing the plugin from other sites and then uploading the plugin in your WordPress.
It is the stage where you might end up with the wrong plugin.
Possibility 1: You Installed Corrupted Plugin:
As there is an option for uploading plugins in WordPress then there are possibilities you can install the wrong or corrupted plugin and at times when plugins do not install using the standard way.
It is the reason why people advise to install plugins from reliable sources. Directly from your self-hosted site WordPress Add Plugins page or from here. So, the chances of downloading a corrupted plugin will end.
However, there are times when you still get this error even if you install the plugin using WordPress or by downloading the plugin from a trusted source then it can because of the other possibilities.
Possibility 2: Wrong Folder Structure:
Even after you have downloaded the plugin from a trusted site or WordPress and still getting the error.
Then there are chances that your folder structure has issues like:
• Plugin zip is inside a zip folder.
• The Actual plugin is present on the second level.
Plugin zip is inside a zip folder:
For uploading that plugin, you need it in compressed zip format. However, some trusted sites have a unique folder structure where the actual plugin files are compressed inside a zip folder.
It is like a box inside a box, you will find the materials inside the core box. Due to its complicated path user often makes mistakes. Following is the path format:
(Wherever you saved the file such as Download, Documents, etc.) \plugin.zip\plugin.1.0.1.zip\plugin\ \ (plugin files are here)
When WordPress installer gets such a folder it doesn’t get to access the actual plugin files So, it throws an error.
For resolving this issue, it is suggested to check the folder structure. You should unzip the downloaded folder and use the zip folder inside that folder. The path will probably become something similar to what’s shown below:
(Wherever you saved the file such as Download, Documents, etc.) \plugin.1.0.1.zip\plugin\ (plugin files are here)
The Actual plugin is present on the second level:
For Example:
You are trying to install the plugin named Genesis Simple Hooks from Add Plugins on your self-hosted WordPress site.


Now you go on the Installed Plugins page using the WordPress dashboard.

Try activating the plugin will be activated.

It is due to the wrong folder structure inside plugins as the path shown below.
C:\xampp\htdocs\wordpress\wp-content\plugins\genesis-simple-hookss\genesis-simple-hooks\ (plugin files are here)as the path shown below.
the problem's visual demonstration:



As it clear from the pictures that the folder of the plugin is inside another folder.
You can try moving your plugin folder a level up like demonstrated in the solution below.
C:\xampp\htdocs\wordpress\wp-content\plugins\genesis-simple-hooks\(plugin files are here)
solution
Step 1: Copy the wp-content of the plugin and paste it directly inside the plugin folder.
Step 2: Delete the folder which was inside the plugin.
You are now able to access the core plugin files directly. In short, it means when you open the plugins folder present inside wp-content as displayed below.


However, sometimes some plugins have subfolders whose file header format is the same as the actual plugin main files header, and the WordPress installer assumes those files to be the main plugin.
That is why then you will have to manually change those file headers so that the WordPress installer does not get confused.
Possibility 3: Caching Problems:
If you still face the same issue. The reason for this unresolvable error can probably be a caching problem.
It is a possibility that the plugin is being cached and such plugin is not pluggable. Garbage caching issues can be resolve by opening the plugin.php file located in wp-admin/includes folder. There you can find this set of code.
$cache_plugins = wp_cache_get( 'plugins', 'plugins' );
if ( ! $cache_plugins ) {
$cache_plugins = array();
}
if ( isset( $cache_plugins[ $plugin_folder ] ) ) {
return $cache_plugins[ $plugin_folder ];
}
Try commenting out the code mentioned above and then install/activate the plugin. You would not get the error.
Conclusion:
The plugin does not have a valid header sure is an infuriating error but not unresolvable. As it is already discussed in the article that this error occurs because it is a generic error for all missing plugins.
The reason for it to occur probably cause of the Corrupted plugin, Wrong Folder structure, or Caching problems. The detailed illustrated solution to all three possibilities is present in the article.