How to fix the ‘The plugin does not have a valid header’ error when activating a WordPress plugin

In: Feeling guru

27 May 2010

You want to extend WordPress’ functionality and decided to download some plugins found in the Official WordPress Plugin repository. After searching the repo, you’ve found two plugins that accomplishes the tasks you needed to implement in your blog. Downloading the plugins gives you two ZIP files that when double-clicked, shows you the contents in the following format:

plugin-a.zip

plugin-a-folder
---- plugin-a-main-file.php
---- plugin-a-readme.txt

plugin-b.zip

plugin-b-folder
---- plugin-b-subfolder
-------- plugin-b-main-file.php
-------- plugin-b-readme.txt

There are two ways to install a plugin. Option 1 is to unzip the file and upload the contents to wordpress_root/wp-content/plugins/ directory. Option 2 is to use the Add New -> Upload option found in the left panel bar of the administrative page of WordPress. Let’s assume the two plugins went through the two installation options.

Installing ‘plugin-a.zip’ using Option 1

  1. Unzip the file
  2. Upload the contents to wordpress_root/wp-content/plugins/
  3. Login as admin and go to Plugins -> Installed.
  4. Locate plugin and click Activate link.
  5. Result:
    Plugin activated.

Installing ‘plugin-a.zip’ using Option 2

  1. Login as admin and go to Plugins -> Add New -> Upload
  2. Locate the file plugin-a.zip by clicking the Browse button.
  3. Click Install Now button.
  4. Result:
    Unpacking the package?
    Installing the plugin?
    Plugin installed successfully.
  5. Click Activate Plugin link.
  6. Result:
    Plugin activated.

Installing ‘plugin-b.zip’ using Option 1

  1. Unzip the file
  2. Upload the contents to wordpress_root/wp-content/plugins/
  3. Login as admin and go to Plugins -> Installed.
  4. Locate plugin and click Activate link.
  5. Error: Plugin does not exists in the list.

Installing ‘plugin-b.zip’ using Option 2

  1. Login as admin and go to Plugins -> Add New -> Upload
  2. Locate the file plugin-b.zip by clicking the Browse button.
  3. Click Install Now button.
  4. Result:
    Unpacking the package?
    Installing the plugin?
    Plugin installed successfully.
  5. Click Activate Plugin link.
  6. WordPress ? Error
    The plugin does not have a valid header.

Based on our testing, plugin-b.zip seems to fail on both methods of installation. To find out what is causing the error, we have to understand how the plugin installation works. Upon checking the core files I found this excerpt in get_plugins() function:

* WordPress only supports plugin files in the base plugins directory
* (wp-content/plugins) and in one directory above the plugins directory
* (wp-content/plugins/my-plugin). The file it looks for has the plugin data and
* must be found in those two locations. It is recommended that do keep your
* plugin files in directories.

The plugin data that the function is looking for can be found below:

<?php
/*
Plugin Name: Name Of The Plugin
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: The Plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
*/
?>

So in order to properly install and activate a plugin, the following two conditions must be satisfied:

  • that a plugin main file (.php) must be placed in plugins root folder or in first-level subdirectory within plugins folder
  • and it should contain the necessary plugin data for identification/validation purposes

In the case of plugin-b.zip, although the main PHP file contains the needed plugin data, the validate_plugin() function returned an error since neither the file can be found or check if it contains the plugin data because it is placed in the second level subdirectory, a directory location in which the function is not designed to scan the content.

To fix the plugin-b.zip file, it needs to have the following content structure:

plugin-b.zip

plugin-b-folder
---- plugin-b-main-file.php
---- plugin-b-readme.txt

I hope this post will enlighten WordPress users who wants to maximize their blog’s potential πŸ™‚

About the author

Richard Feraro is a Magento Enterprise Certified developer from Manila, Philippines with 14 years of solid open-source development experience using Linux, Apache, MySQL & PHP.

35 Responses to How to fix the ‘The plugin does not have a valid header’ error when activating a WordPress plugin

Avatar

Money making opportunies AUSTRALIA

August 30th, 2010 at 5:56 pm

Thanks a lot Richard, I needed this!

I kept thinking I’d been sold dud software!

Cheers,

Peter Phillips

Avatar

Richard Feraro UNITED STATES

August 30th, 2010 at 10:10 pm

Thank you too. Keep on reading!

Avatar

Rooh.it UNITED STATES

November 20th, 2010 at 7:02 am

Our plugin (ver 6.0.1) has the main file in the right location yet we get this error, pls see

http://wordpress.org/extend/plugins/roohit-plugin/

I’m foxed – as to why this is happening!! πŸ™

Avatar

Richard Feraro PHILIPPINES

November 21st, 2010 at 3:47 am

Update to the latest version (6.0.3)

Avatar

Sarah SPAIN

April 12th, 2011 at 6:06 am

Hi Richard,great site.Im using wordpress and I dont know where to find the folder wherein I should change the code as you explained.You see Im also getting the error:he plugin does not have a valid header’.Sometimes I wish there were some affordable outsourcing services to fix and customize WordPress blogs because Im a writer and more on marketing and strategic issues than coding.Please help.Thanks

Avatar

Richard Feraro UNITED STATES

April 12th, 2011 at 1:30 pm

Hello Sarah, thanks for checking out my blog.

Regarding your inquiry, what is the plugin’s name that you’re having trouble with?

Avatar

bill UNITED STATES

May 12th, 2011 at 11:40 am

Thanks Richard, I moved the plugin-appname.php and appname-readme.txt to the first level folder (the plugin folder root) and the plugin activated. I appreciate your help.

Avatar

luca UNITED KINGDOM

June 12th, 2011 at 6:11 am

hi Richard,

i was hopping to solve this for classipress plugin but it doesnt really work.
after i unzip the folder there is no file called “classipress.php” , so i dont know which one is the main file ? i tried renaming index.php to clasipress.php and copy it to the root plugin folder …

i am stuck now and i really need this

thanks

Avatar

Richard Feraro PHILIPPINES

June 24th, 2011 at 12:24 am

Have you check which file contains the plugin data?

Avatar

Richard Feraro

June 30th, 2011 at 8:34 pm

Have you tried looking for the file that contains the plugin data? Those are the details enclosed in /** */

Avatar

Jessica UNITED STATES

July 18th, 2011 at 8:07 am

This is wearing me out. I get one plugin installed and another one self destructs! I’ve updated the version numbers and no luck. Can’t we just disable whatever is checking for the version numbers and carry on with our work? It’s driving me crazy. Who cares what version it’s good up to.

Avatar

Richard Feraro

July 18th, 2011 at 12:58 pm

There’s a good reason why a version check is necessary for the plugin. It keeps our WP instance from breaking due to incompatible version which in your case is possibly the reason why the two plugin didn’t work well together.

Avatar

Ian UNITED KINGDOM

July 19th, 2011 at 8:39 am

Hi Richard

I understand what you’re saying here… to a degree.

How do I alter the zip file? If I double-click it, the file is opened by WinRAR. Do I need to amend one of the files within the zip file?

Regards

Ian

Avatar

Richard Feraro

July 19th, 2011 at 9:36 pm

Just unzip it then move the files to the first subdirectory. After that, you may upload it or zip it again for installation to your WP instance.

Avatar

Zeyad

July 28th, 2011 at 2:11 pm

“that a plugin main file (.php) must be placed in plugins root folder or in first-level subdirectory within plugins folder” … This worked for me .. thanks

Avatar

Richard Feraro PHILIPPINES

July 28th, 2011 at 10:38 pm

You’re welcome πŸ™‚

Avatar

Paul PANAMA

August 11th, 2011 at 6:20 am

Great site mate cheers

Avatar

Richard Feraro PHILIPPINES

August 13th, 2011 at 1:35 pm

Thank you πŸ™‚

Avatar

kishore INDIA

August 23rd, 2011 at 6:00 pm

Everything is perfect from my side, placing plugin in one level directory but also it showing that “The plugin does not have a valid header.”
wordpress version 3.0

Avatar

Richard Feraro PHILIPPINES

August 24th, 2011 at 10:08 pm

Does it have the plugin data?

Avatar

djdminus UNITED STATES

September 7th, 2011 at 2:27 pm

thanks for the troubleshooting . it works like a charm

Avatar

Richard Feraro

September 8th, 2011 at 8:26 am

Thanks for the feedback πŸ™‚

Avatar

Jason UNITED STATES

September 16th, 2011 at 10:35 am

What do i have to move?
β€œThe plugin does not have a valid header.”
Fatal error: Call to undefined function dockgalleryfx_echo_embed_code() on line 12

Welcome to jsnsdr

Avatar

Richard Feraro PHILIPPINES

September 17th, 2011 at 8:02 am

Reinstall or download again the plugin because it says something is missing

Avatar

Tom NETHERLANDS

September 17th, 2011 at 4:37 am

Thanks a lot Richard.

I got a plugin working which was giving me the ‘this plugin has no valid header’-error.

Avatar

Richard Feraro PHILIPPINES

September 17th, 2011 at 8:04 am

I’m glad it worked for you. πŸ˜‰

Avatar

Kulwant Nagi

October 18th, 2011 at 1:08 pm

Wonderful post Brother. My Problem got fixed.

Avatar

Richard Feraro

October 18th, 2011 at 10:31 pm

Glad to know that πŸ™‚

Avatar

Hugo

November 6th, 2011 at 7:58 pm

Mabuhay Richard –

Glad to have found your site while searching the net. As a non-techie guy and with very basic knowledge of PHP and MySQL (mainly simple installing of sites and databases), I hope to learn more from you here.

Used to live in Makati at the Twin towers when working with Ayala Corp. Now in Singapore and starting my full time online presence. A long way to go but taking it in my stride and planning outsourcing work mainly on graphics and sites as well as promo activities through various operatives in Fiverr and others.

This header fixing lesson is very helpful and appreciate very much.

All the best and take care.

Avatar

Richard Feraro

November 6th, 2011 at 9:19 pm

Hello Hugo,

I am glad you found the article to be useful πŸ™‚ I hope you visit once in a while in the site. Read through the comments too. Most of the visitors here find them useful in their job.

Regards πŸ™‚

Avatar

Hugo

November 6th, 2011 at 11:24 pm

Hi Richard,

I am sure all your site’s visitors would certainly benefit from your guidance and tutorials…judging from the compliments from them.
I am happy for you that your effort has reaped the rewards in terms of a great sense of satisfaction.

Rest assured that I have bookmarked your site and you bet I will be here whenever I can to continue learning from you and will make good use of what I have learned here.

Once again, thank you and my best regards to you and your loved ones.

Avatar

Robert PUERTO RICO

May 21st, 2012 at 4:15 am

Richard,

Don’t know what to say about how well you explained this plugin error stuff ” the plugin does not have a valid header”.

I don’t think there are many folks out there with the organizational and teaching skills you have not to mention the generosity in putting this answer together. WOW!
Finally I was able to get the “mediaplayer-5.9-viral” activated thanks to your identification/validation php data example.

For a dummie-newbie like me, your explanation came like a God send,
thank you so much pal and my sincere gratitude.

Avatar

Sonia PORTUGAL

October 2nd, 2012 at 7:57 pm

HI,
Thank you for the post. I’m having the Β«The plugin does not have a valid header.Β» problem. At first I could install plugins but now it doesn’t let me or upgrade the ones I have (It says they are upgraded but they aren’t). I checked the folder plugins and they had the files as you indicate. The wp_plugins folder has now the 777 permission but I still can’t do anything. And one more: I could only upgrade wp to 3.4.2 using the simple scripts.
Do you have any ideas? I’ve searched wp foruns and google it but no solution worked.

Avatar

Jody Murphy UNITED STATES

June 15th, 2013 at 11:42 am

This is helpful, but I’m really puzzled. Our blog plugins — ALL of them — are being auto deactivated. They seem to work for about an hour, then when I login, I receive a page summarizing multiple errors – one for each plugin stating “The plugin does not have a valid header.”

Have you encountered anything like this before? What suggestions do you have? Should we follow your recommendations above for each plugin? I’ve never had a problem like this on any WP blog I’ve set up and it’s got me a bit rattled. Thanks for your insights.

Avatar

neelam AUSTRALIA

September 20th, 2014 at 5:22 pm

“The plugin doesn’t have a valid error”
Please help me. Even i uploaded plugin via FTP and WordPress upload plugin. But same error exist.

Comment Form

About my blog

This blog is targeted towards all levels of developers and also designers. Various topics are discussed such as Magento, PHP & MySQL, jQuery, WordPress, CSS and HTML.

Booking.com

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 5,242 other subscribers

WordPress + Magento

Recent Trackbacks

Archives

Disclaimer

All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or my mom.