- WordPress 3 Plugin Development Essentials
- Brian Bondari Everett Griffiths
- 432字
- 2021-04-09 21:19:58
Information header
Don't just skim this section thinking it's a waste of breath on the self-explanatory header fields. Unlike a normal PHP file in which the comments are purely optional, in WordPress plugin and theme files, the Information Header is required! It is this block of text that causes a file to show up on WordPress' radar so that you can activate it or deactivate it. If your plugin is missing a valid information header, you cannot use it!
Exercise—breaking the header
To reinforce that the information header is an integral part of a plugin, try the following exercise:
- In your WordPress Dashboard, ensure that the "Hello Dolly" plugin has been activated.
- If applicable, use your preferred (s)FTP program to connect to your WordPress installation.
- Using your text editor, temporarily delete the information header from
wp-content/plugins/hello.php
and save the file (you can save the header elsewhere for now). Save the file. - Refresh the Plugins page in your browser.
- You should get a warning from WordPress stating that the plugin does not have a valid header:
After you've seen the tragic consequences, put the header information back into the hello.php
file.
This should make it abundantly clear to you that the information header is absolutely vital for every WordPress plugin. If your plugin has multiple files, the header should be inside the primary file—in this book we use index.php
as our primary file, but many plugins use a file named after the plugin name as their primary file.
Location, name, and format
The header itself is similar in form and function to other content management systems, such as Drupal's module.info
files or Joomla's XML module configurations—it offers a way to store additional information about a plugin in a standardized format. The values can be extended, but the most common header values are listed below:
- Author: Listed below the plugin name
- Author URI: Together with "Author", this creates a link to the author's site
- Description: Main block of text describing the plugin
- Plugin Name: The displayed name of the plugin
- Plugin URI: Destination of the "Visit plugin site" link
- Version: Use this to track your changes over time
For more information about header blocks, see the WordPress codex at: http://codex.wordpress.org/File_Header.
Tip
In order for a PHP file to show up in WordPress' Plugins menu:
- The file must have a
.php
extension. - The file must contain the information header somewhere in it (preferably at the beginning).
- The file must be either in the
/wp-content/plugins
directory, or in a subdirectory of the plugins directory. It cannot be more deeply nested.
- 中文版3ds Max 2024完全自學教程
- 我為PS狂 Photoshop照片處理一分鐘秘笈
- RESTful PHP Web Services
- Blender 3D Architecture, Buildings, and Scenery
- Illustrator平面設計立體化教程:Illustrator 2021(微課版)
- Photoshop CS6實戰基礎培訓教程(全視頻微課版)
- BlackBerry Enterprise Server 5 Implementation Guide
- 人人都能玩賺AI繪畫
- Python Testing Cookbook
- 中文版Photoshop CC基礎教程
- Photoshop CC新媒體圖形圖像設計與制作(全彩慕課版)
- 中文版Photoshop CS5基礎培訓教程(移動學習版)
- HBase企業應用開發實戰
- 中老年學微信(圖解大字版)
- 一定要學的Photoshop人像攝影后期調色技法