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:
So in order to properly install and activate a plugin, the following two conditions must be satisfied:
To fix the
plugin-a.zip
plugin-a-folder ---- plugin-a-main-file.php ---- plugin-a-readme.txt
plugin-b.zipThere are two ways to install a plugin. Option 1 is to unzip the file and upload the contents to
plugin-b-folder ---- plugin-b-subfolder -------- plugin-b-main-file.php -------- plugin-b-readme.txt
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
- Unzip the file
- Upload the contents to
wordpress_root/wp-content/plugins/
- Login as admin and go to
Plugins -> Installed
. - Locate plugin and click Activate link.
- Result: Plugin activated.
Installing ‘plugin-a.zip’ using Option 2
- Login as admin and go to
Plugins -> Add New -> Upload
- Locate the file
plugin-a.zip
by clicking the Browse button. - Click Install Now button.
- Result:
Unpacking the package?
Installing the plugin?
Plugin installed successfully. - Click Activate Plugin link.
- Result: Plugin activated.
Installing ‘plugin-b.zip’ using Option 1
- Unzip the file
- Upload the contents to
wordpress_root/wp-content/plugins/
- Login as admin and go to
Plugins -> Installed
. - Locate plugin and click Activate link.
- Error: Plugin does not exists in the list.
Installing ‘plugin-b.zip’ using Option 2
- Login as admin and go to
Plugins -> Add New -> Upload
- Locate the file
plugin-b.zip
by clicking the Browse button. - Click Install Now button.
- Result:
Unpacking the package?
Installing the plugin?
Plugin installed successfully. - Click Activate Plugin link.
- WordPress ? Error The plugin does not have a valid header.
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 directoryThe plugin data that the function is looking for can be found below:
* (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.
01 |
|
02 | /* |
03 | Plugin Name: Name Of The Plugin |
04 | Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates |
05 | Description: A brief description of the Plugin. |
06 | Version: The Plugin's Version Number, e.g.: 1.0 |
07 | Author: Name Of The Plugin Author |
08 | Author URI: http://URI_Of_The_Plugin_Author |
09 | License: A "Slug" license name e.g. GPL2 |
10 | */ |
11 | ?> |
- 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
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.zipI hope this post will enlighten WordPress users who wants to maximize their blog’s potential
plugin-b-folder ---- plugin-b-main-file.php ---- plugin-b-readme.txt
No comments:
Post a Comment