What is a WordPress Plugin Header?
A WordPress Plugin Header is a standardized PHP comment block placed at the top of your plugin's main execution file. WordPress scans this block to identify the plugin's name, description, author, version, license, and directory compatibility requirements, allowing it to display correctly on the WordPress Plugins admin dashboard.
Key Attributes Required by the WordPress.org Directory
When preparing a plugin for the official WordPress repository, you must declare certain header attributes:
- Plugin Name: The official name of your plugin. Must be unique and descriptive.
- Description: A brief summary (typically under 150 characters) detailing the plugin's features.
- Text Domain: Used for internationalization (i18n). Should match the slug of your plugin folder to ensure translations load correctly.
- Requires at least: The minimum WordPress version required to run your script safely.
- Requires PHP: The minimum PHP execution runtime required (e.g.
7.4or8.0).
Best Security Practices for Plugin Main Files
Direct execution of PHP scripts is a primary vector for site attacks. To prevent malicious actors from accessing your plugin files directly, always append an absolute path check directly below your plugin header comment block:
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}Frequently Asked Questions
Q: Where do I paste this header code?
Paste it at the very top of your plugin's primary PHP file (e.g. my-plugin.php) immediately after the opening <?php tag.
Q: What is the Text Domain utilized for?
It serves as a unique slug identifier for translating your plugin strings into other languages using functions like _e() or __().