WordPress Plugin Development: Plugin Header Comment

Header Comment consists of metadata about the WordPress Plugin.

·

2 min read

WordPress Plugin Development: Plugin Header Comment

What is Plugin Header Comment

In WordPress plugin development, a header comment is a comment in the root PHP file. It has a specific format that WordPress can read. The comment contains metadata about the plugin. Without this comment, WordPress can not recognize the file as a plugin.
In the previous tutorial, we saw the minimum requirement for registering a plugin. That was a header comment containing the name of the plugin.
In this tutorial, we will see what a header comment should consist of.


Writing a Plugin with only Header Comment

The code below in also hosted on github

<?php
/**
 * Plugin Name:       My Plugin Header
 * Plugin URI:        https://github.com/StepAsideLiL/wp-plugin-dev
 * Description:       This plugin shows the metadata of a plugin header comment.
 * Version:           1.0.0
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            Rifat Khan
 * Author URI:        https://stepasidelil.hashnode.dev/
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Update URI:        https://github.com/StepAsideLiL/wp-plugin-dev/tree/main/my-plugin-header
 * Text Domain:       my-plugin-header
 * Domain Path:       /languages
 */

my-plugin-header.png

Description of Header Field

  • Plugin Name is the most important plugin header field. WordPress looks up this header field to register the plugin on the Plugins page.
  • Plugin URI is a unique URL of the plugin. This can not be wordpress.org
  • Description is a short note about the plugin.
  • Version number represents the current version of the plugin. This number should be updated when you update your plugin.
  • Requires at least is the lowest version of WordPress that can run your plugin.
  • Requires PHP is the lowest version of PHP that can run your plugin.
  • Author is the name of the writer of this plugin.
  • Author URI is the author's website.
  • License is the name of the software license. It is a document that provides legally binding guidelines for the use and distribution of software. WordPress plugin must be compatible with the GNU General Public License.
  • License URI is the link to the license document.
  • Update URI is the website link of your plugin. If your plugin is hosted on wordpress.org then you don't need to use this header field. Read more about it from here
  • Text Domain is a unique identifier to ensure WordPress can distinguish between all loaded translations. Read more about it from here
  • Domain Path is the path that lets WordPress know where to find the translations. Read more about it from here

    You can read about details description of each metadata from here