it's my blog anyway
In: Feeling guru
27 May 2010You 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.
wordpress_root/wp-content/plugins/Plugins -> Installed.Plugins -> Add New -> Uploadplugin-a.zip by clicking the Browse button.wordpress_root/wp-content/plugins/Plugins -> Installed.Plugins -> Add New -> Uploadplugin-b.zip by clicking the Browse button.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:
plugins root folder or in first-level subdirectory within plugins folderIn 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
This is a programmer's blog. Whenever I encounter a difficult coding task, I make sure that I'll be able to share it here in the hope that others may find it useful. It's my way of giving back to the open source community who have been a great help to me as well.
31 Responses to How to fix the ‘The plugin does not have a valid header’ error when activating a WordPress plugin
Money making opportunies
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
Richard Feraro
August 30th, 2010 at 10:10 pm
Thank you too. Keep on reading!
Rooh.it
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!!
Richard Feraro
November 21st, 2010 at 3:47 am
Update to the latest version (6.0.3)
Sarah
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
Richard Feraro
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?
bill
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.
luca
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
Richard Feraro
June 24th, 2011 at 12:24 am
Have you check which file contains the plugin data?
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 /** */
Jessica
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.
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.
Ian
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
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.
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
Richard Feraro
July 28th, 2011 at 10:38 pm
You’re welcome
Paul
August 11th, 2011 at 6:20 am
Great site mate cheers
Richard Feraro
August 13th, 2011 at 1:35 pm
Thank you
kishore
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
Richard Feraro
August 24th, 2011 at 10:08 pm
Does it have the plugin data?
djdminus
September 7th, 2011 at 2:27 pm
thanks for the troubleshooting . it works like a charm
Richard Feraro
September 8th, 2011 at 8:26 am
Thanks for the feedback
Jason
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
Tom
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.
Richard Feraro
September 17th, 2011 at 8:02 am
Reinstall or download again the plugin because it says something is missing
Richard Feraro
September 17th, 2011 at 8:04 am
I’m glad it worked for you.
Kulwant Nagi
October 18th, 2011 at 1:08 pm
Wonderful post Brother. My Problem got fixed.
Richard Feraro
October 18th, 2011 at 10:31 pm
Glad to know that
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.
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
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.