Header Requirements in WordPress plugin development

The main PHP file should have a header comment that informs WordPress so in this article we will cover Header Requirements in WordPress plugin development. That the file is a plugin and gives information about the plugin, as outline in Getting Start.

Minimum Fields for Header Requirements in WordPress

At the very least, a header comment must have the following information: Plugin Name:

/**
 * Plugin Name: YOUR PLUGIN NAME
 */

Header Fields

Available header fields:

  • Plugin Name: (essential) The name of your plugin, which shown in the WordPress Admin’s Plugins list.
  • Plugin URI: The plugin’s home page, which should be a distinct URL, preferably on your own website. This should be specific to your plugin. A WordPress.org URL cannot be use here.
  • Description: A brief description of the plugin, as displayed in the WordPress Admin’s Plugins section. Keep this description to a maximum of 140 characters.
  • Version: The plugin’s current version number, such as 1.0.0 or 1.0.9.
  • Requires at least: The earliest WordPress version on which the plugin will operate.
  • Requires PHP: The minimum required PHP version.
  • Author URI: The author’s website or profile on a third-party website, such as WordPress.org.
  • License: The short name (slug) of the plugin’s license (e.g. GPLv2). More information about licensing can be found in the WordPress.org guidelines.
  • License URI: https://www.gnu.org/licenses/gpl-2.0.html.
  • Text Domain: gettext text domain.
  • Domain Path: The domain path instructs WordPress where to look for translations. More details may be found on the How to Internationalize your Plugin page under the Domain Path section
  • Network: whether the plugin can only be activate on a network-wide basis. Can only be set to true and ignore when not require.
  • Update URI: Allows third-party plugins to avoid being replace by an update to a plugin with a similar name in the WordPress.org Plugin Directory.

A legal PHP file containing a header comment may look something like this:

/**
 * Plugin Name:       Softhunt Basics Plugin
 * Plugin URI:        https://softhunt.net/plugins/
 * Description:       Handle the basics with this plugin.
 * Version:           1.10.3
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            Ranjeet
 * Author URI:        https://softhunt.net/
 * License:           GPL v2 or later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Update URI:        https://sothunt.net/my-plugin/
 * Text Domain:       basics-plugin
 * Domain Path:       /languages
 */

Here’s another example that supports both file-level PHPDoc DocBlock and WordPress plugin file headers:

/**
 * Plugin Name
 *
 * @package           PluginPackage
 * @author            Your Name
 * @copyright         2019 Your Name or Company Name
 * @license           GPL-2.0-or-later
 *
 * @wordpress-plugin
 * Plugin Name:       Plugin Name
 * Plugin URI:        https://example.com/plugin-name
 * Description:       Description of the plugin.
 * Version:           1.0.0
 * Requires at least: 5.2
 * Requires PHP:      7.2
 * Author:            Your Name
 * Author URI:        https://example.com
 * Text Domain:       plugin-slug
 * License:           GPL v2 or later
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
 * Update URI:        https://example.com/my-plugin/
 */

Note: When providing a version number to your project, keep in mind that WordPress compares plugin version numbers using the PHP version compare() function. As a result, before releasing a new version of your plugin, ensure that this PHP function considers the new version to be “greater” than the previous one. 1.02, for example, is larger than 1.1.

That’s all for this article if you have any queries please contact us through our website or email us at [email protected]

2 thoughts on “Header Requirements in WordPress plugin development”

  1. Description: A brief description of the plugin, as displayed in the WordPress Admin’s Plugins section. Keep this description to a maximum of 140 characters.

    Is this a documented hard limit? Or is this your suggestion?

    Reply

Leave a Comment